VirtualBox

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

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

get window rect

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 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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 *
21 */
22
23/*
24 * Mesa 3-D graphics library
25 * Version: 6.1
26 *
27 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
28 *
29 * Permission is hereby granted, free of charge, to any person obtaining a
30 * copy of this software and associated documentation files (the "Software"),
31 * to deal in the Software without restriction, including without limitation
32 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
33 * and/or sell copies of the Software, and to permit persons to whom the
34 * Software is furnished to do so, subject to the following conditions:
35 *
36 * The above copyright notice and this permission notice shall be included
37 * in all copies or substantial portions of the Software.
38 *
39 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
40 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
42 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
43 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
44 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45 */
46
47/*
48 * File name: icd.c
49 * Author: Gregor Anich
50 *
51 * ICD (Installable Client Driver) interface.
52 * Based on the windows GDI/WGL driver.
53 */
54
55#include "VBoxOGL.h"
56
57#define GL_FUNC(func) gl##func
58
59static ICDTABLE icdTable = { 336, {
60#define ICD_ENTRY(func) (PROC)GL_FUNC(func),
61#include "VBoxICDList.h"
62#undef ICD_ENTRY
63} };
64
65
66
67BOOL APIENTRY DrvValidateVersion(DWORD version)
68{
69 DbgPrintf(("DrvValidateVersion %x -> always TRUE\n", version));
70 return TRUE;
71}
72
73
74PICDTABLE APIENTRY DrvSetContext(HDC hdc, HGLRC hglrc, void *callback)
75{
76 NOREF(callback);
77
78 /* Note: we ignore the callback parameter here */
79 VBOX_OGL_GEN_SYNC_OP2(DrvSetContext, hdc, hglrc);
80 return &icdTable;
81}
82
83/* DrvSetPixelFormat can only be called once for each window (if hdc associated with one). */
84BOOL APIENTRY DrvSetPixelFormat(HDC hdc, int iPixelFormat)
85{
86 uint32_t cx, cy;
87 HWND hwnd;
88
89 /** check dimensions and pixel format of hdc */
90 hwnd = WindowFromDC(hdc);
91 if (hwnd)
92 {
93 RECT rect;
94
95 GetWindowRect(hwnd, &rect);
96 cx = rect.right - rect.left;
97 cy = rect.bottom - rect.top;
98 }
99 else
100 {
101 /** @todo get dimenions of memory dc; a bitmap should be selected in there */
102 AssertFailed();
103 }
104
105 VBOX_OGL_GEN_SYNC_OP4_RET(BOOL, DrvSetPixelFormat, hdc, iPixelFormat, cx, cy);
106 /* Propagate error through the right channel */
107 SetLastError(glGetError());
108 return retval;
109}
110
111HGLRC APIENTRY DrvCreateContext(HDC hdc)
112{
113 VBOX_OGL_GEN_SYNC_OP1_RET(HGLRC, DrvCreateContext, hdc);
114 /* Propagate error through the right channel */
115 SetLastError(glGetError());
116 return retval;
117}
118
119HGLRC APIENTRY DrvCreateLayerContext(HDC hdc, int iLayerPlane)
120{
121 VBOX_OGL_GEN_SYNC_OP2_RET(HGLRC, DrvCreateLayerContext, hdc, iLayerPlane);
122 /* Propagate error through the right channel */
123 SetLastError(glGetError());
124 return retval;
125}
126
127BOOL APIENTRY DrvDescribeLayerPlane(HDC hdc,int iPixelFormat,
128 int iLayerPlane, UINT nBytes,
129 LPLAYERPLANEDESCRIPTOR plpd)
130{
131 VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(BOOL, DrvDescribeLayerPlane, hdc, iPixelFormat, iLayerPlane, nBytes, nBytes, plpd);
132 /* Propagate error through the right channel */
133 SetLastError(glGetError());
134 return retval;
135}
136
137int APIENTRY DrvGetLayerPaletteEntries(HDC hdc, int iLayerPlane,
138 int iStart, int cEntries,
139 COLORREF *pcr)
140{
141 VBOX_OGL_GEN_SYNC_OP5_PASS_PTR_RET(int, DrvGetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
142 /* Propagate error through the right channel */
143 SetLastError(glGetError());
144 return retval;
145}
146
147int APIENTRY DrvDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd)
148{
149 /* if ppfd == NULL, then DrvDescribelayerPlane returns the maximum nr of supported pixel formats */
150 VBOX_OGL_GEN_SYNC_OP4_PASS_PTR_RET(int, DrvDescribePixelFormat, hdc, iPixelFormat, nBytes, nBytes, ppfd);
151 /* Propagate error through the right channel */
152 SetLastError(glGetError());
153 return retval;
154}
155
156
157BOOL APIENTRY DrvDeleteContext(HGLRC hglrc)
158{
159 VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvDeleteContext, hglrc);
160 /* Propagate error through the right channel */
161 SetLastError(glGetError());
162 return retval;
163}
164
165BOOL APIENTRY DrvCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
166{
167 VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvCopyContext, hglrcSrc, hglrcDst, mask);
168 /* Propagate error through the right channel */
169 SetLastError(glGetError());
170 return retval;
171}
172
173void APIENTRY DrvReleaseContext(HGLRC hglrc)
174{
175 VBOX_OGL_GEN_SYNC_OP1(DrvReleaseContext, hglrc);
176 /* Propagate error through the right channel */
177 SetLastError(glGetError());
178}
179
180BOOL APIENTRY DrvShareLists(HGLRC hglrc1, HGLRC hglrc2)
181{
182 VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvShareLists, hglrc1, hglrc2);
183 /* Propagate error through the right channel */
184 SetLastError(glGetError());
185 return retval;
186}
187
188int APIENTRY DrvSetLayerPaletteEntries(HDC hdc, int iLayerPlane,
189 int iStart, int cEntries,
190 CONST COLORREF *pcr)
191{
192 VBOX_OGL_GEN_SYNC_OP5_PTR_RET(int, DrvSetLayerPaletteEntries, hdc, iLayerPlane, iStart, cEntries, sizeof(COLORREF)*cEntries, pcr);
193 /* Propagate error through the right channel */
194 SetLastError(glGetError());
195 return retval;
196}
197
198
199BOOL APIENTRY DrvRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize)
200{
201 VBOX_OGL_GEN_SYNC_OP3_RET(BOOL, DrvRealizeLayerPalette, hdc, iLayerPlane, bRealize);
202 /* Propagate error through the right channel */
203 SetLastError(glGetError());
204 return retval;
205}
206
207BOOL APIENTRY DrvSwapLayerBuffers(HDC hdc, UINT fuPlanes)
208{
209 VBOX_OGL_GEN_SYNC_OP2_RET(BOOL, DrvSwapLayerBuffers, hdc, fuPlanes);
210 /* Propagate error through the right channel */
211 SetLastError(glGetError());
212 return retval;
213}
214
215BOOL APIENTRY DrvSwapBuffers(HDC hdc)
216{
217 VBOX_OGL_GEN_SYNC_OP1_RET(BOOL, DrvSwapBuffers, hdc);
218 /* Propagate error through the right channel */
219 SetLastError(glGetError());
220 return retval;
221}
222
223#ifdef VBOX_WITH_WGL_EXPORTS
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