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