944,087 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2607
  • C++ RSS
Nov 3rd, 2009
0

Disabling fullscreen using GLUT

Expand Post »
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;

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

Which is calling the following function;

C++ Syntax (Toggle Plain Text)
  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;
C++ Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Skeen is offline Offline
77 posts
since Nov 2009
Nov 4th, 2009
0
Re: Disabling fullscreen using GLUT
Anyone?
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
Skeen is offline Offline
77 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Max Height formula
Next Thread in C++ Forum Timeline: how i do this project in c++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC