VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/OpenGL/drv.cpp@ 8060

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

The Giant CDDL Dual-License Header Change.

File size: 9.2 KB
Line 
1/** @file
2 *
3 * VirtualBox Windows NT/2000/XP guest OpenGL ICD
4 *
5 * ICD entry points.
6 *
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*
19 * Mesa 3-D graphics library
20 * Version: 6.1
21 *
22 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the "Software"),
26 * to deal in the Software without restriction, including without limitation
27 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28 * and/or sell copies of the Software, and to permit persons to whom the
29 * Software is furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice shall be included
32 * in all copies or substantial portions of the Software.
33 *
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
35 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
37 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
38 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */
41
42/*
43 * File name: icd.c
44 * Author: Gregor Anich
45 *
46 * ICD (Installable Client Driver) interface.
47 * Based on the windows GDI/WGL driver.
48 */
49
50#include "VBoxOGL.h"
51
52#define GL_FUNC(func) gl##func
53
54static ICDTABLE icdTable = { 336, {
55#define ICD_ENTRY(func) (PROC)GL_FUNC(func),
56#include "VBoxICDList.h"
57#undef ICD_ENTRY
58} };
59
60
61BOOL APIENTRY DrvValidateVersion(DWORD version)
62{
63 DbgPrintf(("DrvValidateVersion %x -> always TRUE\n", version));
64 return TRUE;
65}
66
67
68PICDTABLE APIENTRY DrvSetContext(HDC hdc, HGLRC hglrc, void *callback)
69{
70 NOREF(callback);
71
72 /* Note: we ignore the callback parameter here */
73 VBOX_OGL_GEN_SYNC_OP2(DrvSetContext, hdc, hglrc);
74 return &icdTable;
75}
76
77/* DrvSetPixelFormat can only be called once for each window (if hdc associated with one). */
78BOOL APIENTRY DrvSetPixelFormat(HDC hdc, int iPixelFormat)
79{
80 uint32_t cx, cy;
81 HWND hwnd;
82
83 /** check dimensions and pixel format of hdc */
84 hwnd = WindowFromDC(hdc);
85 if (hwnd)
86 {
87 RECT rect;
88
89 GetWindowRect(hwnd, &rect);
90 cx = rect.right - rect.left;
91 cy = rect.bottom - rect.top;
92 }
93 else
94 {
95 /** @todo get dimenions of memory dc; a bitmap should be selected in there */
96 AssertFailed();
97 }
98
99 VBOX_OGL_GEN_SYNC_OP4_RET(BOOL, DrvSetPixelFormat, hdc, iPixelFormat, cx, cy);
100 /* Propagate error through the right channel */
101 SetLastError(glGetError());
102 return retval;
103}
104
105HGLRC APIENTRY DrvCreateContext(HDC hdc)
106{
107 VBOX_OGL_GEN_SYNC_OP1_RET(HGLRC, DrvCreateContext, hdc);
108 /* Propagate error through the right channel */
109 SetLastError(glGetError());
110 return retval;
111}
112
113HGLRC APIENTRY DrvCreateLayerContext(HDC hdc, int iLayerPlane)
114{
115 VBOX_OGL_GEN_SYNC_OP2_RET(HGLRC, DrvCreateLayerContext, hdc, iLayerPlane);
116 /* Propagate error through the right channel */
117 SetLastError(glGetError());
118 return retval;
119}
120
121BOOL APIENTRY DrvDescribeLayerPlane(HDC hdc,int iPixelFormat,
122 int iLayerPlane, UINT nBytes,
123 LPLAYERPLANEDESCRIPTOR plpd)
124{
125 VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(BOOL, DrvDescribeLayerPlane, hdc, iPixelFormat, iLayerPlane, nBytes, nBytes, plpd);
126 /* Propagate error through the right channel */
127 SetLastError(glGetError());
128 return retval;
129}
130
131int APIENTRY DrvGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
132 int iStart, int cEntries,
133 COLORREF *pcr)
134{
135 VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(int, DrvGetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
136 /* Propagate error through the right channel */
137 SetLastError(glGetError());
138 return retval;
139}
140
141int APIENTRY DrvDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
142{
143 /* if ppfd == NULL, then DrvDescribelayerPlane returns the maximum nr of supported pixel formats */
144 VBOX_OGL_GEN_SYNC_OP4_PASS_PTR_RET(int, DrvDescribePixelFormat, hdc, iPixelFormat, nBytes, nBytes, ppfd);
145 /* Propagate error through the right channel */
146 SetLastError(glGetError());
147 return retval;
148}
149
150
151BOOL APIENTRY DrvDeleteContext(HGLRC hglrc)
152{
153 VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvDeleteContext, hglrc);
154 /* Propagate error through the right channel */
155 SetLastError(glGetError());
156 return retval;
157}
158
159BOOL APIENTRY DrvCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
160{
161 VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvCopyContext, hglrcSrc, hglrcDst, mask);
162 /* Propagate error through the right channel */
163 SetLastError(glGetError());
164 return retval;
165}
166
167void APIENTRY DrvReleaseContext(HGLRC hglrc)
168{
169 VBOX_OGL_GEN_SYNC_OP1(DrvReleaseContext, hglrc);
170 /* Propagate error through the right channel */
171 SetLastError(glGetError());
172}
173
174BOOL APIENTRY DrvShareLists(HGLRC hglrc1, HGLRC hglrc2)
175{
176 VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvShareLists, hglrc1, hglrc2);
177 /* Propagate error through the right channel */
178 SetLastError(glGetError());
179 return retval;
180}
181
182int APIENTRY DrvSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
183 int iStart, int cEntries,
184 CONST COLORREF *pcr)
185{
186 VBOX_OGL_GEN_SYNC_OP5_PTR_RET(int, DrvSetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
187 /* Propagate error through the right channel */
188 SetLastError(glGetError());
189 return retval;
190}
191
192
193BOOL APIENTRY DrvRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
194{
195 VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvRealizeLayerPalette, hdc, iLayerPlane, bRealize);
196 /* Propagate error through the right channel */
197 SetLastError(glGetError());
198 return retval;
199}
200
201BOOL APIENTRY DrvSwapLayerBuffers(HDC hdc, UINT fuPlanes)
202{
203 VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvSwapLayerBuffers, hdc, fuPlanes);
204 /* Propagate error through the right channel */
205 SetLastError(glGetError());
206 return retval;
207}
208
209BOOL APIENTRY DrvSwapBuffers(HDC hdc)
210{
211 VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvSwapBuffers, hdc);
212 /* Propagate error through the right channel */
213 SetLastError(glGetError());
214 return retval;
215}
216
217#ifdef VBOX_WITH_WGL_EXPORTS
218extern PROC APIENTRY DrvGetProcAddress(LPCSTR lpszProc);
219
220/* Test export for directly linking with vboxogl.dll */
221int WINAPI wglSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
222 int iStart, int cEntries,
223 CONST COLORREF *pcr)
224{
225 return DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
226}
227
228BOOL WINAPI wglSetPixelFormat(HDC hdc, int iPixelFormat)
229{
230 return DrvSetPixelFormat(hdc, iPixelFormat);
231}
232
233BOOL WINAPI wglRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
234{
235 return DrvRealizeLayerPalette(hdc, iLayerPlane, bRealize);
236}
237
238BOOL WINAPI wglDeleteContext(HGLRC hglrc)
239{
240 return DrvDeleteContext(hglrc);
241}
242
243BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes)
244{
245 return DrvSwapLayerBuffers(hdc, fuPlanes);
246}
247
248BOOL WINAPI SwapBuffers(HDC hdc)
249{
250 return DrvSwapBuffers(hdc);
251}
252
253BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
254{
255 return DrvCopyContext(hglrcSrc, hglrcDst, mask);
256}
257
258BOOL WINAPI wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
259{
260 return DrvShareLists(hglrc1, hglrc2);
261}
262
263BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
264{
265 DrvSetContext(hdc, hglrc, NULL);
266 return TRUE;
267}
268
269PROC WINAPI wglGetProcAddress(LPCSTR lpszProc)
270{
271 return DrvGetProcAddress(lpszProc);
272}
273
274int WINAPI wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
275{
276 return DrvDescribePixelFormat(hdc, iPixelFormat, nBytes, ppfd);
277}
278
279BOOL WINAPI wglDescribeLayerPlane(HDC hdc,int iPixelFormat,
280 int iLayerPlane, UINT nBytes,
281 LPLAYERPLANEDESCRIPTOR plpd)
282{
283 return DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
284}
285
286int WINAPI wglGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
287 int iStart, int cEntries,
288 COLORREF *pcr)
289{
290 return DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
291}
292
293HGLRC WINAPI wglCreateContext(HDC hdc)
294{
295 return DrvCreateContext(hdc);
296}
297
298#endif
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