2 * Mesa 3-D graphics library
4 * Copyright (C) 1995-1998 Brian Paul
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * DOS/DJGPP glut driver v1.4 for Mesa
24 * Copyright (C) 2002 - Borca Daniel
25 * Email : dborca@yahoo.com
26 * Web : http://www.geocities.com/dborca
40 static int timer_installed
;
41 static volatile int ticks
;
45 static void ticks_timer (void *p
)
49 } ENDOFUNC(ticks_timer
)
53 int APIENTRY
glutGet (GLenum type
)
57 return g_curwin
->xpos
;
59 return g_curwin
->ypos
;
60 case GLUT_WINDOW_WIDTH
:
61 return g_curwin
->width
;
62 case GLUT_WINDOW_HEIGHT
:
63 return g_curwin
->height
;
64 case GLUT_WINDOW_STENCIL_SIZE
:
66 case GLUT_WINDOW_DEPTH_SIZE
:
68 case GLUT_WINDOW_RGBA
:
69 return !(g_display_mode
& GLUT_INDEX
);
70 case GLUT_WINDOW_COLORMAP_SIZE
:
71 return (g_display_mode
& GLUT_INDEX
) ? (256 - RESERVED_COLORS
) : 0;
72 case GLUT_SCREEN_WIDTH
:
74 case GLUT_SCREEN_HEIGHT
:
76 case GLUT_INIT_WINDOW_X
:
78 case GLUT_INIT_WINDOW_Y
:
80 case GLUT_INIT_WINDOW_WIDTH
:
82 case GLUT_INIT_WINDOW_HEIGHT
:
84 case GLUT_INIT_DISPLAY_MODE
:
85 return g_display_mode
;
86 case GLUT_ELAPSED_TIME
:
87 if (!timer_installed
) {
88 timer_installed
= GL_TRUE
;
90 LOCKFUNC(ticks_timer
);
91 pc_install_int(ticks_timer
, NULL
, FREQUENCY
);
93 return ticks
*1000/FREQUENCY
;
101 int APIENTRY
glutDeviceGet (GLenum type
)
104 case GLUT_HAS_KEYBOARD
:
107 return (g_mouse
!= 0);
108 case GLUT_NUM_MOUSE_BUTTONS
:
110 case GLUT_HAS_SPACEBALL
:
111 case GLUT_HAS_DIAL_AND_BUTTON_BOX
:
112 case GLUT_HAS_TABLET
:
114 case GLUT_NUM_SPACEBALL_BUTTONS
:
115 case GLUT_NUM_BUTTON_BOX_BUTTONS
:
117 case GLUT_NUM_TABLET_BUTTONS
:
126 int APIENTRY
glutGetModifiers (void)
129 int shifts
= pc_keyshifts();
131 if (shifts
& (KB_SHIFT_FLAG
| KB_CAPSLOCK_FLAG
)) {
132 mod
|= GLUT_ACTIVE_SHIFT
;
135 if (shifts
& KB_ALT_FLAG
) {
136 mod
|= GLUT_ACTIVE_ALT
;
139 if (shifts
& KB_CTRL_FLAG
) {
140 mod
|= GLUT_ACTIVE_CTRL
;
149 * Hack alert: incomplete... what is GameMode, anyway?
152 static GLboolean game_possible
;
153 static GLboolean game_active
;
154 static GLuint game_width
;
155 static GLuint game_height
;
156 static GLuint game_bpp
;
157 static GLuint game_refresh
;
161 void APIENTRY
glutGameModeString (const char *string
)
163 if (sscanf(string
, "%ux%u:%u@%u", &game_width
, &game_height
, &game_bpp
, &game_refresh
) == 4) {
164 game_possible
= GL_TRUE
;
170 int APIENTRY
glutGameModeGet (GLenum mode
)
173 case GLUT_GAME_MODE_ACTIVE
:
175 case GLUT_GAME_MODE_POSSIBLE
:
176 return game_possible
&& !g_curwin
;
177 case GLUT_GAME_MODE_WIDTH
:
178 return game_active
? (int)game_width
: -1;
179 case GLUT_GAME_MODE_HEIGHT
:
180 return game_active
? (int)game_height
: -1;
181 case GLUT_GAME_MODE_PIXEL_DEPTH
:
182 return game_active
? (int)game_bpp
: -1;
183 case GLUT_GAME_MODE_REFRESH_RATE
:
184 return game_active
? (int)game_refresh
: -1;
192 int APIENTRY
glutEnterGameMode (void)
194 if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE
)) {
196 g_refresh
= game_refresh
;
198 glutInitWindowSize(game_width
, game_height
);
200 if ((g_game
= glutCreateWindow("<game>")) > 0) {
201 game_active
= GL_TRUE
;
212 void GLUTAPIENTRY
glutLeaveGameMode (void)
214 if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE
)) {
215 game_active
= GL_FALSE
;
217 glutDestroyWindow(g_game
);