2 * X11DRV OpenGL functions
4 * Copyright 2000 Lionel Ulmer
5 * Copyright 2006 Roderick Colenbrander
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
29 #include "wine/library.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wgl);
33 WINE_DECLARE_DEBUG_CHANNEL(opengl);
35 #if defined(HAVE_GL_GL_H) && defined(HAVE_GL_GLX_H)
47 #ifdef HAVE_GL_GLEXT_H
48 # include <GL/glext.h>
55 /* Redefines the constants */
56 #define CALLBACK __stdcall
57 #define WINAPI __stdcall
58 #define APIENTRY WINAPI
60 WINE_DECLARE_DEBUG_CHANNEL(fps);
62 static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) {
63 TRACE(" - size / version : %d / %d\n", ppfd->nSize, ppfd->nVersion);
64 TRACE(" - dwFlags : ");
65 #define TEST_AND_DUMP(t,tv) if ((t) & (tv)) TRACE(#tv " ")
66 TEST_AND_DUMP(ppfd->dwFlags, PFD_DEPTH_DONTCARE);
67 TEST_AND_DUMP(ppfd->dwFlags, PFD_DOUBLEBUFFER);
68 TEST_AND_DUMP(ppfd->dwFlags, PFD_DOUBLEBUFFER_DONTCARE);
69 TEST_AND_DUMP(ppfd->dwFlags, PFD_DRAW_TO_WINDOW);
70 TEST_AND_DUMP(ppfd->dwFlags, PFD_DRAW_TO_BITMAP);
71 TEST_AND_DUMP(ppfd->dwFlags, PFD_GENERIC_ACCELERATED);
72 TEST_AND_DUMP(ppfd->dwFlags, PFD_GENERIC_FORMAT);
73 TEST_AND_DUMP(ppfd->dwFlags, PFD_NEED_PALETTE);
74 TEST_AND_DUMP(ppfd->dwFlags, PFD_NEED_SYSTEM_PALETTE);
75 TEST_AND_DUMP(ppfd->dwFlags, PFD_STEREO);
76 TEST_AND_DUMP(ppfd->dwFlags, PFD_STEREO_DONTCARE);
77 TEST_AND_DUMP(ppfd->dwFlags, PFD_SUPPORT_GDI);
78 TEST_AND_DUMP(ppfd->dwFlags, PFD_SUPPORT_OPENGL);
79 TEST_AND_DUMP(ppfd->dwFlags, PFD_SWAP_COPY);
80 TEST_AND_DUMP(ppfd->dwFlags, PFD_SWAP_EXCHANGE);
81 TEST_AND_DUMP(ppfd->dwFlags, PFD_SWAP_LAYER_BUFFERS);
85 TRACE(" - iPixelType : ");
86 switch (ppfd->iPixelType) {
87 case PFD_TYPE_RGBA: TRACE("PFD_TYPE_RGBA"); break;
88 case PFD_TYPE_COLORINDEX: TRACE("PFD_TYPE_COLORINDEX"); break;
92 TRACE(" - Color : %d\n", ppfd->cColorBits);
93 TRACE(" - Red : %d\n", ppfd->cRedBits);
94 TRACE(" - Green : %d\n", ppfd->cGreenBits);
95 TRACE(" - Blue : %d\n", ppfd->cBlueBits);
96 TRACE(" - Alpha : %d\n", ppfd->cAlphaBits);
97 TRACE(" - Accum : %d\n", ppfd->cAccumBits);
98 TRACE(" - Depth : %d\n", ppfd->cDepthBits);
99 TRACE(" - Stencil : %d\n", ppfd->cStencilBits);
100 TRACE(" - Aux : %d\n", ppfd->cAuxBuffers);
102 TRACE(" - iLayerType : ");
103 switch (ppfd->iLayerType) {
104 case PFD_MAIN_PLANE: TRACE("PFD_MAIN_PLANE"); break;
105 case PFD_OVERLAY_PLANE: TRACE("PFD_OVERLAY_PLANE"); break;
106 case (BYTE)PFD_UNDERLAY_PLANE: TRACE("PFD_UNDERLAY_PLANE"); break;
111 /* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and
112 include all dependencies
115 #define SONAME_LIBGL "libGL.so"
118 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
119 MAKE_FUNCPTR(glGetError)
120 MAKE_FUNCPTR(glXChooseVisual)
121 MAKE_FUNCPTR(glXGetConfig)
122 MAKE_FUNCPTR(glXSwapBuffers)
123 MAKE_FUNCPTR(glXQueryExtension)
125 MAKE_FUNCPTR(glXGetFBConfigs)
126 MAKE_FUNCPTR(glXChooseFBConfig)
127 MAKE_FUNCPTR(glXGetFBConfigAttrib)
128 MAKE_FUNCPTR(glXCreateGLXPixmap)
129 MAKE_FUNCPTR(glXDestroyGLXPixmap)
130 /* MAKE_FUNCPTR(glXQueryDrawable) */
133 static BOOL has_opengl(void)
135 static int init_done;
136 static void *opengl_handle;
138 int error_base, event_base;
140 if (init_done) return (opengl_handle != NULL);
143 opengl_handle = wine_dlopen(SONAME_LIBGL, RTLD_NOW|RTLD_GLOBAL, NULL, 0);
144 if (opengl_handle == NULL) return FALSE;
146 #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(RTLD_DEFAULT, #f, NULL, 0)) == NULL) goto sym_not_found;
147 LOAD_FUNCPTR(glGetError)
148 LOAD_FUNCPTR(glXChooseVisual)
149 LOAD_FUNCPTR(glXGetConfig)
150 LOAD_FUNCPTR(glXSwapBuffers)
151 LOAD_FUNCPTR(glXQueryExtension)
153 LOAD_FUNCPTR(glXGetFBConfigs)
154 LOAD_FUNCPTR(glXChooseFBConfig)
155 LOAD_FUNCPTR(glXGetFBConfigAttrib)
156 LOAD_FUNCPTR(glXCreateGLXPixmap)
157 LOAD_FUNCPTR(glXDestroyGLXPixmap)
161 if (pglXQueryExtension(gdi_display, &error_base, &event_base) == True) {
162 TRACE("GLX is up and running error_base = %d\n", error_base);
164 wine_dlclose(opengl_handle, NULL, 0);
165 opengl_handle = NULL;
168 return (opengl_handle != NULL);
171 wine_dlclose(opengl_handle, NULL, 0);
172 opengl_handle = NULL;
176 /* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
177 * In our WGL implementation we only support a subset of these formats namely the format of
178 * Wine's main visual and offscreen formats (if they are available).
179 * This function converts a WGL format to its corresponding GLX one. It returns the index (zero-based)
180 * into the GLX FB config table and it returns the number of supported WGL formats in fmt_count.
182 static BOOL ConvertPixelFormatWGLtoGLX(Display *display, int iPixelFormat, int *fmt_index, int *fmt_count)
186 GLXFBConfig* cfgs = NULL;
190 int nFormats = 1; /* Start at 1 as we always have a main visual */
191 VisualID visualid = 0;
193 /* Request to look up the format of the main visual when iPixelFormat = 1 */
194 if(iPixelFormat == 1) visualid = XVisualIDFromVisual(visual);
196 /* As mentioned in various parts of the code only the format of the main visual can be used for onscreen rendering.
197 * Next to this format there are also so called offscreen rendering formats (used for pbuffers) which can be supported
198 * because they don't need a visual. Below we use glXGetFBConfigs instead of glXChooseFBConfig to enumerate the fb configurations
199 * bas this call lists both types of formats instead of only onscreen ones. */
200 cfgs = pglXGetFBConfigs(display, DefaultScreen(display), &nCfgs);
201 if (NULL == cfgs || 0 == nCfgs) {
202 ERR("glXChooseFBConfig returns NULL\n");
203 if(cfgs != NULL) XFree(cfgs);
207 /* Find the requested offscreen format and count the number of offscreen formats */
208 for(i=0; i<nCfgs; i++) {
209 pglXGetFBConfigAttrib(display, cfgs[i], GLX_VISUAL_ID, &tmp_vis_id);
210 pglXGetFBConfigAttrib(display, cfgs[i], GLX_FBCONFIG_ID, &tmp_fmt_id);
212 /* We are looking up the GLX index of our main visual and have found it :) */
213 if(iPixelFormat == 1 && visualid == tmp_vis_id) {
215 TRACE("Found FBCONFIG_ID 0x%x at index %d for VISUAL_ID 0x%x\n", tmp_fmt_id, *fmt_index, tmp_vis_id);
218 /* We found an offscreen rendering format :) */
219 else if(tmp_vis_id == 0) {
221 TRACE("Checking offscreen format FBCONFIG_ID 0x%x at index %d\n", tmp_fmt_id, i);
223 if(iPixelFormat == nFormats) {
225 TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", tmp_fmt_id, iPixelFormat, i);
230 *fmt_count = nFormats;
231 TRACE("Number of offscreen formats: %d; returning index: %d\n", *fmt_count, *fmt_index);
233 if(cfgs != NULL) XFree(cfgs);
235 if(res == FALSE && iPixelFormat == 1)
236 ERR("Can't find a matching FBCONFIG_ID for VISUAL_ID 0x%lx!\n", visualid);
242 * X11DRV_ChoosePixelFormat
244 * Equivalent of glXChooseVisual
246 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
247 const PIXELFORMATDESCRIPTOR *ppfd) {
248 GLXFBConfig* cfgs = NULL;
255 ERR("No libGL on this box - disabling OpenGL support !\n");
259 if (TRACE_ON(opengl)) {
260 TRACE("(%p,%p)\n", physDev, ppfd);
262 dump_PIXELFORMATDESCRIPTOR((const PIXELFORMATDESCRIPTOR *) ppfd);
267 ERR("Can't get an opengl visual!\n");
271 /* Get a list containing all supported FB configurations */
272 cfgs = pglXChooseFBConfig(gdi_display, DefaultScreen(gdi_display), NULL, &nCfgs);
273 if (NULL == cfgs || 0 == nCfgs) {
274 ERR("glXChooseFBConfig returns NULL (glError: %d)\n", pglGetError());
278 /* In case an fbconfig was found, check if it matches to the requirements of the ppfd */
279 if(!ConvertPixelFormatWGLtoGLX(gdi_display, 1 /* main visual */, &fmt_index, &value)) {
280 ERR("Can't find a matching FBCONFIG_ID for VISUAL_ID 0x%lx!\n", visual->visualid);
287 pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_RENDER_TYPE, &value);
288 if (value & GLX_RGBA_BIT)
289 iPixelType = PFD_TYPE_RGBA;
291 iPixelType = PFD_TYPE_COLORINDEX;
293 if (ppfd->iPixelType != iPixelType) {
298 pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_DOUBLEBUFFER, &value); if (value) dwFlags |= PFD_DOUBLEBUFFER;
299 if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE)) {
300 if ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != (dwFlags & PFD_DOUBLEBUFFER)) {
306 pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_STEREO, &value); if (value) dwFlags |= PFD_STEREO;
307 if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE)) {
308 if ((ppfd->dwFlags & PFD_STEREO) != (dwFlags & PFD_STEREO)) {
314 pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_ALPHA_SIZE, &value);
315 if (ppfd->iPixelType==PFD_TYPE_RGBA && ppfd->cAlphaBits && !value) {
320 pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_DEPTH_SIZE, &value);
321 if (ppfd->cDepthBits && !value) {
326 pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_STENCIL_SIZE, &value);
327 if (ppfd->cStencilBits && !value) {
332 pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_AUX_BUFFERS, &value);
333 if (ppfd->cAuxBuffers && !value) {
337 /* When we pass all the checks we have found a matching format :) */
339 TRACE("Successfully found a matching mode, returning index: %d\n", ret);
344 TRACE("No matching mode was found returning 0\n");
346 if (NULL != cfgs) XFree(cfgs);
352 * X11DRV_DescribePixelFormat
354 * Get the pixel-format descriptor associated to the given id
356 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
359 PIXELFORMATDESCRIPTOR *ppfd) {
360 /*XVisualInfo *vis;*/
364 GLXFBConfig* cfgs = NULL;
371 ERR("No libGL on this box - disabling OpenGL support !\n");
375 TRACE("(%p,%d,%d,%p)\n", physDev, iPixelFormat, nBytes, ppfd);
378 cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs);
381 if (NULL == cfgs || 0 == nCfgs) {
382 ERR("unexpected iPixelFormat(%d), returns NULL\n", iPixelFormat);
383 return 0; /* unespected error */
386 /* This function always reports the total number of supported pixel formats.
387 * At the moment we only support the pixel format corresponding to the main
388 * visual which got created at x11drv initialization. More formats could be
389 * supported if there was a way to recreate x11 windows in x11drv.
390 * Because we only support one format nCfgs needs to be set to 1.
395 /* The application is only querying the number of visuals */
397 if (NULL != cfgs) XFree(cfgs);
402 if (nBytes < sizeof(PIXELFORMATDESCRIPTOR)) {
403 ERR("Wrong structure size !\n");
404 /* Should set error */
408 if (nCfgs < iPixelFormat || 1 > iPixelFormat) {
409 WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL\n", iPixelFormat, nCfgs);
413 /* Retrieve the index in the FBConfig table corresponding to the visual ID from the main visual */
414 if(!ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, &fmt_index, &value)) {
415 ERR("Can't find a valid pixel format index from the main visual, expect problems!\n");
420 cur = cfgs[fmt_index];
422 memset(ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
423 ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
426 /* These flags are always the same... */
427 ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
428 /* Now the flags extracted from the Visual */
432 pglXGetFBConfigAttrib(gdi_display, cur, GLX_CONFIG_CAVEAT, &value);
433 if(value == GLX_SLOW_CONFIG)
434 ppfd->dwFlags |= PFD_GENERIC_ACCELERATED;
436 pglXGetFBConfigAttrib(gdi_display, cur, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER;
437 pglXGetFBConfigAttrib(gdi_display, cur, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO;
440 pglXGetFBConfigAttrib(gdi_display, cur, GLX_RENDER_TYPE, &value);
441 if (value & GLX_RGBA_BIT)
442 ppfd->iPixelType = PFD_TYPE_RGBA;
444 ppfd->iPixelType = PFD_TYPE_COLORINDEX;
447 pglXGetFBConfigAttrib(gdi_display, cur, GLX_BUFFER_SIZE, &value);
448 ppfd->cColorBits = value;
450 /* Red, green, blue and alpha bits / shifts */
451 if (ppfd->iPixelType == PFD_TYPE_RGBA) {
452 pglXGetFBConfigAttrib(gdi_display, cur, GLX_RED_SIZE, &rb);
453 pglXGetFBConfigAttrib(gdi_display, cur, GLX_GREEN_SIZE, &gb);
454 pglXGetFBConfigAttrib(gdi_display, cur, GLX_BLUE_SIZE, &bb);
455 pglXGetFBConfigAttrib(gdi_display, cur, GLX_ALPHA_SIZE, &ab);
458 ppfd->cRedShift = gb + bb + ab;
459 ppfd->cBlueBits = bb;
460 ppfd->cBlueShift = ab;
461 ppfd->cGreenBits = gb;
462 ppfd->cGreenShift = bb + ab;
463 ppfd->cAlphaBits = ab;
464 ppfd->cAlphaShift = 0;
469 ppfd->cBlueShift = 0;
470 ppfd->cGreenBits = 0;
471 ppfd->cGreenShift = 0;
472 ppfd->cAlphaBits = 0;
473 ppfd->cAlphaShift = 0;
475 /* Accums : to do ... */
478 pglXGetFBConfigAttrib(gdi_display, cur, GLX_DEPTH_SIZE, &value);
479 ppfd->cDepthBits = value;
482 pglXGetFBConfigAttrib(gdi_display, cur, GLX_STENCIL_SIZE, &value);
483 ppfd->cStencilBits = value;
487 /* Aux : to do ... */
489 ppfd->iLayerType = PFD_MAIN_PLANE;
491 if (TRACE_ON(opengl)) {
492 dump_PIXELFORMATDESCRIPTOR(ppfd);
496 if (NULL != cfgs) XFree(cfgs);
503 * X11DRV_GetPixelFormat
505 * Get the pixel-format id used by this DC
507 int X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev) {
508 TRACE("(%p): returns %d\n", physDev, physDev->current_pf);
510 return physDev->current_pf;
514 * X11DRV_SetPixelFormat
516 * Set the pixel-format id used by this DC
518 BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
520 const PIXELFORMATDESCRIPTOR *ppfd) {
521 TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd);
523 /* At the moment we only support the pixelformat corresponding to the main
524 * x11drv visual which got created at x11drv initialization. More formats
525 * can be supported if there was a way to recreate x11 windows in x11drv
527 if(iPixelFormat != 1) {
528 TRACE("Invalid iPixelFormat: %d\n", iPixelFormat);
532 physDev->current_pf = iPixelFormat;
534 if (TRACE_ON(opengl)) {
536 GLXFBConfig* cfgs_fmt = NULL;
542 if(!ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, &fmt_index, &value)) {
543 ERR("Can't find a valid pixel format index from the main visual, expect problems!\n");
544 return TRUE; /* Return true because the SetPixelFormat stuff itself passed */
548 * How to test if hdc current drawable is compatible (visual/FBConfig) ?
550 * in case of root window created HDCs we crash here :(
552 Drawable drawable = get_drawable( physDev->hdc );
553 TRACE(" drawable (%p,%p) have :\n", drawable, root_window);
554 pglXQueryDrawable(gdi_display, drawable, GLX_FBCONFIG_ID, (unsigned int*) &value);
555 TRACE(" - FBCONFIG_ID as 0x%x\n", tmp);
556 pglXQueryDrawable(gdi_display, drawable, GLX_VISUAL_ID, (unsigned int*) &value);
557 TRACE(" - VISUAL_ID as 0x%x\n", tmp);
558 pglXQueryDrawable(gdi_display, drawable, GLX_WIDTH, (unsigned int*) &value);
559 TRACE(" - WIDTH as %d\n", tmp);
560 pglXQueryDrawable(gdi_display, drawable, GLX_HEIGHT, (unsigned int*) &value);
561 TRACE(" - HEIGHT as %d\n", tmp);
563 cfgs_fmt = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs_fmt);
564 cur_cfg = cfgs_fmt[fmt_index];
565 gl_test = pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_FBCONFIG_ID, &value);
567 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
569 TRACE(" FBConfig have :\n");
570 TRACE(" - FBCONFIG_ID 0x%x\n", value);
571 pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_VISUAL_ID, &value);
572 TRACE(" - VISUAL_ID 0x%x\n", value);
573 pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_DRAWABLE_TYPE, &value);
574 TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
581 static XID create_glxpixmap(X11DRV_PDEVICE *physDev)
585 XVisualInfo template;
590 /* Retrieve the visualid from our main visual which is the only visual we can use */
591 template.visualid = XVisualIDFromVisual(visual);
592 vis = XGetVisualInfo(gdi_display, VisualIDMask, &template, &num);
594 ret = pglXCreateGLXPixmap(gdi_display, vis, physDev->bitmap->pixmap);
597 TRACE("return %lx\n", ret);
601 Drawable get_glxdrawable(X11DRV_PDEVICE *physDev)
607 if (physDev->bitmap->hbitmap == BITMAP_stock_phys_bitmap.hbitmap)
608 ret = physDev->drawable; /* PBuffer */
611 if(!physDev->bitmap->glxpixmap)
612 physDev->bitmap->glxpixmap = create_glxpixmap(physDev);
613 ret = physDev->bitmap->glxpixmap;
617 ret = physDev->drawable;
621 BOOL destroy_glxpixmap(XID glxpixmap)
624 pglXDestroyGLXPixmap(gdi_display, glxpixmap);
632 * Swap the buffers of this DC
634 BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev)
636 GLXDrawable drawable;
638 ERR("No libGL on this box - disabling OpenGL support !\n");
642 TRACE_(opengl)("(%p)\n", physDev);
644 drawable = get_glxdrawable(physDev);
646 pglXSwapBuffers(gdi_display, drawable);
652 static long prev_time, frames;
654 DWORD time = GetTickCount();
656 /* every 1.5 seconds */
657 if (time - prev_time > 1500) {
658 TRACE_(fps)("@ approx %.2ffps\n", 1000.0*frames/(time - prev_time));
667 /***********************************************************************
668 * X11DRV_setup_opengl_visual
670 * Setup the default visual used for OpenGL and Direct3D, and the desktop
671 * window (if it exists). If OpenGL isn't available, the visual is simply
672 * set to the default visual for the display
674 XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
676 XVisualInfo *visual = NULL;
677 /* In order to support OpenGL or D3D, we require a double-buffered visual and stencil buffer support, */
678 int dblBuf[] = {GLX_RGBA,GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DOUBLEBUFFER, None};
679 if (!has_opengl()) return NULL;
682 visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf);
684 if (visual == NULL) {
685 /* fallback to 16 bits depth, no alpha */
686 int dblBuf2[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, None};
687 WARN("Failed to get a visual with at least 24 bits depth\n");
690 visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf2);
692 if (visual == NULL) {
693 /* fallback to no stencil */
694 int dblBuf2[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None};
695 WARN("Failed to get a visual with at least 8 bits of stencil\n");
698 visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf2);
700 if (visual == NULL) {
701 /* This should only happen if we cannot find a match with a depth size 16 */
702 FIXME("Failed to find a suitable visual\n");
707 TRACE("Visual ID %lx Chosen\n",visual->visualid);
711 #else /* no OpenGL includes */
713 void X11DRV_OpenGL_Init(Display *display)
717 /***********************************************************************
718 * ChoosePixelFormat (X11DRV.@)
720 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
721 const PIXELFORMATDESCRIPTOR *ppfd) {
722 ERR("No OpenGL support compiled in.\n");
727 /***********************************************************************
728 * DescribePixelFormat (X11DRV.@)
730 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
733 PIXELFORMATDESCRIPTOR *ppfd) {
734 ERR("No OpenGL support compiled in.\n");
739 /***********************************************************************
740 * GetPixelFormat (X11DRV.@)
742 int X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev) {
743 ERR("No OpenGL support compiled in.\n");
748 /***********************************************************************
749 * SetPixelFormat (X11DRV.@)
751 BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
753 const PIXELFORMATDESCRIPTOR *ppfd) {
754 ERR("No OpenGL support compiled in.\n");
759 /***********************************************************************
760 * SwapBuffers (X11DRV.@)
762 BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) {
763 ERR_(opengl)("No OpenGL support compiled in.\n");
768 XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
773 Drawable get_glxdrawable(X11DRV_PDEVICE *physDev)
778 BOOL destroy_glxpixmap(XID glxpixmap)
783 #endif /* defined(HAVE_OPENGL) */