VirtualBox

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

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

The Big Sun Rebranding Header Change

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