summaryrefslogtreecommitdiff
path: root/src/glut/dos/state.c
diff options
context:
space:
mode:
authorDaniel Borca <dborca@users.sourceforge.net>2003-10-13 11:05:36 +0000
committerJosé Fonseca <jfonseca@vmware.com>2011-07-11 20:03:31 +0100
commitad2d0bca80ab99f4262bf1d3b6513ff9dfa54958 (patch)
tree7148521dc08c4255f2293db7406b450f541c64dd /src/glut/dos/state.c
parente5836116380faa710e3bc8640c27b530161f80a5 (diff)
downloadglut-ad2d0bca80ab99f4262bf1d3b6513ff9dfa54958.tar.gz
GameMode
Diffstat (limited to 'src/glut/dos/state.c')
-rw-r--r--src/glut/dos/state.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/glut/dos/state.c b/src/glut/dos/state.c
index e9d854c..b245569 100644
--- a/src/glut/dos/state.c
+++ b/src/glut/dos/state.c
@@ -27,6 +27,8 @@
*/
+#include <stdio.h>
+
#include "glutint.h"
@@ -140,3 +142,78 @@ int APIENTRY glutGetModifiers (void)
return mod;
}
+
+
+
+/* GAME MODE
+ * Hack alert: incomplete... what is GameMode, anyway?
+ */
+GLint g_game;
+static GLboolean game_possible;
+static GLboolean game_active;
+static GLuint game_width;
+static GLuint game_height;
+static GLuint game_bpp;
+static GLuint game_refresh;
+
+
+
+void APIENTRY glutGameModeString (const char *string)
+{
+ if (sscanf(string, "%ux%u:%u@%u", &game_width, &game_height, &game_bpp, &game_refresh) == 4) {
+ game_possible = GL_TRUE;
+ }
+}
+
+
+
+int APIENTRY glutGameModeGet (GLenum mode)
+{
+ switch (mode) {
+ case GLUT_GAME_MODE_ACTIVE:
+ return game_active;
+ case GLUT_GAME_MODE_POSSIBLE:
+ return game_possible && !g_curwin;
+ case GLUT_GAME_MODE_WIDTH:
+ return game_active ? (int)game_width : -1;
+ case GLUT_GAME_MODE_HEIGHT:
+ return game_active ? (int)game_height : -1;
+ case GLUT_GAME_MODE_PIXEL_DEPTH:
+ return game_active ? (int)game_bpp : -1;
+ case GLUT_GAME_MODE_REFRESH_RATE:
+ return game_active ? (int)game_refresh : -1;
+ default:
+ return -1;
+ }
+}
+
+
+
+int APIENTRY glutEnterGameMode (void)
+{
+ if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE)) {
+ g_bpp = game_bpp;
+ g_refresh = game_refresh;
+
+ glutInitWindowSize(game_width, game_height);
+
+ if ((g_game = glutCreateWindow("<game>")) > 0) {
+ game_active = GL_TRUE;
+ }
+
+ return g_game;
+ } else {
+ return 0;
+ }
+}
+
+
+
+void GLUTAPIENTRY glutLeaveGameMode (void)
+{
+ if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE)) {
+ game_active = GL_FALSE;
+
+ glutDestroyWindow(g_game);
+ }
+}