Disabling fullscreen using GLUT

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 52
Reputation: Skeen is an unknown quantity at this point 
Solved Threads: 1
Skeen's Avatar
Skeen Skeen is offline Offline
Junior Poster in Training

Disabling fullscreen using GLUT

 
0
  #1
20 Days Ago
So I'm working on this OpenGL 3D Graph program, and like, I ran into some trouble, since I wanted it to support fullscreen, so I made the following;

  1. int main(int argc, char *argv[])
  2. {
  3. ... // Some stuff
  4. glutSpecialFunc(SpecKey);
  5. ... // More stuff
  6. }

Which is calling the following function;

  1. GLvoid ResetWindowSize(GLvoid) // Reset WindowSize
  2. {
  3. glutReshapeWindow(WindowWidth, WindowHeight);
  4. glutPositionWindow(0,0);
  5. }
  6.  
  7. GLvoid SpecKey(GLint key, GLint x, GLint y)
  8. {
  9. if (key == GLUT_KEY_F1) // Toggle FullScreen
  10. {
  11. fullscreen = !fullscreen; // Toggle FullScreenBool
  12. if (fullscreen)
  13. {
  14. glutFullScreen(); // Enable Fullscreen
  15. }
  16. else
  17. {
  18. ResetWindowSize(); // Make Window, and resize
  19. }
  20. }
  21. }

WindowWidth and WindowHeight are both global variables, which are updated everytime I'm resizing the window.

fullscreen is a global bool.

The problem is, that going to fullscreen is working fine, however returning to windowed mode, is giving me some problem since it returns with a window resolution equal to my desktop resolution, and not the resolution which is givin' in the variables WindowWidth and WindowHeight.

Anyone able to figure out the problem?

EDIT; I'm able to get it into a fixed resolution using fixes values instead of the variables like this;
  1. GLvoid ResetWindowSize(GLvoid) // Reset WindowSize
  2. {
  3. glutReshapeWindow(800, 600);
  4. glutPositionWindow(0,0);
  5. }
However to make this work I'm forced to call the "ResetWindowSize" function twice?
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 52
Reputation: Skeen is an unknown quantity at this point 
Solved Threads: 1
Skeen's Avatar
Skeen Skeen is offline Offline
Junior Poster in Training
 
0
  #2
19 Days Ago
Anyone?
// Skeen
Reply With Quote Quick reply to this message  
Reply

Tags
c/c++, development, graphics, opengl

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC