Migrating from SDL 1.2 to SDL2: some problems

fullscreen = ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);

You want this:

fullscreen = (SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN) != 0;

(Note that this will work whether you used SDL_WINDOW_FULLSCREEN or
SDL_WINDOW_FULLSCREEN_DESKTOP, since they both set the former’s bit.

This is another point where i’m stuck atm.
What if the previuos code for SDL1 uses SDL_DOUBLEBUF or as in this case
SDL_HWPALETTE?

SDL_HWPALETTE doesn’t mean much in modern times; you can just drop it.
Presumably you have a 32-bit display, so if you give SDL an 8-bit
surface, it’ll just convert it to display format as appropriate and not
force a hardware palette that would mess up other windows on the screen.

SDL_DOUBLEBUF doesn’t mean much now either (you’re probably
double-buffered everywhere now), but if you’re using the SDL2 Render API
to get your surface to the screen, you can create the renderer with the
SDL_RENDERER_PRESENTVSYNC to make sure there’s no tearing. If you’re
eventually drawing with OpenGL, you can use SDL_GL_SetSwapInterval(1)
after creating your GL context to the same effect.

–ryan.

1 Like