case SDLK_F1:
flags ^= SDL_FULLSCREEN;
screen = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,flags);
if(screen == NULL)
{
cerr << "SDL_SetVideoMode() Failed: " << SDL_GetError() << endl;
quit(1);
}
initialize_opengl(WINDOW_WIDTH,WINDOW_HEIGHT);
break;
And uh...it didn't take too long to figure out (re-setup everything after resizing), but I'm just wondering if there was an easier way or if I wasted 10 minutes of my life.
Thanks.
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
SDL on Windows - Easier way to resize?
Ok, sorry if this has already been asked a hundred times already, just, uh...delete it and PM me with a link if it has, I guess.
Is there an easy way to resize the window on...windows? I know Linux got the SDL_WM_blahblah() whatever it was that doesn't work, and I ended up using
Things change.
You can't keep the OpenGL context on Windows when changing pixel formats, so switching between windowed and fullscreen modes usually requires everything to be reinitialised. However, I use an Evil Hack for resizing in windowed modes:
Just replace SetVideoMode with SDL_SetVideoMode_Win32Hack when on Windows and it does the trick. I made some modifications to it before posting, so hopefully I didn't stuff anything up :)
SDL_Surface * SDL_SetVideoMode_Win32Hack(int width, int height, int bpp, Uint32 flags){ SDL_Surface *window = SDL_GetVideoSurface(); if (window && !(window->flags & SDL_FULLSCREEN) && !(flags & SDL_FULLSCREEN)) { SDL_SysWMinfo info; info.version.major = SDL_MAJOR_VERSION; info.version.minor = SDL_MINOR_VERSION; info.window = NULL; if (SDL_GetWMInfo(&info)) { RECT rect; rect.left = rect.top = 0; rect.right = width; rect.bottom = height; DWORD style = GetWindowLong(info.window, GWL_STYLE); AdjustWindowRectEx(&rect, style, (style & WS_CHILDWINDOW) ? FALSE : GetMenu(info.window) != NULL, GetWindowLong(info.window, GWL_EXSTYLE)); Uint32 prevFlags = window->flags; window->flags |= SDL_RESIZABLE; // Prevent SDL from stopping resize SetWindowPos( info.window, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOMOVE); window->flags = prevFlags; } window->w = width; window->h = height; } else { // Create new window window = SDL_SetVideoMode(width, height, bpp, flags); /*** Do normal stuff here ***/ }}
Just replace SetVideoMode with SDL_SetVideoMode_Win32Hack when on Windows and it does the trick. I made some modifications to it before posting, so hopefully I didn't stuff anything up :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement