VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/stub.h@ 16387

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

attempt to fix the adds builds

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.5 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
8/*
9 * How this all works...
10 *
11 * This directory implements three different interfaces to Chromium:
12 *
13 * 1. the Chromium interface - this is defined by the functions that start
14 * with the "cr" prefix and are defined in chromium.h and implemented in
15 * stub.c. Typically, this is used by parallel apps (like psubmit).
16 *
17 * 2. GLX emulation interface - the glX*() functions are emulated here.
18 * When glXCreateContext() is called we may either create a real, native
19 * GLX context or a Chromium context (depending on match_window_title and
20 * mimimum_window_size).
21 *
22 * 3. WGL emulation interface - the wgl*() functions are emulated here.
23 * When wglCreateContext() is called we may either create a real, native
24 * WGL context or a Chromium context (depending on match_window_title and
25 * mimimum_window_size).
26 *
27 *
28 */
29
30
31#ifndef CR_STUB_H
32#define CR_STUB_H
33
34#include "chromium.h"
35#include "cr_hash.h"
36#include "cr_process.h"
37#include "cr_spu.h"
38#include "cr_threads.h"
39#include "spu_dispatch_table.h"
40
41
42/* When we first create a rendering context we can't be sure whether
43 * it'll be handled by Chromium or as a native GLX/WGL context. So in
44 * CreateContext() we'll mark the ContextInfo object as UNDECIDED then
45 * switch it to either NATIVE or CHROMIUM the first time MakeCurrent()
46 * is called. In MakeCurrent() we can use a criteria like window size
47 * or window title to decide between CHROMIUM and NATIVE.
48 */
49typedef enum
50{
51 UNDECIDED,
52 CHROMIUM,
53 NATIVE
54} ContextType;
55
56#define MAX_DPY_NAME 1000
57
58typedef struct context_info_t ContextInfo;
59typedef struct window_info_t WindowInfo;
60
61struct context_info_t
62{
63 char dpyName[MAX_DPY_NAME];
64 GLint spuContext; /* returned by head SPU's CreateContext() */
65 ContextType type; /* CHROMIUM, NATIVE or UNDECIDED */
66 unsigned long id; /* the client-visible handle */
67 GLint visBits;
68 WindowInfo *currentDrawable;
69 WindowInfo *pOwnWindow; /* window created by first call to MakeCurrent with this context */
70#ifdef WINDOWS
71 HGLRC hglrc;
72#elif defined(DARWIN)
73 ContextInfo *share;
74 CGLContextObj cglc;
75
76 /* CGLContextEnable (CGLEnable, CGLDisable, and CGLIsEnabled) */
77 unsigned int options;
78
79 /* CGLContextParameter (CGLSetParameter and CGLGetParameter) */
80 GLint parambits;
81 long swap_rect[4], swap_interval;
82 unsigned long client_storage;
83 long surf_order, surf_opacy;
84
85 long disp_mask;
86#elif defined(GLX)
87 Display *dpy;
88 ContextInfo *share;
89 XVisualInfo *visual;
90 Bool direct;
91 GLXContext glxContext;
92#endif
93};
94
95#ifdef DARWIN
96enum {
97 VISBIT_SWAP_RECT,
98 VISBIT_SWAP_INTERVAL,
99 VISBIT_CLIENT_STORAGE
100};
101#endif
102
103struct window_info_t
104{
105 char dpyName[MAX_DPY_NAME];
106 int x, y;
107 unsigned int width, height;
108 ContextType type;
109 GLint spuWindow; /* returned by head SPU's WindowCreate() */
110 GLboolean mapped;
111#ifdef WINDOWS
112 HDC drawable;
113 HRGN hVisibleRegion;
114 DWORD dmPelsWidth;
115 DWORD dmPelsHeight;
116 HWND hWnd;
117#elif defined(DARWIN)
118 CGSConnectionID connection;
119 CGSWindowID drawable;
120 CGSSurfaceID surface;
121#elif defined(GLX)
122 Display *dpy;
123 GLXDrawable drawable;
124#endif
125};
126
127/* "Global" variables for the stub library */
128typedef struct {
129 /* the first SPU in the SPU chain on this app node */
130 SPU *spu;
131
132 /* OpenGL/SPU dispatch tables */
133 crOpenGLInterface wsInterface;
134 SPUDispatchTable spuDispatch;
135 SPUDispatchTable nativeDispatch;
136 GLboolean haveNativeOpenGL;
137
138 /* config options */
139 int appDrawCursor;
140 GLuint minChromiumWindowWidth;
141 GLuint minChromiumWindowHeight;
142 GLuint maxChromiumWindowWidth;
143 GLuint maxChromiumWindowHeight;
144 GLuint matchChromiumWindowCount;
145 GLuint matchChromiumWindowCounter;
146 GLuint *matchChromiumWindowID;
147 GLuint numIgnoreWindowID;
148 char *matchWindowTitle;
149 int ignoreFreeglutMenus;
150 int trackWindowSize;
151 int trackWindowPos;
152 int trackWindowVisibility;
153 int trackWindowVisibleRgn;
154 char *spu_dir;
155 int force_pbuffers;
156
157 /* thread safety stuff */
158 GLboolean threadSafe;
159#ifdef CHROMIUM_THREADSAFE
160 CRtsd dispatchTSD;
161 CRmutex mutex;
162#endif
163
164 CRpid mothershipPID;
165
166 /* contexts */
167 int freeContextNumber;
168 CRHashTable *contextTable;
169 ContextInfo *currentContext; /* may be NULL */
170
171 /* windows */
172 CRHashTable *windowTable;
173
174#ifdef WINDOWS
175 HHOOK hMessageHook;
176#endif
177} Stub;
178
179
180extern Stub stub;
181extern DECLEXPORT(SPUDispatchTable) glim;
182extern SPUDispatchTable stubThreadsafeDispatch;
183extern DECLEXPORT(SPUDispatchTable) stubNULLDispatch;
184
185
186#ifdef WINDOWS
187
188/* WGL versions */
189extern WindowInfo *stubGetWindowInfo( HDC drawable );
190
191extern void stubInstallWindowMessageHook();
192extern void stubUninstallWindowMessageHook();
193
194extern GLboolean stubUpdateWindowVisibileRegions(WindowInfo *pWindow);
195
196#elif defined(DARWIN)
197
198extern CGSConnectionID _CGSDefaultConnection(void);
199extern OSStatus CGSGetWindowLevel( CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *level );
200extern OSStatus CGSSetWindowAlpha( const CGSConnectionID cid, CGSWindowID wid, float alpha );
201
202/* These don't seem to be included in the OSX glext.h ... */
203extern void glPointParameteri( GLenum pname, GLint param );
204extern void glPointParameteriv( GLenum pname, const GLint * param );
205
206extern WindowInfo *stubGetWindowInfo( CGSWindowID drawable );
207
208#elif defined(GLX)
209
210/* GLX versions */
211extern WindowInfo *stubGetWindowInfo( Display *dpy, GLXDrawable drawable );
212extern void stubUseXFont( Display *dpy, Font font, int first, int count, int listbase );
213
214#endif
215
216
217extern ContextInfo *stubNewContext( const char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx );
218extern void stubDestroyContext( unsigned long contextId );
219extern GLboolean stubMakeCurrent( WindowInfo *window, ContextInfo *context );
220extern GLint stubNewWindow( const char *dpyName, GLint visBits );
221extern void stubSwapBuffers( const WindowInfo *window, GLint flags );
222extern void stubGetWindowGeometry( const WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h );
223extern GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate);
224extern GLboolean stubIsWindowVisible( const WindowInfo *win );
225extern bool stubInit(void);
226
227extern void APIENTRY stub_GetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values );
228
229extern void APIENTRY glBoundsInfoCR(const CRrecti *, const GLbyte *, GLint, GLint);
230
231#endif /* CR_STUB_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