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 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/assert.h>
|
---|
31 |
|
---|
32 | #include <VBox/HostServices/VBoxOpenGLSvc.h>
|
---|
33 | #include <VBox/HostServices/VBoxOGLOp.h>
|
---|
34 |
|
---|
35 | typedef struct _icdTable
|
---|
36 | {
|
---|
37 | DWORD size;
|
---|
38 | PROC table[336];
|
---|
39 | } ICDTABLE, *PICDTABLE;
|
---|
40 |
|
---|
41 |
|
---|
42 | typedef struct
|
---|
43 | {
|
---|
44 | HANDLE hGuestDrv;
|
---|
45 |
|
---|
46 | } VBOX_OGL_CTX, *PVBOX_OGL_CTX;
|
---|
47 |
|
---|
48 | typedef struct
|
---|
49 | {
|
---|
50 | uint32_t u32ClientID;
|
---|
51 |
|
---|
52 | GLenum glLastError;
|
---|
53 | uint32_t cCommands;
|
---|
54 | uint8_t *pCmdBuffer;
|
---|
55 | uint8_t *pCmdBufferEnd;
|
---|
56 | uint8_t *pCurrentCmd;
|
---|
57 | } VBOX_OGL_THREAD_CTX, *PVBOX_OGL_THREAD_CTX;
|
---|
58 |
|
---|
59 |
|
---|
60 | extern HINSTANCE hDllVBoxOGL;
|
---|
61 |
|
---|
62 | void APIENTRY glSetError(GLenum glNewError);
|
---|
63 |
|
---|
64 | #ifdef DEBUG
|
---|
65 | #define glLogError(a) \
|
---|
66 | { \
|
---|
67 | /** @todo log error */ \
|
---|
68 | glSetError(a); \
|
---|
69 | }
|
---|
70 | #define DbgPrintf(a) VBoxDbgLog a
|
---|
71 |
|
---|
72 | #ifdef VBOX_DEBUG_LVL2
|
---|
73 | #define DbgPrintf2(a) VBoxDbgLog a
|
---|
74 | #else
|
---|
75 | #define DbgPrintf2(a)
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | #else
|
---|
79 | #define glLogError(a) glSetError(a)
|
---|
80 | #define DbgPrintf(a)
|
---|
81 | #endif
|
---|
82 |
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * Initialize the OpenGL guest-host communication channel
|
---|
86 | *
|
---|
87 | * @return success or failure (boolean)
|
---|
88 | * @param hDllInst Dll instance handle
|
---|
89 | */
|
---|
90 | BOOL VBoxOGLInit(HINSTANCE hDllInst);
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Destroy the OpenGL guest-host communication channel
|
---|
94 | *
|
---|
95 | * @return success or failure (boolean)
|
---|
96 | */
|
---|
97 | BOOL VBoxOGLExit();
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Initialize new thread
|
---|
101 | *
|
---|
102 | * @return success or failure (boolean)
|
---|
103 | */
|
---|
104 | BOOL VBoxOGLThreadAttach();
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Clean up for terminating thread
|
---|
108 | *
|
---|
109 | * @return success or failure (boolean)
|
---|
110 | */
|
---|
111 | BOOL VBoxOGLThreadDetach();
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Set the thread local OpenGL context
|
---|
115 | *
|
---|
116 | * @param pCtx thread local OpenGL context ptr
|
---|
117 | */
|
---|
118 | void VBoxOGLSetThreadCtx(PVBOX_OGL_THREAD_CTX pCtx);
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Return the thread local OpenGL context
|
---|
122 | *
|
---|
123 | * @return thread local OpenGL context ptr or NULL if failure
|
---|
124 | */
|
---|
125 | PVBOX_OGL_THREAD_CTX VBoxOGLGetThreadCtx();
|
---|
126 |
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Queue a new OpenGL command
|
---|
130 | *
|
---|
131 | * @param enmOp OpenGL command op
|
---|
132 | * @param cParam Number of parameters
|
---|
133 | * @param cbParams Memory needed for parameters
|
---|
134 | */
|
---|
135 | void VBoxCmdStart(uint32_t enmOp, uint32_t cParam, uint32_t cbParams);
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * Add a parameter to the currently queued OpenGL command
|
---|
139 | *
|
---|
140 | * @param pParam Parameter ptr
|
---|
141 | * @param cbParam Parameter value size
|
---|
142 | */
|
---|
143 | void VBoxCmdSaveParameter(uint8_t *pParam, uint32_t cbParam);
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Add a parameter (variable size) to the currently queued OpenGL command
|
---|
147 | *
|
---|
148 | * @param pParam Parameter ptr
|
---|
149 | * @param cbParam Parameter value size
|
---|
150 | */
|
---|
151 | void VBoxCmdSaveMemParameter(uint8_t *pParam, uint32_t cbParam);
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Finish the queued command
|
---|
155 | *
|
---|
156 | * @param enmOp OpenGL command op
|
---|
157 | */
|
---|
158 | void VBoxCmdStop(uint32_t enmOp);
|
---|
159 |
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * Send an HGCM request
|
---|
163 | *
|
---|
164 | * @return VBox status code
|
---|
165 | * @param hDriver Driver handle
|
---|
166 | * @param pvData Data pointer
|
---|
167 | * @param cbData Data size
|
---|
168 | */
|
---|
169 | int vboxHGCMCall(HANDLE hDriver, void *pvData, unsigned cbData);
|
---|
170 |
|
---|
171 | #ifdef DEBUG
|
---|
172 | /**
|
---|
173 | * Log to the debug output device
|
---|
174 | *
|
---|
175 | * @param pszFormat Format string
|
---|
176 | * @param ... Variable parameters
|
---|
177 | */
|
---|
178 | void VBoxDbgLog(char *pszFormat, ...);
|
---|
179 | #endif
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Flush the OpenGL command queue and return the return val of the last command
|
---|
183 | *
|
---|
184 | * @returns return val of last command
|
---|
185 | */
|
---|
186 | uint64_t VBoxOGLFlush();
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Flush the OpenGL command queue and return the return val of the last command
|
---|
190 | * The last command's final parameter is a pointer where its result is stored
|
---|
191 | *
|
---|
192 | * @returns return val of last command
|
---|
193 | * @param pLastParam Last parameter's address
|
---|
194 | * @param cbParam Last parameter's size
|
---|
195 | */
|
---|
196 | uint64_t VBoxOGLFlushPtr(void *pLastParam, uint32_t cbParam);
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * Query the specified cached parameter
|
---|
200 | *
|
---|
201 | * @returns requested cached value
|
---|
202 | * @param type Parameter type (Note: minimal checks only!)
|
---|
203 | */
|
---|
204 | GLint glInternalGetIntegerv(GLenum type);
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * Query the specified cached texture level parameter
|
---|
208 | *
|
---|
209 | * @returns requested cached value
|
---|
210 | * @param type Parameter type (Note: minimal checks only!)
|
---|
211 | */
|
---|
212 | GLint glInternalGetTexLevelParameteriv(GLenum type);
|
---|
213 |
|
---|
214 | /**
|
---|
215 | * Query the number of bytes required for a pixel in the specified format
|
---|
216 | *
|
---|
217 | * @returns requested pixel size
|
---|
218 | * @param type Parameter type
|
---|
219 | */
|
---|
220 | GLint glInternalGetPixelFormatElements(GLenum format);
|
---|
221 |
|
---|
222 | /**
|
---|
223 | * Query the size of the specified data type
|
---|
224 | *
|
---|
225 | * @returns type size or 0 if unknown type
|
---|
226 | * @param type data type
|
---|
227 | */
|
---|
228 | GLint glVBoxGetDataTypeSize(GLenum type);
|
---|
229 |
|
---|
230 | uint32_t glInternalLightvElem(GLenum pname);
|
---|
231 | uint32_t glInternalMaterialvElem(GLenum pname);
|
---|
232 | uint32_t glInternalTexEnvvElem(GLenum pname);
|
---|
233 | uint32_t glInternalTexGenvElem(GLenum pname);
|
---|
234 | uint32_t glInternalTexParametervElem(GLenum pname);
|
---|
235 |
|
---|
236 |
|
---|
237 | #endif /* __VBOXOGL_H__ */
|
---|
238 |
|
---|