1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox Windows NT/2000/XP guest OpenGL ICD
|
---|
4 | *
|
---|
5 | * Simple buffered OpenGL functions
|
---|
6 | *
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | *
|
---|
21 | */
|
---|
22 |
|
---|
23 | #include "VBoxOGL.h"
|
---|
24 |
|
---|
25 |
|
---|
26 | /* OpenGL functions */
|
---|
27 | void APIENTRY glFinish (void)
|
---|
28 | {
|
---|
29 | /** @todo if no back buffer, then draw to screen */
|
---|
30 | VBOX_OGL_GEN_SYNC_OP(Finish);
|
---|
31 | }
|
---|
32 |
|
---|
33 | void APIENTRY glFlush (void)
|
---|
34 | {
|
---|
35 | /** @todo if no back buffer, then draw to screen */
|
---|
36 | VBOX_OGL_GEN_SYNC_OP(Flush);
|
---|
37 | }
|
---|
38 |
|
---|
39 | GLuint APIENTRY glGenLists (GLsizei range)
|
---|
40 | {
|
---|
41 | VBOX_OGL_GEN_SYNC_OP1_RET(GLuint, GenLists, range);
|
---|
42 | return retval;
|
---|
43 | }
|
---|
44 |
|
---|
45 | GLboolean APIENTRY glIsEnabled (GLenum cap)
|
---|
46 | {
|
---|
47 | /** @todo cache? */
|
---|
48 | VBOX_OGL_GEN_SYNC_OP1_RET(GLboolean, IsEnabled, cap);
|
---|
49 | return retval;
|
---|
50 | }
|
---|
51 |
|
---|
52 | GLboolean APIENTRY glIsList (GLuint list)
|
---|
53 | {
|
---|
54 | VBOX_OGL_GEN_SYNC_OP1_RET(GLboolean, IsList, list);
|
---|
55 | return retval;
|
---|
56 | }
|
---|
57 |
|
---|
58 | GLboolean APIENTRY glIsTexture (GLuint texture)
|
---|
59 | {
|
---|
60 | VBOX_OGL_GEN_SYNC_OP1_RET(GLboolean, IsTexture, texture);
|
---|
61 | return retval;
|
---|
62 | }
|
---|
63 |
|
---|
64 | static uint32_t vboxglGetNrElements(GLenum pname)
|
---|
65 | {
|
---|
66 | switch(pname)
|
---|
67 | {
|
---|
68 | case GL_ACCUM_ALPHA_BITS:
|
---|
69 | case GL_ACCUM_BLUE_BITS:
|
---|
70 | case GL_ACCUM_GREEN_BITS:
|
---|
71 | case GL_ACCUM_RED_BITS:
|
---|
72 | case GL_ALPHA_BIAS:
|
---|
73 | case GL_ALPHA_BITS:
|
---|
74 | case GL_ALPHA_SCALE:
|
---|
75 | case GL_ALPHA_TEST:
|
---|
76 | case GL_ALPHA_TEST_FUNC:
|
---|
77 | case GL_ALPHA_TEST_REF:
|
---|
78 | case GL_ATTRIB_STACK_DEPTH:
|
---|
79 | case GL_AUTO_NORMAL:
|
---|
80 | case GL_AUX_BUFFERS:
|
---|
81 | case GL_BLEND:
|
---|
82 | case GL_BLEND_DST:
|
---|
83 | // case GL_BLEND_EQUATION_EXT:
|
---|
84 | case GL_BLEND_SRC:
|
---|
85 | case GL_BLUE_BIAS:
|
---|
86 | case GL_BLUE_BITS:
|
---|
87 | case GL_BLUE_SCALE:
|
---|
88 | case GL_CLIENT_ATTRIB_STACK_DEPTH:
|
---|
89 | // case GL_CLIP_PLANEi:
|
---|
90 | case GL_COLOR_ARRAY:
|
---|
91 | case GL_COLOR_ARRAY_SIZE:
|
---|
92 | case GL_COLOR_ARRAY_STRIDE:
|
---|
93 | case GL_COLOR_ARRAY_TYPE:
|
---|
94 | case GL_COLOR_LOGIC_OP:
|
---|
95 | case GL_COLOR_MATERIAL:
|
---|
96 | case GL_COLOR_MATERIAL_FACE:
|
---|
97 | case GL_COLOR_MATERIAL_PARAMETER:
|
---|
98 | case GL_CULL_FACE:
|
---|
99 | case GL_CULL_FACE_MODE:
|
---|
100 | case GL_CURRENT_INDEX:
|
---|
101 | case GL_CURRENT_RASTER_DISTANCE:
|
---|
102 | case GL_CURRENT_RASTER_INDEX:
|
---|
103 | case GL_CURRENT_RASTER_POSITION_VALID:
|
---|
104 | case GL_DEPTH_BIAS:
|
---|
105 | case GL_DEPTH_BITS:
|
---|
106 | case GL_DEPTH_CLEAR_VALUE:
|
---|
107 | case GL_DEPTH_FUNC:
|
---|
108 | case GL_DEPTH_SCALE:
|
---|
109 | case GL_DEPTH_TEST:
|
---|
110 | case GL_DEPTH_WRITEMASK:
|
---|
111 | case GL_DITHER:
|
---|
112 | case GL_DOUBLEBUFFER:
|
---|
113 | case GL_DRAW_BUFFER:
|
---|
114 | case GL_EDGE_FLAG:
|
---|
115 | case GL_EDGE_FLAG_ARRAY:
|
---|
116 | case GL_EDGE_FLAG_ARRAY_STRIDE:
|
---|
117 | case GL_FOG:
|
---|
118 | case GL_FOG_DENSITY:
|
---|
119 | case GL_FOG_END:
|
---|
120 | case GL_FOG_HINT:
|
---|
121 | case GL_FOG_INDEX:
|
---|
122 | case GL_FOG_MODE:
|
---|
123 | case GL_FOG_START:
|
---|
124 | case GL_FRONT_FACE:
|
---|
125 | case GL_GREEN_BIAS:
|
---|
126 | case GL_GREEN_BITS:
|
---|
127 | case GL_GREEN_SCALE:
|
---|
128 | case GL_INDEX_ARRAY:
|
---|
129 | case GL_INDEX_ARRAY_STRIDE:
|
---|
130 | case GL_INDEX_ARRAY_TYPE:
|
---|
131 | case GL_INDEX_BITS:
|
---|
132 | case GL_INDEX_CLEAR_VALUE:
|
---|
133 | case GL_INDEX_LOGIC_OP:
|
---|
134 | case GL_INDEX_MODE:
|
---|
135 | case GL_INDEX_OFFSET:
|
---|
136 | case GL_INDEX_SHIFT:
|
---|
137 | case GL_INDEX_WRITEMASK:
|
---|
138 | // case GL_LIGHTi:
|
---|
139 | case GL_LIGHTING:
|
---|
140 | case GL_LIGHT_MODEL_LOCAL_VIEWER:
|
---|
141 | case GL_LIGHT_MODEL_TWO_SIDE:
|
---|
142 | case GL_LINE_SMOOTH:
|
---|
143 | case GL_LINE_SMOOTH_HINT:
|
---|
144 | case GL_LINE_STIPPLE:
|
---|
145 | case GL_LINE_STIPPLE_PATTERN:
|
---|
146 | case GL_LINE_STIPPLE_REPEAT:
|
---|
147 | case GL_LINE_WIDTH:
|
---|
148 | case GL_LINE_WIDTH_GRANULARITY :
|
---|
149 | case GL_LIST_BASE:
|
---|
150 | case GL_LIST_INDEX:
|
---|
151 | case GL_LIST_MODE:
|
---|
152 | case GL_LOGIC_OP_MODE:
|
---|
153 | case GL_MAP1_COLOR_4:
|
---|
154 | case GL_MAP1_GRID_SEGMENTS:
|
---|
155 | case GL_MAP1_INDEX:
|
---|
156 | case GL_MAP1_NORMAL:
|
---|
157 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
158 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
159 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
160 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
161 | case GL_MAP1_VERTEX_3:
|
---|
162 | case GL_MAP1_VERTEX_4:
|
---|
163 | case GL_MAP2_COLOR_4:
|
---|
164 | case GL_MAP2_INDEX:
|
---|
165 | case GL_MAP2_NORMAL:
|
---|
166 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
167 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
168 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
169 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
170 | case GL_MAP2_VERTEX_3:
|
---|
171 | case GL_MAP2_VERTEX_4:
|
---|
172 | case GL_MAP_COLOR:
|
---|
173 | case GL_MAP_STENCIL:
|
---|
174 | case GL_MATRIX_MODE:
|
---|
175 | case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
|
---|
176 | case GL_MAX_ATTRIB_STACK_DEPTH:
|
---|
177 | case GL_MAX_CLIP_PLANES:
|
---|
178 | case GL_MAX_EVAL_ORDER:
|
---|
179 | case GL_MAX_LIGHTS:
|
---|
180 | case GL_MAX_LIST_NESTING:
|
---|
181 | case GL_MAX_MODELVIEW_STACK_DEPTH:
|
---|
182 | case GL_MAX_NAME_STACK_DEPTH:
|
---|
183 | case GL_MAX_PIXEL_MAP_TABLE:
|
---|
184 | case GL_MAX_PROJECTION_STACK_DEPTH:
|
---|
185 | case GL_MAX_TEXTURE_SIZE:
|
---|
186 | case GL_MAX_TEXTURE_STACK_DEPTH :
|
---|
187 | case GL_MODELVIEW_STACK_DEPTH:
|
---|
188 | case GL_NAME_STACK_DEPTH:
|
---|
189 | case GL_NORMAL_ARRAY:
|
---|
190 | case GL_NORMAL_ARRAY_STRIDE:
|
---|
191 | case GL_NORMAL_ARRAY_TYPE:
|
---|
192 | case GL_NORMALIZE:
|
---|
193 | case GL_PACK_ALIGNMENT:
|
---|
194 | case GL_PACK_LSB_FIRST:
|
---|
195 | case GL_PACK_ROW_LENGTH:
|
---|
196 | case GL_PACK_SKIP_PIXELS:
|
---|
197 | case GL_PACK_SKIP_ROWS:
|
---|
198 | case GL_PACK_SWAP_BYTES:
|
---|
199 | case GL_PERSPECTIVE_CORRECTION_HINT:
|
---|
200 | case GL_PIXEL_MAP_A_TO_A_SIZE:
|
---|
201 | case GL_PIXEL_MAP_B_TO_B_SIZE:
|
---|
202 | case GL_PIXEL_MAP_G_TO_G_SIZE:
|
---|
203 | case GL_PIXEL_MAP_I_TO_A_SIZE:
|
---|
204 | case GL_PIXEL_MAP_I_TO_B_SIZE:
|
---|
205 | case GL_PIXEL_MAP_I_TO_G_SIZE:
|
---|
206 | case GL_PIXEL_MAP_I_TO_I_SIZE:
|
---|
207 | case GL_PIXEL_MAP_I_TO_R_SIZE:
|
---|
208 | case GL_PIXEL_MAP_R_TO_R_SIZE:
|
---|
209 | case GL_PIXEL_MAP_S_TO_S_SIZE:
|
---|
210 | case GL_POINT_SIZE:
|
---|
211 | case GL_POINT_SIZE_GRANULARITY :
|
---|
212 | case GL_POINT_SMOOTH:
|
---|
213 | case GL_POINT_SMOOTH_HINT :
|
---|
214 | case GL_POLYGON_OFFSET_FACTOR:
|
---|
215 | case GL_POLYGON_OFFSET_UNITS :
|
---|
216 | case GL_POLYGON_OFFSET_FILL:
|
---|
217 | case GL_POLYGON_OFFSET_LINE:
|
---|
218 | case GL_POLYGON_OFFSET_POINT:
|
---|
219 | case GL_POLYGON_SMOOTH:
|
---|
220 | case GL_POLYGON_SMOOTH_HINT:
|
---|
221 | case GL_POLYGON_STIPPLE:
|
---|
222 | case GL_PROJECTION_STACK_DEPTH:
|
---|
223 | case GL_READ_BUFFER:
|
---|
224 | case GL_RED_BIAS:
|
---|
225 | case GL_RED_BITS:
|
---|
226 | case GL_RED_SCALE:
|
---|
227 | case GL_RENDER_MODE:
|
---|
228 | case GL_RGBA_MODE:
|
---|
229 | case GL_SCISSOR_TEST:
|
---|
230 | case GL_SHADE_MODEL:
|
---|
231 | case GL_STENCIL_BITS:
|
---|
232 | case GL_STENCIL_CLEAR_VALUE:
|
---|
233 | case GL_STENCIL_FAIL:
|
---|
234 | case GL_STENCIL_FUNC:
|
---|
235 | case GL_STENCIL_PASS_DEPTH_FAIL:
|
---|
236 | case GL_STENCIL_PASS_DEPTH_PASS:
|
---|
237 | case GL_STENCIL_REF:
|
---|
238 | case GL_STENCIL_TEST:
|
---|
239 | case GL_STENCIL_VALUE_MASK:
|
---|
240 | case GL_STENCIL_WRITEMASK:
|
---|
241 | case GL_STEREO:
|
---|
242 | case GL_SUBPIXEL_BITS:
|
---|
243 | case GL_TEXTURE_1D:
|
---|
244 | // case GL_TEXTURE_1D_BINDING:
|
---|
245 | case GL_TEXTURE_2D :
|
---|
246 | // case GL_TEXTURE_2D_BINDING:
|
---|
247 | case GL_TEXTURE_COORD_ARRAY:
|
---|
248 | case GL_TEXTURE_COORD_ARRAY_SIZE:
|
---|
249 | case GL_TEXTURE_COORD_ARRAY_STRIDE:
|
---|
250 | case GL_TEXTURE_COORD_ARRAY_TYPE:
|
---|
251 | case GL_TEXTURE_GEN_Q:
|
---|
252 | case GL_TEXTURE_GEN_R:
|
---|
253 | case GL_TEXTURE_GEN_S:
|
---|
254 | case GL_TEXTURE_GEN_T:
|
---|
255 | case GL_TEXTURE_STACK_DEPTH:
|
---|
256 | case GL_UNPACK_ALIGNMENT:
|
---|
257 | case GL_UNPACK_LSB_FIRST:
|
---|
258 | case GL_UNPACK_ROW_LENGTH:
|
---|
259 | case GL_UNPACK_SKIP_PIXELS:
|
---|
260 | case GL_UNPACK_SKIP_ROWS:
|
---|
261 | case GL_UNPACK_SWAP_BYTES:
|
---|
262 | case GL_VERTEX_ARRAY:
|
---|
263 | case GL_VERTEX_ARRAY_SIZE:
|
---|
264 | case GL_VERTEX_ARRAY_STRIDE:
|
---|
265 | case GL_VERTEX_ARRAY_TYPE:
|
---|
266 | case GL_ZOOM_X:
|
---|
267 | case GL_ZOOM_Y:
|
---|
268 | return 1;
|
---|
269 |
|
---|
270 | case GL_ACCUM_CLEAR_VALUE:
|
---|
271 | // case GL_BLEND_COLOR_EXT:
|
---|
272 | case GL_COLOR_CLEAR_VALUE:
|
---|
273 | case GL_COLOR_WRITEMASK:
|
---|
274 | case GL_CURRENT_COLOR:
|
---|
275 | case GL_CURRENT_RASTER_COLOR:
|
---|
276 | case GL_CURRENT_RASTER_POSITION:
|
---|
277 | case GL_CURRENT_RASTER_TEXTURE_COORDS:
|
---|
278 | case GL_CURRENT_TEXTURE_COORDS:
|
---|
279 | case GL_FOG_COLOR:
|
---|
280 | case GL_LIGHT_MODEL_AMBIENT:
|
---|
281 | case GL_MAP2_GRID_DOMAIN:
|
---|
282 | case GL_VIEWPORT:
|
---|
283 | case GL_SCISSOR_BOX:
|
---|
284 | return 4;
|
---|
285 |
|
---|
286 | case GL_DEPTH_RANGE:
|
---|
287 | case GL_LINE_WIDTH_RANGE:
|
---|
288 | case GL_MAP1_GRID_DOMAIN:
|
---|
289 | case GL_MAP2_GRID_SEGMENTS:
|
---|
290 | case GL_MAX_VIEWPORT_DIMS:
|
---|
291 | case GL_POINT_SIZE_RANGE:
|
---|
292 | case GL_POLYGON_MODE:
|
---|
293 | return 2;
|
---|
294 |
|
---|
295 | case GL_CURRENT_NORMAL:
|
---|
296 | return 3;
|
---|
297 |
|
---|
298 | case GL_MODELVIEW_MATRIX:
|
---|
299 | case GL_PROJECTION_MATRIX:
|
---|
300 | case GL_TEXTURE_MATRIX:
|
---|
301 | return 16;
|
---|
302 |
|
---|
303 | default:
|
---|
304 | AssertMsgFailed(("%s Unknown element %x\n", __FUNCTION__, pname));
|
---|
305 | return 0;
|
---|
306 | }
|
---|
307 | }
|
---|
308 |
|
---|
309 | void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params)
|
---|
310 | {
|
---|
311 | uint32_t n = vboxglGetNrElements(pname);
|
---|
312 |
|
---|
313 | if (!n)
|
---|
314 | {
|
---|
315 | AssertMsgFailed(("glGetBooleanv: Invalid enum %x\n", pname));
|
---|
316 | glSetError(GL_INVALID_ENUM);
|
---|
317 | return;
|
---|
318 | }
|
---|
319 |
|
---|
320 | VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetBooleanv, pname, n*sizeof(GLboolean), params);
|
---|
321 | return;
|
---|
322 | }
|
---|
323 |
|
---|
324 | void APIENTRY glGetDoublev (GLenum pname, GLdouble *params)
|
---|
325 | {
|
---|
326 | uint32_t n = vboxglGetNrElements(pname);
|
---|
327 |
|
---|
328 | if (!n)
|
---|
329 | {
|
---|
330 | AssertMsgFailed(("glGetDoublev: Invalid enum %x\n", pname));
|
---|
331 | glSetError(GL_INVALID_ENUM);
|
---|
332 | return;
|
---|
333 | }
|
---|
334 |
|
---|
335 | VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetDoublev, pname, n*sizeof(GLdouble), params);
|
---|
336 | return;
|
---|
337 | }
|
---|
338 |
|
---|
339 | void APIENTRY glGetFloatv (GLenum pname, GLfloat *params)
|
---|
340 | {
|
---|
341 | uint32_t n = vboxglGetNrElements(pname);
|
---|
342 |
|
---|
343 | if (!n)
|
---|
344 | {
|
---|
345 | AssertMsgFailed(("glGetFloatv: Invalid enum %x\n", pname));
|
---|
346 | glSetError(GL_INVALID_ENUM);
|
---|
347 | return;
|
---|
348 | }
|
---|
349 |
|
---|
350 | VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetFloatv, pname, n*sizeof(GLfloat), params);
|
---|
351 | return;
|
---|
352 | }
|
---|
353 |
|
---|
354 | void APIENTRY glGetIntegerv (GLenum pname, GLint *params)
|
---|
355 | {
|
---|
356 | uint32_t n = vboxglGetNrElements(pname);
|
---|
357 |
|
---|
358 | if (!n)
|
---|
359 | {
|
---|
360 | AssertMsgFailed(("glGetIntegerv: Invalid enum %x\n", pname));
|
---|
361 | glSetError(GL_INVALID_ENUM);
|
---|
362 | return;
|
---|
363 | }
|
---|
364 |
|
---|
365 | VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetIntegerv, pname, n*sizeof(GLint), params);
|
---|
366 | return;
|
---|
367 | }
|
---|
368 |
|
---|
369 |
|
---|
370 | void APIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v)
|
---|
371 | {
|
---|
372 | AssertFailed(); /** @todo */
|
---|
373 | return;
|
---|
374 | }
|
---|
375 |
|
---|
376 | void APIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v)
|
---|
377 | {
|
---|
378 | AssertFailed(); /** @todo */
|
---|
379 | return;
|
---|
380 | }
|
---|
381 |
|
---|
382 | void APIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v)
|
---|
383 | {
|
---|
384 | AssertFailed(); /** @todo */
|
---|
385 | return;
|
---|
386 | }
|
---|
387 |
|
---|
388 | void APIENTRY glGetPointerv (GLenum pname, GLvoid* *params)
|
---|
389 | {
|
---|
390 | AssertFailed(); /** @todo */
|
---|
391 | return;
|
---|
392 | }
|
---|
393 |
|
---|
394 |
|
---|