VirtualBox

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

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

Updates

File size: 6.9 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/* glDrawElement internal state */
51#define VBOX_OGL_DRAWELEMENT_VERTEX 0
52#define VBOX_OGL_DRAWELEMENT_TEXCOORD 1
53#define VBOX_OGL_DRAWELEMENT_COLOR 2
54#define VBOX_OGL_DRAWELEMENT_EDGEFLAG 3
55#define VBOX_OGL_DRAWELEMENT_INDEX 4
56#define VBOX_OGL_DRAWELEMENT_NORMAL 5
57#define VBOX_OGL_DRAWELEMENT_MAX 6
58
59typedef struct
60{
61 GLint size;
62 GLenum type;
63 GLsizei stride;
64 uint32_t cbDataType;
65 const GLvoid *pointer;
66 bool fValid;
67} VBOX_OGL_DRAWELEMENT;
68
69typedef struct
70{
71 uint32_t u32ClientID;
72
73 GLenum glLastError;
74 uint32_t cCommands;
75 uint8_t *pCmdBuffer;
76 uint8_t *pCmdBufferEnd;
77 uint8_t *pCurrentCmd;
78
79 /* Internal OpenGL state variables */
80 VBOX_OGL_DRAWELEMENT Pointer[VBOX_OGL_DRAWELEMENT_MAX];
81
82} VBOX_OGL_THREAD_CTX, *PVBOX_OGL_THREAD_CTX;
83
84
85extern HINSTANCE hDllVBoxOGL;
86
87void APIENTRY glSetError(GLenum glNewError);
88
89#ifdef DEBUG
90#define glLogError(a) \
91 { \
92 /** @todo log error */ \
93 glSetError(a); \
94 }
95#define DbgPrintf(a) VBoxDbgLog a
96
97#ifdef VBOX_DEBUG_LVL2
98#define DbgPrintf2(a) VBoxDbgLog a
99#else
100#define DbgPrintf2(a)
101#endif
102
103#else
104#define glLogError(a) glSetError(a)
105#define DbgPrintf(a)
106#define DbgPrintf2(a)
107#endif
108
109
110/**
111 * Initialize the OpenGL guest-host communication channel
112 *
113 * @return success or failure (boolean)
114 * @param hDllInst Dll instance handle
115 */
116BOOL VBoxOGLInit(HINSTANCE hDllInst);
117
118/**
119 * Destroy the OpenGL guest-host communication channel
120 *
121 * @return success or failure (boolean)
122 */
123BOOL VBoxOGLExit();
124
125/**
126 * Initialize new thread
127 *
128 * @return success or failure (boolean)
129 */
130BOOL VBoxOGLThreadAttach();
131
132/**
133 * Clean up for terminating thread
134 *
135 * @return success or failure (boolean)
136 */
137BOOL VBoxOGLThreadDetach();
138
139/**
140 * Set the thread local OpenGL context
141 *
142 * @param pCtx thread local OpenGL context ptr
143 */
144void VBoxOGLSetThreadCtx(PVBOX_OGL_THREAD_CTX pCtx);
145
146/**
147 * Return the thread local OpenGL context
148 *
149 * @return thread local OpenGL context ptr or NULL if failure
150 */
151PVBOX_OGL_THREAD_CTX VBoxOGLGetThreadCtx();
152
153
154/**
155 * Queue a new OpenGL command
156 *
157 * @param enmOp OpenGL command op
158 * @param cParam Number of parameters
159 * @param cbParams Memory needed for parameters
160 */
161void VBoxCmdStart(uint32_t enmOp, uint32_t cParam, uint32_t cbParams);
162
163/**
164 * Add a parameter to the currently queued OpenGL command
165 *
166 * @param pParam Parameter ptr
167 * @param cbParam Parameter value size
168 */
169void VBoxCmdSaveParameter(uint8_t *pParam, uint32_t cbParam);
170
171/**
172 * Add a parameter (variable size) to the currently queued OpenGL command
173 *
174 * @param pParam Parameter ptr
175 * @param cbParam Parameter value size
176 */
177void VBoxCmdSaveMemParameter(uint8_t *pParam, uint32_t cbParam);
178
179/**
180 * Finish the queued command
181 *
182 * @param enmOp OpenGL command op
183 */
184void VBoxCmdStop(uint32_t enmOp);
185
186
187/**
188 * Send an HGCM request
189 *
190 * @return VBox status code
191 * @param hDriver Driver handle
192 * @param pvData Data pointer
193 * @param cbData Data size
194 */
195int vboxHGCMCall(HANDLE hDriver, void *pvData, unsigned cbData);
196
197#ifdef DEBUG
198/**
199 * Log to the debug output device
200 *
201 * @param pszFormat Format string
202 * @param ... Variable parameters
203 */
204void VBoxDbgLog(char *pszFormat, ...);
205#endif
206
207/**
208 * Flush the OpenGL command queue and return the return val of the last command
209 *
210 * @returns return val of last command
211 */
212uint64_t VBoxOGLFlush();
213
214/**
215 * Flush the OpenGL command queue and return the return val of the last command
216 * The last command's final parameter is a pointer where its result is stored
217 *
218 * @returns return val of last command
219 * @param pLastParam Last parameter's address
220 * @param cbParam Last parameter's size
221 */
222uint64_t VBoxOGLFlushPtr(void *pLastParam, uint32_t cbParam);
223
224
225/**
226 * Initialize OpenGL extensions
227 *
228 * @returns VBox status code
229 */
230int vboxInitOpenGLExtensions();
231
232/**
233 * Check if an OpenGL extension is available on the host
234 *
235 * @returns available or not
236 * @param pszExtFunctionName
237 */
238bool VBoxIsExtensionAvailable(const char *pszExtFunctionName);
239
240/**
241 * Query the specified cached parameter
242 *
243 * @returns requested cached value
244 * @param type Parameter type (Note: minimal checks only!)
245 */
246GLint glInternalGetIntegerv(GLenum type);
247
248/**
249 * Query the specified cached texture level parameter
250 *
251 * @returns requested cached value
252 * @param type Parameter type (Note: minimal checks only!)
253 */
254GLint glInternalGetTexLevelParameteriv(GLenum type);
255
256/**
257 * Query the number of bytes required for a pixel in the specified format
258 *
259 * @returns requested pixel size
260 * @param type Parameter type
261 */
262GLint glInternalGetPixelFormatElements(GLenum format);
263
264/**
265 * Query the size of the specified data type
266 *
267 * @returns type size or 0 if unknown type
268 * @param type data type
269 */
270GLint glVBoxGetDataTypeSize(GLenum type);
271
272uint32_t glInternalLightvElem(GLenum pname);
273uint32_t glInternalMaterialvElem(GLenum pname);
274uint32_t glInternalTexEnvvElem(GLenum pname);
275uint32_t glInternalTexGenvElem(GLenum pname);
276uint32_t glInternalTexParametervElem(GLenum pname);
277
278
279#endif /* __VBOXOGL_H__ */
280
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