So, I’m doing the following (example code):
Code:
SDL_Texture* background;
SDL_Surface *bigSurface, *scaleSurface, *loadingSurface;
loadingSurface = IMG_Load(“bg.png”);
SDL_Rect rect;
rect.w = loadingSurface->w;
rect.h = loadingSurface->h;
bigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, window->w, window->h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
scaleSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, rect->w /2.f, rect->h /2.f, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
SDL_BlitSurface(loadingSurface, NULL, scaleSurface, NULL);
SDL_BlitSurface(scaleSurface, NULL, bigSurface, &rect);
background = SDL_CreateTextureFromSurface(mainRenderer, bigSurface);
SDL_FreeSurface(scaleSurface);
SDL_FreeSurface(loadingSurface);
SDL_FreeSurface(bigSurface);
After the first BlitSurface, the image is okay (if I convert to Texture at that point, it shows up correctly), however after the second BlitSurface operation all I got is black color in place of the image.
What could cause this behaviour, and how may I fix it?------------------------
Runic Girls - a hexa match3 game with girls created using SDL 2.0:
http://www.facebook.com/RunicGirls
Gameplay trailer: