Hi everybody
Well, as written in the title, since 1.2.15, SDL_SetVideoMode launches
SDL_VIDEORESIZE events when called with different width and height
(possibly bpp ?) than the current ones. Even at the very first call. But
not when the call follows a precedent SDL_VIDEORESIZE nor with same
precedent values .
To describe the problem:
I run an app with the SDL_RESIZABLE flag in windowed mode and I can
put it in full-screen mode with the SDL_FULLSCREEN flag (Win7, no
SDL_WM_ToggleFullScreen
http://sdl.beuc.net/sdl.wiki/SDL_WM_ToggleFullScreen magic). So each
SDL_VIDEORESIZE event is caught and a call to SDL_SetVideoMode is done
to effectively resize the surface in windowed mode.
The resizing following an SDL_VIDEORESIZE works perfectly.
But, when the app is passed in Full-screen mode, it goes
full-screen, and then catches an SDL_VIDEORESIZE event from nowhere and
so, a 2nd call to SDL_SetVideoMode is uselessly done (making it loose
its OpenGL context because done outside of the fullscreen switch code
which normally recreate it).
The behavior is similar even without the full-screen flag. I’ve wrote a
little test code to show it.
When using 1.2.14, the SDL_VIDEORESIZE are only generated when the user
resize the window witch I think would be the correct behavior.
It is also correct using the directx driver.
I fixed this with SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE/ENABLE)
around SDL_SetVideoMode but I would like to know if it is effectively a bug.
Thanks
-------------- next part --------------
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include “SDL.h”
int main() {
SDL_Surface *screen;
SDL_Event event;
bool done = false, pressedReturn = false;
int w = 200, h = 200;
srand(time(NULL));
//SDL_putenv("SDL_VIDEODRIVER=directx");
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(w, h, 32, SDL_RESIZABLE);
while(!done) {
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_QUIT:
done = true;
break;
case SDL_VIDEORESIZE:
// A new surface is recreated following the dimensions asked by the user
printf("\n[CASE SDL_VIDEORESIZE]\n");
screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 32, SDL_RESIZABLE);
break;
case SDL_KEYDOWN:
// Each press on [Return] a different surface is created
if (event.key.keysym.sym == SDLK_RETURN && !pressedReturn) {
pressedReturn = true;
screen = SDL_SetVideoMode(rand() % 400, rand() % 400, 32, SDL_RESIZABLE);
}
break;
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_RETURN && pressedReturn)
pressedReturn = false;
break;
}
}
SDL_Flip(screen);
}
return 0;
}