19. OpenGL Fullscreen Mode
just before you call the line to enter glut fullscreen mode you choose
which settings to use when in glut fullscreen mode.
Such as the resolution,
color depth and the refresh rate.
we do this with:
glutGameModeString( “990×768:32@75” );
this is setting the resolution to 990×768, you can also use 800×600, 640×480, etc
next it is saying to use a color depth of 32 bits, you can also use 24, 16, 8, etc
then it is telling the program to run the screen refresh rate at 75hertz, others are 65, 70, 80, 85, etc
after that when then tell GLUT to enter the fullscreen mode which it callse Game Mode.
we do this with:
glutEnterGameMode();
then when we want to exit the program we say:
glutLeaveGameMode(); to set the screen back to how it was
and that was it. simple wasn’t it?
If you have any questions, just email me at swiftless@gmail.com 🙂
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. |
#include <GL/gl.h> #include <GL/glut.h> #include <stdlib.h> #include <math.h> //angle of rotation //draw the cubes, they make a fancy shape from above 😛 void init (void) { void camera (void) { void display (void) { void reshape (int w, int h) { void keyboard (unsigned char key, int x, int y) { if (key==‘z’) if (key==‘w’) if (key==‘s’) if (key==‘d’) if (key==‘a’) int main (int argc, char **argv) { |
In my case, to set proper fullscreen (without window frame and etc.) I use:
glutGameModeString(“1366×768:32@60”);
glutEnterGameMode();
glutFullScreen();
Why not use:
glutFullScreenToggle();
It will go into full screen if we’re currently in windowed mode and to windowed mode if we’re in full screen.
Not sure how to change the resolution of the full screen mode, but should be the same as changing it for the window.
while i was executing the program it is giving the compile errors
Hi mr.jagan,
What are the compile errors? Some people have mentioned in other comments on this page that they have had to make changes. I’m guessing GLUT and FreeGLUT have an incompatibility here.
Cheers,
Swiftless
It’s working for me Swiftless and your tutorial is really helpful now that i deal with openGL, keep at it! 🙂
Unrecognized game mode string error comes up.. 🙁
Hey Nishant,
Have you tried changing the game mode string, eg: “990×768:32@75” to something that your monitor supports? This was done when I had my old CRT monitory and most LCD displays don’t use 75Hz.
Cheers,
Swiftless
Seems like it’s not working for me.
I get the error
“Unrecognized game mode string word: 1200î800:32@60”
My game mode string is “1200×800:32@60”. what to do now? :O
Other than that, your tutorials are really really really awesome! Keep em coming!
I got the same error – check “1200×800:32@60″ string and be sure “x” is x 🙂 delete and press “x” from keyboard….
Thanks to your solution! My code is now working by retyping ‘x’!
Huum, been having a play around with this, though it dosent seem to want to go fullscreen with a single buffer, and when i use a double buffer it seems to stop my update calls.
glutIdleFunc (display); dosent seem to work, and as b4
glutPostRedisplay(); stops working with a double buffer.
As far as I’m aware, if you’re using duble buffers, make sure you’ve got “glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);” and “glutSwapBuffers();” inside your ‘display’ function and that should work, if you’ve got both and its still happenning, then idk lol.