VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/OGLSimpleSync.cpp@ 3413

Last change on this file since 3413 was 3413, checked in by vboxsync, 18 years ago

OGL: correction + more wgl exports

File size: 13.4 KB
Line 
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
26BOOL APIENTRY DrvDeleteContext(HGLRC hglrc)
27{
28 VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvDeleteContext, hglrc);
29 return retval;
30}
31
32/* Test export for directly linking with vboxogl.dll */
33BOOL WINAPI wglDeleteContext(HGLRC hglrc)
34{
35 return DrvDeleteContext(hglrc);
36}
37
38BOOL APIENTRY DrvCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
39{
40 VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvCopyContext, hglrcSrc, hglrcDst, mask);
41 return retval;
42}
43
44/* Test export for directly linking with vboxogl.dll */
45BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
46{
47 return DrvCopyContext(hglrcSrc, hglrcDst, mask);
48}
49
50void APIENTRY DrvReleaseContext(HGLRC hglrc)
51{
52 VBOX_OGL_GEN_SYNC_OP1(DrvReleaseContext, hglrc);
53}
54
55BOOL APIENTRY DrvShareLists(HGLRC hglrc1, HGLRC hglrc2)
56{
57 VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvShareLists, hglrc1, hglrc2);
58 return retval;
59}
60
61BOOL WINAPI wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
62{
63 return DrvShareLists(hglrc1, hglrc2);
64}
65
66int APIENTRY DrvSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
67 int iStart, int cEntries,
68 CONST COLORREF *pcr)
69{
70 VBOX_OGL_GEN_SYNC_OP5_PTR_RET(int, DrvSetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
71 return retval;
72}
73
74/* Test export for directly linking with vboxogl.dll */
75int WINAPI wglSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
76 int iStart, int cEntries,
77 CONST COLORREF *pcr)
78{
79 return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
80}
81
82BOOL APIENTRY DrvRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
83{
84 VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvRealizeLayerPalette, hdc, iLayerPlane, bRealize);
85 return retval;
86}
87
88/* Test export for directly linking with vboxogl.dll */
89BOOL WINAPI wglRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
90{
91 return DrvRealizeLayerPalette(hdc, iLayerPlane, bRealize);
92}
93
94BOOL APIENTRY DrvSwapLayerBuffers(HDC hdc, UINT fuPlanes)
95{
96 VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvSwapLayerBuffers, hdc, fuPlanes);
97 return retval;
98}
99
100/* Test export for directly linking with vboxogl.dll */
101BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes)
102{
103 return DrvSwapLayerBuffers(hdc, fuPlanes);
104}
105
106BOOL APIENTRY DrvSetPixelFormat(HDC hdc, int iPixelFormat)
107{
108 VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvSetPixelFormat, hdc, iPixelFormat);
109 return retval;
110}
111
112/* Test export for directly linking with vboxogl.dll */
113BOOL WINAPI wglSetPixelFormat(HDC hdc, int iPixelFormat)
114{
115 return DrvSetPixelFormat(hdc, iPixelFormat);
116}
117
118BOOL APIENTRY DrvSwapBuffers(HDC hdc)
119{
120 VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvSwapBuffers, hdc);
121 return retval;
122}
123
124/* Test export for directly linking with vboxogl.dll */
125BOOL WINAPI SwapBuffers(HDC hdc)
126{
127 return DrvSwapBuffers(hdc);
128}
129
130/* OpenGL functions */
131void APIENTRY glFinish (void)
132{
133 /** @todo if no back buffer, then draw to screen */
134 VBOX_OGL_GEN_SYNC_OP(Finish);
135}
136
137void APIENTRY glFlush (void)
138{
139 /** @todo if no back buffer, then draw to screen */
140 VBOX_OGL_GEN_SYNC_OP(Flush);
141}
142
143GLuint APIENTRY glGenLists (GLsizei range)
144{
145 VBOX_OGL_GEN_SYNC_OP1_RET(GLuint, GenLists, range);
146 return retval;
147}
148
149GLboolean APIENTRY glIsEnabled (GLenum cap)
150{
151 /** @todo cache? */
152 VBOX_OGL_GEN_SYNC_OP1_RET(GLboolean, IsEnabled, cap);
153 return retval;
154}
155
156GLboolean APIENTRY glIsList (GLuint list)
157{
158 VBOX_OGL_GEN_SYNC_OP1_RET(GLboolean, IsList, list);
159 return retval;
160}
161
162GLboolean APIENTRY glIsTexture (GLuint texture)
163{
164 VBOX_OGL_GEN_SYNC_OP1_RET(GLboolean, IsTexture, texture);
165 return retval;
166}
167
168static uint32_t vboxglGetNrElements(GLenum pname)
169{
170 switch(pname)
171 {
172 case GL_ACCUM_ALPHA_BITS:
173 case GL_ACCUM_BLUE_BITS:
174 case GL_ACCUM_GREEN_BITS:
175 case GL_ACCUM_RED_BITS:
176 case GL_ALPHA_BIAS:
177 case GL_ALPHA_BITS:
178 case GL_ALPHA_SCALE:
179 case GL_ALPHA_TEST:
180 case GL_ALPHA_TEST_FUNC:
181 case GL_ALPHA_TEST_REF:
182 case GL_ATTRIB_STACK_DEPTH:
183 case GL_AUTO_NORMAL:
184 case GL_AUX_BUFFERS:
185 case GL_BLEND:
186 case GL_BLEND_DST:
187// case GL_BLEND_EQUATION_EXT:
188 case GL_BLEND_SRC:
189 case GL_BLUE_BIAS:
190 case GL_BLUE_BITS:
191 case GL_BLUE_SCALE:
192 case GL_CLIENT_ATTRIB_STACK_DEPTH:
193// case GL_CLIP_PLANEi:
194 case GL_COLOR_ARRAY:
195 case GL_COLOR_ARRAY_SIZE:
196 case GL_COLOR_ARRAY_STRIDE:
197 case GL_COLOR_ARRAY_TYPE:
198 case GL_COLOR_LOGIC_OP:
199 case GL_COLOR_MATERIAL:
200 case GL_COLOR_MATERIAL_FACE:
201 case GL_COLOR_MATERIAL_PARAMETER:
202 case GL_CULL_FACE:
203 case GL_CULL_FACE_MODE:
204 case GL_CURRENT_INDEX:
205 case GL_CURRENT_RASTER_DISTANCE:
206 case GL_CURRENT_RASTER_INDEX:
207 case GL_CURRENT_RASTER_POSITION_VALID:
208 case GL_DEPTH_BIAS:
209 case GL_DEPTH_BITS:
210 case GL_DEPTH_CLEAR_VALUE:
211 case GL_DEPTH_FUNC:
212 case GL_DEPTH_SCALE:
213 case GL_DEPTH_TEST:
214 case GL_DEPTH_WRITEMASK:
215 case GL_DITHER:
216 case GL_DOUBLEBUFFER:
217 case GL_DRAW_BUFFER:
218 case GL_EDGE_FLAG:
219 case GL_EDGE_FLAG_ARRAY:
220 case GL_EDGE_FLAG_ARRAY_STRIDE:
221 case GL_FOG:
222 case GL_FOG_DENSITY:
223 case GL_FOG_END:
224 case GL_FOG_HINT:
225 case GL_FOG_INDEX:
226 case GL_FOG_MODE:
227 case GL_FOG_START:
228 case GL_FRONT_FACE:
229 case GL_GREEN_BIAS:
230 case GL_GREEN_BITS:
231 case GL_GREEN_SCALE:
232 case GL_INDEX_ARRAY:
233 case GL_INDEX_ARRAY_STRIDE:
234 case GL_INDEX_ARRAY_TYPE:
235 case GL_INDEX_BITS:
236 case GL_INDEX_CLEAR_VALUE:
237 case GL_INDEX_LOGIC_OP:
238 case GL_INDEX_MODE:
239 case GL_INDEX_OFFSET:
240 case GL_INDEX_SHIFT:
241 case GL_INDEX_WRITEMASK:
242// case GL_LIGHTi:
243 case GL_LIGHTING:
244 case GL_LIGHT_MODEL_LOCAL_VIEWER:
245 case GL_LIGHT_MODEL_TWO_SIDE:
246 case GL_LINE_SMOOTH:
247 case GL_LINE_SMOOTH_HINT:
248 case GL_LINE_STIPPLE:
249 case GL_LINE_STIPPLE_PATTERN:
250 case GL_LINE_STIPPLE_REPEAT:
251 case GL_LINE_WIDTH:
252 case GL_LINE_WIDTH_GRANULARITY :
253 case GL_LIST_BASE:
254 case GL_LIST_INDEX:
255 case GL_LIST_MODE:
256 case GL_LOGIC_OP_MODE:
257 case GL_MAP1_COLOR_4:
258 case GL_MAP1_GRID_SEGMENTS:
259 case GL_MAP1_INDEX:
260 case GL_MAP1_NORMAL:
261 case GL_MAP1_TEXTURE_COORD_1:
262 case GL_MAP1_TEXTURE_COORD_2:
263 case GL_MAP1_TEXTURE_COORD_3:
264 case GL_MAP1_TEXTURE_COORD_4:
265 case GL_MAP1_VERTEX_3:
266 case GL_MAP1_VERTEX_4:
267 case GL_MAP2_COLOR_4:
268 case GL_MAP2_INDEX:
269 case GL_MAP2_NORMAL:
270 case GL_MAP2_TEXTURE_COORD_1:
271 case GL_MAP2_TEXTURE_COORD_2:
272 case GL_MAP2_TEXTURE_COORD_3:
273 case GL_MAP2_TEXTURE_COORD_4:
274 case GL_MAP2_VERTEX_3:
275 case GL_MAP2_VERTEX_4:
276 case GL_MAP_COLOR:
277 case GL_MAP_STENCIL:
278 case GL_MATRIX_MODE:
279 case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
280 case GL_MAX_ATTRIB_STACK_DEPTH:
281 case GL_MAX_CLIP_PLANES:
282 case GL_MAX_EVAL_ORDER:
283 case GL_MAX_LIGHTS:
284 case GL_MAX_LIST_NESTING:
285 case GL_MAX_MODELVIEW_STACK_DEPTH:
286 case GL_MAX_NAME_STACK_DEPTH:
287 case GL_MAX_PIXEL_MAP_TABLE:
288 case GL_MAX_PROJECTION_STACK_DEPTH:
289 case GL_MAX_TEXTURE_SIZE:
290 case GL_MAX_TEXTURE_STACK_DEPTH :
291 case GL_MODELVIEW_STACK_DEPTH:
292 case GL_NAME_STACK_DEPTH:
293 case GL_NORMAL_ARRAY:
294 case GL_NORMAL_ARRAY_STRIDE:
295 case GL_NORMAL_ARRAY_TYPE:
296 case GL_NORMALIZE:
297 case GL_PACK_ALIGNMENT:
298 case GL_PACK_LSB_FIRST:
299 case GL_PACK_ROW_LENGTH:
300 case GL_PACK_SKIP_PIXELS:
301 case GL_PACK_SKIP_ROWS:
302 case GL_PACK_SWAP_BYTES:
303 case GL_PERSPECTIVE_CORRECTION_HINT:
304 case GL_PIXEL_MAP_A_TO_A_SIZE:
305 case GL_PIXEL_MAP_B_TO_B_SIZE:
306 case GL_PIXEL_MAP_G_TO_G_SIZE:
307 case GL_PIXEL_MAP_I_TO_A_SIZE:
308 case GL_PIXEL_MAP_I_TO_B_SIZE:
309 case GL_PIXEL_MAP_I_TO_G_SIZE:
310 case GL_PIXEL_MAP_I_TO_I_SIZE:
311 case GL_PIXEL_MAP_I_TO_R_SIZE:
312 case GL_PIXEL_MAP_R_TO_R_SIZE:
313 case GL_PIXEL_MAP_S_TO_S_SIZE:
314 case GL_POINT_SIZE:
315 case GL_POINT_SIZE_GRANULARITY :
316 case GL_POINT_SMOOTH:
317 case GL_POINT_SMOOTH_HINT :
318 case GL_POLYGON_OFFSET_FACTOR:
319 case GL_POLYGON_OFFSET_UNITS :
320 case GL_POLYGON_OFFSET_FILL:
321 case GL_POLYGON_OFFSET_LINE:
322 case GL_POLYGON_OFFSET_POINT:
323 case GL_POLYGON_SMOOTH:
324 case GL_POLYGON_SMOOTH_HINT:
325 case GL_POLYGON_STIPPLE:
326 case GL_PROJECTION_STACK_DEPTH:
327 case GL_READ_BUFFER:
328 case GL_RED_BIAS:
329 case GL_RED_BITS:
330 case GL_RED_SCALE:
331 case GL_RENDER_MODE:
332 case GL_RGBA_MODE:
333 case GL_SCISSOR_TEST:
334 case GL_SHADE_MODEL:
335 case GL_STENCIL_BITS:
336 case GL_STENCIL_CLEAR_VALUE:
337 case GL_STENCIL_FAIL:
338 case GL_STENCIL_FUNC:
339 case GL_STENCIL_PASS_DEPTH_FAIL:
340 case GL_STENCIL_PASS_DEPTH_PASS:
341 case GL_STENCIL_REF:
342 case GL_STENCIL_TEST:
343 case GL_STENCIL_VALUE_MASK:
344 case GL_STENCIL_WRITEMASK:
345 case GL_STEREO:
346 case GL_SUBPIXEL_BITS:
347 case GL_TEXTURE_1D:
348// case GL_TEXTURE_1D_BINDING:
349 case GL_TEXTURE_2D :
350// case GL_TEXTURE_2D_BINDING:
351 case GL_TEXTURE_COORD_ARRAY:
352 case GL_TEXTURE_COORD_ARRAY_SIZE:
353 case GL_TEXTURE_COORD_ARRAY_STRIDE:
354 case GL_TEXTURE_COORD_ARRAY_TYPE:
355 case GL_TEXTURE_GEN_Q:
356 case GL_TEXTURE_GEN_R:
357 case GL_TEXTURE_GEN_S:
358 case GL_TEXTURE_GEN_T:
359 case GL_TEXTURE_STACK_DEPTH:
360 case GL_UNPACK_ALIGNMENT:
361 case GL_UNPACK_LSB_FIRST:
362 case GL_UNPACK_ROW_LENGTH:
363 case GL_UNPACK_SKIP_PIXELS:
364 case GL_UNPACK_SKIP_ROWS:
365 case GL_UNPACK_SWAP_BYTES:
366 case GL_VERTEX_ARRAY:
367 case GL_VERTEX_ARRAY_SIZE:
368 case GL_VERTEX_ARRAY_STRIDE:
369 case GL_VERTEX_ARRAY_TYPE:
370 case GL_ZOOM_X:
371 case GL_ZOOM_Y:
372 return 1;
373
374 case GL_ACCUM_CLEAR_VALUE:
375// case GL_BLEND_COLOR_EXT:
376 case GL_COLOR_CLEAR_VALUE:
377 case GL_COLOR_WRITEMASK:
378 case GL_CURRENT_COLOR:
379 case GL_CURRENT_RASTER_COLOR:
380 case GL_CURRENT_RASTER_POSITION:
381 case GL_CURRENT_RASTER_TEXTURE_COORDS:
382 case GL_CURRENT_TEXTURE_COORDS:
383 case GL_FOG_COLOR:
384 case GL_LIGHT_MODEL_AMBIENT:
385 case GL_MAP2_GRID_DOMAIN:
386 case GL_VIEWPORT:
387 case GL_SCISSOR_BOX:
388 return 4;
389
390 case GL_DEPTH_RANGE:
391 case GL_LINE_WIDTH_RANGE:
392 case GL_MAP1_GRID_DOMAIN:
393 case GL_MAP2_GRID_SEGMENTS:
394 case GL_MAX_VIEWPORT_DIMS:
395 case GL_POINT_SIZE_RANGE:
396 case GL_POLYGON_MODE:
397 return 2;
398
399 case GL_CURRENT_NORMAL:
400 return 3;
401
402 case GL_MODELVIEW_MATRIX:
403 case GL_PROJECTION_MATRIX:
404 case GL_TEXTURE_MATRIX:
405 return 16;
406
407 default:
408 return 0;
409 }
410}
411
412void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params)
413{
414 uint32_t n = vboxglGetNrElements(pname);
415
416 if (!n)
417 {
418 AssertMsgFailed(("glGetBooleanv: Invalid enum %x\n", pname));
419 glSetError(GL_INVALID_ENUM);
420 return;
421 }
422
423 VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetBooleanv, pname, n*sizeof(GLboolean), params);
424 return;
425}
426
427void APIENTRY glGetDoublev (GLenum pname, GLdouble *params)
428{
429 uint32_t n = vboxglGetNrElements(pname);
430
431 if (!n)
432 {
433 AssertMsgFailed(("glGetDoublev: Invalid enum %x\n", pname));
434 glSetError(GL_INVALID_ENUM);
435 return;
436 }
437
438 VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetDoublev, pname, n*sizeof(GLdouble), params);
439 return;
440}
441
442void APIENTRY glGetFloatv (GLenum pname, GLfloat *params)
443{
444 uint32_t n = vboxglGetNrElements(pname);
445
446 if (!n)
447 {
448 AssertMsgFailed(("glGetFloatv: Invalid enum %x\n", pname));
449 glSetError(GL_INVALID_ENUM);
450 return;
451 }
452
453 VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetFloatv, pname, n*sizeof(GLfloat), params);
454 return;
455}
456
457void APIENTRY glGetIntegerv (GLenum pname, GLint *params)
458{
459 uint32_t n = vboxglGetNrElements(pname);
460
461 if (!n)
462 {
463 AssertMsgFailed(("glGetIntegerv: Invalid enum %x\n", pname));
464 glSetError(GL_INVALID_ENUM);
465 return;
466 }
467
468 VBOX_OGL_GEN_SYNC_OP2_PASS_PTR(GetIntegerv, pname, n*sizeof(GLint), params);
469 return;
470}
471
472
473void APIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v)
474{
475 AssertFailed(); /** @todo */
476 return;
477}
478
479void APIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v)
480{
481 AssertFailed(); /** @todo */
482 return;
483}
484
485void APIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v)
486{
487 AssertFailed(); /** @todo */
488 return;
489}
490
491void APIENTRY glGetPointerv (GLenum pname, GLvoid* *params)
492{
493 AssertFailed(); /** @todo */
494 return;
495}
496
497
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette