dbghelp: StackWalk (32 and 64 bit version).
[wine/multimedia.git] / dlls / x11drv / opengl.c
bloba2a591e2e940030a9ac4055f692e06c09846df0a
1 /*
2 * X11DRV OpenGL functions
4 * Copyright 2000 Lionel Ulmer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdlib.h>
25 #include <string.h>
27 #include "x11drv.h"
28 #include "wine/library.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(opengl);
33 #if defined(HAVE_GL_GL_H) && defined(HAVE_GL_GLX_H)
35 #undef APIENTRY
36 #undef CALLBACK
37 #undef WINAPI
39 #ifdef HAVE_GL_GL_H
40 # include <GL/gl.h>
41 #endif
42 #ifdef HAVE_GL_GLX_H
43 # include <GL/glx.h>
44 #endif
45 #ifdef HAVE_GL_GLEXT_H
46 # include <GL/glext.h>
47 #endif
49 #undef APIENTRY
50 #undef CALLBACK
51 #undef WINAPI
53 /* Redefines the constants */
54 #define CALLBACK __stdcall
55 #define WINAPI __stdcall
56 #define APIENTRY WINAPI
59 static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) {
60 TRACE(" - size / version : %d / %d\n", ppfd->nSize, ppfd->nVersion);
61 TRACE(" - dwFlags : ");
62 #define TEST_AND_DUMP(t,tv) if ((t) & (tv)) TRACE(#tv " ")
63 TEST_AND_DUMP(ppfd->dwFlags, PFD_DEPTH_DONTCARE);
64 TEST_AND_DUMP(ppfd->dwFlags, PFD_DOUBLEBUFFER);
65 TEST_AND_DUMP(ppfd->dwFlags, PFD_DOUBLEBUFFER_DONTCARE);
66 TEST_AND_DUMP(ppfd->dwFlags, PFD_DRAW_TO_WINDOW);
67 TEST_AND_DUMP(ppfd->dwFlags, PFD_DRAW_TO_BITMAP);
68 TEST_AND_DUMP(ppfd->dwFlags, PFD_GENERIC_ACCELERATED);
69 TEST_AND_DUMP(ppfd->dwFlags, PFD_GENERIC_FORMAT);
70 TEST_AND_DUMP(ppfd->dwFlags, PFD_NEED_PALETTE);
71 TEST_AND_DUMP(ppfd->dwFlags, PFD_NEED_SYSTEM_PALETTE);
72 TEST_AND_DUMP(ppfd->dwFlags, PFD_STEREO);
73 TEST_AND_DUMP(ppfd->dwFlags, PFD_STEREO_DONTCARE);
74 TEST_AND_DUMP(ppfd->dwFlags, PFD_SUPPORT_GDI);
75 TEST_AND_DUMP(ppfd->dwFlags, PFD_SUPPORT_OPENGL);
76 TEST_AND_DUMP(ppfd->dwFlags, PFD_SWAP_COPY);
77 TEST_AND_DUMP(ppfd->dwFlags, PFD_SWAP_EXCHANGE);
78 TEST_AND_DUMP(ppfd->dwFlags, PFD_SWAP_LAYER_BUFFERS);
79 #undef TEST_AND_DUMP
80 TRACE("\n");
82 TRACE(" - iPixelType : ");
83 switch (ppfd->iPixelType) {
84 case PFD_TYPE_RGBA: TRACE("PFD_TYPE_RGBA"); break;
85 case PFD_TYPE_COLORINDEX: TRACE("PFD_TYPE_COLORINDEX"); break;
87 TRACE("\n");
89 TRACE(" - Color : %d\n", ppfd->cColorBits);
90 TRACE(" - Red : %d\n", ppfd->cRedBits);
91 TRACE(" - Green : %d\n", ppfd->cGreenBits);
92 TRACE(" - Blue : %d\n", ppfd->cBlueBits);
93 TRACE(" - Alpha : %d\n", ppfd->cAlphaBits);
94 TRACE(" - Accum : %d\n", ppfd->cAccumBits);
95 TRACE(" - Depth : %d\n", ppfd->cDepthBits);
96 TRACE(" - Stencil : %d\n", ppfd->cStencilBits);
97 TRACE(" - Aux : %d\n", ppfd->cAuxBuffers);
99 TRACE(" - iLayerType : ");
100 switch (ppfd->iLayerType) {
101 case PFD_MAIN_PLANE: TRACE("PFD_MAIN_PLANE"); break;
102 case PFD_OVERLAY_PLANE: TRACE("PFD_OVERLAY_PLANE"); break;
103 case (BYTE)PFD_UNDERLAY_PLANE: TRACE("PFD_UNDERLAY_PLANE"); break;
105 TRACE("\n");
108 /* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and
109 include all dependencies
111 #ifndef SONAME_LIBGL
112 #define SONAME_LIBGL "libGL.so"
113 #endif
115 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
116 MAKE_FUNCPTR(glGetError)
117 MAKE_FUNCPTR(glXChooseVisual)
118 MAKE_FUNCPTR(glXGetConfig)
119 MAKE_FUNCPTR(glXSwapBuffers)
120 MAKE_FUNCPTR(glXQueryExtension)
122 MAKE_FUNCPTR(glXGetFBConfigs)
123 MAKE_FUNCPTR(glXChooseFBConfig)
124 MAKE_FUNCPTR(glXGetFBConfigAttrib)
125 MAKE_FUNCPTR(glXCreateGLXPixmap)
126 MAKE_FUNCPTR(glXDestroyGLXPixmap)
127 /* MAKE_FUNCPTR(glXQueryDrawable) */
128 #undef MAKE_FUNCPTR
130 static BOOL has_opengl(void)
132 static int init_done;
133 static void *opengl_handle;
135 int error_base, event_base;
137 if (init_done) return (opengl_handle != NULL);
138 init_done = 1;
140 opengl_handle = wine_dlopen(SONAME_LIBGL, RTLD_NOW|RTLD_GLOBAL, NULL, 0);
141 if (opengl_handle == NULL) return FALSE;
143 #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(RTLD_DEFAULT, #f, NULL, 0)) == NULL) goto sym_not_found;
144 LOAD_FUNCPTR(glGetError)
145 LOAD_FUNCPTR(glXChooseVisual)
146 LOAD_FUNCPTR(glXGetConfig)
147 LOAD_FUNCPTR(glXSwapBuffers)
148 LOAD_FUNCPTR(glXQueryExtension)
150 LOAD_FUNCPTR(glXGetFBConfigs)
151 LOAD_FUNCPTR(glXChooseFBConfig)
152 LOAD_FUNCPTR(glXGetFBConfigAttrib)
153 LOAD_FUNCPTR(glXCreateGLXPixmap)
154 LOAD_FUNCPTR(glXDestroyGLXPixmap)
155 #undef LOAD_FUNCPTR
157 wine_tsx11_lock();
158 if (pglXQueryExtension(gdi_display, &event_base, &error_base) == True) {
159 TRACE("GLX is up and running error_base = %d\n", error_base);
160 } else {
161 wine_dlclose(opengl_handle, NULL, 0);
162 opengl_handle = NULL;
164 wine_tsx11_unlock();
165 return (opengl_handle != NULL);
167 sym_not_found:
168 wine_dlclose(opengl_handle, NULL, 0);
169 opengl_handle = NULL;
170 return FALSE;
173 #define TEST_AND_ADD1(t,a) if (t) att_list[att_pos++] = (a)
174 #define TEST_AND_ADD2(t,a,b) if (t) { att_list[att_pos++] = (a); att_list[att_pos++] = (b); }
175 #define NULL_TEST_AND_ADD2(tv,a,b) att_list[att_pos++] = (a); att_list[att_pos++] = ((tv) == 0 ? 0 : (b))
176 #define ADD2(a,b) att_list[att_pos++] = (a); att_list[att_pos++] = (b)
179 * X11DRV_ChoosePixelFormat
181 * Equivalent of glXChooseVisual
183 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
184 const PIXELFORMATDESCRIPTOR *ppfd) {
185 int att_list[64];
186 int att_pos = 0;
187 int att_pos_fac = 0;
188 GLXFBConfig* cfgs = NULL;
189 int ret = 0;
191 if (!has_opengl()) {
192 ERR("No libGL on this box - disabling OpenGL support !\n");
193 return 0;
196 if (TRACE_ON(opengl)) {
197 TRACE("(%p,%p)\n", physDev, ppfd);
199 dump_PIXELFORMATDESCRIPTOR((const PIXELFORMATDESCRIPTOR *) ppfd);
202 /* Now, build the request to GLX */
204 if (ppfd->iPixelType == PFD_TYPE_COLORINDEX) {
205 ADD2(GLX_BUFFER_SIZE, ppfd->cColorBits);
207 if (ppfd->iPixelType == PFD_TYPE_RGBA) {
208 ADD2(GLX_RENDER_TYPE, GLX_RGBA_BIT);
209 if (ppfd->dwFlags & PFD_DEPTH_DONTCARE) {
210 ADD2(GLX_DEPTH_SIZE, GLX_DONT_CARE);
211 } else {
212 if (32 == ppfd->cDepthBits) {
214 * for 32 bpp depth buffers force to use 24.
215 * needed as some drivers don't support 32bpp
217 TEST_AND_ADD2(ppfd->cDepthBits, GLX_DEPTH_SIZE, 24);
218 } else {
219 TEST_AND_ADD2(ppfd->cDepthBits, GLX_DEPTH_SIZE, ppfd->cDepthBits);
222 if (32 == ppfd->cColorBits) {
223 ADD2(GLX_RED_SIZE, 8);
224 ADD2(GLX_GREEN_SIZE, 8);
225 ADD2(GLX_BLUE_SIZE, 8);
226 ADD2(GLX_ALPHA_SIZE, 8);
227 } else {
228 ADD2(GLX_BUFFER_SIZE, ppfd->cColorBits);
229 TEST_AND_ADD2(ppfd->cAlphaBits, GLX_ALPHA_SIZE, ppfd->cAlphaBits);
232 TEST_AND_ADD2(ppfd->cStencilBits, GLX_STENCIL_SIZE, ppfd->cStencilBits);
233 TEST_AND_ADD2(ppfd->cAuxBuffers, GLX_AUX_BUFFERS, ppfd->cAuxBuffers);
235 /* These flags are not supported yet...
236 ADD2(GLX_ACCUM_SIZE, ppfd->cAccumBits);
239 /** facultative flags now */
240 att_pos_fac = att_pos;
241 if (ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) {
242 ADD2(GLX_DOUBLEBUFFER, GLX_DONT_CARE);
243 } else {
244 ADD2(GLX_DOUBLEBUFFER, (ppfd->dwFlags & PFD_DOUBLEBUFFER) ? TRUE : FALSE);
246 if (ppfd->dwFlags & PFD_STEREO_DONTCARE) {
247 ADD2(GLX_STEREO, GLX_DONT_CARE);
248 } else {
249 ADD2(GLX_STEREO, (ppfd->dwFlags & PFD_STEREO) ? TRUE : FALSE);
252 /** Attributes List End */
253 att_list[att_pos] = None;
255 wine_tsx11_lock();
257 int nCfgs = 0;
258 int gl_test = 0;
259 int fmt_id;
261 GLXFBConfig* cfgs_fmt = NULL;
262 int nCfgs_fmt = 0;
263 int tmp_fmt_id;
264 UINT it_fmt;
266 cfgs = pglXChooseFBConfig(gdi_display, DefaultScreen(gdi_display), att_list, &nCfgs);
267 /**
268 * if we have facultative flags and we failed, try without
269 * as MSDN said
271 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglr_2qb8.asp
273 if ((NULL == cfgs || 0 == nCfgs) && att_pos > att_pos_fac) {
274 att_list[att_pos_fac] = None;
275 cfgs = pglXChooseFBConfig(gdi_display, DefaultScreen(gdi_display), att_list, &nCfgs);
278 if (NULL == cfgs || 0 == nCfgs) {
279 ERR("glXChooseFBConfig returns NULL (glError: %d)\n", pglGetError());
280 ret = 0;
281 goto choose_exit;
284 gl_test = pglXGetFBConfigAttrib(gdi_display, cfgs[0], GLX_FBCONFIG_ID, &fmt_id);
285 if (gl_test) {
286 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
287 ret = 0;
288 goto choose_exit;
291 cfgs_fmt = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs_fmt);
292 if (NULL == cfgs_fmt) {
293 ERR("Failed to get All FB Configs\n");
294 ret = 0;
295 goto choose_exit;
298 for (it_fmt = 0; it_fmt < nCfgs_fmt; ++it_fmt) {
299 gl_test = pglXGetFBConfigAttrib(gdi_display, cfgs_fmt[it_fmt], GLX_FBCONFIG_ID, &tmp_fmt_id);
300 if (gl_test) {
301 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
302 XFree(cfgs_fmt);
303 ret = 0;
304 goto choose_exit;
306 if (fmt_id == tmp_fmt_id) {
307 ret = it_fmt + 1;
308 break ;
311 if (it_fmt == nCfgs_fmt) {
312 ERR("Failed to get valid fmt for FBCONFIG_ID(%d)\n", fmt_id);
313 ret = 0;
315 XFree(cfgs_fmt);
318 choose_exit:
319 if (NULL != cfgs) XFree(cfgs);
320 wine_tsx11_unlock();
321 return ret;
325 * X11DRV_DescribePixelFormat
327 * Get the pixel-format descriptor associated to the given id
329 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
330 int iPixelFormat,
331 UINT nBytes,
332 PIXELFORMATDESCRIPTOR *ppfd) {
333 /*XVisualInfo *vis;*/
334 int value;
335 int rb,gb,bb,ab;
337 GLXFBConfig* cfgs = NULL;
338 GLXFBConfig cur;
339 int nCfgs = 0;
340 int ret = 0;
342 if (!has_opengl()) {
343 ERR("No libGL on this box - disabling OpenGL support !\n");
344 return 0;
347 TRACE("(%p,%d,%d,%p)\n", physDev, iPixelFormat, nBytes, ppfd);
349 wine_tsx11_lock();
350 cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs);
351 wine_tsx11_unlock();
353 if (NULL == cfgs || 0 == nCfgs) {
354 ERR("unexpected iPixelFormat(%d), returns NULL\n", iPixelFormat);
355 return 0; /* unespected error */
358 if (ppfd == NULL) {
359 /* The application is only querying the number of visuals */
360 wine_tsx11_lock();
361 if (NULL != cfgs) XFree(cfgs);
362 wine_tsx11_unlock();
363 return nCfgs;
366 if (nBytes < sizeof(PIXELFORMATDESCRIPTOR)) {
367 ERR("Wrong structure size !\n");
368 /* Should set error */
369 return 0;
372 if (nCfgs < iPixelFormat) {
373 ERR("unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", iPixelFormat, nCfgs);
374 return 0; /* unespected error */
377 ret = nCfgs;
378 cur = cfgs[iPixelFormat - 1];
380 memset(ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
381 ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
382 ppfd->nVersion = 1;
384 /* These flags are always the same... */
385 ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
386 /* Now the flags extracted from the Visual */
388 wine_tsx11_lock();
390 pglXGetFBConfigAttrib(gdi_display, cur, GLX_CONFIG_CAVEAT, &value);
391 if(value == GLX_SLOW_CONFIG)
392 ppfd->dwFlags |= PFD_GENERIC_ACCELERATED;
394 pglXGetFBConfigAttrib(gdi_display, cur, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER;
395 pglXGetFBConfigAttrib(gdi_display, cur, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO;
397 /* Pixel type */
398 pglXGetFBConfigAttrib(gdi_display, cur, GLX_RENDER_TYPE, &value);
399 if (value & GLX_RGBA_BIT)
400 ppfd->iPixelType = PFD_TYPE_RGBA;
401 else
402 ppfd->iPixelType = PFD_TYPE_COLORINDEX;
404 /* Color bits */
405 pglXGetFBConfigAttrib(gdi_display, cur, GLX_BUFFER_SIZE, &value);
406 ppfd->cColorBits = value;
408 /* Red, green, blue and alpha bits / shifts */
409 if (ppfd->iPixelType == PFD_TYPE_RGBA) {
410 pglXGetFBConfigAttrib(gdi_display, cur, GLX_RED_SIZE, &rb);
411 pglXGetFBConfigAttrib(gdi_display, cur, GLX_GREEN_SIZE, &gb);
412 pglXGetFBConfigAttrib(gdi_display, cur, GLX_BLUE_SIZE, &bb);
413 pglXGetFBConfigAttrib(gdi_display, cur, GLX_ALPHA_SIZE, &ab);
415 ppfd->cRedBits = rb;
416 ppfd->cRedShift = gb + bb + ab;
417 ppfd->cBlueBits = bb;
418 ppfd->cBlueShift = ab;
419 ppfd->cGreenBits = gb;
420 ppfd->cGreenShift = bb + ab;
421 ppfd->cAlphaBits = ab;
422 ppfd->cAlphaShift = 0;
423 } else {
424 ppfd->cRedBits = 0;
425 ppfd->cRedShift = 0;
426 ppfd->cBlueBits = 0;
427 ppfd->cBlueShift = 0;
428 ppfd->cGreenBits = 0;
429 ppfd->cGreenShift = 0;
430 ppfd->cAlphaBits = 0;
431 ppfd->cAlphaShift = 0;
433 /* Accums : to do ... */
435 /* Depth bits */
436 pglXGetFBConfigAttrib(gdi_display, cur, GLX_DEPTH_SIZE, &value);
437 ppfd->cDepthBits = value;
439 /* stencil bits */
440 pglXGetFBConfigAttrib(gdi_display, cur, GLX_STENCIL_SIZE, &value);
441 ppfd->cStencilBits = value;
443 wine_tsx11_unlock();
445 /* Aux : to do ... */
447 ppfd->iLayerType = PFD_MAIN_PLANE;
449 if (TRACE_ON(opengl)) {
450 dump_PIXELFORMATDESCRIPTOR(ppfd);
453 wine_tsx11_lock();
454 if (NULL != cfgs) XFree(cfgs);
455 wine_tsx11_unlock();
457 return ret;
461 * X11DRV_GetPixelFormat
463 * Get the pixel-format id used by this DC
465 int X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev) {
466 TRACE("(%p): returns %d\n", physDev, physDev->current_pf);
468 return physDev->current_pf;
472 * X11DRV_SetPixelFormat
474 * Set the pixel-format id used by this DC
476 BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
477 int iPixelFormat,
478 const PIXELFORMATDESCRIPTOR *ppfd) {
479 TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd);
481 physDev->current_pf = iPixelFormat;
483 if (TRACE_ON(opengl)) {
484 int nCfgs_fmt = 0;
485 GLXFBConfig* cfgs_fmt = NULL;
486 GLXFBConfig cur_cfg;
487 int value;
488 int gl_test = 0;
491 * How to test if hdc current drawable is compatible (visual/FBConfig) ?
493 * in case of root window created HDCs we crash here :(
495 Drawable drawable = get_drawable( physDev->hdc );
496 TRACE(" drawable (%p,%p) have :\n", drawable, root_window);
497 pglXQueryDrawable(gdi_display, drawable, GLX_FBCONFIG_ID, (unsigned int*) &value);
498 TRACE(" - FBCONFIG_ID as 0x%x\n", tmp);
499 pglXQueryDrawable(gdi_display, drawable, GLX_VISUAL_ID, (unsigned int*) &value);
500 TRACE(" - VISUAL_ID as 0x%x\n", tmp);
501 pglXQueryDrawable(gdi_display, drawable, GLX_WIDTH, (unsigned int*) &value);
502 TRACE(" - WIDTH as %d\n", tmp);
503 pglXQueryDrawable(gdi_display, drawable, GLX_HEIGHT, (unsigned int*) &value);
504 TRACE(" - HEIGHT as %d\n", tmp);
506 cfgs_fmt = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs_fmt);
507 cur_cfg = cfgs_fmt[iPixelFormat - 1];
508 gl_test = pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_FBCONFIG_ID, &value);
509 if (gl_test) {
510 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
511 } else {
512 TRACE(" FBConfig have :\n");
513 TRACE(" - FBCONFIG_ID 0x%x\n", value);
514 pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_VISUAL_ID, &value);
515 TRACE(" - VISUAL_ID 0x%x\n", value);
516 pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_DRAWABLE_TYPE, &value);
517 TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
519 XFree(cfgs_fmt);
521 return TRUE;
525 * X11DRV_SwapBuffers
527 * Swap the buffers of this DC
529 BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) {
530 if (!has_opengl()) {
531 ERR("No libGL on this box - disabling OpenGL support !\n");
532 return 0;
535 TRACE("(%p)\n", physDev);
537 wine_tsx11_lock();
538 pglXSwapBuffers(gdi_display, physDev->drawable);
539 wine_tsx11_unlock();
541 return TRUE;
544 /***********************************************************************
545 * X11DRV_setup_opengl_visual
547 * Setup the default visual used for OpenGL and Direct3D, and the desktop
548 * window (if it exists). If OpenGL isn't available, the visual is simply
549 * set to the default visual for the display
551 XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
553 XVisualInfo *visual = NULL;
554 /* In order to support OpenGL or D3D, we require a double-buffered visual and stencil buffer support, */
555 int dblBuf[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, None};
556 if (!has_opengl()) return NULL;
558 wine_tsx11_lock();
559 visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf);
560 wine_tsx11_unlock();
561 if (visual == NULL) {
562 /* fallback to no stencil */
563 int dblBuf2[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None};
564 WARN("Failed to get a visual with at least 8 bits of stencil\n");
566 wine_tsx11_lock();
567 visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf2);
568 wine_tsx11_unlock();
569 if (visual == NULL) {
570 /* This should only happen if we cannot find a match with a depth size 16 */
571 FIXME("Failed to find a suitable visual\n");
572 return visual;
575 TRACE("Visual ID %lx Chosen\n",visual->visualid);
576 return visual;
579 XID create_glxpixmap(X11DRV_PDEVICE *physDev)
581 GLXPixmap ret;
582 XVisualInfo *vis;
583 XVisualInfo template;
584 int num;
585 GLXFBConfig *cfgs;
587 wine_tsx11_lock();
588 cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &num);
589 pglXGetFBConfigAttrib(gdi_display, cfgs[physDev->current_pf - 1], GLX_VISUAL_ID, (int *)&template.visualid);
591 vis = XGetVisualInfo(gdi_display, VisualIDMask, &template, &num);
593 ret = pglXCreateGLXPixmap(gdi_display, vis, physDev->bitmap->pixmap);
594 XFree(vis);
595 XFree(cfgs);
596 wine_tsx11_unlock();
597 TRACE("return %lx\n", ret);
598 return ret;
601 BOOL destroy_glxpixmap(XID glxpixmap)
603 wine_tsx11_lock();
604 pglXDestroyGLXPixmap(gdi_display, glxpixmap);
605 wine_tsx11_unlock();
606 return TRUE;
609 #else /* no OpenGL includes */
611 void X11DRV_OpenGL_Init(Display *display)
615 /***********************************************************************
616 * ChoosePixelFormat (X11DRV.@)
618 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
619 const PIXELFORMATDESCRIPTOR *ppfd) {
620 ERR("No OpenGL support compiled in.\n");
622 return 0;
625 /***********************************************************************
626 * DescribePixelFormat (X11DRV.@)
628 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
629 int iPixelFormat,
630 UINT nBytes,
631 PIXELFORMATDESCRIPTOR *ppfd) {
632 ERR("No OpenGL support compiled in.\n");
634 return 0;
637 /***********************************************************************
638 * GetPixelFormat (X11DRV.@)
640 int X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev) {
641 ERR("No OpenGL support compiled in.\n");
643 return 0;
646 /***********************************************************************
647 * SetPixelFormat (X11DRV.@)
649 BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
650 int iPixelFormat,
651 const PIXELFORMATDESCRIPTOR *ppfd) {
652 ERR("No OpenGL support compiled in.\n");
654 return FALSE;
657 /***********************************************************************
658 * SwapBuffers (X11DRV.@)
660 BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) {
661 ERR("No OpenGL support compiled in.\n");
663 return FALSE;
666 XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
668 return NULL;
671 XID create_glxpixmap(X11DRV_PDEVICE *physDev)
673 return 0;
676 BOOL destroy_glxpixmap(XID glxpixmap)
678 return FALSE;
681 #endif /* defined(HAVE_OPENGL) */