VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/VBoxOGL.h@ 3513

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

filter out opengl extensions, that we don't support (yet)

File size: 7.2 KB
Line 
1/** @file
2 *
3 * VirtualBox Windows NT/2000/XP guest OpenGL ICD
4 *
5 * Copyright (C) 2006-2007 innotek GmbH
6 *
7 * This file is part of VirtualBox Open Source Edition (OSE), as
8 * available from http://www.virtualbox.org. This file is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License as published by the Free Software Foundation,
11 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
12 * distribution. VirtualBox OSE is distributed in the hope that it will
13 * be useful, but WITHOUT ANY WARRANTY of any kind.
14 *
15 * If you received this file as part of a commercial VirtualBox
16 * distribution, then only the terms of your commercial VirtualBox
17 * license agreement apply instead of the previous paragraph.
18 *
19 */
20#ifndef __VBOXOGL_H__
21#define __VBOXOGL_H__
22
23#include <windows.h>
24/* get rid of the inconsistent dll linkage warnings */
25#undef WINGDIAPI
26#define WINGDIAPI
27#include "GL/gl.h"
28#define WGL_WGLEXT_PROTOTYPES
29#include <VBox/HostServices/wglext.h>
30
31#include <iprt/cdefs.h>
32#include <iprt/assert.h>
33
34#include <VBox/HostServices/VBoxOpenGLSvc.h>
35#include <VBox/HostServices/VBoxOGLOp.h>
36
37typedef struct _icdTable
38{
39 DWORD size;
40 PROC table[336];
41} ICDTABLE, *PICDTABLE;
42
43
44typedef struct
45{
46 HANDLE hGuestDrv;
47
48} VBOX_OGL_CTX, *PVBOX_OGL_CTX;
49
50/* HGCM macro */
51#define VBOX_INIT_CALL(a, b, c) \
52 (a)->result = VINF_SUCCESS; \
53 (a)->u32ClientID = (c)->u32ClientID; \
54 (a)->u32Function = VBOXOGL_FN_##b; \
55 (a)->cParms = VBOXOGL_CPARMS_##b
56
57/* glDrawElement internal state */
58#define VBOX_OGL_DRAWELEMENT_VERTEX 0
59#define VBOX_OGL_DRAWELEMENT_TEXCOORD 1
60#define VBOX_OGL_DRAWELEMENT_COLOR 2
61#define VBOX_OGL_DRAWELEMENT_EDGEFLAG 3
62#define VBOX_OGL_DRAWELEMENT_INDEX 4
63#define VBOX_OGL_DRAWELEMENT_NORMAL 5
64#define VBOX_OGL_DRAWELEMENT_MAX 6
65
66typedef struct
67{
68 GLint size;
69 GLenum type;
70 GLsizei stride;
71 uint32_t cbDataType;
72 const GLvoid *pointer;
73 bool fValid;
74} VBOX_OGL_DRAWELEMENT;
75
76typedef struct
77{
78 uint32_t u32ClientID;
79
80 GLenum glLastError;
81 uint32_t cCommands;
82 uint8_t *pCmdBuffer;
83 uint8_t *pCmdBufferEnd;
84 uint8_t *pCurrentCmd;
85
86 /* Internal OpenGL state variables */
87 VBOX_OGL_DRAWELEMENT Pointer[VBOX_OGL_DRAWELEMENT_MAX];
88
89} VBOX_OGL_THREAD_CTX, *PVBOX_OGL_THREAD_CTX;
90
91
92extern HINSTANCE hDllVBoxOGL;
93extern char szOpenGLVersion[256];
94extern char szOpenGLExtensions[8192];
95
96void APIENTRY glSetError(GLenum glNewError);
97
98#ifdef DEBUG
99#define glLogError(a) \
100 { \
101 /** @todo log error */ \
102 glSetError(a); \
103 }
104#define DbgPrintf(a) VBoxDbgLog a
105
106#ifdef VBOX_DEBUG_LVL2
107#define DbgPrintf2(a) VBoxDbgLog a
108#else
109#define DbgPrintf2(a)
110#endif
111
112#else
113#define glLogError(a) glSetError(a)
114#define DbgPrintf(a)
115#define DbgPrintf2(a)
116#endif
117
118
119/**
120 * Initialize the OpenGL guest-host communication channel
121 *
122 * @return success or failure (boolean)
123 * @param hDllInst Dll instance handle
124 */
125BOOL VBoxOGLInit(HINSTANCE hDllInst);
126
127/**
128 * Destroy the OpenGL guest-host communication channel
129 *
130 * @return success or failure (boolean)
131 */
132BOOL VBoxOGLExit();
133
134/**
135 * Initialize new thread
136 *
137 * @return success or failure (boolean)
138 */
139BOOL VBoxOGLThreadAttach();
140
141/**
142 * Clean up for terminating thread
143 *
144 * @return success or failure (boolean)
145 */
146BOOL VBoxOGLThreadDetach();
147
148/**
149 * Set the thread local OpenGL context
150 *
151 * @param pCtx thread local OpenGL context ptr
152 */
153void VBoxOGLSetThreadCtx(PVBOX_OGL_THREAD_CTX pCtx);
154
155/**
156 * Return the thread local OpenGL context
157 *
158 * @return thread local OpenGL context ptr or NULL if failure
159 */
160PVBOX_OGL_THREAD_CTX VBoxOGLGetThreadCtx();
161
162
163/**
164 * Queue a new OpenGL command
165 *
166 * @param enmOp OpenGL command op
167 * @param cParam Number of parameters
168 * @param cbParams Memory needed for parameters
169 */
170void VBoxCmdStart(uint32_t enmOp, uint32_t cParam, uint32_t cbParams);
171
172/**
173 * Add a parameter to the currently queued OpenGL command
174 *
175 * @param pParam Parameter ptr
176 * @param cbParam Parameter value size
177 */
178void VBoxCmdSaveParameter(uint8_t *pParam, uint32_t cbParam);
179
180/**
181 * Add a parameter (variable size) to the currently queued OpenGL command
182 *
183 * @param pParam Parameter ptr
184 * @param cbParam Parameter value size
185 */
186void VBoxCmdSaveMemParameter(uint8_t *pParam, uint32_t cbParam);
187
188/**
189 * Finish the queued command
190 *
191 * @param enmOp OpenGL command op
192 */
193void VBoxCmdStop(uint32_t enmOp);
194
195
196/**
197 * Send an HGCM request
198 *
199 * @return VBox status code
200 * @param pvData Data pointer
201 * @param cbData Data size
202 */
203int vboxHGCMCall(void *pvData, unsigned cbData);
204
205#ifdef DEBUG
206/**
207 * Log to the debug output device
208 *
209 * @param pszFormat Format string
210 * @param ... Variable parameters
211 */
212void VBoxDbgLog(char *pszFormat, ...);
213#endif
214
215/**
216 * Flush the OpenGL command queue and return the return val of the last command
217 *
218 * @returns return val of last command
219 */
220uint64_t VBoxOGLFlush();
221
222/**
223 * Flush the OpenGL command queue and return the return val of the last command
224 * The last command's final parameter is a pointer where its result is stored
225 *
226 * @returns return val of last command
227 * @param pLastParam Last parameter's address
228 * @param cbParam Last parameter's size
229 */
230uint64_t VBoxOGLFlushPtr(void *pLastParam, uint32_t cbParam);
231
232
233/**
234 * Initialize OpenGL extensions
235 *
236 * @returns VBox status code
237 * @param pCtx OpenGL thread context
238 */
239int vboxInitOpenGLExtensions(PVBOX_OGL_THREAD_CTX pCtx);
240
241/**
242 * Check if an OpenGL extension is available on the host
243 *
244 * @returns available or not
245 * @param pszExtFunctionName
246 */
247bool VBoxIsExtensionAvailable(const char *pszExtFunctionName);
248
249/**
250 * Query the specified cached parameter
251 *
252 * @returns requested cached value
253 * @param type Parameter type (Note: minimal checks only!)
254 */
255GLint glInternalGetIntegerv(GLenum type);
256
257/**
258 * Query the specified cached texture level parameter
259 *
260 * @returns requested cached value
261 * @param type Parameter type (Note: minimal checks only!)
262 */
263GLint glInternalGetTexLevelParameteriv(GLenum type);
264
265/**
266 * Query the number of bytes required for a pixel in the specified format
267 *
268 * @returns requested pixel size
269 * @param type Parameter type
270 */
271GLint glInternalGetPixelFormatElements(GLenum format);
272
273/**
274 * Query the size of the specified data type
275 *
276 * @returns type size or 0 if unknown type
277 * @param type data type
278 */
279GLint glVBoxGetDataTypeSize(GLenum type);
280
281uint32_t glInternalLightvElem(GLenum pname);
282uint32_t glInternalMaterialvElem(GLenum pname);
283uint32_t glInternalTexEnvvElem(GLenum pname);
284uint32_t glInternalTexGenvElem(GLenum pname);
285uint32_t glInternalTexParametervElem(GLenum pname);
286
287
288#endif /* __VBOXOGL_H__ */
289
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