VirtualBox

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

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

OpenGL extensions init

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