2 * DOS/DJGPP Mesa Utility Toolkit
5 * Copyright (C) 2005 Daniel Borca All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include <aros/debug.h>
31 extern struct AROSMesaGLUT_TaskNode
*_glut_findtask(struct Task
*);
33 static int timer_installed
;
36 static struct timeval time_start
;
42 D(bug("[AMGLUT] In glutGet(type:%d) ", type
));
44 struct AROSMesaGLUT_TaskNode
*__glutTask
= _glut_findtask(FindTask(NULL
));
49 D(bug("GLUT_WINDOW_X = %d\n", __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_xpos
));
51 return __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_xpos
;
55 D(bug("GLUT_WINDOW_Y = %d\n", __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_ypos
));
57 return __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_ypos
;
59 case GLUT_WINDOW_WIDTH
:
61 D(bug("GLUT_WINDOW_WIDTH = %d\n", __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_width
));
63 return __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_width
;
65 case GLUT_WINDOW_HEIGHT
:
67 D(bug("GLUT_WINDOW_HEIGHT = %d\n", __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_height
));
69 return __glutTask
->AMGLUTTN_WindowCurrent
->amglutwin_height
;
71 case GLUT_WINDOW_STENCIL_SIZE
:
73 D(bug("GLUT_STENCIL_SIZE = %d\n", _glut_visual
.stencil
));
75 return _glut_visual
.stencil
;
77 case GLUT_WINDOW_DEPTH_SIZE
:
79 D(bug("GLUT_DEPTH_SIZE = %d\n", _glut_visual
.depth
));
81 return _glut_visual
.depth
;
83 case GLUT_WINDOW_RGBA
:
85 D(bug("GLUT_WINDOW_RGBA = %d", !(_glut_default
.mode
& GLUT_INDEX
)));
87 return !(_glut_default
.mode
& GLUT_INDEX
);
89 case GLUT_WINDOW_COLORMAP_SIZE
:
91 D(bug("GLUT_WINDOW_COLORMAP_SIZE\n"));
93 return (_glut_default
.mode
& GLUT_INDEX
) ? (256 - RESERVED_COLORS
) : 0;
95 case GLUT_SCREEN_WIDTH
:
97 D(bug("GLUT_SCREEN_WIDTH = %d\n", _glut_visual
.geometry
[0]));
99 return _glut_visual
.geometry
[0];
101 case GLUT_SCREEN_HEIGHT
:
103 D(bug("GLUT_SCREEN_HEIGHT = %d\n", _glut_visual
.geometry
[1]));
105 return _glut_visual
.geometry
[1];
107 case GLUT_INIT_WINDOW_X
:
108 return _glut_default
.x
;
109 case GLUT_INIT_WINDOW_Y
:
110 return _glut_default
.y
;
111 case GLUT_INIT_WINDOW_WIDTH
:
112 return _glut_default
.width
;
113 case GLUT_INIT_WINDOW_HEIGHT
:
114 return _glut_default
.height
;
115 case GLUT_INIT_DISPLAY_MODE
:
116 return _glut_default
.mode
;
117 case GLUT_ELAPSED_TIME
:
119 D(bug("GLUT_ELAPSED_TIME\n"));
121 if (!timer_installed
) {
122 timer_installed
= GL_TRUE
;
123 /* gettimeofday(&then, NULL);*/
124 CurrentTime(&time_start
.tv_sec
, &time_start
.tv_usec
);
127 struct timeval time_current
;
128 /* gettimeofday(&now, NULL);
129 return (now.tv_usec - then.tv_usec) / 1000 +
130 (now.tv_sec - then.tv_sec) * 1000;*/
131 CurrentTime(&time_current
.tv_sec
, &time_current
.tv_usec
);
132 return (time_current
.tv_usec
- time_start
.tv_usec
) / 1000 +
133 (time_current
.tv_sec
- time_start
.tv_sec
) * 1000;
138 D(bug("UNKNOWN VALUE!\n"));
147 glutDeviceGet (GLenum type
)
149 D(bug("[AMGLUT] In glutDeviceGet()\n"));
152 case GLUT_HAS_KEYBOARD
:
156 case GLUT_NUM_MOUSE_BUTTONS
:
158 case GLUT_HAS_SPACEBALL
:
159 case GLUT_HAS_DIAL_AND_BUTTON_BOX
:
160 case GLUT_HAS_TABLET
:
162 case GLUT_NUM_SPACEBALL_BUTTONS
:
163 case GLUT_NUM_BUTTON_BOX_BUTTONS
:
165 case GLUT_NUM_TABLET_BUTTONS
:
174 glutGetModifiers (void)
178 D(bug("[AMGLUT] In glutGetModifiers()\n"));
180 // int shifts = pc_keyshifts();
182 /* if (shifts & (KB_SHIFT_FLAG | KB_CAPSLOCK_FLAG)) {
183 mod |= GLUT_ACTIVE_SHIFT;
186 if (shifts & KB_ALT_FLAG) {
187 mod |= GLUT_ACTIVE_ALT;
190 if (shifts & KB_CTRL_FLAG) {
191 mod |= GLUT_ACTIVE_CTRL;
199 glutReportErrors (void)
201 D(bug("[AMGLUT] In glutReportErrors()\n"));
203 /* reports all the OpenGL errors that happened till now */
208 * Hack alert: incomplete... what is GameMode, anyway?
211 static GLboolean game_possible
;
212 static GLboolean game_active
;
213 static GLuint game_width
;
214 static GLuint game_height
;
215 static GLuint game_bpp
;
216 static GLuint game_refresh
;
220 glutGameModeString (const char *string
)
222 D(bug("[AMGLUT] In glutGameModeString()\n"));
224 if (sscanf(string
, "%ux%u:%u@%u", &game_width
, &game_height
, &game_bpp
, &game_refresh
) == 4) {
225 game_possible
= GL_TRUE
;
231 glutGameModeGet (GLenum mode
)
233 D(bug("[AMGLUT] In glutGameModeGet()\n"));
235 struct AROSMesaGLUT_TaskNode
*__glutTask
= _glut_findtask(FindTask(NULL
));
237 case GLUT_GAME_MODE_ACTIVE
:
239 case GLUT_GAME_MODE_POSSIBLE
:
240 return game_possible
&& !__glutTask
->AMGLUTTN_WindowCurrent
;
241 case GLUT_GAME_MODE_WIDTH
:
242 return game_active
? (int)game_width
: -1;
243 case GLUT_GAME_MODE_HEIGHT
:
244 return game_active
? (int)game_height
: -1;
245 case GLUT_GAME_MODE_PIXEL_DEPTH
:
246 return game_active
? (int)game_bpp
: -1;
247 case GLUT_GAME_MODE_REFRESH_RATE
:
248 return game_active
? (int)game_refresh
: -1;
256 glutEnterGameMode (void)
258 D(bug("[AMGLUT] In glutEnterGameMode()\n"));
260 if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE
)) {
261 _glut_visual
.bpp
= game_bpp
;
262 _glut_visual
.refresh
= game_refresh
;
264 glutInitWindowSize(game_width
, game_height
);
266 if ((game
= glutCreateWindow("<game>")) > 0) {
267 game_active
= GL_TRUE
;
278 glutLeaveGameMode (void)
280 D(bug("[AMGLUT] In glutLeaveGameMode()\n"));
282 if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE
)) {
283 game_active
= GL_FALSE
;
285 glutDestroyWindow(game
);