Display formating (SDL)
Things seem to move slower when I display format than when I don't. What could I be doing wrong?
I used surface = SDL_DisplayFormat(surface) instead of just loading the surface and just blitting. The process seems to be much slower.
Quote:
Original post by AntiGuy
I used surface = SDL_DisplayFormat(surface) instead of just loading the surface and just blitting. The process seems to be much slower.
Are you freeing the surface after you use SDL_DisplayFormat?
temp = SDL_DisplayFormat(surface);SDL_FreeSurface( surface );surface = temp;
Define "slower" and show us some code. One could only guess what's wrong at this point.
#include "Main.h"SDL_Surface* surface;SDL_Surface* temp;int main(int argc, char* argv[]) {LoadGame();temp = IMG_Load("Images/image.gif");surface= SDL_DisplayFormat(temp);SDL_FreeSurface(temp);for(;;){SDL_PollEvent(&event);SDL_BlitSurface(surface,0,screen,0);SDL_Flip(screen);CalculateFrameRate();}}
And by slow I mean the framerate slows down. It moves much faster if I say surface = IMG_Load("image");
Does IMG_Load load into a hardware surface by default? The only thing I can think of is you were blitting hw -> hw before and now you're blitting sw -> hw. hw -> hw accelerated blits are usually much faster. Also, take that SDL_Flip out for raw speed calculations, it might be waiting for retrace, depending on your video mode. Use SDL_UpdateRect instead.
I'm not really sure. I used SDL_ANYFORMAT and didn't do anything about HW & SW.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement