Hi
I’m making my first SDL app and I wrote an image open function for opening
and converting an image to be blittable to the screen. At first i used a
SWSURFACE screen but later on I switched to HWSURFACE since SWSURFACE only
gave me about 9-15 FPS at best !! (atleast on M$ Windoze, it worked fine on
Linux :D). Now I can draw on the surface, I have good fps and no flickering
but i can’t blit anything to the screen. Here’s my code:
SDL_Surface* LoadImage (char *file)
{
SDL_Surface *tempSurface, *ret;
tempSurface = IMG_Load(file); // i use SDL_image
ret = SDL_ConvertSurface(tempSurface, screen->format, SDL_SWSURFACE);
SDL_FreeSurface(tempSurface);
return ret;
}
void render()
{
…lock…
SDL_BlitSurface(picture, NULL, screen, NULL);
…unlock…
SDL_Flip(screen);
…clearscreen…
}
void main()
{
…
screen = SDL_SetVideoMode(XRES, YRES, 32, SDL_DOUBLEBUF | SDL_HWSURFACE |
SDL_FULLSCREEN | SDL_RLEACCEL | SDL_HWPALETTE);
// screen was initially SDL_SWSURFACE | SDL_FULLSCREEN
picture = LoadImage(“picture.png”);
…
}
What’s wrong with this code ?
Thanks in advance
Steve