SDL window centering?

closed account (Dy7SLyTq)
I am trying to do two things that i have an issue with finding on google. the first is im trying to center the main window, but i cant figure out how to do it.
secondly i want to make it full screen but the flag for setvideomode doesnt work. is there another way?
To center the window you can do
before you call SDL_SetVideoMode.

Unfortunately this use the POSIX function putenv (if available) that takes a non-const char* as argument despite that the documentation say SDL_putenv takes const char* so this could generate a warning or error depending on the compiler.

To avoid that I guess you better store it inside a local array first so that you can pass a non-const char*.
char center_env[] = "SDL_VIDEO_CENTERED=center";

Make sure that the fullscreen dimensions are supported. You can use SDL_VideoModeOK to test one specific, or use SDL_ListModes to get a list of supported fullscreen dimensions.
Topic archived. No new replies allowed.