{
SDL_Surface* sdl_surface;
- Uint32 rmask, gmask, bmask, amask;
-
- /* SDL interprets each pixel as a 32-bit number, so our masks must depend
- on the endianness (byte order) of the machine */
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
-#else
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
-#endif
-
- sdl_surface = SDL_CreateRGBSurface(screen->flags, w, h,
- screen->format->BitsPerPixel, rmask, gmask, bmask, amask);
-
- if(sdl_surface == NULL)
- st_abort("Cannot create surface for the gradient", "SURFACE");
-
- float redstep = (float(bottom.red)-float(top.red)) / float(h);
- float greenstep = (float(bottom.green)-float(top.green)) / float(h);
- float bluestep = (float(bottom.blue) - float(top.blue)) / float(h);
-
- SDL_Rect rect;
- rect.x = 0;
- rect.w = w;
- rect.h = 1;
- for(float y = 0; y < h; y++)
- {
- rect.y = (int)y;
- SDL_FillRect(sdl_surface, &rect, SDL_MapRGB(sdl_surface->format,
- int(float(top.red) + redstep * y),
- int(float(top.green) + greenstep * y),
- int(float(top.blue) + bluestep * y)));
- }
+ sdl_surface = SDL_CreateRGBSurface(screen->flags, w, h,
+ screen->format->BitsPerPixel, screen->format->Rmask,
+ screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
+
+ if(sdl_surface == NULL)
+ st_abort("Cannot create surface for the gradient", "SURFACE");
+
+ float redstep = (float(bottom.red)-float(top.red)) / float(h);
+ float greenstep = (float(bottom.green)-float(top.green)) / float(h);
+ float bluestep = (float(bottom.blue) - float(top.blue)) / float(h);
+
+ SDL_Rect rect;
+ rect.x = 0;
+ rect.w = w;
+ rect.h = 1;
+ for(float y = 0; y < h; y++)
+ {
+ rect.y = (int)y;
+ SDL_FillRect(sdl_surface, &rect, SDL_MapRGB(sdl_surface->format,
+ int(float(top.red) + redstep * y),
+ int(float(top.green) + greenstep * y),
+ int(float(top.blue) + bluestep * y)));
+ }
return sdl_surface;
}