Hi,
i have a problem on Win32 that on when i “lock” a fullscreen
surface and unlock it afterwards, i don’t see anything.
Please let me describe the structure of my program first:
There’s one function to switch the video mode:
void chvid_mode(void) {
static void chvid_mode(void) {
screen = SDL_SetVideoMode(xwidth, yheight,
video_info->vfmt->BitsPerPixel, vmode);
if(screen == NULL) {
printf(“couldn’t get screen: %s\n”, SDL_GetError());
exit(-1);
}
dst = screen;
sf_rect.x = 0;
sf_rect.y = 0;
sf_rect.w = dst->w;
sf_rect.h = dst->h;
}
Basically it switches to a mode described by some file-global
variables and sets some other data.
vmode has SDL_FULLSCREEN and SDL_DOUBLEBUF set.
Then there’s the output function:
void output_cyclic(void) {
if(SDL_MUSTLOCK(screen)) {
// SDL_LockSurface(screen); // problem
}
// do all the output using SDL_BlitSurface()
srect.x = 0;
srect.y = 0;
srect.w = source_width;
srect.h = source_height;
drect.x = x;
drect.y = y;
SDL_BlitSurface(a_surface, &srect, dst, &drect);
SDL_Flip(screen);
if(SDL_MUSTLOCK(screen)) {
// SDL_UnlockSurface(screen); // problem
}
}
When i comment away the SDL_Lock… and SDL_Unlock…
everything is fine. With them there’s just a black
screen.
I played around with some other options and with/without
SDL_DOUBLEBUF and SDL_Flip(), but the way above was the
only one that worked.
I don’t know why i need to comment those functions out.
Can anybody please explain this to me?
I use SDL version 1.2.9. The problem happens on Win32.
On Linux SDL_MUSTLOCK() is never true, so the code is not
needed.
Best regards,
Torsten.