1 | /** @file
|
---|
2 | * VBox OpenGL windows helper functions
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
17 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
18 | * additional information or have any questions.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef ___VBOXGLWIN_H
|
---|
22 | #define ___VBOXGLWIN_H
|
---|
23 |
|
---|
24 | #include <iprt/types.h>
|
---|
25 | #include <iprt/mem.h>
|
---|
26 |
|
---|
27 | #ifdef RT_OS_WINDOWS
|
---|
28 | #define VBOX_OGL_DEBUG_WINDOW_OUTPUT
|
---|
29 | #elif defined(RT_OS_LINUX)
|
---|
30 |
|
---|
31 | #define GLX_GLXEXT_PROTOTYPES
|
---|
32 | #include <X11/Xlib.h>
|
---|
33 | #include <GL/gl.h>
|
---|
34 | #include <GL/glx.h>
|
---|
35 | #include <GL/glxext.h>
|
---|
36 |
|
---|
37 | #define VBOX_OGL_DEBUG_WINDOW_OUTPUT
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #ifdef VBOX_OGL_DEBUG_WINDOW_OUTPUT
|
---|
41 | #if defined(RT_OS_WINDOWS)
|
---|
42 | #define VBOX_OGL_GUEST_TO_HOST_HDC(a) pClient->hdc
|
---|
43 | #elif defined(RT_OS_LINUX)
|
---|
44 | #define VBOX_OGL_GUEST_TO_HOST_HDC(a) pClient->glxContext
|
---|
45 | #endif
|
---|
46 | #endif
|
---|
47 |
|
---|
48 |
|
---|
49 | typedef struct
|
---|
50 | {
|
---|
51 | uint64_t lastretval;
|
---|
52 | uint32_t ulLastError;
|
---|
53 |
|
---|
54 | bool fHasLastError;
|
---|
55 |
|
---|
56 | uint8_t *pLastParam;
|
---|
57 | uint32_t cbLastParam;
|
---|
58 |
|
---|
59 | struct
|
---|
60 | {
|
---|
61 | #ifdef RT_OS_WINDOWS
|
---|
62 | HWND hwnd;
|
---|
63 | HDC hdc;
|
---|
64 | HGLRC hglrc;
|
---|
65 | #elif defined RT_OS_LINUX
|
---|
66 | Display *dpy;
|
---|
67 | Window win;
|
---|
68 | GLXContext ctx;
|
---|
69 | GLXFBConfig *fbConfig;
|
---|
70 | XVisualInfo *visinfo;
|
---|
71 | #endif
|
---|
72 | } enable;
|
---|
73 |
|
---|
74 | #ifdef VBOX_OGL_DEBUG_WINDOW_OUTPUT
|
---|
75 | #ifdef RT_OS_WINDOWS
|
---|
76 | HWND hwnd;
|
---|
77 | HDC hdc;
|
---|
78 | #elif defined RT_OS_LINUX
|
---|
79 | Display *dpy;
|
---|
80 | Window xWindow;
|
---|
81 | GLXFBConfig actFBConfig;
|
---|
82 | int winWidth, winHeight;
|
---|
83 | GLXFBConfig *PixelFormatToFBConfigMapper;
|
---|
84 | int numFBConfigs;
|
---|
85 | GLXContext glxContext;
|
---|
86 | PFNGLXCHOOSEFBCONFIGSGIXPROC glxChooseFBConfig;
|
---|
87 | PFNGLXGETVISUALFROMFBCONFIGSGIXPROC glxGetVisualFromFBConfig;
|
---|
88 | PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC glxCreateNewContext;
|
---|
89 | #endif
|
---|
90 | #endif
|
---|
91 | } VBOXOGLCTX, *PVBOXOGLCTX;
|
---|
92 |
|
---|
93 |
|
---|
94 | #ifndef RT_OS_WINDOWS
|
---|
95 |
|
---|
96 | typedef uint32_t DWORD;
|
---|
97 | typedef uint16_t WORD;
|
---|
98 | typedef uint8_t BYTE;
|
---|
99 | typedef BYTE BOOL;
|
---|
100 | typedef RTGCUINTPTR HANDLE;
|
---|
101 | typedef HANDLE HDC;
|
---|
102 | typedef HANDLE HGLRC;
|
---|
103 | typedef uint32_t UINT;
|
---|
104 | typedef uint32_t COLORREF;
|
---|
105 | typedef void VOID;
|
---|
106 | typedef void * LPVOID;
|
---|
107 | typedef int16_t SHORT;
|
---|
108 | typedef uint16_t USHORT;
|
---|
109 | typedef int64_t INT64;
|
---|
110 | typedef int32_t INT32;
|
---|
111 | typedef float FLOAT; /* ??? */
|
---|
112 |
|
---|
113 | #define DECLARE_HANDLE(a) typedef HANDLE a
|
---|
114 | #define WINAPI
|
---|
115 |
|
---|
116 | #define PFD_DOUBLEBUFFER 0x00000001
|
---|
117 | #define PFD_STEREO 0x00000002
|
---|
118 | #define PFD_DRAW_TO_WINDOW 0x00000004
|
---|
119 | #define PFD_SUPPORT_OPENGL 0x00000020
|
---|
120 |
|
---|
121 | #define PFD_TYPE_RGBA 0
|
---|
122 | #define PFD_TYPE_COLORINDEX 1
|
---|
123 |
|
---|
124 | #define PFD_MAIN_PLANE 0
|
---|
125 | #define PFD_OVERLAY_PLANE 1
|
---|
126 | #define PFD_UNDERLAY_PLANE (-1)
|
---|
127 |
|
---|
128 | typedef struct
|
---|
129 | {
|
---|
130 | WORD nSize;
|
---|
131 | WORD nVersion;
|
---|
132 | DWORD dwFlags;
|
---|
133 | BYTE iPixelType;
|
---|
134 | BYTE cColorBits;
|
---|
135 | BYTE cRedBits;
|
---|
136 | BYTE cRedShift;
|
---|
137 | BYTE cGreenBits;
|
---|
138 | BYTE cGreenShift;
|
---|
139 | BYTE cBlueBits;
|
---|
140 | BYTE cBlueShift;
|
---|
141 | BYTE cAlphaBits;
|
---|
142 | BYTE cAlphaShift;
|
---|
143 | BYTE cAccumBits;
|
---|
144 | BYTE cAccumRedBits;
|
---|
145 | BYTE cAccumGreenBits;
|
---|
146 | BYTE cAccumBlueBits;
|
---|
147 | BYTE cAccumAlphaBits;
|
---|
148 | BYTE cDepthBits;
|
---|
149 | BYTE cStencilBits;
|
---|
150 | BYTE cAuxBuffers;
|
---|
151 | BYTE iLayerType;
|
---|
152 | BYTE bReserved;
|
---|
153 | DWORD dwLayerMask;
|
---|
154 | DWORD dwVisibleMask;
|
---|
155 | DWORD dwDamageMask;
|
---|
156 | } PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
|
---|
157 |
|
---|
158 | typedef struct
|
---|
159 | {
|
---|
160 | WORD nSize;
|
---|
161 | WORD nVersion;
|
---|
162 | DWORD dwFlags;
|
---|
163 | BYTE iPixelType;
|
---|
164 | BYTE cColorBits;
|
---|
165 | BYTE cRedBits;
|
---|
166 | BYTE cRedShift;
|
---|
167 | BYTE cGreenBits;
|
---|
168 | BYTE cGreenShift;
|
---|
169 | BYTE cBlueBits;
|
---|
170 | BYTE cBlueShift;
|
---|
171 | BYTE cAlphaBits;
|
---|
172 | BYTE cAlphaShift;
|
---|
173 | BYTE cAccumBits;
|
---|
174 | BYTE cAccumRedBits;
|
---|
175 | BYTE cAccumGreenBits;
|
---|
176 | BYTE cAccumBlueBits;
|
---|
177 | BYTE cAccumAlphaBits;
|
---|
178 | BYTE cDepthBits;
|
---|
179 | BYTE cStencilBits;
|
---|
180 | BYTE cAuxBuffers;
|
---|
181 | BYTE iLayerPlane;
|
---|
182 | BYTE bReserved;
|
---|
183 | COLORREF crTransparent;
|
---|
184 | } LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, LPLAYERPLANEDESCRIPTOR;
|
---|
185 |
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | void vboxglDrvReleaseContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
189 | void vboxglDrvCreateContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
190 | void vboxglDrvDeleteContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
191 | void vboxglDrvCopyContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
192 | void vboxglDrvSetContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
193 | void vboxglDrvCreateLayerContext(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
194 | void vboxglDrvShareLists(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
195 | void vboxglDrvDescribeLayerPlane(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
196 | void vboxglDrvSetLayerPaletteEntries(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
197 | void vboxglDrvGetLayerPaletteEntries(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
198 | void vboxglDrvRealizeLayerPalette(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
199 | void vboxglDrvSwapLayerBuffers(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
200 | void vboxglDrvDescribePixelFormat(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
201 | void vboxglDrvSetPixelFormat(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
202 | void vboxglDrvSwapBuffers(VBOXOGLCTX *pClient, uint8_t *pCmdBuffer);
|
---|
203 |
|
---|
204 | int vboxglEnableOpenGL(VBOXOGLCTX *pClient);
|
---|
205 | int vboxglDisableOpenGL(VBOXOGLCTX *pClient);
|
---|
206 |
|
---|
207 | RTUINTPTR vboxDrvIsExtensionAvailable(char *pszExtFunctionName);
|
---|
208 |
|
---|
209 | #endif /* !___VBOXGLWIN_H */
|
---|