Author Topic: Toggle Fullscreen  (Read 3302 times)

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Toggle Fullscreen
« on: 25 January 2008, 12:59:31 »
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
Code: [Select]
   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

Code: [Select]
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
Code: [Select]
void toggleFullscreen();
In shared_lib/sources/platform/win32/window.cpp
Code: [Select]
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?
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Jamesgamer

  • Guest
(No subject)
« Reply #1 on: 27 January 2008, 00:19:47 »
ty, this will help

haven't tried it yet...
« Last Edit: 1 January 1970, 00:00:00 by Jamesgamer »

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
(No subject)
« Reply #2 on: 28 January 2008, 09:02:12 »
Hi, I told martinho and matze about this patch and I'm quite shure it will be included soon.
« Last Edit: 1 January 1970, 00:00:00 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

myles

  • Technician
  • ****
  • Posts: 113
    • View Profile
    • Myles Lambert's Portfolio
(No subject)
« Reply #3 on: 28 January 2008, 17:33:11 »
Great work Hail,

I really hope you learn more and more about C++ and what not. Good work!
« Last Edit: 1 January 1970, 00:00:00 by myles »

martiño

  • Behemoth
  • *******
  • Posts: 1,095
    • View Profile
(No subject)
« Reply #4 on: 28 January 2008, 23:33:21 »
The code would not work on windows, since setStyle has to be called before creating the window. I don't have a good understanding of the windows API to be honest and I don't really know how to do this, bu I will investigate.
« Last Edit: 1 January 1970, 00:00:00 by martiño »

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
(No subject)
« Reply #5 on: 29 January 2008, 05:27:16 »
What about destroying the window then recreating it with the existing (or resized) drawing area?
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
(No subject)
« Reply #6 on: 8 February 2008, 12:42:27 »
I just wanted to thank you for this! It's a really good feature for the linux version. Without this multiplayer/irc  things would be very annoying!
« Last Edit: 1 January 1970, 00:00:00 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Jamesgamer

  • Guest
(No subject)
« Reply #7 on: 10 February 2008, 01:59:04 »
There must be some way to do this in windows; Armagetron was able to...
« Last Edit: 1 January 1970, 00:00:00 by Jamesgamer »

tux-gamer

  • Guest
(No subject)
« Reply #8 on: 20 February 2008, 13:18:07 »
How to Aplly this Patch to glest-source-3.1.0.tar.bz2  ?

Thank's before
« Last Edit: 1 January 1970, 00:00:00 by tux-gamer »