-
Dying on SDL_Flip.
It seems my SDL program dies whenever I flip pages.
Code:
screen = SDL_SetVideoMode(800, 600, 16,
SDL_SWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("Fight", NULL);
...
SDL_Flip(screen);
Am I doing something wrong? I haven't drawn anything on screen yet.
nevermind, i figured it out. it was an unrelated pointer thing.
-
Not sure about SDL - I wrote my own flip code in assembly.
Simply retrieve a pointer from DirectX to the buffer and primary surface.
Code:
push ds
push esi
push edi
lds esi,[SecondaryBuffer]
les edi,[PrimaryBuffer]
mov ecx,[size]
rep movsd
pop edi
pop esi
pop ds
A faster way would be MMX except that MMX does not allow memory to memory transfers. Besides that the only faster way I know of is REP STOSQ which is only available on the Intel IA-64 Itanium CPU.
-
When not in fullscreen mode...
you don't need SDL_DOUBLEBUFF
you should'nt use SDL_Flip
use SDL_UpdateRect
*rummages for reference*
God this book is small....
Code:
Prototype
void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
also
void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects);
Ex.1 for a 800x600 window:
SDL_UpdateRect(screen, 0, 0, 800, 600)
Ex.2 for a 800x600 window:
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = 800;
rect.h = 600;
SDL_UpdateRects(screen, 1, &rect)
Also, i suggest using macros for screen hieght/width because they are used so often... and its alot easier to change and... yeah.