VirtualBox

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

Last change on this file since 4071 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

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