This was fairly simple to implement once I figured out how. You will need to add more code if you want different resolutions for windowed and fullscreen.
All Platforms:
I was going to use the 'F11' key but it would need more work to setup. This is in void Program::keyDown(char key) in glest_game/main/program.cpp
if(key=='Q'){
window->toggleFullscreen();
}
Linux:
The
SDL_GetVideoSurface(void) and
SDL_WM_ToggleFullScreen(SDL_Surface *surface) functions were easy enough to put into shared_lib/include/platform/sdl/window.h
void toggleFullscreen() { SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); }
Windows:
I haven't tested this but it should work if the setStyle function does what I think it does.
In shared_lib/include/platform/win32/window.h
void toggleFullscreen();
In shared_lib/sources/platform/win32/window.cpp
void Window::toggleFullscreen(){
if(windowStyle == wsFullscreen){
setStyle(wsWindowedFixed);
} else {
setStyle(wsFullscreen);
}
}
The diff of this is
here.
When doing this I noticed that config.getBool("Windowed") was being called a few times in program.cpp so wouldn't it be better to use an instance variable to contain the boolean value?