I'm developing a small game and I've bumped into problem with SDL surfaces.
I've written function for creating surfaces:
[source lang="cpp"]SDL_Surface *create_surface(int width, int height){ /* Create a 32-bit surface with the bytes of each pixel in R,G,B,A order, as expected by OpenGL for textures */ SDL_Surface *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; } surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); return surface;}[/source]
But when i try to do something with it nothing happens:
[source lang="cpp"]Uint32 p_color;p_color = SDL_MapRGB(screen->format,255,255,255);SDL_Surface *srf = NULL;srf = create_surface(16,16);SDL_Rect temp;temp.x = 0;temp.y = 0;temp.w = 16;temp.h = 16; SDL_FillRect(srf,&temp,p_color);apply_surface(0,0, srf, screen, NULL); //simple function for blitting one surface to another.[/source]
I definitely know that srf and screen are 32bits and function for creating surfaces was copied from SDL docs.
apply_surface function works perfectly for any loaded image.
Please, help me out with this simple problem






