2 * X11DRV OpenGL functions
4 * Copyright 2000 Lionel Ulmer
5 * Copyright 2005 Alex Woods
6 * Copyright 2005 Raphael Junqueira
7 * Copyright 2006 Roderick Colenbrander
8 * Copyright 2006 Tomas Carnecky
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/port.h"
34 #include "wine/library.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wgl
);
38 WINE_DECLARE_DEBUG_CHANNEL(opengl
);
40 #if defined(HAVE_GL_GL_H) && defined(HAVE_GL_GLX_H)
52 #ifdef HAVE_GL_GLEXT_H
53 # include <GL/glext.h>
62 /* Redefines the constants */
63 #define CALLBACK __stdcall
64 #define WINAPI __stdcall
65 #define APIENTRY WINAPI
68 WINE_DECLARE_DEBUG_CHANNEL(fps
);
70 typedef struct wine_glcontext
{
76 X11DRV_PDEVICE
*physDev
;
80 struct wine_glcontext
*next
;
81 struct wine_glcontext
*prev
;
84 typedef struct wine_glpbuffer
{
93 int use_render_texture
;
94 GLuint texture_target
;
95 GLuint texture_bind_target
;
104 typedef struct wine_glextension
{
107 const char *funcName
;
113 const char *glVersion
;
114 const char *glExtensions
;
118 const char *glxServerVersion
;
119 const char *glxServerExtensions
;
121 const char *glxClientVersion
;
122 const char *glxClientExtensions
;
124 const char *glxExtensions
;
127 char wglExtensions
[4096];
130 typedef struct wine_glpixelformat
{
136 static Wine_GLContext
*context_list
;
137 static struct WineGLInfo WineGLInfo
= { 0 };
138 static int use_render_texture_emulation
= 0;
139 static int use_render_texture_ati
= 0;
140 static int swap_interval
= 1;
142 #define MAX_EXTENSIONS 16
143 static const WineGLExtension
*WineGLExtensionList
[MAX_EXTENSIONS
];
144 static int WineGLExtensionListSize
;
146 #define MAX_GLPIXELFORMATS 32
147 static WineGLPixelFormat WineGLPixelFormatList
[MAX_GLPIXELFORMATS
];
148 static int WineGLPixelFormatListSize
= 0;
150 static void X11DRV_WineGL_LoadExtensions(void);
152 static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR
*ppfd
) {
153 TRACE(" - size / version : %d / %d\n", ppfd
->nSize
, ppfd
->nVersion
);
154 TRACE(" - dwFlags : ");
155 #define TEST_AND_DUMP(t,tv) if ((t) & (tv)) TRACE(#tv " ")
156 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DEPTH_DONTCARE
);
157 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER
);
158 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER_DONTCARE
);
159 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_WINDOW
);
160 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_BITMAP
);
161 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_ACCELERATED
);
162 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_FORMAT
);
163 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_PALETTE
);
164 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_SYSTEM_PALETTE
);
165 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO
);
166 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO_DONTCARE
);
167 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_GDI
);
168 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_OPENGL
);
169 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_COPY
);
170 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_EXCHANGE
);
171 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_LAYER_BUFFERS
);
175 TRACE(" - iPixelType : ");
176 switch (ppfd
->iPixelType
) {
177 case PFD_TYPE_RGBA
: TRACE("PFD_TYPE_RGBA"); break;
178 case PFD_TYPE_COLORINDEX
: TRACE("PFD_TYPE_COLORINDEX"); break;
182 TRACE(" - Color : %d\n", ppfd
->cColorBits
);
183 TRACE(" - Red : %d\n", ppfd
->cRedBits
);
184 TRACE(" - Green : %d\n", ppfd
->cGreenBits
);
185 TRACE(" - Blue : %d\n", ppfd
->cBlueBits
);
186 TRACE(" - Alpha : %d\n", ppfd
->cAlphaBits
);
187 TRACE(" - Accum : %d\n", ppfd
->cAccumBits
);
188 TRACE(" - Depth : %d\n", ppfd
->cDepthBits
);
189 TRACE(" - Stencil : %d\n", ppfd
->cStencilBits
);
190 TRACE(" - Aux : %d\n", ppfd
->cAuxBuffers
);
192 TRACE(" - iLayerType : ");
193 switch (ppfd
->iLayerType
) {
194 case PFD_MAIN_PLANE
: TRACE("PFD_MAIN_PLANE"); break;
195 case PFD_OVERLAY_PLANE
: TRACE("PFD_OVERLAY_PLANE"); break;
196 case (BYTE
)PFD_UNDERLAY_PLANE
: TRACE("PFD_UNDERLAY_PLANE"); break;
201 /* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and
202 include all dependencies
205 #define SONAME_LIBGL "libGL.so"
208 #define PUSH1(attribs,att) do { attribs[nAttribs++] = (att); } while (0)
209 #define PUSH2(attribs,att,value) do { attribs[nAttribs++] = (att); attribs[nAttribs++] = (value); } while(0)
211 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
213 MAKE_FUNCPTR(glXChooseVisual
)
214 MAKE_FUNCPTR(glXCreateContext
)
215 MAKE_FUNCPTR(glXCreateGLXPixmap
)
216 MAKE_FUNCPTR(glXGetCurrentContext
)
217 MAKE_FUNCPTR(glXDestroyContext
)
218 MAKE_FUNCPTR(glXDestroyGLXPixmap
)
219 MAKE_FUNCPTR(glXGetConfig
)
220 MAKE_FUNCPTR(glXIsDirect
)
221 MAKE_FUNCPTR(glXMakeCurrent
)
222 MAKE_FUNCPTR(glXSwapBuffers
)
223 MAKE_FUNCPTR(glXQueryExtension
)
224 MAKE_FUNCPTR(glXQueryVersion
)
225 MAKE_FUNCPTR(glXUseXFont
)
228 MAKE_FUNCPTR(glXGetClientString
)
229 MAKE_FUNCPTR(glXQueryExtensionsString
)
230 MAKE_FUNCPTR(glXQueryServerString
)
233 MAKE_FUNCPTR(glXGetFBConfigs
)
234 MAKE_FUNCPTR(glXChooseFBConfig
)
235 MAKE_FUNCPTR(glXCreatePbuffer
)
236 MAKE_FUNCPTR(glXDestroyPbuffer
)
237 MAKE_FUNCPTR(glXGetFBConfigAttrib
)
238 MAKE_FUNCPTR(glXGetVisualFromFBConfig
)
239 MAKE_FUNCPTR(glXMakeContextCurrent
)
240 MAKE_FUNCPTR(glXQueryDrawable
)
241 MAKE_FUNCPTR(glXGetCurrentReadDrawable
)
244 static void* (*pglXGetProcAddressARB
)(const GLubyte
*);
245 static BOOL (*pglXBindTexImageARB
)(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
);
246 static BOOL (*pglXReleaseTexImageARB
)(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
);
247 static BOOL (*pglXDrawableAttribARB
)(Display
*dpy
, GLXDrawable draw
, const int *attribList
);
248 static int (*pglXSwapIntervalSGI
)(int);
250 /* NV GLX Extension */
251 static void* (*pglXAllocateMemoryNV
)(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
);
252 static void (*pglXFreeMemoryNV
)(GLvoid
*pointer
);
254 /* Standard OpenGL */
255 MAKE_FUNCPTR(glBindTexture
)
256 MAKE_FUNCPTR(glBitmap
)
257 MAKE_FUNCPTR(glCopyTexSubImage1D
)
258 MAKE_FUNCPTR(glCopyTexSubImage2D
)
259 MAKE_FUNCPTR(glDisable
)
260 MAKE_FUNCPTR(glDrawBuffer
)
261 MAKE_FUNCPTR(glEnable
)
262 MAKE_FUNCPTR(glEndList
)
263 MAKE_FUNCPTR(glGetError
)
264 MAKE_FUNCPTR(glGetIntegerv
)
265 MAKE_FUNCPTR(glGetString
)
266 MAKE_FUNCPTR(glIsEnabled
)
267 MAKE_FUNCPTR(glNewList
)
268 MAKE_FUNCPTR(glPixelStorei
)
269 MAKE_FUNCPTR(glScissor
)
270 MAKE_FUNCPTR(glViewport
)
273 static BOOL
X11DRV_WineGL_InitOpenglInfo(void)
275 static BOOL infoInitialized
= FALSE
;
277 int screen
= DefaultScreen(gdi_display
);
278 Window win
= RootWindow(gdi_display
, screen
);
280 XVisualInfo
template;
283 GLXContext ctx
= NULL
;
287 infoInitialized
= TRUE
;
291 visual
= DefaultVisual(gdi_display
, screen
);
292 template.visualid
= XVisualIDFromVisual(visual
);
293 vis
= XGetVisualInfo(gdi_display
, VisualIDMask
, &template, &num
);
295 /* Create a GLX Context. Without one we can't query GL information */
296 ctx
= pglXCreateContext(gdi_display
, vis
, None
, GL_TRUE
);
300 pglXMakeCurrent(gdi_display
, win
, ctx
);
302 ERR(" couldn't initialize OpenGL, expect problems\n");
307 WineGLInfo
.glVersion
= (const char *) pglGetString(GL_VERSION
);
308 WineGLInfo
.glExtensions
= (const char *) pglGetString(GL_EXTENSIONS
);
310 /* Get the common GLX version supported by GLX client and server ( major/minor) */
311 pglXQueryVersion(gdi_display
, &WineGLInfo
.glxVersion
[0], &WineGLInfo
.glxVersion
[1]);
313 WineGLInfo
.glxServerVersion
= pglXQueryServerString(gdi_display
, screen
, GLX_VERSION
);
314 WineGLInfo
.glxServerExtensions
= pglXQueryServerString(gdi_display
, screen
, GLX_EXTENSIONS
);
316 WineGLInfo
.glxClientVersion
= pglXGetClientString(gdi_display
, GLX_VERSION
);
317 WineGLInfo
.glxClientExtensions
= pglXGetClientString(gdi_display
, GLX_EXTENSIONS
);
319 WineGLInfo
.glxExtensions
= pglXQueryExtensionsString(gdi_display
, screen
);
320 WineGLInfo
.glxDirect
= pglXIsDirect(gdi_display
, ctx
);
322 TRACE("GL version : %s.\n", WineGLInfo
.glVersion
);
323 TRACE("GLX version : %d.%d.\n", WineGLInfo
.glxVersion
[0], WineGLInfo
.glxVersion
[1]);
324 TRACE("Server GLX version : %s.\n", WineGLInfo
.glxServerVersion
);
325 TRACE("Client GLX version : %s.\n", WineGLInfo
.glxClientVersion
);
326 TRACE("Direct rendering enabled: %s\n", WineGLInfo
.glxDirect
? "True" : "False");
330 pglXMakeCurrent(gdi_display
, None
, NULL
);
331 pglXDestroyContext(gdi_display
, ctx
);
337 static BOOL
has_opengl(void)
339 static int init_done
;
340 static void *opengl_handle
;
341 const char *glx_extensions
;
343 int error_base
, event_base
;
345 if (init_done
) return (opengl_handle
!= NULL
);
348 opengl_handle
= wine_dlopen(SONAME_LIBGL
, RTLD_NOW
|RTLD_GLOBAL
, NULL
, 0);
349 if (opengl_handle
== NULL
) return FALSE
;
351 pglXGetProcAddressARB
= wine_dlsym(opengl_handle
, "glXGetProcAddressARB", NULL
, 0);
352 if (pglXGetProcAddressARB
== NULL
) {
353 ERR("could not find glXGetProcAddressARB in libGL.\n");
357 #define LOAD_FUNCPTR(f) if((p##f = (void*)pglXGetProcAddressARB((const unsigned char*)#f)) == NULL) goto sym_not_found;
359 LOAD_FUNCPTR(glXChooseVisual
)
360 LOAD_FUNCPTR(glXCreateContext
)
361 LOAD_FUNCPTR(glXCreateGLXPixmap
)
362 LOAD_FUNCPTR(glXGetCurrentContext
)
363 LOAD_FUNCPTR(glXDestroyContext
)
364 LOAD_FUNCPTR(glXDestroyGLXPixmap
)
365 LOAD_FUNCPTR(glXGetConfig
)
366 LOAD_FUNCPTR(glXIsDirect
)
367 LOAD_FUNCPTR(glXMakeCurrent
)
368 LOAD_FUNCPTR(glXSwapBuffers
)
369 LOAD_FUNCPTR(glXQueryExtension
)
370 LOAD_FUNCPTR(glXQueryVersion
)
371 LOAD_FUNCPTR(glXUseXFont
)
374 LOAD_FUNCPTR(glXGetClientString
)
375 LOAD_FUNCPTR(glXQueryExtensionsString
)
376 LOAD_FUNCPTR(glXQueryServerString
)
379 LOAD_FUNCPTR(glXCreatePbuffer
)
380 LOAD_FUNCPTR(glXDestroyPbuffer
)
381 LOAD_FUNCPTR(glXMakeContextCurrent
)
382 LOAD_FUNCPTR(glXGetCurrentReadDrawable
)
383 LOAD_FUNCPTR(glXGetFBConfigs
)
385 /* Standard OpenGL calls */
386 LOAD_FUNCPTR(glBindTexture
)
387 LOAD_FUNCPTR(glBitmap
)
388 LOAD_FUNCPTR(glCopyTexSubImage1D
)
389 LOAD_FUNCPTR(glCopyTexSubImage2D
)
390 LOAD_FUNCPTR(glDisable
)
391 LOAD_FUNCPTR(glDrawBuffer
)
392 LOAD_FUNCPTR(glEnable
)
393 LOAD_FUNCPTR(glEndList
)
394 LOAD_FUNCPTR(glGetError
)
395 LOAD_FUNCPTR(glGetIntegerv
)
396 LOAD_FUNCPTR(glGetString
)
397 LOAD_FUNCPTR(glIsEnabled
)
398 LOAD_FUNCPTR(glNewList
)
399 LOAD_FUNCPTR(glPixelStorei
)
400 LOAD_FUNCPTR(glScissor
)
401 LOAD_FUNCPTR(glViewport
)
404 /* It doesn't matter if these fail. They'll only be used if the driver reports
405 the associated extension is available (and if a driver reports the extension
406 is available but fails to provide the functions, it's quite broken) */
407 #define LOAD_FUNCPTR(f) p##f = (void*)pglXGetProcAddressARB((const unsigned char*)#f);
408 /* NV GLX Extension */
409 LOAD_FUNCPTR(glXAllocateMemoryNV
)
410 LOAD_FUNCPTR(glXFreeMemoryNV
)
413 if(!X11DRV_WineGL_InitOpenglInfo()) {
414 ERR("Intialization of OpenGL info failed, disabling OpenGL!\n");
415 wine_dlclose(opengl_handle
, NULL
, 0);
416 opengl_handle
= NULL
;
421 if (pglXQueryExtension(gdi_display
, &error_base
, &event_base
) == True
) {
422 TRACE("GLX is up and running error_base = %d\n", error_base
);
424 wine_dlclose(opengl_handle
, NULL
, 0);
425 opengl_handle
= NULL
;
428 /* In case of GLX you have direct and indirect rendering. Most of the time direct rendering is used
429 * as in general only that is hardware accelerated. In some cases like in case of remote X indirect
432 * The main problem for our OpenGL code is that we need certain GLX calls but their presence
433 * depends on the reported GLX client / server version and on the client / server extension list.
434 * Those don't have to be the same.
436 * In general the server GLX information should be used in case of indirect rendering. When direct
437 * rendering is used, the OpenGL client library is responsible for which GLX calls are available.
438 * Nvidia's OpenGL drivers are the best in terms of GLX features. At the moment of writing their
439 * 8762 drivers support 1.3 for the server and 1.4 for the client and they support lots of extensions.
440 * Unfortunately it is much more complicated for Mesa/DRI-based drivers and ATI's drivers.
441 * Both sets of drivers report a server version of 1.2 and the client version can be 1.3 or 1.4.
442 * Further, in case of at least ATI's drivers, one crucial extension needed for our pixel format code
443 * is only available in the list of server extensions and not in the client list.
445 * The versioning checks below try to take into account the comments from above.
448 /* Depending on the use of direct or indirect rendering we need either the list of extensions
449 * exported by the client or by the server.
451 if(WineGLInfo
.glxDirect
)
452 glx_extensions
= WineGLInfo
.glxClientExtensions
;
454 glx_extensions
= WineGLInfo
.glxServerExtensions
;
456 /* Based on the default opengl context we decide whether direct or indirect rendering is used.
457 * In case of indirect rendering we check if the GLX version of the server is 1.2 and else
458 * the client version is checked.
460 if ((!WineGLInfo
.glxDirect
&& !strcmp("1.2", WineGLInfo
.glxServerVersion
)) ||
461 (WineGLInfo
.glxDirect
&& !strcmp("1.2", WineGLInfo
.glxClientVersion
)))
463 if (NULL
!= strstr(glx_extensions
, "GLX_SGIX_fbconfig")) {
464 pglXChooseFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfigSGIX");
465 pglXGetFBConfigAttrib
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttribSGIX");
466 pglXGetVisualFromFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfigSGIX");
468 ERR(" glx_version is %s and GLX_SGIX_fbconfig extension is unsupported. Expect problems.\n", WineGLInfo
.glxClientVersion
);
471 pglXChooseFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfig");
472 pglXGetFBConfigAttrib
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttrib");
473 pglXGetVisualFromFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfig");
476 /* The mesa libGL client library seems to forward glXQueryDrawable to the Xserver, so only
477 * enable this function when the Xserver understand GLX 1.3 or newer
479 if (!strcmp("1.2", WineGLInfo
.glxServerVersion
))
480 pglXQueryDrawable
= NULL
;
482 pglXQueryDrawable
= wine_dlsym(RTLD_DEFAULT
, "glXQueryDrawable", NULL
, 0);
484 if (NULL
!= strstr(glx_extensions
, "GLX_ATI_render_texture")) {
485 pglXBindTexImageARB
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXBindTexImageARB");
486 pglXReleaseTexImageARB
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXReleaseTexImageARB");
487 pglXDrawableAttribARB
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXDrawableAttribARB");
490 X11DRV_WineGL_LoadExtensions();
493 return (opengl_handle
!= NULL
);
496 wine_dlclose(opengl_handle
, NULL
, 0);
497 opengl_handle
= NULL
;
501 static inline Wine_GLContext
*alloc_context(void)
505 if ((ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(Wine_GLContext
))))
507 ret
->next
= context_list
;
508 if (context_list
) context_list
->prev
= ret
;
514 static inline void free_context(Wine_GLContext
*context
)
516 if (context
->next
!= NULL
) context
->next
->prev
= context
->prev
;
517 if (context
->prev
!= NULL
) context
->prev
->next
= context
->next
;
518 else context_list
= context
->next
;
520 HeapFree(GetProcessHeap(), 0, context
);
523 static inline Wine_GLContext
*get_context_from_GLXContext(GLXContext ctx
)
526 if (!ctx
) return NULL
;
527 for (ret
= context_list
; ret
; ret
= ret
->next
) if (ctx
== ret
->ctx
) break;
532 * get_drawable (internal)
534 * Retrieve the GLX drawable to use on a given DC.
536 inline static Drawable
get_drawable( HDC hdc
)
538 GLXDrawable drawable
;
539 enum x11drv_escape_codes escape
= X11DRV_GET_GLX_DRAWABLE
;
541 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPCSTR
)&escape
,
542 sizeof(drawable
), (LPSTR
)&drawable
)) drawable
= 0;
547 * get_hdc_from_Drawable (internal)
549 * For use by wglGetCurrentReadDCARB.
551 inline static HDC
get_hdc_from_Drawable(GLXDrawable d
)
554 for (ret
= context_list
; ret
; ret
= ret
->next
) {
555 if (d
== ret
->physDev
->drawable
) {
562 inline static BOOL
is_valid_context( Wine_GLContext
*ctx
)
565 for (ptr
= context_list
; ptr
; ptr
= ptr
->next
) if (ptr
== ctx
) break;
566 return (ptr
!= NULL
);
569 static int describeContext(Wine_GLContext
* ctx
) {
572 TRACE(" Context %p have (vis:%p):\n", ctx
, ctx
->vis
);
573 pglXGetFBConfigAttrib(gdi_display
, ctx
->fb_conf
, GLX_FBCONFIG_ID
, &tmp
);
574 TRACE(" - FBCONFIG_ID 0x%x\n", tmp
);
575 pglXGetFBConfigAttrib(gdi_display
, ctx
->fb_conf
, GLX_VISUAL_ID
, &tmp
);
576 TRACE(" - VISUAL_ID 0x%x\n", tmp
);
581 static int describeDrawable(Wine_GLContext
* ctx
, Drawable drawable
) {
584 int attribList
[3] = { GLX_FBCONFIG_ID
, 0, None
};
587 if (pglXQueryDrawable
== NULL
) {
588 /** glXQueryDrawable not available so returns not supported */
592 TRACE(" Drawable %p have :\n", (void*) drawable
);
593 pglXQueryDrawable(gdi_display
, drawable
, GLX_WIDTH
, (unsigned int*) &tmp
);
594 TRACE(" - WIDTH as %d\n", tmp
);
595 pglXQueryDrawable(gdi_display
, drawable
, GLX_HEIGHT
, (unsigned int*) &tmp
);
596 TRACE(" - HEIGHT as %d\n", tmp
);
597 pglXQueryDrawable(gdi_display
, drawable
, GLX_FBCONFIG_ID
, (unsigned int*) &tmp
);
598 TRACE(" - FBCONFIG_ID as 0x%x\n", tmp
);
601 fbCfgs
= pglXChooseFBConfig(gdi_display
, DefaultScreen(gdi_display
), attribList
, &nElements
);
602 if (fbCfgs
== NULL
) {
606 pglXGetFBConfigAttrib(gdi_display
, fbCfgs
[0], GLX_VISUAL_ID
, &tmp
);
607 TRACE(" - VISUAL_ID as 0x%x\n", tmp
);
614 static int ConvertAttribWGLtoGLX(const int* iWGLAttr
, int* oGLXAttr
, Wine_GLPBuffer
* pbuf
) {
620 int wantColorBits
= 0;
623 while (0 != iWGLAttr
[cur
]) {
624 TRACE("pAttr[%d] = %x\n", cur
, iWGLAttr
[cur
]);
626 switch (iWGLAttr
[cur
]) {
627 case WGL_COLOR_BITS_ARB
:
628 pop
= iWGLAttr
[++cur
];
629 wantColorBits
= pop
; /** see end */
631 case WGL_BLUE_BITS_ARB
:
632 pop
= iWGLAttr
[++cur
];
633 PUSH2(oGLXAttr
, GLX_BLUE_SIZE
, pop
);
634 TRACE("pAttr[%d] = GLX_BLUE_SIZE: %d\n", cur
, pop
);
636 case WGL_RED_BITS_ARB
:
637 pop
= iWGLAttr
[++cur
];
638 PUSH2(oGLXAttr
, GLX_RED_SIZE
, pop
);
639 TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur
, pop
);
641 case WGL_GREEN_BITS_ARB
:
642 pop
= iWGLAttr
[++cur
];
643 PUSH2(oGLXAttr
, GLX_GREEN_SIZE
, pop
);
644 TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur
, pop
);
646 case WGL_ALPHA_BITS_ARB
:
647 pop
= iWGLAttr
[++cur
];
649 PUSH2(oGLXAttr
, GLX_ALPHA_SIZE
, pop
);
650 TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur
, pop
);
652 case WGL_DEPTH_BITS_ARB
:
653 pop
= iWGLAttr
[++cur
];
654 PUSH2(oGLXAttr
, GLX_DEPTH_SIZE
, pop
);
655 TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur
, pop
);
657 case WGL_STENCIL_BITS_ARB
:
658 pop
= iWGLAttr
[++cur
];
659 PUSH2(oGLXAttr
, GLX_STENCIL_SIZE
, pop
);
660 TRACE("pAttr[%d] = GLX_STENCIL_SIZE: %d\n", cur
, pop
);
662 case WGL_DOUBLE_BUFFER_ARB
:
663 pop
= iWGLAttr
[++cur
];
664 PUSH2(oGLXAttr
, GLX_DOUBLEBUFFER
, pop
);
665 TRACE("pAttr[%d] = GLX_DOUBLEBUFFER: %d\n", cur
, pop
);
668 case WGL_PIXEL_TYPE_ARB
:
669 pop
= iWGLAttr
[++cur
];
671 case WGL_TYPE_COLORINDEX_ARB
: pop
= GLX_COLOR_INDEX_BIT
; isColor
= 1; break ;
672 case WGL_TYPE_RGBA_ARB
: pop
= GLX_RGBA_BIT
; break ;
673 case WGL_TYPE_RGBA_FLOAT_ATI
: pop
= GLX_RGBA_FLOAT_ATI_BIT
; break ;
675 ERR("unexpected PixelType(%x)\n", pop
);
678 PUSH2(oGLXAttr
, GLX_RENDER_TYPE
, pop
);
679 TRACE("pAttr[%d] = GLX_RENDER_TYPE: %d\n", cur
, pop
);
682 case WGL_SUPPORT_GDI_ARB
:
683 pop
= iWGLAttr
[++cur
];
684 /* We only support a limited number of formats which are all renderable by X (similar to GDI).
685 * Ignore this attribute to prevent us from not finding a match due to the limited
686 * amount of formats supported right now. This option could be matched to GLX_X_RENDERABLE
687 * but the issue is that when a program asks for no GDI support, there's no format we can return
688 * as all our supported formats are renderable by X.
690 TRACE("pAttr[%d] = WGL_SUPPORT_GDI_ARB: %d\n", cur
, pop
);
693 case WGL_DRAW_TO_BITMAP_ARB
:
694 pop
= iWGLAttr
[++cur
];
695 TRACE("pAttr[%d] = WGL_DRAW_TO_BITMAP_ARB: %d\n", cur
, pop
);
696 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
698 drawattrib
|= GLX_PIXMAP_BIT
;
702 case WGL_DRAW_TO_WINDOW_ARB
:
703 pop
= iWGLAttr
[++cur
];
704 TRACE("pAttr[%d] = WGL_DRAW_TO_WINDOW_ARB: %d\n", cur
, pop
);
705 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
707 drawattrib
|= GLX_WINDOW_BIT
;
711 case WGL_DRAW_TO_PBUFFER_ARB
:
712 pop
= iWGLAttr
[++cur
];
713 TRACE("pAttr[%d] = WGL_DRAW_TO_PBUFFER_ARB: %d\n", cur
, pop
);
714 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
716 drawattrib
|= GLX_PBUFFER_BIT
;
720 case WGL_ACCELERATION_ARB
:
721 case WGL_SUPPORT_OPENGL_ARB
:
722 pop
= iWGLAttr
[++cur
];
723 /** nothing to do, if we are here, supposing support Accelerated OpenGL */
724 TRACE("pAttr[%d] = WGL_SUPPORT_OPENGL_ARB: %d\n", cur
, pop
);
727 case WGL_PBUFFER_LARGEST_ARB
:
728 pop
= iWGLAttr
[++cur
];
729 PUSH2(oGLXAttr
, GLX_LARGEST_PBUFFER
, pop
);
730 TRACE("pAttr[%d] = GLX_LARGEST_PBUFFER: %x\n", cur
, pop
);
733 case WGL_SAMPLE_BUFFERS_ARB
:
734 pop
= iWGLAttr
[++cur
];
735 PUSH2(oGLXAttr
, GLX_SAMPLE_BUFFERS_ARB
, pop
);
736 TRACE("pAttr[%d] = GLX_SAMPLE_BUFFERS_ARB: %x\n", cur
, pop
);
739 case WGL_SAMPLES_ARB
:
740 pop
= iWGLAttr
[++cur
];
741 PUSH2(oGLXAttr
, GLX_SAMPLES_ARB
, pop
);
742 TRACE("pAttr[%d] = GLX_SAMPLES_ARB: %x\n", cur
, pop
);
745 case WGL_TEXTURE_FORMAT_ARB
:
746 case WGL_TEXTURE_TARGET_ARB
:
747 case WGL_MIPMAP_TEXTURE_ARB
:
748 TRACE("WGL_render_texture Attributes: %x as %x\n", iWGLAttr
[cur
], iWGLAttr
[cur
+ 1]);
749 pop
= iWGLAttr
[++cur
];
751 ERR("trying to use GLX_Pbuffer Attributes without Pbuffer (was %x)\n", iWGLAttr
[cur
]);
753 if (use_render_texture_ati
) {
754 /** nothing to do here */
756 else if (!use_render_texture_emulation
) {
757 if (WGL_NO_TEXTURE_ARB
!= pop
) {
758 ERR("trying to use WGL_render_texture Attributes without support (was %x)\n", iWGLAttr
[cur
]);
759 return -1; /** error: don't support it */
761 PUSH2(oGLXAttr
, GLX_X_RENDERABLE
, pop
);
762 drawattrib
|= GLX_PBUFFER_BIT
;
767 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
768 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
769 pop
= iWGLAttr
[++cur
];
770 /** cannot be converted, see direct handling on
771 * - wglGetPixelFormatAttribivARB
772 * TODO: wglChoosePixelFormat
777 FIXME("unsupported %x WGL Attribute\n", iWGLAttr
[cur
]);
784 * Trick as WGL_COLOR_BITS_ARB != GLX_BUFFER_SIZE
785 * WGL_COLOR_BITS_ARB + WGL_ALPHA_BITS_ARB == GLX_BUFFER_SIZE
788 * The number of color bitplanes in each color buffer. For RGBA
789 * pixel types, it is the size of the color buffer, excluding the
790 * alpha bitplanes. For color-index pixels, it is the size of the
791 * color index buffer.
794 * This attribute defines the number of bits per color buffer.
795 * For GLX FBConfigs that correspond to a PseudoColor or StaticColor visual,
796 * this is equal to the depth value reported in the X11 visual.
797 * For GLX FBConfigs that correspond to TrueColor or DirectColor visual,
798 * this is the sum of GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_BLUE_SIZE, and GLX_ALPHA_SIZE.
801 if (0 < wantColorBits
) {
803 wantColorBits
+= sz_alpha
;
805 if (32 < wantColorBits
) {
806 ERR("buggy %d GLX_BUFFER_SIZE default to 32\n", wantColorBits
);
809 PUSH2(oGLXAttr
, GLX_BUFFER_SIZE
, wantColorBits
);
810 TRACE("pAttr[%d] = WGL_COLOR_BITS_ARB: %d\n", cur
, wantColorBits
);
813 /* Apply the OR'd drawable type bitmask now. */
815 PUSH2(oGLXAttr
, GLX_DRAWABLE_TYPE
, drawattrib
);
816 TRACE("pAttr[?] = GLX_DRAWABLE_TYPE: %#x\n", drawattrib
);
822 BOOL
get_fbconfig_from_visualid(Display
*display
, Visual
*visual
, int *fmt_id
, int *fmt_index
)
824 GLXFBConfig
* cfgs
= NULL
;
831 if(!display
|| !display
) {
832 ERR("Invalid display or visual\n");
834 visualid
= XVisualIDFromVisual(visual
);
836 /* Get a list of all available framebuffer configurations */
837 cfgs
= pglXGetFBConfigs(display
, DefaultScreen(display
), &nCfgs
);
838 if (NULL
== cfgs
|| 0 == nCfgs
) {
839 ERR("glXChooseFBConfig returns NULL\n");
840 if(cfgs
!= NULL
) XFree(cfgs
);
844 /* Find the requested offscreen format and count the number of offscreen formats */
845 for(i
=0; i
<nCfgs
; i
++) {
846 pglXGetFBConfigAttrib(display
, cfgs
[i
], GLX_VISUAL_ID
, &tmp_vis_id
);
847 pglXGetFBConfigAttrib(display
, cfgs
[i
], GLX_FBCONFIG_ID
, &tmp_fmt_id
);
849 /* We are looking up the GLX index of our main visual and have found it :) */
850 if(visualid
== tmp_vis_id
) {
851 TRACE("Found FBCONFIG_ID 0x%x at index %d for VISUAL_ID 0x%x\n", tmp_fmt_id
, i
, tmp_vis_id
);
853 *fmt_id
= tmp_fmt_id
;
859 ERR("No fbconfig found for Wine's main visual (0x%lx), expect problems!\n", visualid
);
864 static BOOL
init_formats(Display
*display
, int screen
, Visual
*visual
)
866 int fmt_id
, fmt_index
;
868 /* Locate the fbconfig correspondig to our main visual */
869 if(!get_fbconfig_from_visualid(display
, visual
, &fmt_id
, &fmt_index
)) {
870 ERR("Can't get the FBCONFIG_ID for the main visual, expect problems!\n");
874 /* Put Wine's internal format at the first index */
875 WineGLPixelFormatList
[0].iPixelFormat
= 1;
876 WineGLPixelFormatList
[0].fbconfig
= fmt_id
;
877 WineGLPixelFormatList
[0].fmt_index
= fmt_index
;
878 WineGLPixelFormatListSize
= 1;
880 /* In the future test for compatible formats here */
885 /* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
886 * In our WGL implementation we only support a subset of these formats namely the format of
887 * Wine's main visual and offscreen formats (if they are available).
888 * This function converts a WGL format to its corresponding GLX one. It returns the index (zero-based)
889 * into the GLX FB config table and it returns the number of supported WGL formats in fmt_count.
891 static BOOL
ConvertPixelFormatWGLtoGLX(Display
*display
, int iPixelFormat
, int *fmt_index
, int *fmt_count
)
895 /* Init the list of pixel formats when we need it */
896 if(!WineGLPixelFormatListSize
)
897 init_formats(display
, DefaultScreen(display
), visual
);
899 if((iPixelFormat
<= 0) || (iPixelFormat
> WineGLPixelFormatListSize
)) {
900 ERR("invalid iPixelFormat %d\n", iPixelFormat
);
906 *fmt_index
= WineGLPixelFormatList
[iPixelFormat
-1].fmt_index
;
909 *fmt_count
= WineGLPixelFormatListSize
;
910 TRACE("Returning fmt_index=%d, fmt_count=%d for iPixelFormat=%d\n", *fmt_index
, *fmt_count
, iPixelFormat
);
915 /* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
916 static int ConvertPixelFormatGLXtoWGL(Display
*display
, int fbconfig
)
920 /* Init the list of pixel formats when we need it */
921 if(!WineGLPixelFormatListSize
)
922 init_formats(display
, DefaultScreen(display
), visual
);
924 for(i
=0; i
<WineGLPixelFormatListSize
; i
++) {
925 if(WineGLPixelFormatList
[i
].fbconfig
== fbconfig
) {
926 TRACE("Returning iPixelFormat %d for fbconfig 0x%x\n", WineGLPixelFormatList
[i
].iPixelFormat
, fbconfig
);
927 return WineGLPixelFormatList
[i
].iPixelFormat
;
930 TRACE("No compatible format found for FBCONFIG_ID=0x%x\n", fbconfig
);
935 * X11DRV_ChoosePixelFormat
937 * Equivalent to glXChooseVisual.
939 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE
*physDev
,
940 const PIXELFORMATDESCRIPTOR
*ppfd
) {
941 GLXFBConfig
* cfgs
= NULL
;
948 ERR("No libGL on this box - disabling OpenGL support !\n");
952 if (TRACE_ON(opengl
)) {
953 TRACE("(%p,%p)\n", physDev
, ppfd
);
955 dump_PIXELFORMATDESCRIPTOR((const PIXELFORMATDESCRIPTOR
*) ppfd
);
960 ERR("Can't get an opengl visual!\n");
964 /* Get a list containing all supported FB configurations */
965 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
966 if (NULL
== cfgs
|| 0 == nCfgs
) {
967 ERR("glXGetFBConfigs returns NULL (glError: %d)\n", pglGetError());
971 /* In case an fbconfig was found, check if it matches to the requirements of the ppfd */
972 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, 1 /* main visual */, &fmt_index
, &value
)) {
973 ERR("Can't find a matching FBCONFIG_ID for VISUAL_ID 0x%lx!\n", visual
->visualid
);
980 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_RENDER_TYPE
, &value
);
981 if (value
& GLX_RGBA_BIT
)
982 iPixelType
= PFD_TYPE_RGBA
;
984 iPixelType
= PFD_TYPE_COLORINDEX
;
986 if (ppfd
->iPixelType
!= iPixelType
) {
987 TRACE("pixel type mismatch\n");
992 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_DOUBLEBUFFER
, &value
); if (value
) dwFlags
|= PFD_DOUBLEBUFFER
;
993 if (!(ppfd
->dwFlags
& PFD_DOUBLEBUFFER_DONTCARE
) && (ppfd
->dwFlags
& PFD_DOUBLEBUFFER
)) {
994 if (!(dwFlags
& PFD_DOUBLEBUFFER
)) {
995 TRACE("dbl buffer mismatch\n");
1001 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_STEREO
, &value
); if (value
) dwFlags
|= PFD_STEREO
;
1002 if (!(ppfd
->dwFlags
& PFD_STEREO_DONTCARE
) && (ppfd
->dwFlags
& PFD_STEREO
)) {
1003 if (!(dwFlags
& PFD_STEREO
)) {
1004 TRACE("stereo mismatch\n");
1010 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_ALPHA_SIZE
, &value
);
1011 if (ppfd
->iPixelType
==PFD_TYPE_RGBA
&& ppfd
->cAlphaBits
&& !value
) {
1012 TRACE("alpha mismatch\n");
1017 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_DEPTH_SIZE
, &value
);
1018 if (ppfd
->cDepthBits
&& !value
) {
1019 TRACE("depth mismatch\n");
1024 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_STENCIL_SIZE
, &value
);
1025 if (ppfd
->cStencilBits
&& !value
) {
1026 TRACE("stencil mismatch\n");
1031 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_AUX_BUFFERS
, &value
);
1032 if (ppfd
->cAuxBuffers
&& !value
) {
1033 TRACE("aux mismatch\n");
1037 /* When we pass all the checks we have found a matching format :) */
1039 TRACE("Successfully found a matching mode, returning index: %d\n", ret
);
1044 TRACE("No matching mode was found returning 0\n");
1046 if (NULL
!= cfgs
) XFree(cfgs
);
1047 wine_tsx11_unlock();
1052 * X11DRV_DescribePixelFormat
1054 * Get the pixel-format descriptor associated to the given id
1056 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE
*physDev
,
1059 PIXELFORMATDESCRIPTOR
*ppfd
) {
1060 /*XVisualInfo *vis;*/
1064 GLXFBConfig
* cfgs
= NULL
;
1072 if (!has_opengl()) {
1073 ERR("No libGL on this box - disabling OpenGL support !\n");
1077 TRACE("(%p,%d,%d,%p)\n", physDev
, iPixelFormat
, nBytes
, ppfd
);
1080 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
1081 wine_tsx11_unlock();
1083 if (NULL
== cfgs
|| 0 == nCfgs
) {
1084 ERR("unexpected iPixelFormat(%d), returns NULL\n", iPixelFormat
);
1085 return 0; /* unespected error */
1088 /* Look for the iPixelFormat in our list of supported formats. If it is supported we get the index in the FBConfig table and the number of supported formats back */
1089 res
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &fmt_count
);
1092 /* The application is only querying the number of visuals */
1094 if (NULL
!= cfgs
) XFree(cfgs
);
1095 wine_tsx11_unlock();
1097 } else if(res
== FALSE
) {
1098 WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat
, fmt_count
);
1100 if (NULL
!= cfgs
) XFree(cfgs
);
1101 wine_tsx11_unlock();
1105 if (nBytes
< sizeof(PIXELFORMATDESCRIPTOR
)) {
1106 ERR("Wrong structure size !\n");
1107 /* Should set error */
1112 cur
= cfgs
[fmt_index
];
1114 memset(ppfd
, 0, sizeof(PIXELFORMATDESCRIPTOR
));
1115 ppfd
->nSize
= sizeof(PIXELFORMATDESCRIPTOR
);
1118 /* These flags are always the same... */
1119 ppfd
->dwFlags
= PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
;
1120 /* Now the flags extracted from the Visual */
1124 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_CONFIG_CAVEAT
, &value
);
1125 if(value
== GLX_SLOW_CONFIG
)
1126 ppfd
->dwFlags
|= PFD_GENERIC_ACCELERATED
;
1128 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_DOUBLEBUFFER
, &value
); if (value
) ppfd
->dwFlags
|= PFD_DOUBLEBUFFER
;
1129 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_STEREO
, &value
); if (value
) ppfd
->dwFlags
|= PFD_STEREO
;
1132 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_RENDER_TYPE
, &value
);
1133 if (value
& GLX_RGBA_BIT
)
1134 ppfd
->iPixelType
= PFD_TYPE_RGBA
;
1136 ppfd
->iPixelType
= PFD_TYPE_COLORINDEX
;
1139 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_BUFFER_SIZE
, &value
);
1140 ppfd
->cColorBits
= value
;
1142 /* Red, green, blue and alpha bits / shifts */
1143 if (ppfd
->iPixelType
== PFD_TYPE_RGBA
) {
1144 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_RED_SIZE
, &rb
);
1145 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_GREEN_SIZE
, &gb
);
1146 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_BLUE_SIZE
, &bb
);
1147 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_ALPHA_SIZE
, &ab
);
1149 ppfd
->cRedBits
= rb
;
1150 ppfd
->cRedShift
= gb
+ bb
+ ab
;
1151 ppfd
->cBlueBits
= bb
;
1152 ppfd
->cBlueShift
= ab
;
1153 ppfd
->cGreenBits
= gb
;
1154 ppfd
->cGreenShift
= bb
+ ab
;
1155 ppfd
->cAlphaBits
= ab
;
1156 ppfd
->cAlphaShift
= 0;
1159 ppfd
->cRedShift
= 0;
1160 ppfd
->cBlueBits
= 0;
1161 ppfd
->cBlueShift
= 0;
1162 ppfd
->cGreenBits
= 0;
1163 ppfd
->cGreenShift
= 0;
1164 ppfd
->cAlphaBits
= 0;
1165 ppfd
->cAlphaShift
= 0;
1167 /* Accums : to do ... */
1170 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_DEPTH_SIZE
, &value
);
1171 ppfd
->cDepthBits
= value
;
1174 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_STENCIL_SIZE
, &value
);
1175 ppfd
->cStencilBits
= value
;
1177 wine_tsx11_unlock();
1179 /* Aux : to do ... */
1181 ppfd
->iLayerType
= PFD_MAIN_PLANE
;
1183 if (TRACE_ON(opengl
)) {
1184 dump_PIXELFORMATDESCRIPTOR(ppfd
);
1188 if (NULL
!= cfgs
) XFree(cfgs
);
1189 wine_tsx11_unlock();
1195 * X11DRV_GetPixelFormat
1197 * Get the pixel-format id used by this DC
1199 int X11DRV_GetPixelFormat(X11DRV_PDEVICE
*physDev
) {
1200 TRACE("(%p): returns %d\n", physDev
, physDev
->current_pf
);
1202 return physDev
->current_pf
;
1206 * X11DRV_SetPixelFormat
1208 * Set the pixel-format id used by this DC
1210 BOOL
X11DRV_SetPixelFormat(X11DRV_PDEVICE
*physDev
,
1212 const PIXELFORMATDESCRIPTOR
*ppfd
) {
1216 TRACE("(%p,%d,%p)\n", physDev
, iPixelFormat
, ppfd
);
1218 if (!has_opengl()) {
1219 ERR("No libGL on this box - disabling OpenGL support !\n");
1223 /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
1224 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &value
)) {
1225 ERR("Invalid iPixelFormat: %d\n", iPixelFormat
);
1229 physDev
->current_pf
= iPixelFormat
;
1231 if (TRACE_ON(opengl
)) {
1233 GLXFBConfig
* cfgs_fmt
= NULL
;
1234 GLXFBConfig cur_cfg
;
1238 * How to test if hdc current drawable is compatible (visual/FBConfig) ?
1240 * in case of root window created HDCs we crash here :(
1242 Drawable drawable = get_drawable( physDev->hdc );
1243 TRACE(" drawable (%p,%p) have :\n", drawable, root_window);
1244 pglXQueryDrawable(gdi_display, drawable, GLX_FBCONFIG_ID, (unsigned int*) &value);
1245 TRACE(" - FBCONFIG_ID as 0x%x\n", tmp);
1246 pglXQueryDrawable(gdi_display, drawable, GLX_VISUAL_ID, (unsigned int*) &value);
1247 TRACE(" - VISUAL_ID as 0x%x\n", tmp);
1248 pglXQueryDrawable(gdi_display, drawable, GLX_WIDTH, (unsigned int*) &value);
1249 TRACE(" - WIDTH as %d\n", tmp);
1250 pglXQueryDrawable(gdi_display, drawable, GLX_HEIGHT, (unsigned int*) &value);
1251 TRACE(" - HEIGHT as %d\n", tmp);
1253 cfgs_fmt
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs_fmt
);
1254 cur_cfg
= cfgs_fmt
[fmt_index
];
1255 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_FBCONFIG_ID
, &value
);
1257 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
1259 TRACE(" FBConfig have :\n");
1260 TRACE(" - FBCONFIG_ID 0x%x\n", value
);
1261 pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_VISUAL_ID
, &value
);
1262 TRACE(" - VISUAL_ID 0x%x\n", value
);
1263 pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_DRAWABLE_TYPE
, &value
);
1264 TRACE(" - DRAWABLE_TYPE 0x%x\n", value
);
1272 * X11DRV_wglCreateContext
1274 * For OpenGL32 wglCreateContext.
1276 HGLRC
X11DRV_wglCreateContext(X11DRV_PDEVICE
*physDev
)
1278 Wine_GLContext
*ret
;
1279 GLXFBConfig
* cfgs_fmt
= NULL
;
1280 GLXFBConfig cur_cfg
;
1281 int hdcPF
= physDev
->current_pf
;
1287 HDC hdc
= physDev
->hdc
;
1289 TRACE("(%p)->(PF:%d)\n", hdc
, hdcPF
);
1291 if (!has_opengl()) {
1292 ERR("No libGL on this box - disabling OpenGL support !\n");
1296 /* First, get the visual in use by the X11DRV */
1297 if (!gdi_display
) return 0;
1299 /* We can only render using the iPixelFormat (1) of Wine's Main visual, we need to get the corresponding GLX format.
1300 * If this fails something is very wrong on the system. */
1301 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, hdcPF
, &fmt_index
, &fmt_count
)) {
1302 ERR("Cannot get FB Config for main iPixelFormat 1, expect problems!\n");
1303 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1307 cfgs_fmt
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs_fmt
);
1308 if (NULL
== cfgs_fmt
|| 0 == nCfgs_fmt
) {
1309 ERR("Cannot get FB Configs, expect problems.\n");
1310 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1314 if (fmt_count
< hdcPF
) {
1315 ERR("(%p): unexpected pixelFormat(%d) > nFormats(%d), returns NULL\n", hdc
, hdcPF
, fmt_count
);
1316 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1320 cur_cfg
= cfgs_fmt
[fmt_index
];
1321 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_FBCONFIG_ID
, &value
);
1323 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
1324 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1329 /* The context will be allocated in the wglMakeCurrent call */
1331 ret
= alloc_context();
1332 wine_tsx11_unlock();
1334 ret
->physDev
= physDev
;
1335 ret
->fb_conf
= cur_cfg
;
1337 ret
->vis
= pglXGetVisualFromFBConfig(gdi_display
, cur_cfg
);
1339 TRACE(" creating context %p (GL context creation delayed)\n", ret
);
1344 * X11DRV_wglDeleteContext
1346 * For OpenGL32 wglDeleteContext.
1348 BOOL
X11DRV_wglDeleteContext(HGLRC hglrc
)
1350 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1353 TRACE("(%p)\n", hglrc
);
1355 if (!has_opengl()) {
1356 ERR("No libGL on this box - disabling OpenGL support !\n");
1361 /* A game (Half Life not to name it) deletes twice the same context,
1362 * so make sure it is valid first */
1363 if (is_valid_context( ctx
))
1365 if (ctx
->ctx
) pglXDestroyContext(gdi_display
, ctx
->ctx
);
1370 WARN("Error deleting context !\n");
1371 SetLastError(ERROR_INVALID_HANDLE
);
1374 wine_tsx11_unlock();
1380 * X11DRV_wglGetCurrentReadDCARB
1382 * For OpenGL32 wglGetCurrentReadDCARB.
1384 static HDC WINAPI
X11DRV_wglGetCurrentReadDCARB(void)
1392 gl_d
= pglXGetCurrentReadDrawable();
1393 ret
= get_hdc_from_Drawable(gl_d
);
1394 wine_tsx11_unlock();
1396 TRACE(" returning %p (GL drawable %lu)\n", ret
, gl_d
);
1401 * X11DRV_wglGetProcAddress
1403 * For OpenGL32 wglGetProcAddress.
1405 PROC
X11DRV_wglGetProcAddress(LPCSTR lpszProc
)
1408 const WineGLExtension
*ext
;
1410 int padding
= 32 - strlen(lpszProc
);
1414 if (!has_opengl()) {
1415 ERR("No libGL on this box - disabling OpenGL support !\n");
1419 /* Check the table of WGL extensions to see if we need to return a WGL extension
1420 * or a function pointer to a native OpenGL function. */
1421 if(strncmp(lpszProc
, "wgl", 3) != 0) {
1422 return pglXGetProcAddressARB((const GLubyte
*)lpszProc
);
1424 TRACE("('%s'):%*s", lpszProc
, padding
, " ");
1425 for (i
= 0; i
< WineGLExtensionListSize
; ++i
) {
1426 ext
= WineGLExtensionList
[i
];
1427 for (j
= 0; ext
->extEntryPoints
[j
].funcName
; ++j
) {
1428 if (strcmp(ext
->extEntryPoints
[j
].funcName
, lpszProc
) == 0) {
1429 TRACE("(%p) - WineGL\n", ext
->extEntryPoints
[j
].funcAddress
);
1430 return ext
->extEntryPoints
[j
].funcAddress
;
1436 ERR("(%s) - not found\n", lpszProc
);
1440 /***********************************************************************
1441 * sync_current_drawable
1443 * Adjust the current viewport and scissor in order to position
1444 * and size the current drawable correctly on the parent window.
1446 static void sync_current_drawable(BOOL updatedc
)
1452 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1456 if (ctx
&& ctx
->physDev
)
1459 GetClipBox(ctx
->physDev
->hdc
, &rc
); /* Make sure physDev is up to date */
1461 dy
= ctx
->physDev
->drawable_rect
.bottom
- ctx
->physDev
->drawable_rect
.top
-
1462 ctx
->physDev
->dc_rect
.bottom
;
1463 width
= ctx
->physDev
->dc_rect
.right
- ctx
->physDev
->dc_rect
.left
;
1464 height
= ctx
->physDev
->dc_rect
.bottom
- ctx
->physDev
->dc_rect
.top
;
1468 pglViewport(ctx
->physDev
->dc_rect
.left
+ ctx
->viewport
.left
,
1469 dy
+ ctx
->viewport
.top
,
1470 ctx
->viewport
.right
? (ctx
->viewport
.right
- ctx
->viewport
.left
) : width
,
1471 ctx
->viewport
.bottom
? (ctx
->viewport
.bottom
- ctx
->viewport
.top
) : height
);
1473 pglEnable(GL_SCISSOR_TEST
);
1475 if (ctx
->scissor_enabled
)
1476 pglScissor(ctx
->physDev
->dc_rect
.left
+ min(width
, max(0, ctx
->scissor
.left
)),
1477 dy
+ min(height
, max(0, ctx
->scissor
.top
)),
1478 min(width
, max(0, ctx
->scissor
.right
- ctx
->scissor
.left
)),
1479 min(height
, max(0, ctx
->scissor
.bottom
- ctx
->scissor
.top
)));
1481 pglScissor(ctx
->physDev
->dc_rect
.left
, dy
, width
, height
);
1483 wine_tsx11_unlock();
1488 * X11DRV_wglMakeCurrent
1490 * For OpenGL32 wglMakeCurrent.
1492 BOOL
X11DRV_wglMakeCurrent(X11DRV_PDEVICE
*physDev
, HGLRC hglrc
) {
1494 HDC hdc
= physDev
->hdc
;
1495 DWORD type
= GetObjectType(hdc
);
1497 TRACE("(%p,%p)\n", hdc
, hglrc
);
1499 if (!has_opengl()) {
1500 ERR("No libGL on this box - disabling OpenGL support !\n");
1505 if (hglrc
== NULL
) {
1506 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1507 NtCurrentTeb()->glContext
= NULL
;
1509 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1510 Drawable drawable
= physDev
->drawable
;
1511 if (ctx
->ctx
== NULL
) {
1512 /* The describe lines below are for debugging purposes only */
1513 if (TRACE_ON(wgl
)) {
1514 describeDrawable(ctx
, drawable
);
1515 describeContext(ctx
);
1518 /* Create a GLX context using the same visual as chosen earlier in wglCreateContext.
1519 * We are certain that the drawable and context are compatible as we only allow compatible formats.
1521 TRACE(" Creating GLX Context\n");
1522 ctx
->ctx
= pglXCreateContext(gdi_display
, ctx
->vis
, NULL
, type
== OBJ_MEMDC
? False
: True
);
1523 TRACE(" created a delayed OpenGL context (%p)\n", ctx
->ctx
);
1525 TRACE(" make current for dis %p, drawable %p, ctx %p\n", gdi_display
, (void*) drawable
, ctx
->ctx
);
1526 ret
= pglXMakeCurrent(gdi_display
, drawable
, ctx
->ctx
);
1527 NtCurrentTeb()->glContext
= ctx
;
1530 ctx
->physDev
= physDev
;
1532 if (type
== OBJ_MEMDC
)
1534 ctx
->do_escape
= TRUE
;
1535 pglDrawBuffer(GL_FRONT_LEFT
);
1539 sync_current_drawable(FALSE
);
1543 wine_tsx11_unlock();
1544 TRACE(" returning %s\n", (ret
? "True" : "False"));
1549 * X11DRV_wglMakeContextCurrentARB
1551 * For OpenGL32 wglMakeContextCurrentARB
1553 BOOL
X11DRV_wglMakeContextCurrentARB(X11DRV_PDEVICE
* hDrawDev
, X11DRV_PDEVICE
* hReadDev
, HGLRC hglrc
)
1556 TRACE("(%p,%p,%p)\n", hDrawDev
, hReadDev
, hglrc
);
1558 if (!has_opengl()) {
1559 ERR("No libGL on this box - disabling OpenGL support !\n");
1564 if (hglrc
== NULL
) {
1565 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1566 NtCurrentTeb()->glContext
= NULL
;
1568 if (NULL
== pglXMakeContextCurrent
) {
1571 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1572 Drawable d_draw
= get_glxdrawable(hDrawDev
);
1573 Drawable d_read
= get_glxdrawable(hReadDev
);
1575 if (ctx
->ctx
== NULL
) {
1576 ctx
->ctx
= pglXCreateContext(gdi_display
, ctx
->vis
, NULL
, GetObjectType(hDrawDev
->hdc
) == OBJ_MEMDC
? False
: True
);
1577 TRACE(" created a delayed OpenGL context (%p)\n", ctx
->ctx
);
1579 ret
= pglXMakeContextCurrent(gdi_display
, d_draw
, d_read
, ctx
->ctx
);
1580 NtCurrentTeb()->glContext
= ctx
;
1583 wine_tsx11_unlock();
1585 TRACE(" returning %s\n", (ret
? "True" : "False"));
1590 * X11DRV_wglShareLists
1592 * For OpenGL32 wglShaderLists.
1594 BOOL
X11DRV_wglShareLists(HGLRC hglrc1
, HGLRC hglrc2
) {
1595 Wine_GLContext
*org
= (Wine_GLContext
*) hglrc1
;
1596 Wine_GLContext
*dest
= (Wine_GLContext
*) hglrc2
;
1598 TRACE("(%p, %p)\n", org
, dest
);
1600 if (!has_opengl()) {
1601 ERR("No libGL on this box - disabling OpenGL support !\n");
1605 if (NULL
!= dest
&& dest
->ctx
!= NULL
) {
1606 ERR("Could not share display lists, context already created !\n");
1609 if (org
->ctx
== NULL
) {
1611 describeContext(org
);
1612 org
->ctx
= pglXCreateContext(gdi_display
, org
->vis
, NULL
, GetObjectType(org
->physDev
->hdc
) == OBJ_MEMDC
? False
: True
);
1613 wine_tsx11_unlock();
1614 TRACE(" created a delayed OpenGL context (%p) for Wine context %p\n", org
->ctx
, org
);
1618 describeContext(dest
);
1619 /* Create the destination context with display lists shared */
1620 dest
->ctx
= pglXCreateContext(gdi_display
, dest
->vis
, org
->ctx
, GetObjectType(org
->physDev
->hdc
) == OBJ_MEMDC
? False
: True
);
1621 wine_tsx11_unlock();
1622 TRACE(" created a delayed OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest
->ctx
, dest
, org
->ctx
);
1629 static BOOL
internal_wglUseFontBitmaps(HDC hdc
, DWORD first
, DWORD count
, DWORD listBase
, DWORD (WINAPI
*GetGlyphOutline_ptr
)(HDC
,UINT
,UINT
,LPGLYPHMETRICS
,DWORD
,LPVOID
,const MAT2
*))
1631 /* We are running using client-side rendering fonts... */
1635 void *bitmap
= NULL
, *gl_bitmap
= NULL
;
1639 pglGetIntegerv(GL_UNPACK_ALIGNMENT
, &org_alignment
);
1640 pglPixelStorei(GL_UNPACK_ALIGNMENT
, 4);
1641 wine_tsx11_unlock();
1643 for (glyph
= first
; glyph
< first
+ count
; glyph
++) {
1644 unsigned int needed_size
= GetGlyphOutline_ptr(hdc
, glyph
, GGO_BITMAP
, &gm
, 0, NULL
, NULL
);
1645 int height
, width_int
;
1647 TRACE("Glyph : %3d / List : %d\n", glyph
, listBase
);
1648 if (needed_size
== GDI_ERROR
) {
1649 TRACE(" - needed size : %d (GDI_ERROR)\n", needed_size
);
1652 TRACE(" - needed size : %d\n", needed_size
);
1655 if (needed_size
> size
) {
1657 HeapFree(GetProcessHeap(), 0, bitmap
);
1658 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
1659 bitmap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
1660 gl_bitmap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
1662 if (GetGlyphOutline_ptr(hdc
, glyph
, GGO_BITMAP
, &gm
, size
, bitmap
, NULL
) == GDI_ERROR
) goto error
;
1663 if (TRACE_ON(opengl
)) {
1664 unsigned int height
, width
, bitmask
;
1665 unsigned char *bitmap_
= (unsigned char *) bitmap
;
1667 TRACE(" - bbox : %d x %d\n", gm
.gmBlackBoxX
, gm
.gmBlackBoxY
);
1668 TRACE(" - origin : (%d , %d)\n", gm
.gmptGlyphOrigin
.x
, gm
.gmptGlyphOrigin
.y
);
1669 TRACE(" - increment : %d - %d\n", gm
.gmCellIncX
, gm
.gmCellIncY
);
1670 if (needed_size
!= 0) {
1671 TRACE(" - bitmap :\n");
1672 for (height
= 0; height
< gm
.gmBlackBoxY
; height
++) {
1674 for (width
= 0, bitmask
= 0x80; width
< gm
.gmBlackBoxX
; width
++, bitmask
>>= 1) {
1679 if (*bitmap_
& bitmask
)
1684 bitmap_
+= (4 - ((UINT_PTR
)bitmap_
& 0x03));
1690 /* In OpenGL, the bitmap is drawn from the bottom to the top... So we need to invert the
1691 * glyph for it to be drawn properly.
1693 if (needed_size
!= 0) {
1694 width_int
= (gm
.gmBlackBoxX
+ 31) / 32;
1695 for (height
= 0; height
< gm
.gmBlackBoxY
; height
++) {
1697 for (width
= 0; width
< width_int
; width
++) {
1698 ((int *) gl_bitmap
)[(gm
.gmBlackBoxY
- height
- 1) * width_int
+ width
] =
1699 ((int *) bitmap
)[height
* width_int
+ width
];
1705 pglNewList(listBase
++, GL_COMPILE
);
1706 if (needed_size
!= 0) {
1707 pglBitmap(gm
.gmBlackBoxX
, gm
.gmBlackBoxY
,
1708 0 - (int) gm
.gmptGlyphOrigin
.x
, (int) gm
.gmBlackBoxY
- (int) gm
.gmptGlyphOrigin
.y
,
1709 gm
.gmCellIncX
, gm
.gmCellIncY
,
1712 /* This is the case of 'empty' glyphs like the space character */
1713 pglBitmap(0, 0, 0, 0, gm
.gmCellIncX
, gm
.gmCellIncY
, NULL
);
1716 wine_tsx11_unlock();
1720 pglPixelStorei(GL_UNPACK_ALIGNMENT
, org_alignment
);
1721 wine_tsx11_unlock();
1723 HeapFree(GetProcessHeap(), 0, bitmap
);
1724 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
1729 pglPixelStorei(GL_UNPACK_ALIGNMENT
, org_alignment
);
1730 wine_tsx11_unlock();
1732 HeapFree(GetProcessHeap(), 0, bitmap
);
1733 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
1738 * X11DRV_wglUseFontBitmapsA
1740 * For OpenGL32 wglUseFontBitmapsA.
1742 BOOL
X11DRV_wglUseFontBitmapsA(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
1744 Font fid
= physDev
->font
;
1746 TRACE("(%p, %d, %d, %d) using font %ld\n", physDev
->hdc
, first
, count
, listBase
, fid
);
1748 if (!has_opengl()) {
1749 ERR("No libGL on this box - disabling OpenGL support !\n");
1754 return internal_wglUseFontBitmaps(physDev
->hdc
, first
, count
, listBase
, GetGlyphOutlineA
);
1758 /* I assume that the glyphs are at the same position for X and for Windows */
1759 pglXUseXFont(fid
, first
, count
, listBase
);
1760 wine_tsx11_unlock();
1765 * X11DRV_wglUseFontBitmapsW
1767 * For OpenGL32 wglUseFontBitmapsW.
1769 BOOL
X11DRV_wglUseFontBitmapsW(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
1771 Font fid
= physDev
->font
;
1773 TRACE("(%p, %d, %d, %d) using font %ld\n", physDev
->hdc
, first
, count
, listBase
, fid
);
1775 if (!has_opengl()) {
1776 ERR("No libGL on this box - disabling OpenGL support !\n");
1781 return internal_wglUseFontBitmaps(physDev
->hdc
, first
, count
, listBase
, GetGlyphOutlineW
);
1784 WARN("Using the glX API for the WCHAR variant - some characters may come out incorrectly !\n");
1787 /* I assume that the glyphs are at the same position for X and for Windows */
1788 pglXUseXFont(fid
, first
, count
, listBase
);
1789 wine_tsx11_unlock();
1793 static void WINAPI
X11DRV_wglDisable(GLenum cap
)
1795 if (cap
== GL_SCISSOR_TEST
)
1797 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1800 ctx
->scissor_enabled
= FALSE
;
1806 wine_tsx11_unlock();
1810 static void WINAPI
X11DRV_wglEnable(GLenum cap
)
1812 if (cap
== GL_SCISSOR_TEST
)
1814 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1817 ctx
->scissor_enabled
= TRUE
;
1823 wine_tsx11_unlock();
1827 /* WGL helper function which handles differences in glGetIntegerv from WGL and GLX */
1828 static void WINAPI
X11DRV_wglGetIntegerv(GLenum pname
, GLint
* params
)
1835 GLXContext gl_ctx
= pglXGetCurrentContext();
1836 Wine_GLContext
* ret
= get_context_from_GLXContext(gl_ctx
);
1838 pglGetIntegerv(pname
, params
);
1840 * if we cannot find a Wine Context
1841 * we only have the default wine desktop context,
1842 * so if we have only a 24 depth say we have 32
1844 if (NULL
== ret
&& 24 == *params
) {
1847 TRACE("returns GL_DEPTH_BITS as '%d'\n", *params
);
1852 GLXContext gl_ctx
= pglXGetCurrentContext();
1853 Wine_GLContext
* ret
= get_context_from_GLXContext(gl_ctx
);
1855 pglXGetFBConfigAttrib(gdi_display
, ret
->fb_conf
, GLX_ALPHA_SIZE
, params
);
1856 TRACE("returns GL_ALPHA_BITS as '%d'\n", *params
);
1860 pglGetIntegerv(pname
, params
);
1863 wine_tsx11_unlock();
1866 static GLboolean WINAPI
X11DRV_wglIsEnabled(GLenum cap
)
1868 GLboolean enabled
= False
;
1870 if (cap
== GL_SCISSOR_TEST
)
1872 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1875 enabled
= ctx
->scissor_enabled
;
1880 enabled
= pglIsEnabled(cap
);
1881 wine_tsx11_unlock();
1886 static void WINAPI
X11DRV_wglScissor(GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1888 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1892 ctx
->scissor
.left
= x
;
1893 ctx
->scissor
.top
= y
;
1894 ctx
->scissor
.right
= x
+ width
;
1895 ctx
->scissor
.bottom
= y
+ height
;
1897 sync_current_drawable(TRUE
);
1901 static void WINAPI
X11DRV_wglViewport(GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1903 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1907 ctx
->viewport
.left
= x
;
1908 ctx
->viewport
.top
= y
;
1909 ctx
->viewport
.right
= x
+ width
;
1910 ctx
->viewport
.bottom
= y
+ height
;
1912 sync_current_drawable(TRUE
);
1917 * X11DRV_wglGetExtensionsStringARB
1919 * WGL_ARB_extensions_string: wglGetExtensionsStringARB
1921 static const char * WINAPI
X11DRV_wglGetExtensionsStringARB(HDC hdc
) {
1922 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
1923 return WineGLInfo
.wglExtensions
;
1927 * X11DRV_wglCreatePbufferARB
1929 * WGL_ARB_pbuffer: wglCreatePbufferARB
1931 static HPBUFFERARB WINAPI
X11DRV_wglCreatePbufferARB(HDC hdc
, int iPixelFormat
, int iWidth
, int iHeight
, const int *piAttribList
)
1933 Wine_GLPBuffer
* object
= NULL
;
1934 GLXFBConfig
* cfgs
= NULL
;
1937 unsigned nAttribs
= 0;
1940 TRACE("(%p, %d, %d, %d, %p)\n", hdc
, iPixelFormat
, iWidth
, iHeight
, piAttribList
);
1942 if (0 >= iPixelFormat
) {
1943 ERR("(%p): unexpected iPixelFormat(%d) <= 0, returns NULL\n", hdc
, iPixelFormat
);
1944 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1945 return NULL
; /* unexpected error */
1948 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
1950 if (NULL
== cfgs
|| 0 == nCfgs
) {
1951 ERR("(%p): Cannot get FB Configs for iPixelFormat(%d), returns NULL\n", hdc
, iPixelFormat
);
1952 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1953 return NULL
; /* unexpected error */
1956 /* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
1957 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &nCfgs
)) {
1958 ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc
, iPixelFormat
, nCfgs
);
1959 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1960 goto create_failed
; /* unexpected error */
1963 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(Wine_GLPBuffer
));
1964 if (NULL
== object
) {
1965 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
1966 goto create_failed
; /* unexpected error */
1969 object
->display
= gdi_display
;
1970 object
->width
= iWidth
;
1971 object
->height
= iHeight
;
1972 object
->pixelFormat
= iPixelFormat
;
1974 nAttribs
= ConvertAttribWGLtoGLX(piAttribList
, attribs
, object
);
1975 if (-1 == nAttribs
) {
1976 WARN("Cannot convert WGL to GLX attributes\n");
1979 PUSH2(attribs
, GLX_PBUFFER_WIDTH
, iWidth
);
1980 PUSH2(attribs
, GLX_PBUFFER_HEIGHT
, iHeight
);
1981 while (0 != *piAttribList
) {
1983 switch (*piAttribList
) {
1984 case WGL_TEXTURE_FORMAT_ARB
: {
1986 attr_v
= *piAttribList
;
1987 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_FORMAT_ARB as %x\n", attr_v
);
1988 if (use_render_texture_ati
) {
1991 case WGL_NO_TEXTURE_ARB
: type
= GLX_NO_TEXTURE_ATI
; break ;
1992 case WGL_TEXTURE_RGB_ARB
: type
= GLX_TEXTURE_RGB_ATI
; break ;
1993 case WGL_TEXTURE_RGBA_ARB
: type
= GLX_TEXTURE_RGBA_ATI
; break ;
1995 SetLastError(ERROR_INVALID_DATA
);
1998 object
->use_render_texture
= 1;
1999 PUSH2(attribs
, GLX_TEXTURE_FORMAT_ATI
, type
);
2001 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2002 object
->use_render_texture
= 0;
2004 if (!use_render_texture_emulation
) {
2005 SetLastError(ERROR_INVALID_DATA
);
2009 case WGL_TEXTURE_RGB_ARB
:
2010 object
->use_render_texture
= GL_RGB
;
2012 case WGL_TEXTURE_RGBA_ARB
:
2013 object
->use_render_texture
= GL_RGBA
;
2016 SetLastError(ERROR_INVALID_DATA
);
2024 case WGL_TEXTURE_TARGET_ARB
: {
2026 attr_v
= *piAttribList
;
2027 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_TARGET_ARB as %x\n", attr_v
);
2028 if (use_render_texture_ati
) {
2031 case WGL_NO_TEXTURE_ARB
: type
= GLX_NO_TEXTURE_ATI
; break ;
2032 case WGL_TEXTURE_CUBE_MAP_ARB
: type
= GLX_TEXTURE_CUBE_MAP_ATI
; break ;
2033 case WGL_TEXTURE_1D_ARB
: type
= GLX_TEXTURE_1D_ATI
; break ;
2034 case WGL_TEXTURE_2D_ARB
: type
= GLX_TEXTURE_2D_ATI
; break ;
2036 SetLastError(ERROR_INVALID_DATA
);
2039 PUSH2(attribs
, GLX_TEXTURE_TARGET_ATI
, type
);
2041 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2042 object
->texture_target
= 0;
2044 if (!use_render_texture_emulation
) {
2045 SetLastError(ERROR_INVALID_DATA
);
2049 case WGL_TEXTURE_CUBE_MAP_ARB
: {
2050 if (iWidth
!= iHeight
) {
2051 SetLastError(ERROR_INVALID_DATA
);
2054 object
->texture_target
= GL_TEXTURE_CUBE_MAP
;
2055 object
->texture_bind_target
= GL_TEXTURE_CUBE_MAP
;
2058 case WGL_TEXTURE_1D_ARB
: {
2060 SetLastError(ERROR_INVALID_DATA
);
2063 object
->texture_target
= GL_TEXTURE_1D
;
2064 object
->texture_bind_target
= GL_TEXTURE_1D
;
2067 case WGL_TEXTURE_2D_ARB
: {
2068 object
->texture_target
= GL_TEXTURE_2D
;
2069 object
->texture_bind_target
= GL_TEXTURE_2D
;
2073 SetLastError(ERROR_INVALID_DATA
);
2081 case WGL_MIPMAP_TEXTURE_ARB
: {
2083 attr_v
= *piAttribList
;
2084 TRACE("WGL_render_texture Attribute: WGL_MIPMAP_TEXTURE_ARB as %x\n", attr_v
);
2085 if (use_render_texture_ati
) {
2086 PUSH2(attribs
, GLX_MIPMAP_TEXTURE_ATI
, attr_v
);
2088 if (!use_render_texture_emulation
) {
2089 SetLastError(ERROR_INVALID_DATA
);
2099 PUSH1(attribs
, None
);
2100 object
->drawable
= pglXCreatePbuffer(gdi_display
, cfgs
[fmt_index
], attribs
);
2101 TRACE("new Pbuffer drawable as %p\n", (void*) object
->drawable
);
2102 if (!object
->drawable
) {
2103 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
2104 goto create_failed
; /* unexpected error */
2106 TRACE("->(%p)\n", object
);
2110 return (HPBUFFERARB
) object
;
2113 if (NULL
!= cfgs
) XFree(cfgs
);
2114 HeapFree(GetProcessHeap(), 0, object
);
2115 TRACE("->(FAILED)\n");
2116 return (HPBUFFERARB
) NULL
;
2120 * X11DRV_wglDestroyPbufferARB
2122 * WGL_ARB_pbuffer: wglDestroyPbufferARB
2124 static GLboolean WINAPI
X11DRV_wglDestroyPbufferARB(HPBUFFERARB hPbuffer
)
2126 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2127 TRACE("(%p)\n", hPbuffer
);
2128 if (NULL
== object
) {
2129 SetLastError(ERROR_INVALID_HANDLE
);
2132 pglXDestroyPbuffer(object
->display
, object
->drawable
);
2133 HeapFree(GetProcessHeap(), 0, object
);
2138 * X11DRV_wglGetPbufferDCARB
2140 * WGL_ARB_pbuffer: wglGetPbufferDCARB
2141 * The function wglGetPbufferDCARB returns a device context for a pbuffer.
2142 * Gdi32 implements the part of this function which creates a device context.
2143 * This part associates the physDev with the X drawable of the pbuffer.
2145 HDC
X11DRV_wglGetPbufferDCARB(X11DRV_PDEVICE
*physDev
, HPBUFFERARB hPbuffer
)
2147 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2148 if (NULL
== object
) {
2149 SetLastError(ERROR_INVALID_HANDLE
);
2153 /* The function wglGetPbufferDCARB returns a DC to which the pbuffer can be connected.
2154 * All formats in our pixelformat list are compatible with each other and the main drawable. */
2155 physDev
->current_pf
= object
->pixelFormat
;
2156 physDev
->drawable
= object
->drawable
;
2158 TRACE("(%p)->(%p)\n", hPbuffer
, physDev
->hdc
);
2159 return physDev
->hdc
;
2163 * X11DRV_wglQueryPbufferARB
2165 * WGL_ARB_pbuffer: wglQueryPbufferARB
2167 static GLboolean WINAPI
X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer
, int iAttribute
, int *piValue
)
2169 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2170 TRACE("(%p, 0x%x, %p)\n", hPbuffer
, iAttribute
, piValue
);
2171 if (NULL
== object
) {
2172 SetLastError(ERROR_INVALID_HANDLE
);
2175 switch (iAttribute
) {
2176 case WGL_PBUFFER_WIDTH_ARB
:
2177 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_WIDTH
, (unsigned int*) piValue
);
2179 case WGL_PBUFFER_HEIGHT_ARB
:
2180 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_HEIGHT
, (unsigned int*) piValue
);
2183 case WGL_PBUFFER_LOST_ARB
:
2184 FIXME("unsupported WGL_PBUFFER_LOST_ARB (need glXSelectEvent/GLX_DAMAGED work)\n");
2187 case WGL_TEXTURE_FORMAT_ARB
:
2188 if (use_render_texture_ati
) {
2190 int type
= WGL_NO_TEXTURE_ARB
;
2191 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_TEXTURE_FORMAT_ATI
, &tmp
);
2193 case GLX_NO_TEXTURE_ATI
: type
= WGL_NO_TEXTURE_ARB
; break ;
2194 case GLX_TEXTURE_RGB_ATI
: type
= WGL_TEXTURE_RGB_ARB
; break ;
2195 case GLX_TEXTURE_RGBA_ATI
: type
= WGL_TEXTURE_RGBA_ARB
; break ;
2199 if (!object
->use_render_texture
) {
2200 *piValue
= WGL_NO_TEXTURE_ARB
;
2202 if (!use_render_texture_emulation
) {
2203 SetLastError(ERROR_INVALID_HANDLE
);
2206 if (GL_RGBA
== object
->use_render_texture
) {
2207 *piValue
= WGL_TEXTURE_RGBA_ARB
;
2209 *piValue
= WGL_TEXTURE_RGB_ARB
;
2215 case WGL_TEXTURE_TARGET_ARB
:
2216 if (use_render_texture_ati
) {
2218 int type
= WGL_NO_TEXTURE_ARB
;
2219 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_TEXTURE_TARGET_ATI
, &tmp
);
2221 case GLX_NO_TEXTURE_ATI
: type
= WGL_NO_TEXTURE_ARB
; break ;
2222 case GLX_TEXTURE_CUBE_MAP_ATI
: type
= WGL_TEXTURE_CUBE_MAP_ARB
; break ;
2223 case GLX_TEXTURE_1D_ATI
: type
= WGL_TEXTURE_1D_ARB
; break ;
2224 case GLX_TEXTURE_2D_ATI
: type
= WGL_TEXTURE_2D_ARB
; break ;
2228 if (!object
->texture_target
) {
2229 *piValue
= WGL_NO_TEXTURE_ARB
;
2231 if (!use_render_texture_emulation
) {
2232 SetLastError(ERROR_INVALID_DATA
);
2235 switch (object
->texture_target
) {
2236 case GL_TEXTURE_1D
: *piValue
= WGL_TEXTURE_CUBE_MAP_ARB
; break;
2237 case GL_TEXTURE_2D
: *piValue
= WGL_TEXTURE_1D_ARB
; break;
2238 case GL_TEXTURE_CUBE_MAP
: *piValue
= WGL_TEXTURE_2D_ARB
; break;
2244 case WGL_MIPMAP_TEXTURE_ARB
:
2245 if (use_render_texture_ati
) {
2246 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_MIPMAP_TEXTURE_ATI
, (unsigned int*) piValue
);
2248 *piValue
= GL_FALSE
; /** don't support that */
2249 FIXME("unsupported WGL_ARB_render_texture attribute query for 0x%x\n", iAttribute
);
2254 FIXME("unexpected attribute %x\n", iAttribute
);
2262 * X11DRV_wglReleasePbufferDCARB
2264 * WGL_ARB_pbuffer: wglReleasePbufferDCARB
2266 static int WINAPI
X11DRV_wglReleasePbufferDCARB(HPBUFFERARB hPbuffer
, HDC hdc
)
2268 TRACE("(%p, %p)\n", hPbuffer
, hdc
);
2274 * X11DRV_wglSetPbufferAttribARB
2276 * WGL_ARB_pbuffer: wglSetPbufferAttribARB
2278 static GLboolean WINAPI
X11DRV_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer
, const int *piAttribList
)
2280 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2281 WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer
, piAttribList
);
2282 if (NULL
== object
) {
2283 SetLastError(ERROR_INVALID_HANDLE
);
2286 if (!object
->use_render_texture
) {
2287 SetLastError(ERROR_INVALID_HANDLE
);
2290 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
2293 if (NULL
!= pglXDrawableAttribARB
) {
2294 if (use_render_texture_ati
) {
2295 FIXME("Need conversion for GLX_ATI_render_texture\n");
2297 return pglXDrawableAttribARB(object
->display
, object
->drawable
, piAttribList
);
2303 * X11DRV_wglChoosePixelFormatARB
2305 * WGL_ARB_pixel_format: wglChoosePixelFormatARB
2307 static GLboolean WINAPI
X11DRV_wglChoosePixelFormatARB(HDC hdc
, const int *piAttribIList
, const FLOAT
*pfAttribFList
, UINT nMaxFormats
, int *piFormats
, UINT
*nNumFormats
)
2312 GLXFBConfig
* cfgs
= NULL
;
2317 GLXFBConfig
* cfgs_fmt
= NULL
;
2323 TRACE("(%p, %p, %p, %d, %p, %p): hackish\n", hdc
, piAttribIList
, pfAttribFList
, nMaxFormats
, piFormats
, nNumFormats
);
2324 if (NULL
!= pfAttribFList
) {
2325 FIXME("unused pfAttribFList\n");
2328 nAttribs
= ConvertAttribWGLtoGLX(piAttribIList
, attribs
, NULL
);
2329 if (-1 == nAttribs
) {
2330 WARN("Cannot convert WGL to GLX attributes\n");
2333 PUSH1(attribs
, None
);
2335 /* Search for FB configurations matching the requirements in attribs */
2336 cfgs
= pglXChooseFBConfig(gdi_display
, DefaultScreen(gdi_display
), attribs
, &nCfgs
);
2338 WARN("Compatible Pixel Format not found\n");
2342 /* Get a list of all FB configurations */
2343 cfgs_fmt
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs_fmt
);
2344 if (NULL
== cfgs_fmt
) {
2345 ERR("Failed to get All FB Configs\n");
2350 /* Loop through all matching formats and check if they are suitable.
2351 * Note that this function should at max return nMaxFormats different formats */
2352 for (it
= 0; pfmt_it
< nMaxFormats
&& it
< nCfgs
; ++it
) {
2353 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cfgs
[it
], GLX_FBCONFIG_ID
, &fmt_id
);
2355 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
2359 /* Search for the format in our list of compatible formats */
2360 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fmt_id
);
2364 piFormats
[pfmt_it
] = fmt
;
2365 TRACE("at %d/%d found FBCONFIG_ID 0x%x (%d/%d)\n", it
+ 1, nCfgs
, fmt_id
, piFormats
[pfmt_it
], nCfgs_fmt
);
2369 *nNumFormats
= pfmt_it
;
2377 * X11DRV_wglGetPixelFormatAttribivARB
2379 * WGL_ARB_pixel_format: wglGetPixelFormatAttribivARB
2381 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribivARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, int *piValues
)
2384 GLXFBConfig
* cfgs
= NULL
;
2385 GLXFBConfig curCfg
= NULL
;
2390 int nWGLFormats
= 0;
2393 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, piValues
);
2395 if (0 < iLayerPlane
) {
2396 FIXME("unsupported iLayerPlane(%d) > 0, returns FALSE\n", iLayerPlane
);
2400 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
2402 ERR("no FB Configs found for display(%p)\n", gdi_display
);
2406 /* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supoprted.
2407 * We don't have to fail yet as a program can specify an invaled iPixelFormat (lets say 0) if it wants to query
2408 * the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
2409 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &nWGLFormats
)) {
2410 WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat
);
2413 for (i
= 0; i
< nAttributes
; ++i
) {
2414 const int curWGLAttr
= piAttributes
[i
];
2415 TRACE("pAttr[%d] = %x\n", i
, curWGLAttr
);
2417 switch (curWGLAttr
) {
2418 case WGL_NUMBER_PIXEL_FORMATS_ARB
:
2419 piValues
[i
] = nWGLFormats
;
2422 case WGL_SUPPORT_OPENGL_ARB
:
2423 piValues
[i
] = GL_TRUE
;
2426 case WGL_ACCELERATION_ARB
:
2427 curGLXAttr
= GLX_CONFIG_CAVEAT
;
2429 if (nCfgs
< iPixelFormat
|| 0 >= iPixelFormat
) goto pix_error
;
2430 curCfg
= cfgs
[iPixelFormat
- 1];
2432 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2433 if (hTest
) goto get_error
;
2435 case GLX_NONE
: piValues
[i
] = WGL_FULL_ACCELERATION_ARB
; break;
2436 case GLX_SLOW_CONFIG
: piValues
[i
] = WGL_NO_ACCELERATION_ARB
; break;
2437 case GLX_NON_CONFORMANT_CONFIG
: piValues
[i
] = WGL_FULL_ACCELERATION_ARB
; break;
2439 ERR("unexpected Config Caveat(%x)\n", tmp
);
2440 piValues
[i
] = WGL_NO_ACCELERATION_ARB
;
2444 case WGL_TRANSPARENT_ARB
:
2445 curGLXAttr
= GLX_TRANSPARENT_TYPE
;
2446 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2447 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2448 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2449 curCfg
= cfgs
[fmt_index
];
2450 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2451 if (hTest
) goto get_error
;
2452 piValues
[i
] = GL_FALSE
;
2453 if (GLX_NONE
!= tmp
) piValues
[i
] = GL_TRUE
;
2456 case WGL_PIXEL_TYPE_ARB
:
2457 curGLXAttr
= GLX_RENDER_TYPE
;
2458 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2459 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2460 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2461 curCfg
= cfgs
[fmt_index
];
2462 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2463 if (hTest
) goto get_error
;
2464 TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp
);
2465 if (tmp
& GLX_RGBA_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_ARB
; }
2466 else if (tmp
& GLX_COLOR_INDEX_BIT
) { piValues
[i
] = WGL_TYPE_COLORINDEX_ARB
; }
2467 else if (tmp
& GLX_RGBA_FLOAT_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2468 else if (tmp
& GLX_RGBA_FLOAT_ATI_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2470 ERR("unexpected RenderType(%x)\n", tmp
);
2471 piValues
[i
] = WGL_TYPE_RGBA_ARB
;
2475 case WGL_COLOR_BITS_ARB
:
2476 /** see ConvertAttribWGLtoGLX for explain */
2477 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2478 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2479 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2480 curCfg
= cfgs
[fmt_index
];
2481 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_BUFFER_SIZE
, piValues
+ i
);
2482 if (hTest
) goto get_error
;
2483 TRACE("WGL_COLOR_BITS_ARB: GLX_BUFFER_SIZE = %d\n", piValues
[i
]);
2484 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_ALPHA_SIZE
, &tmp
);
2485 if (hTest
) goto get_error
;
2486 TRACE("WGL_COLOR_BITS_ARB: GLX_ALPHA_SIZE = %d\n", tmp
);
2487 piValues
[i
] = piValues
[i
] - tmp
;
2490 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
2491 if (use_render_texture_ati
) {
2492 curGLXAttr
= GLX_BIND_TO_TEXTURE_RGB_ATI
;
2495 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
2496 if (use_render_texture_ati
) {
2497 curGLXAttr
= GLX_BIND_TO_TEXTURE_RGBA_ATI
;
2500 if (!use_render_texture_emulation
) {
2501 piValues
[i
] = GL_FALSE
;
2504 curGLXAttr
= GLX_RENDER_TYPE
;
2505 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2506 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2507 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2508 curCfg
= cfgs
[fmt_index
];
2509 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2510 if (hTest
) goto get_error
;
2511 if (GLX_COLOR_INDEX_BIT
== tmp
) {
2512 piValues
[i
] = GL_FALSE
;
2515 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_DRAWABLE_TYPE
, &tmp
);
2516 if (hTest
) goto get_error
;
2517 piValues
[i
] = (tmp
& GLX_PBUFFER_BIT
) ? GL_TRUE
: GL_FALSE
;
2520 case WGL_BLUE_BITS_ARB
:
2521 curGLXAttr
= GLX_BLUE_SIZE
;
2523 case WGL_RED_BITS_ARB
:
2524 curGLXAttr
= GLX_RED_SIZE
;
2526 case WGL_GREEN_BITS_ARB
:
2527 curGLXAttr
= GLX_GREEN_SIZE
;
2529 case WGL_ALPHA_BITS_ARB
:
2530 curGLXAttr
= GLX_ALPHA_SIZE
;
2532 case WGL_DEPTH_BITS_ARB
:
2533 curGLXAttr
= GLX_DEPTH_SIZE
;
2535 case WGL_STENCIL_BITS_ARB
:
2536 curGLXAttr
= GLX_STENCIL_SIZE
;
2538 case WGL_DOUBLE_BUFFER_ARB
:
2539 curGLXAttr
= GLX_DOUBLEBUFFER
;
2541 case WGL_STEREO_ARB
:
2542 curGLXAttr
= GLX_STEREO
;
2544 case WGL_AUX_BUFFERS_ARB
:
2545 curGLXAttr
= GLX_AUX_BUFFERS
;
2547 case WGL_SUPPORT_GDI_ARB
:
2548 case WGL_DRAW_TO_WINDOW_ARB
:
2549 case WGL_DRAW_TO_BITMAP_ARB
:
2550 /* We only supported a limited number of formats right now which are all renderable by X 'GLX_X_RENDERABLE' */
2551 piValues
[i
] = GL_TRUE
;
2553 case WGL_DRAW_TO_PBUFFER_ARB
:
2554 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_DRAWABLE_TYPE
, &tmp
);
2555 if (hTest
) goto get_error
;
2556 piValues
[i
] = (tmp
& GLX_PBUFFER_BIT
) ? GL_TRUE
: GL_FALSE
;
2559 case WGL_PBUFFER_LARGEST_ARB
:
2560 curGLXAttr
= GLX_LARGEST_PBUFFER
;
2563 case WGL_SAMPLE_BUFFERS_ARB
:
2564 curGLXAttr
= GLX_SAMPLE_BUFFERS_ARB
;
2567 case WGL_SAMPLES_ARB
:
2568 curGLXAttr
= GLX_SAMPLES_ARB
;
2572 FIXME("unsupported %x WGL Attribute\n", curWGLAttr
);
2575 if (0 != curGLXAttr
) {
2576 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2577 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2578 if((iPixelFormat
> 0) && ((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
))) goto pix_error
;
2579 curCfg
= cfgs
[fmt_index
];
2580 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, piValues
+ i
);
2581 if (hTest
) goto get_error
;
2584 piValues
[i
] = GL_FALSE
;
2590 ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc
, curGLXAttr
);
2595 ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc
, iPixelFormat
, nCfgs
);
2601 * X11DRV_wglGetPixelFormatAttribfvARB
2603 * WGL_ARB_pixel_format: wglGetPixelFormatAttribfvARB
2605 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribfvARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, FLOAT
*pfValues
)
2611 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, pfValues
);
2613 /* Allocate a temporary array to store integer values */
2614 attr
= HeapAlloc(GetProcessHeap(), 0, nAttributes
* sizeof(int));
2616 ERR("couldn't allocate %d array\n", nAttributes
);
2620 /* Piggy-back on wglGetPixelFormatAttribivARB */
2621 ret
= X11DRV_wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, attr
);
2623 /* Convert integer values to float. Should also check for attributes
2624 that can give decimal values here */
2625 for (i
=0; i
<nAttributes
;i
++) {
2626 pfValues
[i
] = attr
[i
];
2630 HeapFree(GetProcessHeap(), 0, attr
);
2635 * X11DRV_wglBindTexImageARB
2637 * WGL_ARB_render_texture: wglBindTexImageARB
2639 static GLboolean WINAPI
X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2641 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2642 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2643 if (NULL
== object
) {
2644 SetLastError(ERROR_INVALID_HANDLE
);
2647 if (!object
->use_render_texture
) {
2648 SetLastError(ERROR_INVALID_HANDLE
);
2651 /* Disable WGL_ARB_render_texture support until it is implemented properly
2652 * using pbuffers or FBOs */
2654 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
2656 GLint prev_binded_tex
;
2657 pglGetIntegerv(object
->texture_target
, &prev_binded_tex
);
2658 if (NULL
== object
->render_ctx
) {
2659 object
->render_hdc
= X11DRV_wglGetPbufferDCARB(hPbuffer
);
2660 /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */
2661 object
->render_ctx
= wglCreateContext(object
->render_hdc
);
2664 object
->prev_hdc
= wglGetCurrentDC();
2665 object
->prev_ctx
= wglGetCurrentContext();
2666 /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */
2667 wglMakeCurrent(object
->render_hdc
, object
->render_ctx
);
2670 glBindTexture(object->texture_target, object->texture);
2671 if (GL_RGBA == object->use_render_texture) {
2672 glTexImage2D(object->texture_target, 0, GL_RGBA8, object->width, object->height, 0, GL_RGBA, GL_FLOAT, NULL);
2674 glTexImage2D(object->texture_target, 0, GL_RGB8, object->width, object->height, 0, GL_RGB, GL_FLOAT, NULL);
2678 object
->texture
= prev_binded_tex
;
2682 if (NULL
!= pglXBindTexImageARB
) {
2683 return pglXBindTexImageARB(object
->display
, object
->drawable
, iBuffer
);
2689 * X11DRV_wglReleaseTexImageARB
2691 * WGL_ARB_render_texture: wglReleaseTexImageARB
2693 static GLboolean WINAPI
X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2695 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2696 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2697 if (NULL
== object
) {
2698 SetLastError(ERROR_INVALID_HANDLE
);
2701 if (!object
->use_render_texture
) {
2702 SetLastError(ERROR_INVALID_HANDLE
);
2705 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
2707 GLint prev_binded_tex;
2708 glGetIntegerv(object->texture_target, &prev_binded_tex);
2709 if (GL_TEXTURE_1D == object->texture_target) {
2710 glCopyTexSubImage1D(object->texture_target, object->texture_level, 0, 0, 0, object->width);
2712 glCopyTexSubImage2D(object->texture_target, object->texture_level, 0, 0, 0, 0, object->width, object->height);
2714 glBindTexture(object->texture_target, prev_binded_tex);
2715 SwapBuffers(object->render_hdc);
2717 pglBindTexture(object
->texture_target
, object
->texture
);
2718 if (GL_TEXTURE_1D
== object
->texture_target
) {
2719 pglCopyTexSubImage1D(object
->texture_target
, object
->texture_level
, 0, 0, 0, object
->width
);
2721 pglCopyTexSubImage2D(object
->texture_target
, object
->texture_level
, 0, 0, 0, 0, object
->width
, object
->height
);
2724 /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */
2725 wglMakeCurrent(object
->prev_hdc
, object
->prev_ctx
);
2728 if (NULL
!= pglXReleaseTexImageARB
) {
2729 return pglXReleaseTexImageARB(object
->display
, object
->drawable
, iBuffer
);
2735 * X11DRV_wglGetExtensionsStringEXT
2737 * WGL_EXT_extensions_string: wglGetExtensionsStringEXT
2739 static const char * WINAPI
X11DRV_wglGetExtensionsStringEXT(void) {
2740 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
2741 return WineGLInfo
.wglExtensions
;
2745 * X11DRV_wglGetSwapIntervalEXT
2747 * WGL_EXT_swap_control: wglGetSwapIntervalEXT
2749 static int WINAPI
X11DRV_wglGetSwapIntervalEXT(VOID
) {
2750 FIXME("(),stub!\n");
2751 return swap_interval
;
2755 * X11DRV_wglSwapIntervalEXT
2757 * WGL_EXT_swap_control: wglSwapIntervalEXT
2759 static BOOL WINAPI
X11DRV_wglSwapIntervalEXT(int interval
) {
2760 TRACE("(%d)\n", interval
);
2761 swap_interval
= interval
;
2762 if (NULL
!= pglXSwapIntervalSGI
) {
2763 return 0 == pglXSwapIntervalSGI(interval
);
2765 WARN("(): GLX_SGI_swap_control extension seems not supported\n");
2770 * X11DRV_wglAllocateMemoryNV
2772 * WGL_NV_vertex_array_range: wglAllocateMemoryNV
2774 static void* WINAPI
X11DRV_wglAllocateMemoryNV(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
) {
2775 TRACE("(%d, %f, %f, %f)\n", size
, readfreq
, writefreq
, priority
);
2776 if (pglXAllocateMemoryNV
== NULL
)
2779 return pglXAllocateMemoryNV(size
, readfreq
, writefreq
, priority
);
2783 * X11DRV_wglFreeMemoryNV
2785 * WGL_NV_vertex_array_range: wglFreeMemoryNV
2787 static void WINAPI
X11DRV_wglFreeMemoryNV(GLvoid
* pointer
) {
2788 TRACE("(%p)\n", pointer
);
2789 if (pglXFreeMemoryNV
== NULL
)
2792 pglXFreeMemoryNV(pointer
);
2796 * glxRequireVersion (internal)
2798 * Check if the supported GLX version matches requiredVersion.
2800 static BOOL
glxRequireVersion(int requiredVersion
)
2802 /* Both requiredVersion and glXVersion[1] contains the minor GLX version */
2803 if(requiredVersion
<= WineGLInfo
.glxVersion
[1])
2809 static BOOL
glxRequireExtension(const char *requiredExtension
)
2811 if (strstr(WineGLInfo
.glxClientExtensions
, requiredExtension
) == NULL
) {
2818 static BOOL
register_extension(const WineGLExtension
* ext
)
2822 assert( WineGLExtensionListSize
< MAX_EXTENSIONS
);
2823 WineGLExtensionList
[WineGLExtensionListSize
++] = ext
;
2825 strcat(WineGLInfo
.wglExtensions
, " ");
2826 strcat(WineGLInfo
.wglExtensions
, ext
->extName
);
2828 TRACE("'%s'\n", ext
->extName
);
2830 for (i
= 0; ext
->extEntryPoints
[i
].funcName
; ++i
)
2831 TRACE(" - '%s'\n", ext
->extEntryPoints
[i
].funcName
);
2836 static const WineGLExtension WGL_internal_functions
=
2840 { "wglDisable", X11DRV_wglDisable
},
2841 { "wglEnable", X11DRV_wglEnable
},
2842 { "wglGetIntegerv", X11DRV_wglGetIntegerv
},
2843 { "wglIsEnabled", X11DRV_wglIsEnabled
},
2844 { "wglScissor", X11DRV_wglScissor
},
2845 { "wglViewport", X11DRV_wglViewport
},
2850 static const WineGLExtension WGL_ARB_extensions_string
=
2852 "WGL_ARB_extensions_string",
2854 { "wglGetExtensionsStringARB", X11DRV_wglGetExtensionsStringARB
},
2858 static const WineGLExtension WGL_ARB_make_current_read
=
2860 "WGL_ARB_make_current_read",
2862 { "wglGetCurrentReadDCARB", X11DRV_wglGetCurrentReadDCARB
},
2863 { "wglMakeContextCurrentARB", X11DRV_wglMakeContextCurrentARB
},
2867 static const WineGLExtension WGL_ARB_multisample
=
2869 "WGL_ARB_multisample",
2872 static const WineGLExtension WGL_ARB_pbuffer
=
2876 { "wglCreatePbufferARB", X11DRV_wglCreatePbufferARB
},
2877 { "wglDestroyPbufferARB", X11DRV_wglDestroyPbufferARB
},
2878 { "wglGetPbufferDCARB", X11DRV_wglGetPbufferDCARB
},
2879 { "wglQueryPbufferARB", X11DRV_wglQueryPbufferARB
},
2880 { "wglReleasePbufferDCARB", X11DRV_wglReleasePbufferDCARB
},
2881 { "wglSetPbufferAttribARB", X11DRV_wglSetPbufferAttribARB
},
2885 static const WineGLExtension WGL_ARB_pixel_format
=
2887 "WGL_ARB_pixel_format",
2889 { "wglChoosePixelFormatARB", X11DRV_wglChoosePixelFormatARB
},
2890 { "wglGetPixelFormatAttribfvARB", X11DRV_wglGetPixelFormatAttribfvARB
},
2891 { "wglGetPixelFormatAttribivARB", X11DRV_wglGetPixelFormatAttribivARB
},
2895 static const WineGLExtension WGL_ARB_render_texture
=
2897 "WGL_ARB_render_texture",
2899 { "wglBindTexImageARB", X11DRV_wglBindTexImageARB
},
2900 { "wglReleaseTexImageARB", X11DRV_wglReleaseTexImageARB
},
2904 static const WineGLExtension WGL_EXT_extensions_string
=
2906 "WGL_EXT_extensions_string",
2908 { "wglGetExtensionsStringEXT", X11DRV_wglGetExtensionsStringEXT
},
2912 static const WineGLExtension WGL_EXT_swap_control
=
2914 "WGL_EXT_swap_control",
2916 { "wglSwapIntervalEXT", X11DRV_wglSwapIntervalEXT
},
2917 { "wglGetSwapIntervalEXT", X11DRV_wglGetSwapIntervalEXT
},
2921 static const WineGLExtension WGL_NV_vertex_array_range
=
2923 "WGL_NV_vertex_array_range",
2925 { "wglAllocateMemoryNV", X11DRV_wglAllocateMemoryNV
},
2926 { "wglFreeMemoryNV", X11DRV_wglFreeMemoryNV
},
2931 * X11DRV_WineGL_LoadExtensions
2933 static void X11DRV_WineGL_LoadExtensions(void)
2935 WineGLInfo
.wglExtensions
[0] = 0;
2937 /* Load Wine internal functions */
2938 register_extension(&WGL_internal_functions
);
2940 /* ARB Extensions */
2942 register_extension(&WGL_ARB_extensions_string
);
2944 if (glxRequireVersion(3))
2945 register_extension(&WGL_ARB_make_current_read
);
2947 if (glxRequireExtension("GLX_ARB_multisample"))
2948 register_extension(&WGL_ARB_multisample
);
2950 /* In general pbuffer functionality requires support in the X-server. The functionality is
2951 * available either when the GLX_SGIX_pbuffer is present or when the GLX server version is 1.3.
2952 * All display drivers except for Nvidia's use the GLX module from Xfree86/Xorg which only
2953 * supports GLX 1.2. The endresult is that only Nvidia's drivers support pbuffers.
2955 * The only other drive which has pbuffer support is Ati's FGLRX driver. They provide clientside GLX 1.3 support
2956 * without support in the X-server (which other Mesa based drivers require).
2958 * Support pbuffers when the GLX version is 1.3 and GLX_SGIX_pbuffer is available. Further pbuffers can
2959 * also be supported when GLX_ATI_render_texture is available. This extension depends on pbuffers, so when it
2960 * is available pbuffers must be available too. */
2961 if ( (glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer")) || glxRequireExtension("GLX_ATI_render_texture"))
2962 register_extension(&WGL_ARB_pbuffer
);
2964 register_extension(&WGL_ARB_pixel_format
);
2966 if (glxRequireExtension("GLX_ATI_render_texture") ||
2967 glxRequireExtension("GLX_ARB_render_texture"))
2968 register_extension(&WGL_ARB_render_texture
);
2970 /* EXT Extensions */
2972 register_extension(&WGL_EXT_extensions_string
);
2974 if (glxRequireExtension("GLX_SGI_swap_control"))
2975 register_extension(&WGL_EXT_swap_control
);
2977 /* The OpenGL extension GL_NV_vertex_array_range adds wgl/glX functions which aren't exported as 'real' wgl/glX extensions. */
2978 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_vertex_array_range") != NULL
)
2979 register_extension(&WGL_NV_vertex_array_range
);
2983 static XID
create_glxpixmap(X11DRV_PDEVICE
*physDev
)
2987 XVisualInfo
template;
2992 /* Retrieve the visualid from our main visual which is the only visual we can use */
2993 template.visualid
= XVisualIDFromVisual(visual
);
2994 vis
= XGetVisualInfo(gdi_display
, VisualIDMask
, &template, &num
);
2996 ret
= pglXCreateGLXPixmap(gdi_display
, vis
, physDev
->bitmap
->pixmap
);
2998 wine_tsx11_unlock();
2999 TRACE("return %lx\n", ret
);
3003 Drawable
get_glxdrawable(X11DRV_PDEVICE
*physDev
)
3009 if (physDev
->bitmap
->hbitmap
== BITMAP_stock_phys_bitmap
.hbitmap
)
3010 ret
= physDev
->drawable
; /* PBuffer */
3013 if(!physDev
->bitmap
->glxpixmap
)
3014 physDev
->bitmap
->glxpixmap
= create_glxpixmap(physDev
);
3015 ret
= physDev
->bitmap
->glxpixmap
;
3019 ret
= physDev
->drawable
;
3023 BOOL
destroy_glxpixmap(XID glxpixmap
)
3026 pglXDestroyGLXPixmap(gdi_display
, glxpixmap
);
3027 wine_tsx11_unlock();
3032 * X11DRV_SwapBuffers
3034 * Swap the buffers of this DC
3036 BOOL
X11DRV_SwapBuffers(X11DRV_PDEVICE
*physDev
)
3038 GLXDrawable drawable
;
3039 if (!has_opengl()) {
3040 ERR("No libGL on this box - disabling OpenGL support !\n");
3044 TRACE_(opengl
)("(%p)\n", physDev
);
3046 drawable
= get_glxdrawable(physDev
);
3048 pglXSwapBuffers(gdi_display
, drawable
);
3049 wine_tsx11_unlock();
3054 static long prev_time
, frames
;
3056 DWORD time
= GetTickCount();
3058 /* every 1.5 seconds */
3059 if (time
- prev_time
> 1500) {
3060 TRACE_(fps
)("@ approx %.2ffps\n", 1000.0*frames
/(time
- prev_time
));
3069 /***********************************************************************
3070 * X11DRV_setup_opengl_visual
3072 * Setup the default visual used for OpenGL and Direct3D, and the desktop
3073 * window (if it exists). If OpenGL isn't available, the visual is simply
3074 * set to the default visual for the display
3076 XVisualInfo
*X11DRV_setup_opengl_visual( Display
*display
)
3078 XVisualInfo
*visual
= NULL
;
3079 /* In order to support OpenGL or D3D, we require a double-buffered visual and stencil buffer support, */
3080 int dblBuf
[] = {GLX_RGBA
,GLX_DEPTH_SIZE
, 24, GLX_STENCIL_SIZE
, 8, GLX_ALPHA_SIZE
, 8, GLX_DOUBLEBUFFER
, None
};
3081 if (!has_opengl()) return NULL
;
3084 visual
= pglXChooseVisual(display
, DefaultScreen(display
), dblBuf
);
3085 wine_tsx11_unlock();
3086 if (visual
== NULL
) {
3087 /* fallback to 16 bits depth, no alpha */
3088 int dblBuf2
[] = {GLX_RGBA
,GLX_DEPTH_SIZE
, 16, GLX_STENCIL_SIZE
, 8, GLX_DOUBLEBUFFER
, None
};
3089 WARN("Failed to get a visual with at least 24 bits depth\n");
3092 visual
= pglXChooseVisual(display
, DefaultScreen(display
), dblBuf2
);
3093 wine_tsx11_unlock();
3094 if (visual
== NULL
) {
3095 /* fallback to no stencil */
3096 int dblBuf2
[] = {GLX_RGBA
,GLX_DEPTH_SIZE
, 16, GLX_DOUBLEBUFFER
, None
};
3097 WARN("Failed to get a visual with at least 8 bits of stencil\n");
3100 visual
= pglXChooseVisual(display
, DefaultScreen(display
), dblBuf2
);
3101 wine_tsx11_unlock();
3102 if (visual
== NULL
) {
3103 /* This should only happen if we cannot find a match with a depth size 16 */
3104 FIXME("Failed to find a suitable visual\n");
3109 TRACE("Visual ID %lx Chosen\n",visual
->visualid
);
3113 #else /* no OpenGL includes */
3115 /***********************************************************************
3116 * ChoosePixelFormat (X11DRV.@)
3118 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE
*physDev
,
3119 const PIXELFORMATDESCRIPTOR
*ppfd
) {
3120 ERR("No OpenGL support compiled in.\n");
3125 /***********************************************************************
3126 * DescribePixelFormat (X11DRV.@)
3128 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE
*physDev
,
3131 PIXELFORMATDESCRIPTOR
*ppfd
) {
3132 ERR("No OpenGL support compiled in.\n");
3137 /***********************************************************************
3138 * GetPixelFormat (X11DRV.@)
3140 int X11DRV_GetPixelFormat(X11DRV_PDEVICE
*physDev
) {
3141 ERR("No OpenGL support compiled in.\n");
3146 /***********************************************************************
3147 * SetPixelFormat (X11DRV.@)
3149 BOOL
X11DRV_SetPixelFormat(X11DRV_PDEVICE
*physDev
,
3151 const PIXELFORMATDESCRIPTOR
*ppfd
) {
3152 ERR("No OpenGL support compiled in.\n");
3157 /***********************************************************************
3158 * SwapBuffers (X11DRV.@)
3160 BOOL
X11DRV_SwapBuffers(X11DRV_PDEVICE
*physDev
) {
3161 ERR_(opengl
)("No OpenGL support compiled in.\n");
3167 * X11DRV_wglCreateContext
3169 * For OpenGL32 wglCreateContext.
3171 HGLRC
X11DRV_wglCreateContext(X11DRV_PDEVICE
*physDev
) {
3172 ERR_(opengl
)("No OpenGL support compiled in.\n");
3177 * X11DRV_wglDeleteContext
3179 * For OpenGL32 wglDeleteContext.
3181 BOOL
X11DRV_wglDeleteContext(HGLRC hglrc
) {
3182 ERR_(opengl
)("No OpenGL support compiled in.\n");
3187 * X11DRV_wglGetProcAddress
3189 * For OpenGL32 wglGetProcAddress.
3191 PROC
X11DRV_wglGetProcAddress(LPCSTR lpszProc
) {
3192 ERR_(opengl
)("No OpenGL support compiled in.\n");
3196 HDC
X11DRV_wglGetPbufferDCARB(X11DRV_PDEVICE
*hDevice
, void *hPbuffer
)
3198 ERR_(opengl
)("No OpenGL support compiled in.\n");
3202 BOOL
X11DRV_wglMakeContextCurrentARB(X11DRV_PDEVICE
* hDrawDev
, X11DRV_PDEVICE
* hReadDev
, HGLRC hglrc
) {
3203 ERR_(opengl
)("No OpenGL support compiled in.\n");
3208 * X11DRV_wglMakeCurrent
3210 * For OpenGL32 wglMakeCurrent.
3212 BOOL
X11DRV_wglMakeCurrent(X11DRV_PDEVICE
*physDev
, HGLRC hglrc
) {
3213 ERR_(opengl
)("No OpenGL support compiled in.\n");
3218 * X11DRV_wglShareLists
3220 * For OpenGL32 wglShaderLists.
3222 BOOL
X11DRV_wglShareLists(HGLRC hglrc1
, HGLRC hglrc2
) {
3223 ERR_(opengl
)("No OpenGL support compiled in.\n");
3228 * X11DRV_wglUseFontBitmapsA
3230 * For OpenGL32 wglUseFontBitmapsA.
3232 BOOL
X11DRV_wglUseFontBitmapsA(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
3234 ERR_(opengl
)("No OpenGL support compiled in.\n");
3239 * X11DRV_wglUseFontBitmapsW
3241 * For OpenGL32 wglUseFontBitmapsW.
3243 BOOL
X11DRV_wglUseFontBitmapsW(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
3245 ERR_(opengl
)("No OpenGL support compiled in.\n");
3249 XVisualInfo
*X11DRV_setup_opengl_visual( Display
*display
)
3254 Drawable
get_glxdrawable(X11DRV_PDEVICE
*physDev
)
3259 BOOL
destroy_glxpixmap(XID glxpixmap
)
3264 #endif /* defined(HAVE_OPENGL) */