VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h@ 18735

Last change on this file since 18735 was 18721, checked in by vboxsync, 16 years ago

crOpenGL-OSX: more clipping updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_RENDERSPU_H
8#define CR_RENDERSPU_H
9
10#ifdef WINDOWS
11#define WIN32_LEAN_AND_MEAN
12#include <windows.h>
13#define RENDER_APIENTRY __stdcall
14#elif defined(DARWIN)
15#include <AGL/AGL.h>
16#define RENDER_APIENTRY
17#else
18#include <GL/glx.h>
19#define RENDER_APIENTRY
20#endif
21#include "cr_threads.h"
22#include "cr_spu.h"
23#include "cr_hash.h"
24#include "cr_server.h"
25
26#include <iprt/cdefs.h>
27
28#define MAX_VISUALS 32
29
30#ifdef RT_OS_DARWIN
31enum
32{
33 /* Event classes */
34 kEventClassVBox = 'vbox',
35 /* Event kinds */
36 kEventVBoxShowWindow = 'swin',
37 kEventVBoxHideWindow = 'hwin',
38 kEventVBoxMoveWindow = 'mwin',
39 kEventVBoxResizeWindow = 'rwin',
40 kEventVBoxDisposeWindow = 'dwin',
41 kEventVBoxUpdateDock = 'udck',
42 kEventVBoxUpdateContext = 'uctx',
43 kEventVBoxBoundsChanged = 'bchg'
44};
45pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void* userData);
46#endif /* RT_OS_DARWIN */
47
48/**
49 * Visual info
50 */
51typedef struct {
52 GLbitfield visAttribs;
53 const char *displayName;
54#if defined(WINDOWS)
55 HDC device_context;
56#elif defined(DARWIN)
57 WindowRef window;
58#elif defined(GLX)
59 Display *dpy;
60 XVisualInfo *visual;
61#ifdef GLX_VERSION_1_3
62 GLXFBConfig fbconfig;
63#endif /* GLX_VERSION_1_3 */
64#endif
65} VisualInfo;
66
67/**
68 * Window info
69 */
70typedef struct {
71 int x, y;
72 int width, height;
73 int id; /**< integer window ID */
74 VisualInfo *visual;
75 GLboolean mapPending;
76 GLboolean visible;
77 GLboolean everCurrent; /**< has this window ever been bound? */
78 char *title;
79#if defined(WINDOWS)
80 HDC nativeWindow; /**< for render_to_app_window */
81 HWND hWnd;
82 HDC device_context;
83#elif defined(DARWIN)
84 WindowRef window;
85 WindowRef nativeWindow; /**< for render_to_app_window */
86 WindowRef appWindow;
87 EventHandlerUPP event_handler;
88 GLint bufferName;
89 AGLContext dummyContext;
90 RgnHandle hVisibleRegion;
91 /* unsigned long context_ptr; */
92#elif defined(GLX)
93 Window window;
94 Window nativeWindow; /**< for render_to_app_window */
95 Window appWindow; /**< Same as nativeWindow but for garbage collections purposes */
96#endif
97 int nvSwapGroup;
98
99#ifdef USE_OSMESA
100 GLubyte *buffer; /**< for rendering to off screen buffer. */
101 int in_buffer_width;
102 int in_buffer_height;
103#endif
104
105} WindowInfo;
106
107/**
108 * Context Info
109 */
110typedef struct _ContextInfo {
111 int id; /**< integer context ID */
112 VisualInfo *visual;
113 GLboolean everCurrent;
114 GLboolean haveWindowPosARB;
115 WindowInfo *currentWindow;
116#if defined(WINDOWS)
117 HGLRC hRC;
118#elif defined(DARWIN)
119 AGLContext context;
120#elif defined(GLX)
121 GLXContext context;
122#endif
123 struct _ContextInfo *shared;
124 char *extensionString;
125} ContextInfo;
126
127/**
128 * Barrier info
129 */
130typedef struct {
131 CRbarrier barrier;
132 GLuint count;
133} Barrier;
134
135/**
136 * Renderspu state info
137 */
138typedef struct {
139 SPUDispatchTable self;
140 int id;
141
142 unsigned int window_id;
143 unsigned int context_id;
144
145 /** config options */
146 /*@{*/
147 char *window_title;
148 int defaultX, defaultY;
149 unsigned int defaultWidth, defaultHeight;
150 int default_visual;
151 int use_L2;
152 int fullscreen, ontop;
153 char display_string[100];
154#if defined(GLX)
155 int try_direct;
156 int force_direct;
157 int sync;
158#endif
159 int render_to_app_window;
160 int render_to_crut_window;
161 int crut_drawable;
162 int resizable;
163 int use_lut8, lut8[3][256];
164 int borderless;
165 int nvSwapGroup;
166 int ignore_papi;
167 int ignore_window_moves;
168 int pbufferWidth, pbufferHeight;
169 int use_glxchoosevisual;
170 int draw_bbox;
171 /*@}*/
172
173 CRServer *server;
174 int gather_port;
175 int gather_userbuf_size;
176 CRConnection **gather_conns;
177
178 GLint drawCursor;
179 GLint cursorX, cursorY;
180
181 int numVisuals;
182 VisualInfo visuals[MAX_VISUALS];
183
184 CRHashTable *windowTable;
185 CRHashTable *contextTable;
186
187#ifndef CHROMIUM_THREADSAFE
188 ContextInfo *currentContext;
189#endif
190
191 crOpenGLInterface ws; /**< Window System interface */
192
193 CRHashTable *barrierHash;
194
195 int is_swap_master, num_swap_clients;
196 int swap_mtu;
197 char *swap_master_url;
198 CRConnection **swap_conns;
199
200#ifdef USE_OSMESA
201 /** Off screen rendering hooks. */
202 int use_osmesa;
203
204 OSMesaContext (*OSMesaCreateContext)( GLenum format, OSMesaContext sharelist );
205 GLboolean (* OSMesaMakeCurrent)( OSMesaContext ctx,
206 GLubyte *buffer,
207 GLenum type,
208 GLsizei width,
209 GLsizei height );
210 void (*OSMesaDestroyContext)( OSMesaContext ctx );
211#endif
212
213#ifdef RT_OS_WINDOWS
214 DWORD dwWinThreadId;
215 HANDLE hWinThreadReadyEvent;
216#endif
217
218#ifdef RT_OS_DARWIN
219 RgnHandle hRootVisibleRegion;
220 RTSEMFASTMUTEX syncMutex;
221 EventHandlerUPP hParentEventHandler;
222 WindowGroupRef pParentGroup;
223 WindowGroupRef pMasterGroup;
224 GLint currentBufferName;
225 uint64_t uiDockUpdateTS;
226#endif /* RT_OS_DARWIN */
227} RenderSPU;
228
229#ifdef RT_OS_WINDOWS
230
231/* Asks window thread to create new window.
232 msg.lParam - holds pointer to CREATESTRUCT structure
233 note that lpCreateParams is used to specify address to store handle of created window
234 msg.wParam - unused, should be NULL
235*/
236#define WM_VBOX_RENDERSPU_CREATE_WINDOW (WM_APP+1)
237
238typedef struct _VBOX_RENDERSPU_DESTROY_WINDOW {
239 HWND hWnd; /* handle to window to destroy */
240} VBOX_RENDERSPU_DESTROY_WINDOW;
241
242/* Asks window thread to destroy previously created window.
243 msg.lParam - holds pointer to RENDERSPU_VBOX_WINDOW_DESTROY structure
244 msg.wParam - unused, should be NULL
245*/
246#define WM_VBOX_RENDERSPU_DESTROY_WINDOW (WM_APP+2)
247
248#endif
249
250extern RenderSPU render_spu;
251
252/* @todo remove this hack */
253extern unsigned int render_spu_parent_window_id;
254
255#ifdef CHROMIUM_THREADSAFE
256extern CRtsd _RenderTSD;
257#define GET_CONTEXT(T) ContextInfo *T = (ContextInfo *) crGetTSD(&_RenderTSD)
258#else
259#define GET_CONTEXT(T) ContextInfo *T = render_spu.currentContext
260#endif
261
262extern void renderspuSetVBoxConfiguration( RenderSPU *spu );
263extern void renderspuMakeVisString( GLbitfield visAttribs, char *s );
264extern VisualInfo *renderspuFindVisual(const char *displayName, GLbitfield visAttribs );
265extern GLboolean renderspu_SystemInitVisual( VisualInfo *visual );
266extern GLboolean renderspu_SystemCreateContext( VisualInfo *visual, ContextInfo *context, ContextInfo *sharedContext );
267extern void renderspu_SystemDestroyContext( ContextInfo *context );
268extern GLboolean renderspu_SystemCreateWindow( VisualInfo *visual, GLboolean showIt, WindowInfo *window );
269extern GLboolean renderspu_SystemVBoxCreateWindow( VisualInfo *visual, GLboolean showIt, WindowInfo *window );
270extern void renderspu_SystemDestroyWindow( WindowInfo *window );
271extern void renderspu_SystemWindowSize( WindowInfo *window, GLint w, GLint h );
272extern void renderspu_SystemGetWindowGeometry( WindowInfo *window, GLint *x, GLint *y, GLint *w, GLint *h );
273extern void renderspu_SystemGetMaxWindowSize( WindowInfo *window, GLint *w, GLint *h );
274extern void renderspu_SystemWindowPosition( WindowInfo *window, GLint x, GLint y );
275extern void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, GLint* pRects);
276extern void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window);
277#ifdef RT_OS_DARWIN
278extern void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects);
279#endif
280extern void renderspu_SystemShowWindow( WindowInfo *window, GLboolean showIt );
281extern void renderspu_SystemMakeCurrent( WindowInfo *window, GLint windowInfor, ContextInfo *context );
282extern void renderspu_SystemSwapBuffers( WindowInfo *window, GLint flags );
283extern void renderspu_GCWindow(void);
284extern int renderspuCreateFunctions( SPUNamedFunctionTable table[] );
285
286extern GLint RENDER_APIENTRY renderspuWindowCreate( const char *dpyName, GLint visBits );
287extern GLint RENDER_APIENTRY renderspuCreateContext( const char *dpyname, GLint visBits, GLint shareCtx );
288extern void RENDER_APIENTRY renderspuMakeCurrent(GLint crWindow, GLint nativeWindow, GLint ctx);
289extern void RENDER_APIENTRY renderspuSwapBuffers( GLint window, GLint flags );
290
291#ifdef __cplusplus
292extern "C" {
293#endif
294DECLEXPORT(void) renderspuSetWindowId(unsigned int winId);
295DECLEXPORT(void) renderspuSetRootVisibleRegion(GLint cRects, GLint *pRects);
296#ifdef __cplusplus
297}
298#endif
299
300#endif /* CR_RENDERSPU_H */
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