2 * X11DRV OpenGL functions
4 * Copyright 2000 Lionel Ulmer
5 * Copyright 2005 Alex Woods
6 * Copyright 2005 Raphael Junqueira
7 * Copyright 2006-2009 Roderick Colenbrander
8 * Copyright 2006 Tomas Carnecky
9 * Copyright 2012 Alexandre Julliard
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/port.h"
33 #ifdef HAVE_SYS_SOCKET_H
34 #include <sys/socket.h>
42 #include "wine/library.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(wgl
);
49 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
68 /* Redefines the constants */
69 #define CALLBACK __stdcall
70 #define WINAPI __stdcall
71 #define APIENTRY WINAPI
74 WINE_DECLARE_DEBUG_CHANNEL(fps
);
76 typedef struct wine_glextension
{
85 const char *glVersion
;
90 const char *glxServerVersion
;
91 const char *glxServerVendor
;
92 const char *glxServerExtensions
;
94 const char *glxClientVersion
;
95 const char *glxClientVendor
;
96 const char *glxClientExtensions
;
98 const char *glxExtensions
;
101 char wglExtensions
[4096];
104 typedef struct wine_glpixelformat
{
106 GLXFBConfig fbconfig
;
110 DWORD dwFlags
; /* We store some PFD_* flags in here for emulated bitmap formats */
116 BOOL has_been_current
;
120 WineGLPixelFormat
*fmt
;
121 int numAttribs
; /* This is needed for delaying wglCreateContextAttribsARB */
122 int attribList
[16]; /* This is needed for delaying wglCreateContextAttribsARB */
125 Drawable drawables
[2];
126 BOOL refresh_drawables
;
127 Pixmap pixmap
; /* pixmap for memory DCs */
128 GLXPixmap glxpixmap
; /* GLX pixmap for memory DCs */
129 SIZE pixmap_size
; /* pixmap size for memory DCs */
133 typedef struct wine_glpbuffer
{
136 WineGLPixelFormat
* fmt
;
142 int use_render_texture
; /* This is also the internal texture format */
143 int texture_bind_target
;
145 GLint texture_format
;
146 GLuint texture_target
;
154 struct gdi_physdev dev
;
155 X11DRV_PDEVICE
*x11dev
;
156 enum dc_gl_type type
; /* type of GL device context */
159 Pixmap pixmap
; /* pixmap for a DL_GL_PIXMAP_WIN drawable */
162 static const struct wgl_funcs glxdrv_wgl_funcs
;
163 static const struct gdi_dc_funcs glxdrv_funcs
;
165 static inline struct glx_physdev
*get_glxdrv_dev( PHYSDEV dev
)
167 return (struct glx_physdev
*)dev
;
170 static struct list context_list
= LIST_INIT( context_list
);
171 static struct WineGLInfo WineGLInfo
= { 0 };
172 static int use_render_texture_emulation
= 1;
173 static BOOL has_swap_control
;
174 static int swap_interval
= 1;
176 #define MAX_EXTENSIONS 16
177 static const WineGLExtension
*WineGLExtensionList
[MAX_EXTENSIONS
];
178 static int WineGLExtensionListSize
;
180 static void X11DRV_WineGL_LoadExtensions(void);
181 static WineGLPixelFormat
* ConvertPixelFormatWGLtoGLX(Display
*display
, int iPixelFormat
, BOOL AllowOffscreen
, int *fmt_count
);
182 static BOOL
glxRequireVersion(int requiredVersion
);
183 static BOOL
glxRequireExtension(const char *requiredExtension
);
185 static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR
*ppfd
) {
186 TRACE(" - size / version : %d / %d\n", ppfd
->nSize
, ppfd
->nVersion
);
187 TRACE(" - dwFlags : ");
188 #define TEST_AND_DUMP(t,tv) if ((t) & (tv)) TRACE(#tv " ")
189 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DEPTH_DONTCARE
);
190 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER
);
191 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER_DONTCARE
);
192 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_WINDOW
);
193 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_BITMAP
);
194 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_ACCELERATED
);
195 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_FORMAT
);
196 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_PALETTE
);
197 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_SYSTEM_PALETTE
);
198 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO
);
199 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO_DONTCARE
);
200 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_GDI
);
201 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_OPENGL
);
202 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_COPY
);
203 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_EXCHANGE
);
204 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_LAYER_BUFFERS
);
205 /* PFD_SUPPORT_COMPOSITION is new in Vista, it is similar to composition
206 * under X e.g. COMPOSITE + GLX_EXT_TEXTURE_FROM_PIXMAP. */
207 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_COMPOSITION
);
211 TRACE(" - iPixelType : ");
212 switch (ppfd
->iPixelType
) {
213 case PFD_TYPE_RGBA
: TRACE("PFD_TYPE_RGBA"); break;
214 case PFD_TYPE_COLORINDEX
: TRACE("PFD_TYPE_COLORINDEX"); break;
218 TRACE(" - Color : %d\n", ppfd
->cColorBits
);
219 TRACE(" - Red : %d\n", ppfd
->cRedBits
);
220 TRACE(" - Green : %d\n", ppfd
->cGreenBits
);
221 TRACE(" - Blue : %d\n", ppfd
->cBlueBits
);
222 TRACE(" - Alpha : %d\n", ppfd
->cAlphaBits
);
223 TRACE(" - Accum : %d\n", ppfd
->cAccumBits
);
224 TRACE(" - Depth : %d\n", ppfd
->cDepthBits
);
225 TRACE(" - Stencil : %d\n", ppfd
->cStencilBits
);
226 TRACE(" - Aux : %d\n", ppfd
->cAuxBuffers
);
228 TRACE(" - iLayerType : ");
229 switch (ppfd
->iLayerType
) {
230 case PFD_MAIN_PLANE
: TRACE("PFD_MAIN_PLANE"); break;
231 case PFD_OVERLAY_PLANE
: TRACE("PFD_OVERLAY_PLANE"); break;
232 case (BYTE
)PFD_UNDERLAY_PLANE
: TRACE("PFD_UNDERLAY_PLANE"); break;
237 #define PUSH1(attribs,att) do { attribs[nAttribs++] = (att); } while (0)
238 #define PUSH2(attribs,att,value) do { attribs[nAttribs++] = (att); attribs[nAttribs++] = (value); } while(0)
240 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
242 MAKE_FUNCPTR(glXChooseVisual
)
243 MAKE_FUNCPTR(glXCopyContext
)
244 MAKE_FUNCPTR(glXCreateContext
)
245 MAKE_FUNCPTR(glXCreateGLXPixmap
)
246 MAKE_FUNCPTR(glXGetCurrentContext
)
247 MAKE_FUNCPTR(glXGetCurrentDrawable
)
248 MAKE_FUNCPTR(glXDestroyContext
)
249 MAKE_FUNCPTR(glXDestroyGLXPixmap
)
250 MAKE_FUNCPTR(glXGetConfig
)
251 MAKE_FUNCPTR(glXIsDirect
)
252 MAKE_FUNCPTR(glXMakeCurrent
)
253 MAKE_FUNCPTR(glXSwapBuffers
)
254 MAKE_FUNCPTR(glXQueryExtension
)
255 MAKE_FUNCPTR(glXQueryVersion
)
258 MAKE_FUNCPTR(glXGetClientString
)
259 MAKE_FUNCPTR(glXQueryExtensionsString
)
260 MAKE_FUNCPTR(glXQueryServerString
)
263 MAKE_FUNCPTR(glXGetFBConfigs
)
264 MAKE_FUNCPTR(glXChooseFBConfig
)
265 MAKE_FUNCPTR(glXCreatePbuffer
)
266 MAKE_FUNCPTR(glXCreateNewContext
)
267 MAKE_FUNCPTR(glXDestroyPbuffer
)
268 MAKE_FUNCPTR(glXGetFBConfigAttrib
)
269 MAKE_FUNCPTR(glXGetVisualFromFBConfig
)
270 MAKE_FUNCPTR(glXMakeContextCurrent
)
271 MAKE_FUNCPTR(glXQueryDrawable
)
272 MAKE_FUNCPTR(glXGetCurrentReadDrawable
)
275 static GLXContext (*pglXCreateContextAttribsARB
)(Display
*dpy
, GLXFBConfig config
, GLXContext share_context
, Bool direct
, const int *attrib_list
);
276 static void* (*pglXGetProcAddressARB
)(const GLubyte
*);
277 static int (*pglXSwapIntervalSGI
)(int);
279 /* NV GLX Extension */
280 static void* (*pglXAllocateMemoryNV
)(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
);
281 static void (*pglXFreeMemoryNV
)(GLvoid
*pointer
);
283 /* MESA GLX Extensions */
284 static void (*pglXCopySubBufferMESA
)(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
);
286 /* Standard OpenGL */
287 MAKE_FUNCPTR(glBindTexture
)
288 MAKE_FUNCPTR(glBitmap
)
289 MAKE_FUNCPTR(glCopyTexSubImage1D
)
290 MAKE_FUNCPTR(glCopyTexImage2D
)
291 MAKE_FUNCPTR(glCopyTexSubImage2D
)
292 MAKE_FUNCPTR(glDrawBuffer
)
293 MAKE_FUNCPTR(glEndList
)
294 MAKE_FUNCPTR(glGetError
)
295 MAKE_FUNCPTR(glGetIntegerv
)
296 MAKE_FUNCPTR(glGetString
)
297 MAKE_FUNCPTR(glNewList
)
298 MAKE_FUNCPTR(glPixelStorei
)
299 MAKE_FUNCPTR(glReadPixels
)
300 MAKE_FUNCPTR(glTexImage2D
)
301 MAKE_FUNCPTR(glFinish
)
302 MAKE_FUNCPTR(glFlush
)
305 static int GLXErrorHandler(Display
*dpy
, XErrorEvent
*event
, void *arg
)
307 /* In the future we might want to find the exact X or GLX error to report back to the app */
311 static BOOL infoInitialized
= FALSE
;
312 static BOOL
X11DRV_WineGL_InitOpenglInfo(void)
314 int screen
= DefaultScreen(gdi_display
);
315 Window win
= 0, root
= 0;
316 const char *gl_renderer
;
319 GLXContext ctx
= NULL
;
320 XSetWindowAttributes attr
;
322 int attribList
[] = {GLX_RGBA
, GLX_DOUBLEBUFFER
, None
};
326 infoInitialized
= TRUE
;
328 attr
.override_redirect
= True
;
329 attr
.colormap
= None
;
330 attr
.border_pixel
= 0;
334 vis
= pglXChooseVisual(gdi_display
, screen
, attribList
);
337 WORD old_fs
= wine_get_fs();
338 /* Create a GLX Context. Without one we can't query GL information */
339 ctx
= pglXCreateContext(gdi_display
, vis
, None
, GL_TRUE
);
340 if (wine_get_fs() != old_fs
)
342 wine_set_fs( old_fs
);
343 ERR( "%%fs register corrupted, probably broken ATI driver, disabling OpenGL.\n" );
344 ERR( "You need to set the \"UseFastTls\" option to \"2\" in your X config file.\n" );
348 ctx
= pglXCreateContext(gdi_display
, vis
, None
, GL_TRUE
);
353 root
= RootWindow( gdi_display
, vis
->screen
);
354 if (vis
->visual
!= DefaultVisual( gdi_display
, vis
->screen
))
355 attr
.colormap
= XCreateColormap( gdi_display
, root
, vis
->visual
, AllocNone
);
356 if ((win
= XCreateWindow( gdi_display
, root
, -1, -1, 1, 1, 0, vis
->depth
, InputOutput
,
357 vis
->visual
, CWBorderPixel
| CWOverrideRedirect
| CWColormap
, &attr
)))
358 XMapWindow( gdi_display
, win
);
362 if(pglXMakeCurrent(gdi_display
, win
, ctx
) == 0)
364 ERR_(winediag
)( "Unable to activate OpenGL context, most likely your OpenGL drivers haven't been installed correctly\n" );
367 gl_renderer
= (const char *)pglGetString(GL_RENDERER
);
368 WineGLInfo
.glVersion
= (const char *) pglGetString(GL_VERSION
);
369 str
= (const char *) pglGetString(GL_EXTENSIONS
);
370 WineGLInfo
.glExtensions
= HeapAlloc(GetProcessHeap(), 0, strlen(str
)+1);
371 strcpy(WineGLInfo
.glExtensions
, str
);
373 /* Get the common GLX version supported by GLX client and server ( major/minor) */
374 pglXQueryVersion(gdi_display
, &WineGLInfo
.glxVersion
[0], &WineGLInfo
.glxVersion
[1]);
376 WineGLInfo
.glxServerVersion
= pglXQueryServerString(gdi_display
, screen
, GLX_VERSION
);
377 WineGLInfo
.glxServerVendor
= pglXQueryServerString(gdi_display
, screen
, GLX_VENDOR
);
378 WineGLInfo
.glxServerExtensions
= pglXQueryServerString(gdi_display
, screen
, GLX_EXTENSIONS
);
380 WineGLInfo
.glxClientVersion
= pglXGetClientString(gdi_display
, GLX_VERSION
);
381 WineGLInfo
.glxClientVendor
= pglXGetClientString(gdi_display
, GLX_VENDOR
);
382 WineGLInfo
.glxClientExtensions
= pglXGetClientString(gdi_display
, GLX_EXTENSIONS
);
384 WineGLInfo
.glxExtensions
= pglXQueryExtensionsString(gdi_display
, screen
);
385 WineGLInfo
.glxDirect
= pglXIsDirect(gdi_display
, ctx
);
387 TRACE("GL version : %s.\n", WineGLInfo
.glVersion
);
388 TRACE("GL renderer : %s.\n", gl_renderer
);
389 TRACE("GLX version : %d.%d.\n", WineGLInfo
.glxVersion
[0], WineGLInfo
.glxVersion
[1]);
390 TRACE("Server GLX version : %s.\n", WineGLInfo
.glxServerVersion
);
391 TRACE("Server GLX vendor: : %s.\n", WineGLInfo
.glxServerVendor
);
392 TRACE("Client GLX version : %s.\n", WineGLInfo
.glxClientVersion
);
393 TRACE("Client GLX vendor: : %s.\n", WineGLInfo
.glxClientVendor
);
394 TRACE("Direct rendering enabled: %s\n", WineGLInfo
.glxDirect
? "True" : "False");
396 if(!WineGLInfo
.glxDirect
)
398 int fd
= ConnectionNumber(gdi_display
);
399 struct sockaddr_un uaddr
;
400 unsigned int uaddrlen
= sizeof(struct sockaddr_un
);
402 /* In general indirect rendering on a local X11 server indicates a driver problem.
403 * Detect a local X11 server by checking whether the X11 socket is a Unix socket.
405 if(!getsockname(fd
, (struct sockaddr
*)&uaddr
, &uaddrlen
) && uaddr
.sun_family
== AF_UNIX
)
406 ERR_(winediag
)("Direct rendering is disabled, most likely your OpenGL drivers "
407 "haven't been installed correctly (using GL renderer %s, version %s).\n",
408 debugstr_a(gl_renderer
), debugstr_a(WineGLInfo
.glVersion
));
412 /* In general you would expect that if direct rendering is returned, that you receive hardware
413 * accelerated OpenGL rendering. The definition of direct rendering is that rendering is performed
414 * client side without sending all GL commands to X using the GLX protocol. When Mesa falls back to
415 * software rendering, it shows direct rendering.
417 * Depending on the cause of software rendering a different rendering string is shown. In case Mesa fails
418 * to load a DRI module 'Software Rasterizer' is returned. When Mesa is compiled as a OpenGL reference driver
419 * it shows 'Mesa X11'.
421 if(!strcmp(gl_renderer
, "Software Rasterizer") || !strcmp(gl_renderer
, "Mesa X11"))
422 ERR_(winediag
)("The Mesa OpenGL driver is using software rendering, most likely your OpenGL "
423 "drivers haven't been installed correctly (using GL renderer %s, version %s).\n",
424 debugstr_a(gl_renderer
), debugstr_a(WineGLInfo
.glVersion
));
431 pglXMakeCurrent(gdi_display
, None
, NULL
);
432 pglXDestroyContext(gdi_display
, ctx
);
434 if (win
!= root
) XDestroyWindow( gdi_display
, win
);
435 if (attr
.colormap
) XFreeColormap( gdi_display
, attr
.colormap
);
437 if (!ret
) ERR(" couldn't initialize OpenGL, expect problems\n");
441 static BOOL
has_opengl(void)
443 static int init_done
;
444 static void *opengl_handle
;
447 int error_base
, event_base
;
449 if (init_done
) return (opengl_handle
!= NULL
);
452 /* No need to load any other libraries as according to the ABI, libGL should be self-sufficient
453 and include all dependencies */
454 opengl_handle
= wine_dlopen(SONAME_LIBGL
, RTLD_NOW
|RTLD_GLOBAL
, buffer
, sizeof(buffer
));
455 if (opengl_handle
== NULL
)
457 ERR( "Failed to load libGL: %s\n", buffer
);
458 ERR( "OpenGL support is disabled.\n");
462 pglXGetProcAddressARB
= wine_dlsym(opengl_handle
, "glXGetProcAddressARB", NULL
, 0);
463 if (pglXGetProcAddressARB
== NULL
) {
464 ERR("Could not find glXGetProcAddressARB in libGL, disabling OpenGL.\n");
468 #define LOAD_FUNCPTR(f) do if((p##f = (void*)pglXGetProcAddressARB((const unsigned char*)#f)) == NULL) \
470 ERR( "%s not found in libGL, disabling OpenGL.\n", #f ); \
475 LOAD_FUNCPTR(glXChooseVisual
);
476 LOAD_FUNCPTR(glXCopyContext
);
477 LOAD_FUNCPTR(glXCreateContext
);
478 LOAD_FUNCPTR(glXCreateGLXPixmap
);
479 LOAD_FUNCPTR(glXGetCurrentContext
);
480 LOAD_FUNCPTR(glXGetCurrentDrawable
);
481 LOAD_FUNCPTR(glXDestroyContext
);
482 LOAD_FUNCPTR(glXDestroyGLXPixmap
);
483 LOAD_FUNCPTR(glXGetConfig
);
484 LOAD_FUNCPTR(glXIsDirect
);
485 LOAD_FUNCPTR(glXMakeCurrent
);
486 LOAD_FUNCPTR(glXSwapBuffers
);
487 LOAD_FUNCPTR(glXQueryExtension
);
488 LOAD_FUNCPTR(glXQueryVersion
);
491 LOAD_FUNCPTR(glXGetClientString
);
492 LOAD_FUNCPTR(glXQueryExtensionsString
);
493 LOAD_FUNCPTR(glXQueryServerString
);
496 LOAD_FUNCPTR(glXCreatePbuffer
);
497 LOAD_FUNCPTR(glXCreateNewContext
);
498 LOAD_FUNCPTR(glXDestroyPbuffer
);
499 LOAD_FUNCPTR(glXMakeContextCurrent
);
500 LOAD_FUNCPTR(glXGetCurrentReadDrawable
);
501 LOAD_FUNCPTR(glXGetFBConfigs
);
503 /* Standard OpenGL calls */
504 LOAD_FUNCPTR(glBindTexture
);
505 LOAD_FUNCPTR(glBitmap
);
506 LOAD_FUNCPTR(glCopyTexSubImage1D
);
507 LOAD_FUNCPTR(glCopyTexImage2D
);
508 LOAD_FUNCPTR(glCopyTexSubImage2D
);
509 LOAD_FUNCPTR(glDrawBuffer
);
510 LOAD_FUNCPTR(glEndList
);
511 LOAD_FUNCPTR(glGetError
);
512 LOAD_FUNCPTR(glGetIntegerv
);
513 LOAD_FUNCPTR(glGetString
);
514 LOAD_FUNCPTR(glNewList
);
515 LOAD_FUNCPTR(glPixelStorei
);
516 LOAD_FUNCPTR(glReadPixels
);
517 LOAD_FUNCPTR(glTexImage2D
);
518 LOAD_FUNCPTR(glFinish
);
519 LOAD_FUNCPTR(glFlush
);
522 /* It doesn't matter if these fail. They'll only be used if the driver reports
523 the associated extension is available (and if a driver reports the extension
524 is available but fails to provide the functions, it's quite broken) */
525 #define LOAD_FUNCPTR(f) p##f = pglXGetProcAddressARB((const GLubyte *)#f)
526 /* ARB GLX Extension */
527 LOAD_FUNCPTR(glXCreateContextAttribsARB
);
528 /* SGI GLX Extension */
529 LOAD_FUNCPTR(glXSwapIntervalSGI
);
530 /* NV GLX Extension */
531 LOAD_FUNCPTR(glXAllocateMemoryNV
);
532 LOAD_FUNCPTR(glXFreeMemoryNV
);
535 if(!X11DRV_WineGL_InitOpenglInfo()) goto failed
;
538 if (pglXQueryExtension(gdi_display
, &error_base
, &event_base
)) {
539 TRACE("GLX is up and running error_base = %d\n", error_base
);
542 ERR( "GLX extension is missing, disabling OpenGL.\n" );
546 /* In case of GLX you have direct and indirect rendering. Most of the time direct rendering is used
547 * as in general only that is hardware accelerated. In some cases like in case of remote X indirect
550 * The main problem for our OpenGL code is that we need certain GLX calls but their presence
551 * depends on the reported GLX client / server version and on the client / server extension list.
552 * Those don't have to be the same.
554 * In general the server GLX information lists the capabilities in case of indirect rendering.
555 * When direct rendering is used, the OpenGL client library is responsible for which GLX calls are
556 * available and in that case the client GLX informat can be used.
557 * OpenGL programs should use the 'intersection' of both sets of information which is advertised
558 * in the GLX version/extension list. When a program does this it works for certain for both
559 * direct and indirect rendering.
561 * The problem we are having in this area is that ATI's Linux drivers are broken. For some reason
562 * they haven't added some very important GLX extensions like GLX_SGIX_fbconfig to their client
563 * extension list which causes this extension not to be listed. (Wine requires this extension).
564 * ATI advertises a GLX client version of 1.3 which implies that this fbconfig extension among
565 * pbuffers is around.
567 * In order to provide users of Ati's proprietary drivers with OpenGL support, we need to detect
568 * the ATI drivers and from then on use GLX client information for them.
571 if(glxRequireVersion(3)) {
572 pglXChooseFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfig");
573 pglXGetFBConfigAttrib
= pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttrib");
574 pglXGetVisualFromFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfig");
575 pglXQueryDrawable
= pglXGetProcAddressARB((const GLubyte
*) "glXQueryDrawable");
576 } else if(glxRequireExtension("GLX_SGIX_fbconfig")) {
577 pglXChooseFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfigSGIX");
578 pglXGetFBConfigAttrib
= pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttribSGIX");
579 pglXGetVisualFromFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfigSGIX");
581 /* The mesa libGL client library seems to forward glXQueryDrawable to the Xserver, so only
582 * enable this function when the Xserver understand GLX 1.3 or newer
584 pglXQueryDrawable
= NULL
;
585 } else if(strcmp("ATI", WineGLInfo
.glxClientVendor
) == 0) {
586 TRACE("Overriding ATI GLX capabilities!\n");
587 pglXChooseFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfig");
588 pglXGetFBConfigAttrib
= pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttrib");
589 pglXGetVisualFromFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfig");
590 pglXQueryDrawable
= pglXGetProcAddressARB((const GLubyte
*) "glXQueryDrawable");
592 /* Use client GLX information in case of the ATI drivers. We override the
593 * capabilities over here and not somewhere else as ATI might better their
594 * life in the future. In case they release proper drivers this block of
595 * code won't be called. */
596 WineGLInfo
.glxExtensions
= WineGLInfo
.glxClientExtensions
;
598 ERR(" glx_version is %s and GLX_SGIX_fbconfig extension is unsupported. Expect problems.\n", WineGLInfo
.glxServerVersion
);
601 if(glxRequireExtension("GLX_MESA_copy_sub_buffer")) {
602 pglXCopySubBufferMESA
= pglXGetProcAddressARB((const GLubyte
*) "glXCopySubBufferMESA");
605 X11DRV_WineGL_LoadExtensions();
611 wine_dlclose(opengl_handle
, NULL
, 0);
612 opengl_handle
= NULL
;
616 static int describeContext( struct wgl_context
*ctx
) {
619 TRACE(" Context %p have (vis:%p):\n", ctx
, ctx
->vis
);
620 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_FBCONFIG_ID
, &tmp
);
621 TRACE(" - FBCONFIG_ID 0x%x\n", tmp
);
622 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_VISUAL_ID
, &tmp
);
623 TRACE(" - VISUAL_ID 0x%x\n", tmp
);
628 static int ConvertAttribWGLtoGLX(const int* iWGLAttr
, int* oGLXAttr
, Wine_GLPBuffer
* pbuf
) {
633 int nvfloatattrib
= GLX_DONT_CARE
;
634 int pixelattrib
= GLX_DONT_CARE
;
636 /* The list of WGL attributes is allowed to be NULL. We don't return here for NULL
637 * because we need to do fixups for GLX_DRAWABLE_TYPE/GLX_RENDER_TYPE/GLX_FLOAT_COMPONENTS_NV. */
638 while (iWGLAttr
&& 0 != iWGLAttr
[cur
]) {
639 TRACE("pAttr[%d] = %x\n", cur
, iWGLAttr
[cur
]);
641 switch (iWGLAttr
[cur
]) {
642 case WGL_AUX_BUFFERS_ARB
:
643 pop
= iWGLAttr
[++cur
];
644 PUSH2(oGLXAttr
, GLX_AUX_BUFFERS
, pop
);
645 TRACE("pAttr[%d] = GLX_AUX_BUFFERS: %d\n", cur
, pop
);
647 case WGL_COLOR_BITS_ARB
:
648 pop
= iWGLAttr
[++cur
];
649 PUSH2(oGLXAttr
, GLX_BUFFER_SIZE
, pop
);
650 TRACE("pAttr[%d] = GLX_BUFFER_SIZE: %d\n", cur
, pop
);
652 case WGL_BLUE_BITS_ARB
:
653 pop
= iWGLAttr
[++cur
];
654 PUSH2(oGLXAttr
, GLX_BLUE_SIZE
, pop
);
655 TRACE("pAttr[%d] = GLX_BLUE_SIZE: %d\n", cur
, pop
);
657 case WGL_RED_BITS_ARB
:
658 pop
= iWGLAttr
[++cur
];
659 PUSH2(oGLXAttr
, GLX_RED_SIZE
, pop
);
660 TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur
, pop
);
662 case WGL_GREEN_BITS_ARB
:
663 pop
= iWGLAttr
[++cur
];
664 PUSH2(oGLXAttr
, GLX_GREEN_SIZE
, pop
);
665 TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur
, pop
);
667 case WGL_ALPHA_BITS_ARB
:
668 pop
= iWGLAttr
[++cur
];
669 PUSH2(oGLXAttr
, GLX_ALPHA_SIZE
, pop
);
670 TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur
, pop
);
672 case WGL_DEPTH_BITS_ARB
:
673 pop
= iWGLAttr
[++cur
];
674 PUSH2(oGLXAttr
, GLX_DEPTH_SIZE
, pop
);
675 TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur
, pop
);
677 case WGL_STENCIL_BITS_ARB
:
678 pop
= iWGLAttr
[++cur
];
679 PUSH2(oGLXAttr
, GLX_STENCIL_SIZE
, pop
);
680 TRACE("pAttr[%d] = GLX_STENCIL_SIZE: %d\n", cur
, pop
);
682 case WGL_DOUBLE_BUFFER_ARB
:
683 pop
= iWGLAttr
[++cur
];
684 PUSH2(oGLXAttr
, GLX_DOUBLEBUFFER
, pop
);
685 TRACE("pAttr[%d] = GLX_DOUBLEBUFFER: %d\n", cur
, pop
);
688 pop
= iWGLAttr
[++cur
];
689 PUSH2(oGLXAttr
, GLX_STEREO
, pop
);
690 TRACE("pAttr[%d] = GLX_STEREO: %d\n", cur
, pop
);
693 case WGL_PIXEL_TYPE_ARB
:
694 pop
= iWGLAttr
[++cur
];
695 TRACE("pAttr[%d] = WGL_PIXEL_TYPE_ARB: %d\n", cur
, pop
);
697 case WGL_TYPE_COLORINDEX_ARB
: pixelattrib
= GLX_COLOR_INDEX_BIT
; break ;
698 case WGL_TYPE_RGBA_ARB
: pixelattrib
= GLX_RGBA_BIT
; break ;
699 /* This is the same as WGL_TYPE_RGBA_FLOAT_ATI but the GLX constants differ, only the ARB GLX one is widely supported so use that */
700 case WGL_TYPE_RGBA_FLOAT_ATI
: pixelattrib
= GLX_RGBA_FLOAT_BIT
; break ;
701 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
: pixelattrib
= GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
; break ;
703 ERR("unexpected PixelType(%x)\n", pop
);
708 case WGL_SUPPORT_GDI_ARB
:
709 /* This flag is set in a WineGLPixelFormat */
710 pop
= iWGLAttr
[++cur
];
711 TRACE("pAttr[%d] = WGL_SUPPORT_GDI_ARB: %d\n", cur
, pop
);
714 case WGL_DRAW_TO_BITMAP_ARB
:
715 /* This flag is set in a WineGLPixelFormat */
716 pop
= iWGLAttr
[++cur
];
717 TRACE("pAttr[%d] = WGL_DRAW_TO_BITMAP_ARB: %d\n", cur
, pop
);
720 case WGL_DRAW_TO_WINDOW_ARB
:
721 pop
= iWGLAttr
[++cur
];
722 TRACE("pAttr[%d] = WGL_DRAW_TO_WINDOW_ARB: %d\n", cur
, pop
);
723 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
725 drawattrib
|= GLX_WINDOW_BIT
;
729 case WGL_DRAW_TO_PBUFFER_ARB
:
730 pop
= iWGLAttr
[++cur
];
731 TRACE("pAttr[%d] = WGL_DRAW_TO_PBUFFER_ARB: %d\n", cur
, pop
);
732 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
734 drawattrib
|= GLX_PBUFFER_BIT
;
738 case WGL_ACCELERATION_ARB
:
739 /* This flag is set in a WineGLPixelFormat */
740 pop
= iWGLAttr
[++cur
];
741 TRACE("pAttr[%d] = WGL_ACCELERATION_ARB: %d\n", cur
, pop
);
744 case WGL_SUPPORT_OPENGL_ARB
:
745 pop
= iWGLAttr
[++cur
];
746 /** nothing to do, if we are here, supposing support Accelerated OpenGL */
747 TRACE("pAttr[%d] = WGL_SUPPORT_OPENGL_ARB: %d\n", cur
, pop
);
750 case WGL_SWAP_METHOD_ARB
:
751 pop
= iWGLAttr
[++cur
];
752 /* For now we ignore this and just return SWAP_EXCHANGE */
753 TRACE("pAttr[%d] = WGL_SWAP_METHOD_ARB: %#x\n", cur
, pop
);
756 case WGL_PBUFFER_LARGEST_ARB
:
757 pop
= iWGLAttr
[++cur
];
758 PUSH2(oGLXAttr
, GLX_LARGEST_PBUFFER
, pop
);
759 TRACE("pAttr[%d] = GLX_LARGEST_PBUFFER: %x\n", cur
, pop
);
762 case WGL_SAMPLE_BUFFERS_ARB
:
763 pop
= iWGLAttr
[++cur
];
764 PUSH2(oGLXAttr
, GLX_SAMPLE_BUFFERS_ARB
, pop
);
765 TRACE("pAttr[%d] = GLX_SAMPLE_BUFFERS_ARB: %x\n", cur
, pop
);
768 case WGL_SAMPLES_ARB
:
769 pop
= iWGLAttr
[++cur
];
770 PUSH2(oGLXAttr
, GLX_SAMPLES_ARB
, pop
);
771 TRACE("pAttr[%d] = GLX_SAMPLES_ARB: %x\n", cur
, pop
);
774 case WGL_TEXTURE_FORMAT_ARB
:
775 case WGL_TEXTURE_TARGET_ARB
:
776 case WGL_MIPMAP_TEXTURE_ARB
:
777 TRACE("WGL_render_texture Attributes: %x as %x\n", iWGLAttr
[cur
], iWGLAttr
[cur
+ 1]);
778 pop
= iWGLAttr
[++cur
];
780 ERR("trying to use GLX_Pbuffer Attributes without Pbuffer (was %x)\n", iWGLAttr
[cur
]);
782 if (!use_render_texture_emulation
) {
783 if (WGL_NO_TEXTURE_ARB
!= pop
) {
784 ERR("trying to use WGL_render_texture Attributes without support (was %x)\n", iWGLAttr
[cur
]);
785 return -1; /** error: don't support it */
787 drawattrib
|= GLX_PBUFFER_BIT
;
791 case WGL_FLOAT_COMPONENTS_NV
:
792 nvfloatattrib
= iWGLAttr
[++cur
];
793 TRACE("pAttr[%d] = WGL_FLOAT_COMPONENTS_NV: %x\n", cur
, nvfloatattrib
);
795 case WGL_BIND_TO_TEXTURE_DEPTH_NV
:
796 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
797 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
798 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV
:
799 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV
:
800 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV
:
801 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV
:
802 pop
= iWGLAttr
[++cur
];
803 /** cannot be converted, see direct handling on
804 * - wglGetPixelFormatAttribivARB
805 * TODO: wglChoosePixelFormat
808 case WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT
:
809 pop
= iWGLAttr
[++cur
];
810 PUSH2(oGLXAttr
, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
, pop
);
811 TRACE("pAttr[%d] = GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT: %x\n", cur
, pop
);
814 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
:
815 pop
= iWGLAttr
[++cur
];
816 PUSH2(oGLXAttr
, GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
, pop
);
817 TRACE("pAttr[%d] = GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT: %x\n", cur
, pop
);
820 FIXME("unsupported %x WGL Attribute\n", iWGLAttr
[cur
]);
826 /* By default glXChooseFBConfig defaults to GLX_WINDOW_BIT. wglChoosePixelFormatARB searches through
827 * all formats. Unless drawattrib is set to a non-zero value override it with GLX_DONT_CARE, so that
828 * pixmap and pbuffer formats appear as well. */
829 if (!drawattrib
) drawattrib
= GLX_DONT_CARE
;
830 PUSH2(oGLXAttr
, GLX_DRAWABLE_TYPE
, drawattrib
);
831 TRACE("pAttr[?] = GLX_DRAWABLE_TYPE: %#x\n", drawattrib
);
833 /* By default glXChooseFBConfig uses GLX_RGBA_BIT as the default value. Since wglChoosePixelFormatARB
834 * searches in all formats we have to do the same. For this reason we set GLX_RENDER_TYPE to
835 * GLX_DONT_CARE unless it is overridden. */
836 PUSH2(oGLXAttr
, GLX_RENDER_TYPE
, pixelattrib
);
837 TRACE("pAttr[?] = GLX_RENDER_TYPE: %#x\n", pixelattrib
);
839 /* Set GLX_FLOAT_COMPONENTS_NV all the time */
840 if(strstr(WineGLInfo
.glxExtensions
, "GLX_NV_float_buffer")) {
841 PUSH2(oGLXAttr
, GLX_FLOAT_COMPONENTS_NV
, nvfloatattrib
);
842 TRACE("pAttr[?] = GLX_FLOAT_COMPONENTS_NV: %#x\n", nvfloatattrib
);
848 static int get_render_type_from_fbconfig(Display
*display
, GLXFBConfig fbconfig
)
850 int render_type
=0, render_type_bit
;
851 pglXGetFBConfigAttrib(display
, fbconfig
, GLX_RENDER_TYPE
, &render_type_bit
);
852 switch(render_type_bit
)
855 render_type
= GLX_RGBA_TYPE
;
857 case GLX_COLOR_INDEX_BIT
:
858 render_type
= GLX_COLOR_INDEX_TYPE
;
860 case GLX_RGBA_FLOAT_BIT
:
861 render_type
= GLX_RGBA_FLOAT_TYPE
;
863 case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
:
864 render_type
= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
;
867 ERR("Unknown render_type: %x\n", render_type_bit
);
872 /* Check whether a fbconfig is suitable for Windows-style bitmap rendering */
873 static BOOL
check_fbconfig_bitmap_capability(Display
*display
, GLXFBConfig fbconfig
)
876 pglXGetFBConfigAttrib(display
, fbconfig
, GLX_DOUBLEBUFFER
, &dbuf
);
877 pglXGetFBConfigAttrib(gdi_display
, fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
879 /* Windows only supports bitmap rendering on single buffered formats, further the fbconfig needs to have
880 * the GLX_PIXMAP_BIT set. */
881 return !dbuf
&& (value
& GLX_PIXMAP_BIT
);
884 static WineGLPixelFormat
*get_formats(Display
*display
, int *size_ret
, int *onscreen_size_ret
)
886 static WineGLPixelFormat
*list
;
887 static int size
, onscreen_size
;
889 int fmt_id
, nCfgs
, i
, run
, bmp_formats
;
891 XVisualInfo
*visinfo
;
896 cfgs
= pglXGetFBConfigs(display
, DefaultScreen(display
), &nCfgs
);
897 if (NULL
== cfgs
|| 0 == nCfgs
) {
898 if(cfgs
!= NULL
) XFree(cfgs
);
900 ERR("glXChooseFBConfig returns NULL\n");
904 /* Bitmap rendering on Windows implies the use of the Microsoft GDI software renderer.
905 * Further most GLX drivers only offer pixmap rendering using indirect rendering (except for modern drivers which support 'AIGLX' / composite).
906 * Indirect rendering can indicate software rendering (on Nvidia it is hw accelerated)
907 * Since bitmap rendering implies the use of software rendering we can safely use indirect rendering for bitmaps.
909 * Below we count the number of formats which are suitable for bitmap rendering. Windows restricts bitmap rendering to single buffered formats.
911 for(i
=0, bmp_formats
=0; i
<nCfgs
; i
++)
913 if(check_fbconfig_bitmap_capability(display
, cfgs
[i
]))
916 TRACE("Found %d bitmap capable fbconfigs\n", bmp_formats
);
918 list
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (nCfgs
+ bmp_formats
)*sizeof(WineGLPixelFormat
));
920 /* Fill the pixel format list. Put onscreen formats at the top and offscreen ones at the bottom.
921 * Do this as GLX doesn't guarantee that the list is sorted */
922 for(run
=0; run
< 2; run
++)
924 for(i
=0; i
<nCfgs
; i
++) {
925 pglXGetFBConfigAttrib(display
, cfgs
[i
], GLX_FBCONFIG_ID
, &fmt_id
);
926 visinfo
= pglXGetVisualFromFBConfig(display
, cfgs
[i
]);
928 /* The first run we only add onscreen formats (ones which have an associated X Visual).
929 * The second run we only set offscreen formats. */
932 /* We implement child window rendering using offscreen buffers (using composite or an XPixmap).
933 * The contents is copied to the destination using XCopyArea. For the copying to work
934 * the depth of the source and destination window should be the same. In general this should
935 * not be a problem for OpenGL as drivers only advertise formats with a similar depth (or no depth).
936 * As of the introduction of composition managers at least Nvidia now also offers ARGB visuals
937 * with a depth of 32 in addition to the default 24 bit. In order to prevent BadMatch errors we only
938 * list formats with the same depth. */
939 if(visinfo
->depth
!= screen_depth
)
945 TRACE("Found onscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
946 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
947 list
[size
].fbconfig
= cfgs
[i
];
948 list
[size
].fmt_id
= fmt_id
;
949 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
950 list
[size
].offscreenOnly
= FALSE
;
951 list
[size
].dwFlags
= 0;
955 /* Clone a format if it is bitmap capable for indirect rendering to bitmaps */
956 if(check_fbconfig_bitmap_capability(display
, cfgs
[i
]))
958 TRACE("Found bitmap capable format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
959 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
960 list
[size
].fbconfig
= cfgs
[i
];
961 list
[size
].fmt_id
= fmt_id
;
962 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
963 list
[size
].offscreenOnly
= FALSE
;
964 list
[size
].dwFlags
= PFD_DRAW_TO_BITMAP
| PFD_SUPPORT_GDI
| PFD_GENERIC_FORMAT
;
968 } else if(run
&& !visinfo
) {
969 int window_drawable
=0;
970 pglXGetFBConfigAttrib(gdi_display
, cfgs
[i
], GLX_DRAWABLE_TYPE
, &window_drawable
);
972 /* Recent Nvidia drivers and DRI drivers offer window drawable formats without a visual.
973 * This are formats like 16-bit rgb on a 24-bit desktop. In order to support these formats
974 * onscreen we would have to use glXCreateWindow instead of XCreateWindow. Further it will
975 * likely make our child window opengl rendering more complicated since likely you can't use
976 * XCopyArea on a GLX Window.
977 * For now ignore fbconfigs which are window drawable but lack a visual. */
978 if(window_drawable
& GLX_WINDOW_BIT
)
980 TRACE("Skipping FBCONFIG_ID 0x%x as an offscreen format because it is window_drawable\n", fmt_id
);
984 TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
985 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
986 list
[size
].fbconfig
= cfgs
[i
];
987 list
[size
].fmt_id
= fmt_id
;
988 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
989 list
[size
].offscreenOnly
= TRUE
;
990 list
[size
].dwFlags
= 0;
994 if (visinfo
) XFree(visinfo
);
1001 if (size_ret
) *size_ret
= size
;
1002 if (onscreen_size_ret
) *onscreen_size_ret
= onscreen_size
;
1003 wine_tsx11_unlock();
1007 /* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
1008 * In our WGL implementation we only support a subset of these formats namely the format of
1009 * Wine's main visual and offscreen formats (if they are available).
1010 * This function converts a WGL format to its corresponding GLX one. It returns a WineGLPixelFormat
1011 * and it returns the number of supported WGL formats in fmt_count.
1013 static WineGLPixelFormat
* ConvertPixelFormatWGLtoGLX(Display
*display
, int iPixelFormat
, BOOL AllowOffscreen
, int *fmt_count
)
1015 WineGLPixelFormat
*list
, *res
= NULL
;
1016 int size
, onscreen_size
;
1018 if (!(list
= get_formats(display
, &size
, &onscreen_size
))) return NULL
;
1020 /* Check if the pixelformat is valid. Note that it is legal to pass an invalid
1021 * iPixelFormat in case of probing the number of pixelformats.
1023 if((iPixelFormat
> 0) && (iPixelFormat
<= size
) &&
1024 (!list
[iPixelFormat
-1].offscreenOnly
|| AllowOffscreen
)) {
1025 res
= &list
[iPixelFormat
-1];
1026 TRACE("Returning fmt_id=%#x for iPixelFormat=%d\n", res
->fmt_id
, iPixelFormat
);
1032 *fmt_count
= onscreen_size
;
1034 TRACE("Number of returned pixelformats=%d\n", *fmt_count
);
1039 /* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
1040 static WineGLPixelFormat
* ConvertPixelFormatGLXtoWGL(Display
*display
, int fmt_id
, DWORD dwFlags
)
1042 WineGLPixelFormat
*list
;
1045 if (!(list
= get_formats(display
, &size
, NULL
))) return NULL
;
1047 for(i
=0; i
<size
; i
++) {
1048 /* A GLX format can appear multiple times in the pixel format list due to fake formats for bitmap rendering.
1049 * Fake formats might get selected when the user passes the proper flags using the dwFlags parameter. */
1050 if( (list
[i
].fmt_id
== fmt_id
) && ((list
[i
].dwFlags
& dwFlags
) == dwFlags
) ) {
1051 TRACE("Returning iPixelFormat %d for fmt_id 0x%x\n", list
[i
].iPixelFormat
, fmt_id
);
1055 TRACE("No compatible format found for fmt_id 0x%x\n", fmt_id
);
1059 static int pixelformat_from_fbconfig_id(XID fbconfig_id
)
1061 WineGLPixelFormat
*fmt
;
1063 if (!fbconfig_id
) return 0;
1065 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fbconfig_id
, 0 /* no flags */);
1067 return fmt
->iPixelFormat
;
1068 /* This will happen on hwnds without a pixel format set; it's ok */
1073 /* Mark any allocated context using the glx drawable 'old' to use 'new' */
1074 void mark_drawable_dirty(Drawable old
, Drawable
new)
1076 struct wgl_context
*ctx
;
1077 LIST_FOR_EACH_ENTRY( ctx
, &context_list
, struct wgl_context
, entry
)
1079 if (old
== ctx
->drawables
[0]) {
1080 ctx
->drawables
[0] = new;
1081 ctx
->refresh_drawables
= TRUE
;
1083 if (old
== ctx
->drawables
[1]) {
1084 ctx
->drawables
[1] = new;
1085 ctx
->refresh_drawables
= TRUE
;
1090 /* Given the current context, make sure its drawable is sync'd */
1091 static inline void sync_context(struct wgl_context
*context
)
1093 if(context
&& context
->refresh_drawables
) {
1094 if (glxRequireVersion(3))
1095 pglXMakeContextCurrent(gdi_display
, context
->drawables
[0],
1096 context
->drawables
[1], context
->ctx
);
1098 pglXMakeCurrent(gdi_display
, context
->drawables
[0], context
->ctx
);
1099 context
->refresh_drawables
= FALSE
;
1104 static GLXContext
create_glxcontext(Display
*display
, struct wgl_context
*context
, GLXContext shareList
)
1108 /* We use indirect rendering for rendering to bitmaps. See get_formats for a comment about this. */
1109 BOOL indirect
= (context
->fmt
->dwFlags
& PFD_DRAW_TO_BITMAP
) ? FALSE
: TRUE
;
1111 if(context
->gl3_context
)
1113 if(context
->numAttribs
)
1114 ctx
= pglXCreateContextAttribsARB(gdi_display
, context
->fmt
->fbconfig
, shareList
, indirect
, context
->attribList
);
1116 ctx
= pglXCreateContextAttribsARB(gdi_display
, context
->fmt
->fbconfig
, shareList
, indirect
, NULL
);
1118 else if(context
->vis
)
1119 ctx
= pglXCreateContext(gdi_display
, context
->vis
, shareList
, indirect
);
1120 else /* Create a GLX Context for a pbuffer */
1121 ctx
= pglXCreateNewContext(gdi_display
, context
->fmt
->fbconfig
, context
->fmt
->render_type
, shareList
, TRUE
);
1127 Drawable
create_glxpixmap(Display
*display
, XVisualInfo
*vis
, Pixmap parent
)
1129 return pglXCreateGLXPixmap(display
, vis
, parent
);
1134 * glxdrv_DescribePixelFormat
1136 * Get the pixel-format descriptor associated to the given id
1138 static int glxdrv_DescribePixelFormat(PHYSDEV dev
, int iPixelFormat
,
1139 UINT nBytes
, PIXELFORMATDESCRIPTOR
*ppfd
)
1141 /*XVisualInfo *vis;*/
1144 WineGLPixelFormat
*fmt
;
1148 if (!has_opengl()) return 0;
1150 TRACE("(%p,%d,%d,%p)\n", dev
->hdc
, iPixelFormat
, nBytes
, ppfd
);
1152 /* 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 */
1153 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, FALSE
/* Offscreen */, &fmt_count
);
1155 /* The application is only querying the number of pixelformats */
1157 } else if(fmt
== NULL
) {
1158 WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat
, fmt_count
);
1162 if (nBytes
< sizeof(PIXELFORMATDESCRIPTOR
)) {
1163 ERR("Wrong structure size !\n");
1164 /* Should set error */
1170 memset(ppfd
, 0, sizeof(PIXELFORMATDESCRIPTOR
));
1171 ppfd
->nSize
= sizeof(PIXELFORMATDESCRIPTOR
);
1174 /* These flags are always the same... */
1175 ppfd
->dwFlags
= PFD_SUPPORT_OPENGL
;
1176 /* Now the flags extracted from the Visual */
1180 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1181 if(value
& GLX_WINDOW_BIT
)
1182 ppfd
->dwFlags
|= PFD_DRAW_TO_WINDOW
;
1184 /* On Windows bitmap rendering is only offered using the GDI Software renderer. We reserve some formats (see get_formats for more info)
1185 * for bitmap rendering since we require indirect rendering for this. Further pixel format logs of a GeforceFX, Geforce8800GT, Radeon HD3400 and a
1186 * Radeon 9000 indicated that all bitmap formats have PFD_SUPPORT_GDI. Except for 2 formats on the Radeon 9000 none of the hw accelerated formats
1187 * offered the GDI bit either. */
1188 ppfd
->dwFlags
|= fmt
->dwFlags
& (PFD_DRAW_TO_BITMAP
| PFD_SUPPORT_GDI
);
1190 /* PFD_GENERIC_FORMAT - gdi software rendering
1191 * PFD_GENERIC_ACCELERATED - some parts are accelerated by a display driver (MCD e.g. 3dfx minigl)
1192 * none set - full hardware accelerated by a ICD
1194 * We only set PFD_GENERIC_FORMAT on bitmap formats (see get_formats) as that's what ATI and Nvidia Windows drivers do */
1195 ppfd
->dwFlags
|= fmt
->dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
);
1197 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DOUBLEBUFFER
, &value
);
1199 ppfd
->dwFlags
|= PFD_DOUBLEBUFFER
;
1200 ppfd
->dwFlags
&= ~PFD_SUPPORT_GDI
;
1202 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STEREO
, &value
); if (value
) ppfd
->dwFlags
|= PFD_STEREO
;
1205 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_RENDER_TYPE
, &value
);
1206 if (value
& GLX_RGBA_BIT
)
1207 ppfd
->iPixelType
= PFD_TYPE_RGBA
;
1209 ppfd
->iPixelType
= PFD_TYPE_COLORINDEX
;
1212 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_BUFFER_SIZE
, &value
);
1213 ppfd
->cColorBits
= value
;
1215 /* Red, green, blue and alpha bits / shifts */
1216 if (ppfd
->iPixelType
== PFD_TYPE_RGBA
) {
1217 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_RED_SIZE
, &rb
);
1218 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_GREEN_SIZE
, &gb
);
1219 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_BLUE_SIZE
, &bb
);
1220 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ALPHA_SIZE
, &ab
);
1222 ppfd
->cRedBits
= rb
;
1223 ppfd
->cRedShift
= gb
+ bb
+ ab
;
1224 ppfd
->cBlueBits
= bb
;
1225 ppfd
->cBlueShift
= ab
;
1226 ppfd
->cGreenBits
= gb
;
1227 ppfd
->cGreenShift
= bb
+ ab
;
1228 ppfd
->cAlphaBits
= ab
;
1229 ppfd
->cAlphaShift
= 0;
1232 ppfd
->cRedShift
= 0;
1233 ppfd
->cBlueBits
= 0;
1234 ppfd
->cBlueShift
= 0;
1235 ppfd
->cGreenBits
= 0;
1236 ppfd
->cGreenShift
= 0;
1237 ppfd
->cAlphaBits
= 0;
1238 ppfd
->cAlphaShift
= 0;
1241 /* Accum RGBA bits */
1242 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_RED_SIZE
, &rb
);
1243 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_GREEN_SIZE
, &gb
);
1244 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_BLUE_SIZE
, &bb
);
1245 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_ALPHA_SIZE
, &ab
);
1247 ppfd
->cAccumBits
= rb
+gb
+bb
+ab
;
1248 ppfd
->cAccumRedBits
= rb
;
1249 ppfd
->cAccumGreenBits
= gb
;
1250 ppfd
->cAccumBlueBits
= bb
;
1251 ppfd
->cAccumAlphaBits
= ab
;
1254 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_AUX_BUFFERS
, &value
);
1255 ppfd
->cAuxBuffers
= value
;
1258 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DEPTH_SIZE
, &value
);
1259 ppfd
->cDepthBits
= value
;
1262 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STENCIL_SIZE
, &value
);
1263 ppfd
->cStencilBits
= value
;
1265 wine_tsx11_unlock();
1267 ppfd
->iLayerType
= PFD_MAIN_PLANE
;
1269 if (TRACE_ON(wgl
)) {
1270 dump_PIXELFORMATDESCRIPTOR(ppfd
);
1276 /***********************************************************************
1277 * glxdrv_GetPixelFormat
1279 static int glxdrv_GetPixelFormat( HDC hdc
)
1281 struct x11drv_escape_get_drawable escape
;
1282 WineGLPixelFormat
*fmt
;
1285 TRACE( "(%p)\n", hdc
);
1287 escape
.code
= X11DRV_GET_DRAWABLE
;
1288 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
.code
), (LPCSTR
)&escape
.code
,
1289 sizeof(escape
), (LPSTR
)&escape
))
1292 if (!escape
.pixel_format
) return 0; /* not set yet */
1294 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, escape
.pixel_format
, TRUE
, &tmp
);
1297 ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", escape
.pixel_format
);
1300 if (fmt
->offscreenOnly
)
1302 /* Offscreen formats can't be used with traditional WGL calls.
1303 * As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
1304 TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt
->iPixelFormat
);
1307 TRACE("(%p): returns %d\n", hdc
, escape
.pixel_format
);
1308 return escape
.pixel_format
;
1311 /***********************************************************************
1312 * glxdrv_SetPixelFormat
1314 static BOOL
glxdrv_SetPixelFormat(PHYSDEV dev
, int iPixelFormat
, const PIXELFORMATDESCRIPTOR
*ppfd
)
1316 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1317 WineGLPixelFormat
*fmt
;
1321 TRACE("(%p,%d,%p)\n", dev
->hdc
, iPixelFormat
, ppfd
);
1323 if (!has_opengl()) return FALSE
;
1325 if(physdev
->pixel_format
) /* cannot change it if already set */
1326 return (physdev
->pixel_format
== iPixelFormat
);
1328 /* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */
1329 if(physdev
->x11dev
->drawable
== root_window
)
1331 ERR("Invalid operation on root_window\n");
1335 /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
1336 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, FALSE
/* Offscreen */, &value
);
1338 ERR("Invalid iPixelFormat: %d\n", iPixelFormat
);
1343 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1344 wine_tsx11_unlock();
1346 hwnd
= WindowFromDC(physdev
->dev
.hdc
);
1348 if(!(value
&GLX_WINDOW_BIT
)) {
1349 WARN("Pixel format %d is not compatible for window rendering\n", iPixelFormat
);
1353 if(!SendMessageW(hwnd
, WM_X11DRV_SET_WIN_FORMAT
, fmt
->fmt_id
, 0)) {
1354 ERR("Couldn't set format of the window, returning failure\n");
1357 /* physDev->current_pf will be set by the DCE update */
1359 else if (GetObjectType( physdev
->dev
.hdc
) == OBJ_MEMDC
) {
1360 if(!(value
&GLX_PIXMAP_BIT
)) {
1361 WARN("Pixel format %d is not compatible for bitmap rendering\n", iPixelFormat
);
1365 physdev
->pixel_format
= iPixelFormat
;
1366 physdev
->type
= DC_GL_BITMAP
;
1369 FIXME("called on a non-window, non-bitmap object?\n");
1372 if (TRACE_ON(wgl
)) {
1376 gl_test
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_FBCONFIG_ID
, &value
);
1378 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
1380 TRACE(" FBConfig have :\n");
1381 TRACE(" - FBCONFIG_ID 0x%x\n", value
);
1382 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_VISUAL_ID
, &value
);
1383 TRACE(" - VISUAL_ID 0x%x\n", value
);
1384 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1385 TRACE(" - DRAWABLE_TYPE 0x%x\n", value
);
1387 wine_tsx11_unlock();
1392 /***********************************************************************
1393 * glxdrv_wglCopyContext
1395 static BOOL
glxdrv_wglCopyContext(struct wgl_context
*src
, struct wgl_context
*dst
, UINT mask
)
1397 TRACE("%p -> %p mask %#x\n", src
, dst
, mask
);
1400 pglXCopyContext(gdi_display
, src
->ctx
, dst
->ctx
, mask
);
1401 wine_tsx11_unlock();
1403 /* As opposed to wglCopyContext, glXCopyContext doesn't return anything, so hopefully we passed */
1407 /***********************************************************************
1408 * glxdrv_wglCreateContext
1410 static struct wgl_context
*glxdrv_wglCreateContext( HDC hdc
)
1412 struct x11drv_escape_get_drawable escape
;
1413 struct wgl_context
*ret
;
1414 WineGLPixelFormat
*fmt
;
1417 TRACE( "(%p)\n", hdc
);
1419 escape
.code
= X11DRV_GET_DRAWABLE
;
1420 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
.code
), (LPCSTR
)&escape
.code
,
1421 sizeof(escape
), (LPSTR
)&escape
))
1424 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, escape
.pixel_format
, TRUE
/* Offscreen */, &fmt_count
);
1425 /* We can render using the iPixelFormat (1) of Wine's Main visual AND using some offscreen formats.
1426 * Note that standard WGL-calls don't recognize offscreen-only formats. For that reason pbuffers
1427 * use a sort of 'proxy' HDC (wglGetPbufferDCARB).
1428 * If this fails something is very wrong on the system. */
1430 ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", escape
.pixel_format
);
1431 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1435 if (!(ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
)))) return 0;
1439 ret
->has_been_current
= FALSE
;
1440 ret
->sharing
= FALSE
;
1443 ret
->vis
= pglXGetVisualFromFBConfig(gdi_display
, fmt
->fbconfig
);
1444 ret
->ctx
= create_glxcontext(gdi_display
, ret
, NULL
);
1445 list_add_head( &context_list
, &ret
->entry
);
1446 wine_tsx11_unlock();
1448 TRACE(" creating context %p (GL context creation delayed)\n", ret
);
1452 /***********************************************************************
1453 * glxdrv_wglDeleteContext
1455 static void glxdrv_wglDeleteContext(struct wgl_context
*ctx
)
1457 TRACE("(%p)\n", ctx
);
1460 list_remove( &ctx
->entry
);
1461 if (ctx
->ctx
) pglXDestroyContext( gdi_display
, ctx
->ctx
);
1462 if (ctx
->glxpixmap
) pglXDestroyGLXPixmap( gdi_display
, ctx
->glxpixmap
);
1463 if (ctx
->pixmap
) XFreePixmap( gdi_display
, ctx
->pixmap
);
1464 if (ctx
->vis
) XFree( ctx
->vis
);
1465 wine_tsx11_unlock();
1467 HeapFree( GetProcessHeap(), 0, ctx
);
1471 * X11DRV_wglGetCurrentReadDCARB
1473 * For OpenGL32 wglGetCurrentReadDCARB.
1475 static HDC WINAPI
X11DRV_wglGetCurrentReadDCARB(void)
1478 struct wgl_context
*ctx
= NtCurrentTeb()->glContext
;
1480 if (ctx
) ret
= ctx
->read_hdc
;
1482 TRACE(" returning %p (GL drawable %lu)\n", ret
, ctx
? ctx
->drawables
[1] : 0);
1486 /***********************************************************************
1487 * glxdrv_wglGetProcAddress
1489 static PROC
glxdrv_wglGetProcAddress(LPCSTR lpszProc
)
1492 const WineGLExtension
*ext
;
1494 int padding
= 32 - strlen(lpszProc
);
1498 /* Check the table of WGL extensions to see if we need to return a WGL extension
1499 * or a function pointer to a native OpenGL function. */
1500 if(strncmp(lpszProc
, "wgl", 3) != 0) {
1501 return pglXGetProcAddressARB((const GLubyte
*)lpszProc
);
1503 TRACE("('%s'):%*s", lpszProc
, padding
, " ");
1504 for (i
= 0; i
< WineGLExtensionListSize
; ++i
) {
1505 ext
= WineGLExtensionList
[i
];
1506 for (j
= 0; ext
->extEntryPoints
[j
].funcName
; ++j
) {
1507 if (strcmp(ext
->extEntryPoints
[j
].funcName
, lpszProc
) == 0) {
1508 TRACE("(%p) - WineGL\n", ext
->extEntryPoints
[j
].funcAddress
);
1509 return ext
->extEntryPoints
[j
].funcAddress
;
1515 WARN("(%s) - not found\n", lpszProc
);
1519 static GLXPixmap
get_context_pixmap( HDC hdc
, struct wgl_context
*ctx
)
1525 GetObjectW( GetCurrentObject( hdc
, OBJ_BITMAP
), sizeof(bmp
), &bmp
);
1528 ctx
->pixmap
= XCreatePixmap( gdi_display
, root_window
,
1529 bmp
.bmWidth
, bmp
.bmHeight
, ctx
->vis
->depth
);
1530 ctx
->glxpixmap
= pglXCreateGLXPixmap( gdi_display
, ctx
->vis
, ctx
->pixmap
);
1531 wine_tsx11_unlock();
1532 ctx
->pixmap_size
.cx
= bmp
.bmWidth
;
1533 ctx
->pixmap_size
.cy
= bmp
.bmHeight
;
1535 return ctx
->glxpixmap
;
1538 /***********************************************************************
1539 * glxdrv_wglMakeCurrent
1541 static BOOL
glxdrv_wglMakeCurrent(HDC hdc
, struct wgl_context
*ctx
)
1544 struct x11drv_escape_get_drawable escape
;
1546 TRACE("(%p,%p)\n", hdc
, ctx
);
1551 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1552 wine_tsx11_unlock();
1553 NtCurrentTeb()->glContext
= NULL
;
1557 escape
.code
= X11DRV_GET_DRAWABLE
;
1558 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
.code
), (LPCSTR
)&escape
.code
,
1559 sizeof(escape
), (LPSTR
)&escape
))
1562 if (!escape
.pixel_format
)
1564 WARN("Trying to use an invalid drawable\n");
1565 SetLastError(ERROR_INVALID_HANDLE
);
1568 if (ctx
->fmt
->iPixelFormat
!= escape
.pixel_format
)
1570 WARN( "mismatched pixel format hdc %p %u ctx %p %u\n",
1571 hdc
, escape
.pixel_format
, ctx
, ctx
->fmt
->iPixelFormat
);
1572 SetLastError( ERROR_INVALID_PIXEL_FORMAT
);
1577 if (escape
.gl_type
== DC_GL_BITMAP
) escape
.drawable
= get_context_pixmap( hdc
, ctx
);
1581 if (TRACE_ON(wgl
)) {
1583 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_VISUAL_ID
, &vis_id
);
1584 describeContext(ctx
);
1585 TRACE("hdc %p drawable %lx fmt %u vis %x ctx %p\n", hdc
,
1586 escape
.drawable
, escape
.pixel_format
, vis_id
, ctx
->ctx
);
1589 ret
= pglXMakeCurrent(gdi_display
, escape
.drawable
, ctx
->ctx
);
1593 NtCurrentTeb()->glContext
= ctx
;
1595 ctx
->has_been_current
= TRUE
;
1597 ctx
->read_hdc
= hdc
;
1598 ctx
->drawables
[0] = escape
.drawable
;
1599 ctx
->drawables
[1] = escape
.drawable
;
1600 ctx
->refresh_drawables
= FALSE
;
1602 if (escape
.gl_type
== DC_GL_BITMAP
) pglDrawBuffer(GL_FRONT_LEFT
);
1605 SetLastError(ERROR_INVALID_HANDLE
);
1606 wine_tsx11_unlock();
1608 TRACE(" returning %s\n", (ret
? "True" : "False"));
1612 /***********************************************************************
1613 * glxdrv_wglMakeContextCurrentARB
1615 static BOOL
glxdrv_wglMakeContextCurrentARB( HDC draw_hdc
, HDC read_hdc
, struct wgl_context
*ctx
)
1617 struct x11drv_escape_get_drawable escape_draw
, escape_read
;
1620 TRACE("(%p,%p,%p)\n", draw_hdc
, read_hdc
, ctx
);
1625 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1626 wine_tsx11_unlock();
1627 NtCurrentTeb()->glContext
= NULL
;
1631 escape_draw
.code
= X11DRV_GET_DRAWABLE
;
1632 if (!ExtEscape( draw_hdc
, X11DRV_ESCAPE
, sizeof(escape_draw
.code
), (LPCSTR
)&escape_draw
.code
,
1633 sizeof(escape_draw
), (LPSTR
)&escape_draw
))
1636 escape_read
.code
= X11DRV_GET_DRAWABLE
;
1637 if (!ExtEscape( read_hdc
, X11DRV_ESCAPE
, sizeof(escape_read
.code
), (LPCSTR
)&escape_read
.code
,
1638 sizeof(escape_read
), (LPSTR
)&escape_read
))
1641 if (!escape_draw
.pixel_format
)
1643 WARN("Trying to use an invalid drawable\n");
1644 SetLastError(ERROR_INVALID_HANDLE
);
1649 if (!pglXMakeContextCurrent
) return FALSE
;
1651 if (escape_draw
.gl_type
== DC_GL_BITMAP
) escape_draw
.drawable
= get_context_pixmap( draw_hdc
, ctx
);
1652 if (escape_read
.gl_type
== DC_GL_BITMAP
) escape_read
.drawable
= get_context_pixmap( read_hdc
, ctx
);
1655 ret
= pglXMakeContextCurrent(gdi_display
, escape_draw
.drawable
, escape_read
.drawable
, ctx
->ctx
);
1658 ctx
->has_been_current
= TRUE
;
1659 ctx
->hdc
= draw_hdc
;
1660 ctx
->read_hdc
= read_hdc
;
1661 ctx
->drawables
[0] = escape_draw
.drawable
;
1662 ctx
->drawables
[1] = escape_read
.drawable
;
1663 ctx
->refresh_drawables
= FALSE
;
1664 NtCurrentTeb()->glContext
= ctx
;
1667 SetLastError(ERROR_INVALID_HANDLE
);
1668 wine_tsx11_unlock();
1671 TRACE(" returning %s\n", (ret
? "True" : "False"));
1675 /***********************************************************************
1676 * glxdrv_wglShareLists
1678 static BOOL
glxdrv_wglShareLists(struct wgl_context
*org
, struct wgl_context
*dest
)
1680 TRACE("(%p, %p)\n", org
, dest
);
1682 /* Sharing of display lists works differently in GLX and WGL. In case of GLX it is done
1683 * at context creation time but in case of WGL it is done using wglShareLists.
1684 * In the past we tried to emulate wglShareLists by delaying GLX context creation until
1685 * either a wglMakeCurrent or wglShareLists. This worked fine for most apps but it causes
1686 * issues for OpenGL 3 because there wglCreateContextAttribsARB can fail in a lot of cases,
1687 * so there delaying context creation doesn't work.
1689 * The new approach is to create a GLX context in wglCreateContext / wglCreateContextAttribsARB
1690 * and when a program requests sharing we recreate the destination context if it hasn't been made
1691 * current or when it hasn't shared display lists before.
1694 if((org
->has_been_current
&& dest
->has_been_current
) || dest
->has_been_current
)
1696 ERR("Could not share display lists, one of the contexts has been current already !\n");
1699 else if(dest
->sharing
)
1701 ERR("Could not share display lists because hglrc2 has already shared lists before\n");
1706 if((GetObjectType(org
->hdc
) == OBJ_MEMDC
) ^ (GetObjectType(dest
->hdc
) == OBJ_MEMDC
))
1708 WARN("Attempting to share a context between a direct and indirect rendering context, expect issues!\n");
1712 describeContext(org
);
1713 describeContext(dest
);
1715 /* Re-create the GLX context and share display lists */
1716 pglXDestroyContext(gdi_display
, dest
->ctx
);
1717 dest
->ctx
= create_glxcontext(gdi_display
, dest
, org
->ctx
);
1718 wine_tsx11_unlock();
1719 TRACE(" re-created an OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest
->ctx
, dest
, org
->ctx
);
1721 org
->sharing
= TRUE
;
1722 dest
->sharing
= TRUE
;
1728 /***********************************************************************
1729 * glxdrv_wglGetCurrentDC
1731 static HDC
glxdrv_wglGetCurrentDC( struct wgl_context
*ctx
)
1733 TRACE("hdc %p\n", ctx
->hdc
);
1737 /* WGL helper function which handles differences in glGetIntegerv from WGL and GLX */
1738 static void WINAPI
X11DRV_wglGetIntegerv(GLenum pname
, GLint
* params
)
1745 struct wgl_context
*ctx
= NtCurrentTeb()->glContext
;
1747 pglGetIntegerv(pname
, params
);
1749 * if we cannot find a Wine Context
1750 * we only have the default wine desktop context,
1751 * so if we have only a 24 depth say we have 32
1753 if (!ctx
&& *params
== 24) {
1756 TRACE("returns GL_DEPTH_BITS as '%d'\n", *params
);
1761 struct wgl_context
*ctx
= NtCurrentTeb()->glContext
;
1763 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_ALPHA_SIZE
, params
);
1764 TRACE("returns GL_ALPHA_BITS as '%d'\n", *params
);
1768 pglGetIntegerv(pname
, params
);
1771 wine_tsx11_unlock();
1774 static void flush_pixmap( struct wgl_context
*ctx
)
1776 char buffer
[FIELD_OFFSET( BITMAPINFO
, bmiColors
[256] )];
1777 BITMAPINFO
*info
= (BITMAPINFO
*)buffer
;
1778 struct gdi_image_bits bits
;
1780 if (!get_pixmap_image( ctx
->pixmap
, ctx
->pixmap_size
.cx
, ctx
->pixmap_size
.cy
, ctx
->vis
, info
, &bits
))
1782 HBITMAP bitmap
= GetCurrentObject( ctx
->hdc
, OBJ_BITMAP
);
1783 SetDIBits( 0, bitmap
, 0, ctx
->pixmap_size
.cy
, bits
.ptr
, info
, DIB_RGB_COLORS
);
1784 if (bits
.free
) bits
.free( &bits
);
1788 static void flush_gl_drawable( struct glx_physdev
*physdev
)
1791 int w
= physdev
->x11dev
->dc_rect
.right
- physdev
->x11dev
->dc_rect
.left
;
1792 int h
= physdev
->x11dev
->dc_rect
.bottom
- physdev
->x11dev
->dc_rect
.top
;
1793 Drawable src
= physdev
->drawable
;
1795 if (w
<= 0 || h
<= 0) return;
1797 switch (physdev
->type
)
1799 case DC_GL_PIXMAP_WIN
:
1800 src
= physdev
->pixmap
;
1802 case DC_GL_CHILD_WIN
:
1803 /* The GL drawable may be lagged behind if we don't flush first, so
1804 * flush the display make sure we copy up-to-date data */
1806 XFlush(gdi_display
);
1807 XSetFunction(gdi_display
, physdev
->x11dev
->gc
, GXcopy
);
1808 XCopyArea(gdi_display
, src
, physdev
->x11dev
->drawable
, physdev
->x11dev
->gc
, 0, 0, w
, h
,
1809 physdev
->x11dev
->dc_rect
.left
, physdev
->x11dev
->dc_rect
.top
);
1810 wine_tsx11_unlock();
1811 SetRect( &rect
, 0, 0, w
, h
);
1812 add_device_bounds( physdev
->x11dev
, &rect
);
1819 static void WINAPI
X11DRV_wglFinish(void)
1821 struct wgl_context
*ctx
= NtCurrentTeb()->glContext
;
1822 enum x11drv_escape_codes code
= X11DRV_FLUSH_GL_DRAWABLE
;
1827 wine_tsx11_unlock();
1830 if (ctx
->pixmap
) flush_pixmap( ctx
);
1831 else ExtEscape( ctx
->hdc
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, 0, NULL
);
1835 static void WINAPI
X11DRV_wglFlush(void)
1837 struct wgl_context
*ctx
= NtCurrentTeb()->glContext
;
1838 enum x11drv_escape_codes code
= X11DRV_FLUSH_GL_DRAWABLE
;
1843 wine_tsx11_unlock();
1846 if (ctx
->pixmap
) flush_pixmap( ctx
);
1847 else ExtEscape( ctx
->hdc
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, 0, NULL
);
1851 /***********************************************************************
1852 * glxdrv_wglCreateContextAttribsARB
1854 static struct wgl_context
*glxdrv_wglCreateContextAttribsARB( HDC hdc
, struct wgl_context
*hShareContext
,
1855 const int* attribList
)
1857 struct x11drv_escape_get_drawable escape
;
1858 struct wgl_context
*ret
;
1859 WineGLPixelFormat
*fmt
;
1862 TRACE("(%p %p %p)\n", hdc
, hShareContext
, attribList
);
1864 escape
.code
= X11DRV_GET_DRAWABLE
;
1865 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
.code
), (LPCSTR
)&escape
.code
,
1866 sizeof(escape
), (LPSTR
)&escape
))
1869 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, escape
.pixel_format
, TRUE
/* Offscreen */, &fmt_count
);
1870 /* wglCreateContextAttribsARB supports ALL pixel formats, so also offscreen ones.
1871 * If this fails something is very wrong on the system. */
1874 ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", escape
.pixel_format
);
1875 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1879 if (!(ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
)))) return 0;
1883 ret
->vis
= NULL
; /* glXCreateContextAttribsARB requires a fbconfig instead of a visual */
1884 ret
->gl3_context
= TRUE
;
1886 ret
->numAttribs
= 0;
1889 int *pAttribList
= (int*)attribList
;
1890 int *pContextAttribList
= &ret
->attribList
[0];
1891 /* attribList consists of pairs {token, value] terminated with 0 */
1892 while(pAttribList
[0] != 0)
1894 TRACE("%#x %#x\n", pAttribList
[0], pAttribList
[1]);
1895 switch(pAttribList
[0])
1897 case WGL_CONTEXT_MAJOR_VERSION_ARB
:
1898 pContextAttribList
[0] = GLX_CONTEXT_MAJOR_VERSION_ARB
;
1899 pContextAttribList
[1] = pAttribList
[1];
1901 case WGL_CONTEXT_MINOR_VERSION_ARB
:
1902 pContextAttribList
[0] = GLX_CONTEXT_MINOR_VERSION_ARB
;
1903 pContextAttribList
[1] = pAttribList
[1];
1905 case WGL_CONTEXT_LAYER_PLANE_ARB
:
1907 case WGL_CONTEXT_FLAGS_ARB
:
1908 pContextAttribList
[0] = GLX_CONTEXT_FLAGS_ARB
;
1909 pContextAttribList
[1] = pAttribList
[1];
1911 case WGL_CONTEXT_PROFILE_MASK_ARB
:
1912 pContextAttribList
[0] = GLX_CONTEXT_PROFILE_MASK_ARB
;
1913 pContextAttribList
[1] = pAttribList
[1];
1916 ERR("Unhandled attribList pair: %#x %#x\n", pAttribList
[0], pAttribList
[1]);
1921 pContextAttribList
+= 2;
1926 X11DRV_expect_error(gdi_display
, GLXErrorHandler
, NULL
);
1927 ret
->ctx
= create_glxcontext(gdi_display
, ret
, NULL
);
1929 XSync(gdi_display
, False
);
1930 if(X11DRV_check_error() || !ret
->ctx
)
1932 /* In the future we should convert the GLX error to a win32 one here if needed */
1933 ERR("Context creation failed\n");
1934 HeapFree( GetProcessHeap(), 0, ret
);
1935 wine_tsx11_unlock();
1939 list_add_head( &context_list
, &ret
->entry
);
1940 wine_tsx11_unlock();
1941 TRACE(" creating context %p\n", ret
);
1946 * X11DRV_wglGetExtensionsStringARB
1948 * WGL_ARB_extensions_string: wglGetExtensionsStringARB
1950 static const char * WINAPI
X11DRV_wglGetExtensionsStringARB(HDC hdc
) {
1951 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
1952 return WineGLInfo
.wglExtensions
;
1956 * X11DRV_wglCreatePbufferARB
1958 * WGL_ARB_pbuffer: wglCreatePbufferARB
1960 static HPBUFFERARB WINAPI
X11DRV_wglCreatePbufferARB(HDC hdc
, int iPixelFormat
, int iWidth
, int iHeight
, const int *piAttribList
)
1962 Wine_GLPBuffer
* object
= NULL
;
1963 WineGLPixelFormat
*fmt
= NULL
;
1968 TRACE("(%p, %d, %d, %d, %p)\n", hdc
, iPixelFormat
, iWidth
, iHeight
, piAttribList
);
1970 if (0 >= iPixelFormat
) {
1971 ERR("(%p): unexpected iPixelFormat(%d) <= 0, returns NULL\n", hdc
, iPixelFormat
);
1972 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1973 return NULL
; /* unexpected error */
1976 /* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
1977 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, TRUE
/* Offscreen */, &nCfgs
);
1979 ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc
, iPixelFormat
, nCfgs
);
1980 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1981 goto create_failed
; /* unexpected error */
1984 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(Wine_GLPBuffer
));
1985 if (NULL
== object
) {
1986 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
1987 goto create_failed
; /* unexpected error */
1990 object
->display
= gdi_display
;
1991 object
->width
= iWidth
;
1992 object
->height
= iHeight
;
1995 PUSH2(attribs
, GLX_PBUFFER_WIDTH
, iWidth
);
1996 PUSH2(attribs
, GLX_PBUFFER_HEIGHT
, iHeight
);
1997 while (piAttribList
&& 0 != *piAttribList
) {
1999 switch (*piAttribList
) {
2000 case WGL_PBUFFER_LARGEST_ARB
: {
2002 attr_v
= *piAttribList
;
2003 TRACE("WGL_LARGEST_PBUFFER_ARB = %d\n", attr_v
);
2004 PUSH2(attribs
, GLX_LARGEST_PBUFFER
, attr_v
);
2008 case WGL_TEXTURE_FORMAT_ARB
: {
2010 attr_v
= *piAttribList
;
2011 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_FORMAT_ARB as %x\n", attr_v
);
2012 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2013 object
->use_render_texture
= 0;
2015 if (!use_render_texture_emulation
) {
2016 SetLastError(ERROR_INVALID_DATA
);
2020 case WGL_TEXTURE_RGB_ARB
:
2021 object
->use_render_texture
= GL_RGB
;
2022 object
->texture_bpp
= 3;
2023 object
->texture_format
= GL_RGB
;
2024 object
->texture_type
= GL_UNSIGNED_BYTE
;
2026 case WGL_TEXTURE_RGBA_ARB
:
2027 object
->use_render_texture
= GL_RGBA
;
2028 object
->texture_bpp
= 4;
2029 object
->texture_format
= GL_RGBA
;
2030 object
->texture_type
= GL_UNSIGNED_BYTE
;
2033 /* WGL_FLOAT_COMPONENTS_NV */
2034 case WGL_TEXTURE_FLOAT_R_NV
:
2035 object
->use_render_texture
= GL_FLOAT_R_NV
;
2036 object
->texture_bpp
= 4;
2037 object
->texture_format
= GL_RED
;
2038 object
->texture_type
= GL_FLOAT
;
2040 case WGL_TEXTURE_FLOAT_RG_NV
:
2041 object
->use_render_texture
= GL_FLOAT_RG_NV
;
2042 object
->texture_bpp
= 8;
2043 object
->texture_format
= GL_LUMINANCE_ALPHA
;
2044 object
->texture_type
= GL_FLOAT
;
2046 case WGL_TEXTURE_FLOAT_RGB_NV
:
2047 object
->use_render_texture
= GL_FLOAT_RGB_NV
;
2048 object
->texture_bpp
= 12;
2049 object
->texture_format
= GL_RGB
;
2050 object
->texture_type
= GL_FLOAT
;
2052 case WGL_TEXTURE_FLOAT_RGBA_NV
:
2053 object
->use_render_texture
= GL_FLOAT_RGBA_NV
;
2054 object
->texture_bpp
= 16;
2055 object
->texture_format
= GL_RGBA
;
2056 object
->texture_type
= GL_FLOAT
;
2059 ERR("Unknown texture format: %x\n", attr_v
);
2060 SetLastError(ERROR_INVALID_DATA
);
2067 case WGL_TEXTURE_TARGET_ARB
: {
2069 attr_v
= *piAttribList
;
2070 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_TARGET_ARB as %x\n", attr_v
);
2071 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2072 object
->texture_target
= 0;
2074 if (!use_render_texture_emulation
) {
2075 SetLastError(ERROR_INVALID_DATA
);
2079 case WGL_TEXTURE_CUBE_MAP_ARB
: {
2080 if (iWidth
!= iHeight
) {
2081 SetLastError(ERROR_INVALID_DATA
);
2084 object
->texture_target
= GL_TEXTURE_CUBE_MAP
;
2085 object
->texture_bind_target
= GL_TEXTURE_BINDING_CUBE_MAP
;
2088 case WGL_TEXTURE_1D_ARB
: {
2090 SetLastError(ERROR_INVALID_DATA
);
2093 object
->texture_target
= GL_TEXTURE_1D
;
2094 object
->texture_bind_target
= GL_TEXTURE_BINDING_1D
;
2097 case WGL_TEXTURE_2D_ARB
: {
2098 object
->texture_target
= GL_TEXTURE_2D
;
2099 object
->texture_bind_target
= GL_TEXTURE_BINDING_2D
;
2102 case WGL_TEXTURE_RECTANGLE_NV
: {
2103 object
->texture_target
= GL_TEXTURE_RECTANGLE_NV
;
2104 object
->texture_bind_target
= GL_TEXTURE_BINDING_RECTANGLE_NV
;
2108 ERR("Unknown texture target: %x\n", attr_v
);
2109 SetLastError(ERROR_INVALID_DATA
);
2116 case WGL_MIPMAP_TEXTURE_ARB
: {
2118 attr_v
= *piAttribList
;
2119 TRACE("WGL_render_texture Attribute: WGL_MIPMAP_TEXTURE_ARB as %x\n", attr_v
);
2120 if (!use_render_texture_emulation
) {
2121 SetLastError(ERROR_INVALID_DATA
);
2130 PUSH1(attribs
, None
);
2132 object
->drawable
= pglXCreatePbuffer(gdi_display
, fmt
->fbconfig
, attribs
);
2133 wine_tsx11_unlock();
2134 TRACE("new Pbuffer drawable as %lx\n", object
->drawable
);
2135 if (!object
->drawable
) {
2136 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
2137 goto create_failed
; /* unexpected error */
2139 TRACE("->(%p)\n", object
);
2143 HeapFree(GetProcessHeap(), 0, object
);
2144 TRACE("->(FAILED)\n");
2149 * X11DRV_wglDestroyPbufferARB
2151 * WGL_ARB_pbuffer: wglDestroyPbufferARB
2153 static GLboolean WINAPI
X11DRV_wglDestroyPbufferARB(HPBUFFERARB hPbuffer
)
2155 Wine_GLPBuffer
* object
= hPbuffer
;
2156 TRACE("(%p)\n", hPbuffer
);
2157 if (NULL
== object
) {
2158 SetLastError(ERROR_INVALID_HANDLE
);
2162 pglXDestroyPbuffer(object
->display
, object
->drawable
);
2163 wine_tsx11_unlock();
2164 HeapFree(GetProcessHeap(), 0, object
);
2169 * X11DRV_wglGetPbufferDCARB
2171 * WGL_ARB_pbuffer: wglGetPbufferDCARB
2173 static HDC WINAPI
X11DRV_wglGetPbufferDCARB(HPBUFFERARB hPbuffer
)
2175 struct x11drv_escape_set_drawable escape
;
2176 Wine_GLPBuffer
* object
= hPbuffer
;
2179 if (NULL
== object
) {
2180 SetLastError(ERROR_INVALID_HANDLE
);
2184 hdc
= CreateDCA( "DISPLAY", NULL
, NULL
, NULL
);
2187 escape
.code
= X11DRV_SET_DRAWABLE
;
2188 escape
.drawable
= object
->drawable
;
2189 escape
.mode
= IncludeInferiors
;
2190 SetRect( &escape
.drawable_rect
, 0, 0, object
->width
, object
->height
);
2191 escape
.dc_rect
= escape
.drawable_rect
;
2192 escape
.fbconfig_id
= object
->fmt
->fmt_id
;
2193 escape
.gl_drawable
= object
->drawable
;
2195 escape
.gl_type
= DC_GL_PBUFFER
;
2196 ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPSTR
)&escape
, 0, NULL
);
2198 TRACE( "(%p)->(%p)\n", hPbuffer
, hdc
);
2203 * X11DRV_wglQueryPbufferARB
2205 * WGL_ARB_pbuffer: wglQueryPbufferARB
2207 static GLboolean WINAPI
X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer
, int iAttribute
, int *piValue
)
2209 Wine_GLPBuffer
* object
= hPbuffer
;
2210 TRACE("(%p, 0x%x, %p)\n", hPbuffer
, iAttribute
, piValue
);
2211 if (NULL
== object
) {
2212 SetLastError(ERROR_INVALID_HANDLE
);
2215 switch (iAttribute
) {
2216 case WGL_PBUFFER_WIDTH_ARB
:
2218 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_WIDTH
, (unsigned int*) piValue
);
2219 wine_tsx11_unlock();
2221 case WGL_PBUFFER_HEIGHT_ARB
:
2223 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_HEIGHT
, (unsigned int*) piValue
);
2224 wine_tsx11_unlock();
2227 case WGL_PBUFFER_LOST_ARB
:
2228 /* GLX Pbuffers cannot be lost by default. We can support this by
2229 * setting GLX_PRESERVED_CONTENTS to False and using glXSelectEvent
2230 * to receive pixel buffer clobber events, however that may or may
2231 * not give any benefit */
2232 *piValue
= GL_FALSE
;
2235 case WGL_TEXTURE_FORMAT_ARB
:
2236 if (!object
->use_render_texture
) {
2237 *piValue
= WGL_NO_TEXTURE_ARB
;
2239 if (!use_render_texture_emulation
) {
2240 SetLastError(ERROR_INVALID_HANDLE
);
2243 switch(object
->use_render_texture
) {
2245 *piValue
= WGL_TEXTURE_RGB_ARB
;
2248 *piValue
= WGL_TEXTURE_RGBA_ARB
;
2250 /* WGL_FLOAT_COMPONENTS_NV */
2252 *piValue
= WGL_TEXTURE_FLOAT_R_NV
;
2254 case GL_FLOAT_RG_NV
:
2255 *piValue
= WGL_TEXTURE_FLOAT_RG_NV
;
2257 case GL_FLOAT_RGB_NV
:
2258 *piValue
= WGL_TEXTURE_FLOAT_RGB_NV
;
2260 case GL_FLOAT_RGBA_NV
:
2261 *piValue
= WGL_TEXTURE_FLOAT_RGBA_NV
;
2264 ERR("Unknown texture format: %x\n", object
->use_render_texture
);
2269 case WGL_TEXTURE_TARGET_ARB
:
2270 if (!object
->texture_target
){
2271 *piValue
= WGL_NO_TEXTURE_ARB
;
2273 if (!use_render_texture_emulation
) {
2274 SetLastError(ERROR_INVALID_DATA
);
2277 switch (object
->texture_target
) {
2278 case GL_TEXTURE_1D
: *piValue
= WGL_TEXTURE_1D_ARB
; break;
2279 case GL_TEXTURE_2D
: *piValue
= WGL_TEXTURE_2D_ARB
; break;
2280 case GL_TEXTURE_CUBE_MAP
: *piValue
= WGL_TEXTURE_CUBE_MAP_ARB
; break;
2281 case GL_TEXTURE_RECTANGLE_NV
: *piValue
= WGL_TEXTURE_RECTANGLE_NV
; break;
2286 case WGL_MIPMAP_TEXTURE_ARB
:
2287 *piValue
= GL_FALSE
; /** don't support that */
2288 FIXME("unsupported WGL_ARB_render_texture attribute query for 0x%x\n", iAttribute
);
2292 FIXME("unexpected attribute %x\n", iAttribute
);
2300 * X11DRV_wglReleasePbufferDCARB
2302 * WGL_ARB_pbuffer: wglReleasePbufferDCARB
2304 static int WINAPI
X11DRV_wglReleasePbufferDCARB(HPBUFFERARB hPbuffer
, HDC hdc
)
2306 TRACE("(%p, %p)\n", hPbuffer
, hdc
);
2307 return DeleteDC(hdc
);
2311 * X11DRV_wglSetPbufferAttribARB
2313 * WGL_ARB_pbuffer: wglSetPbufferAttribARB
2315 static GLboolean WINAPI
X11DRV_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer
, const int *piAttribList
)
2317 Wine_GLPBuffer
* object
= hPbuffer
;
2318 GLboolean ret
= GL_FALSE
;
2320 WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer
, piAttribList
);
2321 if (NULL
== object
) {
2322 SetLastError(ERROR_INVALID_HANDLE
);
2325 if (!object
->use_render_texture
) {
2326 SetLastError(ERROR_INVALID_HANDLE
);
2329 if (1 == use_render_texture_emulation
) {
2336 * X11DRV_wglChoosePixelFormatARB
2338 * WGL_ARB_pixel_format: wglChoosePixelFormatARB
2340 static GLboolean WINAPI
X11DRV_wglChoosePixelFormatARB(HDC hdc
, const int *piAttribIList
, const FLOAT
*pfAttribFList
, UINT nMaxFormats
, int *piFormats
, UINT
*nNumFormats
)
2345 GLXFBConfig
* cfgs
= NULL
;
2349 WineGLPixelFormat
*fmt
;
2355 TRACE("(%p, %p, %p, %d, %p, %p): hackish\n", hdc
, piAttribIList
, pfAttribFList
, nMaxFormats
, piFormats
, nNumFormats
);
2356 if (NULL
!= pfAttribFList
) {
2357 FIXME("unused pfAttribFList\n");
2360 nAttribs
= ConvertAttribWGLtoGLX(piAttribIList
, attribs
, NULL
);
2361 if (-1 == nAttribs
) {
2362 WARN("Cannot convert WGL to GLX attributes\n");
2365 PUSH1(attribs
, None
);
2367 /* There is no 1:1 mapping between GLX and WGL formats because we duplicate some GLX formats for bitmap rendering (see get_formats).
2368 * Flags like PFD_SUPPORT_GDI, PFD_DRAW_TO_BITMAP and others are a property of the WineGLPixelFormat. We don't query these attributes
2369 * using glXChooseFBConfig but we filter the result of glXChooseFBConfig later on by passing a dwFlags to 'ConvertPixelFormatGLXtoWGL'. */
2370 for(i
=0; piAttribIList
[i
] != 0; i
+=2)
2372 switch(piAttribIList
[i
])
2374 case WGL_DRAW_TO_BITMAP_ARB
:
2375 if(piAttribIList
[i
+1])
2376 dwFlags
|= PFD_DRAW_TO_BITMAP
;
2378 case WGL_ACCELERATION_ARB
:
2379 switch(piAttribIList
[i
+1])
2381 case WGL_NO_ACCELERATION_ARB
:
2382 dwFlags
|= PFD_GENERIC_FORMAT
;
2384 case WGL_GENERIC_ACCELERATION_ARB
:
2385 dwFlags
|= PFD_GENERIC_ACCELERATED
;
2387 case WGL_FULL_ACCELERATION_ARB
:
2392 case WGL_SUPPORT_GDI_ARB
:
2393 if(piAttribIList
[i
+1])
2394 dwFlags
|= PFD_SUPPORT_GDI
;
2399 /* Search for FB configurations matching the requirements in attribs */
2401 cfgs
= pglXChooseFBConfig(gdi_display
, DefaultScreen(gdi_display
), attribs
, &nCfgs
);
2403 wine_tsx11_unlock();
2404 WARN("Compatible Pixel Format not found\n");
2408 /* Loop through all matching formats and check if they are suitable.
2409 * Note that this function should at max return nMaxFormats different formats */
2410 for(run
=0; run
< 2; run
++)
2412 for (it
= 0; it
< nCfgs
&& pfmt_it
< nMaxFormats
; ++it
)
2414 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cfgs
[it
], GLX_FBCONFIG_ID
, &fmt_id
);
2416 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
2420 /* Search for the format in our list of compatible formats */
2421 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fmt_id
, dwFlags
);
2425 /* During the first run we only want onscreen formats and during the second only offscreen 'XOR' */
2426 if( ((run
== 0) && fmt
->offscreenOnly
) || ((run
== 1) && !fmt
->offscreenOnly
) )
2429 piFormats
[pfmt_it
] = fmt
->iPixelFormat
;
2430 TRACE("at %d/%d found FBCONFIG_ID 0x%x (%d)\n", it
+ 1, nCfgs
, fmt_id
, piFormats
[pfmt_it
]);
2435 *nNumFormats
= pfmt_it
;
2438 wine_tsx11_unlock();
2443 * X11DRV_wglGetPixelFormatAttribivARB
2445 * WGL_ARB_pixel_format: wglGetPixelFormatAttribivARB
2447 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribivARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, int *piValues
)
2450 WineGLPixelFormat
*fmt
= NULL
;
2454 int nWGLFormats
= 0;
2456 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, piValues
);
2458 if (0 < iLayerPlane
) {
2459 FIXME("unsupported iLayerPlane(%d) > 0, returns FALSE\n", iLayerPlane
);
2463 /* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supported.
2464 * We don't have to fail yet as a program can specify an invalid iPixelFormat (lets say 0) if it wants to query
2465 * the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
2466 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, TRUE
/* Offscreen */, &nWGLFormats
);
2468 WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat
);
2472 for (i
= 0; i
< nAttributes
; ++i
) {
2473 const int curWGLAttr
= piAttributes
[i
];
2474 TRACE("pAttr[%d] = %x\n", i
, curWGLAttr
);
2476 switch (curWGLAttr
) {
2477 case WGL_NUMBER_PIXEL_FORMATS_ARB
:
2478 piValues
[i
] = nWGLFormats
;
2481 case WGL_SUPPORT_OPENGL_ARB
:
2482 piValues
[i
] = GL_TRUE
;
2485 case WGL_ACCELERATION_ARB
:
2486 curGLXAttr
= GLX_CONFIG_CAVEAT
;
2487 if (!fmt
) goto pix_error
;
2488 if(fmt
->dwFlags
& PFD_GENERIC_FORMAT
)
2489 piValues
[i
] = WGL_NO_ACCELERATION_ARB
;
2490 else if(fmt
->dwFlags
& PFD_GENERIC_ACCELERATED
)
2491 piValues
[i
] = WGL_GENERIC_ACCELERATION_ARB
;
2493 piValues
[i
] = WGL_FULL_ACCELERATION_ARB
;
2496 case WGL_TRANSPARENT_ARB
:
2497 curGLXAttr
= GLX_TRANSPARENT_TYPE
;
2498 if (!fmt
) goto pix_error
;
2499 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
2500 if (hTest
) goto get_error
;
2501 piValues
[i
] = GL_FALSE
;
2502 if (GLX_NONE
!= tmp
) piValues
[i
] = GL_TRUE
;
2505 case WGL_PIXEL_TYPE_ARB
:
2506 curGLXAttr
= GLX_RENDER_TYPE
;
2507 if (!fmt
) goto pix_error
;
2508 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
2509 if (hTest
) goto get_error
;
2510 TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp
);
2511 if (tmp
& GLX_RGBA_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_ARB
; }
2512 else if (tmp
& GLX_COLOR_INDEX_BIT
) { piValues
[i
] = WGL_TYPE_COLORINDEX_ARB
; }
2513 else if (tmp
& GLX_RGBA_FLOAT_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2514 else if (tmp
& GLX_RGBA_FLOAT_ATI_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2515 else if (tmp
& GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
) { piValues
[i
] = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
; }
2517 ERR("unexpected RenderType(%x)\n", tmp
);
2518 piValues
[i
] = WGL_TYPE_RGBA_ARB
;
2522 case WGL_COLOR_BITS_ARB
:
2523 curGLXAttr
= GLX_BUFFER_SIZE
;
2526 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
2527 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
2528 if (!use_render_texture_emulation
) {
2529 piValues
[i
] = GL_FALSE
;
2532 curGLXAttr
= GLX_RENDER_TYPE
;
2533 if (!fmt
) goto pix_error
;
2534 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
2535 if (hTest
) goto get_error
;
2536 if (GLX_COLOR_INDEX_BIT
== tmp
) {
2537 piValues
[i
] = GL_FALSE
;
2540 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &tmp
);
2541 if (hTest
) goto get_error
;
2542 piValues
[i
] = (tmp
& GLX_PBUFFER_BIT
) ? GL_TRUE
: GL_FALSE
;
2545 case WGL_BLUE_BITS_ARB
:
2546 curGLXAttr
= GLX_BLUE_SIZE
;
2548 case WGL_RED_BITS_ARB
:
2549 curGLXAttr
= GLX_RED_SIZE
;
2551 case WGL_GREEN_BITS_ARB
:
2552 curGLXAttr
= GLX_GREEN_SIZE
;
2554 case WGL_ALPHA_BITS_ARB
:
2555 curGLXAttr
= GLX_ALPHA_SIZE
;
2557 case WGL_DEPTH_BITS_ARB
:
2558 curGLXAttr
= GLX_DEPTH_SIZE
;
2560 case WGL_STENCIL_BITS_ARB
:
2561 curGLXAttr
= GLX_STENCIL_SIZE
;
2563 case WGL_DOUBLE_BUFFER_ARB
:
2564 curGLXAttr
= GLX_DOUBLEBUFFER
;
2566 case WGL_STEREO_ARB
:
2567 curGLXAttr
= GLX_STEREO
;
2569 case WGL_AUX_BUFFERS_ARB
:
2570 curGLXAttr
= GLX_AUX_BUFFERS
;
2573 case WGL_SUPPORT_GDI_ARB
:
2574 if (!fmt
) goto pix_error
;
2575 piValues
[i
] = (fmt
->dwFlags
& PFD_SUPPORT_GDI
) ? TRUE
: FALSE
;
2578 case WGL_DRAW_TO_BITMAP_ARB
:
2579 if (!fmt
) goto pix_error
;
2580 piValues
[i
] = (fmt
->dwFlags
& PFD_DRAW_TO_BITMAP
) ? TRUE
: FALSE
;
2583 case WGL_DRAW_TO_WINDOW_ARB
:
2584 case WGL_DRAW_TO_PBUFFER_ARB
:
2585 if (!fmt
) goto pix_error
;
2586 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &tmp
);
2587 if (hTest
) goto get_error
;
2588 if((curWGLAttr
== WGL_DRAW_TO_WINDOW_ARB
&& (tmp
&GLX_WINDOW_BIT
)) ||
2589 (curWGLAttr
== WGL_DRAW_TO_PBUFFER_ARB
&& (tmp
&GLX_PBUFFER_BIT
)))
2590 piValues
[i
] = GL_TRUE
;
2592 piValues
[i
] = GL_FALSE
;
2595 case WGL_SWAP_METHOD_ARB
:
2596 /* For now return SWAP_EXCHANGE_ARB which is the best type of buffer switch available.
2597 * Later on we can also use GLX_OML_swap_method on drivers which support this. At this
2598 * point only ATI offers this.
2600 piValues
[i
] = WGL_SWAP_EXCHANGE_ARB
;
2603 case WGL_PBUFFER_LARGEST_ARB
:
2604 curGLXAttr
= GLX_LARGEST_PBUFFER
;
2607 case WGL_SAMPLE_BUFFERS_ARB
:
2608 curGLXAttr
= GLX_SAMPLE_BUFFERS_ARB
;
2611 case WGL_SAMPLES_ARB
:
2612 curGLXAttr
= GLX_SAMPLES_ARB
;
2615 case WGL_FLOAT_COMPONENTS_NV
:
2616 curGLXAttr
= GLX_FLOAT_COMPONENTS_NV
;
2619 case WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT
:
2620 curGLXAttr
= GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
;
2623 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
:
2624 curGLXAttr
= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
;
2627 case WGL_ACCUM_RED_BITS_ARB
:
2628 curGLXAttr
= GLX_ACCUM_RED_SIZE
;
2630 case WGL_ACCUM_GREEN_BITS_ARB
:
2631 curGLXAttr
= GLX_ACCUM_GREEN_SIZE
;
2633 case WGL_ACCUM_BLUE_BITS_ARB
:
2634 curGLXAttr
= GLX_ACCUM_BLUE_SIZE
;
2636 case WGL_ACCUM_ALPHA_BITS_ARB
:
2637 curGLXAttr
= GLX_ACCUM_ALPHA_SIZE
;
2639 case WGL_ACCUM_BITS_ARB
:
2640 if (!fmt
) goto pix_error
;
2641 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_RED_SIZE
, &tmp
);
2642 if (hTest
) goto get_error
;
2644 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_GREEN_SIZE
, &tmp
);
2645 if (hTest
) goto get_error
;
2647 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_BLUE_SIZE
, &tmp
);
2648 if (hTest
) goto get_error
;
2650 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_ALPHA_SIZE
, &tmp
);
2651 if (hTest
) goto get_error
;
2656 FIXME("unsupported %x WGL Attribute\n", curWGLAttr
);
2659 /* Retrieve a GLX FBConfigAttrib when the attribute to query is valid and
2660 * iPixelFormat != 0. When iPixelFormat is 0 the only value which makes
2661 * sense to query is WGL_NUMBER_PIXEL_FORMATS_ARB.
2663 * TODO: properly test the behavior of wglGetPixelFormatAttrib*v on Windows
2664 * and check which options can work using iPixelFormat=0 and which not.
2665 * A problem would be that this function is an extension. This would
2666 * mean that the behavior could differ between different vendors (ATI, Nvidia, ..).
2668 if (0 != curGLXAttr
&& iPixelFormat
!= 0) {
2669 if (!fmt
) goto pix_error
;
2670 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, piValues
+ i
);
2671 if (hTest
) goto get_error
;
2674 piValues
[i
] = GL_FALSE
;
2677 wine_tsx11_unlock();
2681 wine_tsx11_unlock();
2682 ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc
, curGLXAttr
);
2686 wine_tsx11_unlock();
2687 ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc
, iPixelFormat
, nWGLFormats
);
2692 * X11DRV_wglGetPixelFormatAttribfvARB
2694 * WGL_ARB_pixel_format: wglGetPixelFormatAttribfvARB
2696 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribfvARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, FLOAT
*pfValues
)
2702 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, pfValues
);
2704 /* Allocate a temporary array to store integer values */
2705 attr
= HeapAlloc(GetProcessHeap(), 0, nAttributes
* sizeof(int));
2707 ERR("couldn't allocate %d array\n", nAttributes
);
2711 /* Piggy-back on wglGetPixelFormatAttribivARB */
2712 ret
= X11DRV_wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, attr
);
2714 /* Convert integer values to float. Should also check for attributes
2715 that can give decimal values here */
2716 for (i
=0; i
<nAttributes
;i
++) {
2717 pfValues
[i
] = attr
[i
];
2721 HeapFree(GetProcessHeap(), 0, attr
);
2726 * X11DRV_wglBindTexImageARB
2728 * WGL_ARB_render_texture: wglBindTexImageARB
2730 static GLboolean WINAPI
X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2732 Wine_GLPBuffer
* object
= hPbuffer
;
2733 GLboolean ret
= GL_FALSE
;
2735 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2736 if (NULL
== object
) {
2737 SetLastError(ERROR_INVALID_HANDLE
);
2740 if (!object
->use_render_texture
) {
2741 SetLastError(ERROR_INVALID_HANDLE
);
2745 if (1 == use_render_texture_emulation
) {
2746 static int init
= 0;
2747 int prev_binded_texture
= 0;
2748 GLXContext prev_context
;
2749 Drawable prev_drawable
;
2750 GLXContext tmp_context
;
2753 prev_context
= pglXGetCurrentContext();
2754 prev_drawable
= pglXGetCurrentDrawable();
2756 /* Our render_texture emulation is basic and lacks some features (1D/Cube support).
2757 This is mostly due to lack of demos/games using them. Further the use of glReadPixels
2758 isn't ideal performance wise but I wasn't able to get other ways working.
2761 init
= 1; /* Only show the FIXME once for performance reasons */
2762 FIXME("partial stub!\n");
2765 TRACE("drawable=%lx, context=%p\n", object
->drawable
, prev_context
);
2766 tmp_context
= pglXCreateNewContext(gdi_display
, object
->fmt
->fbconfig
, object
->fmt
->render_type
, prev_context
, True
);
2768 pglGetIntegerv(object
->texture_bind_target
, &prev_binded_texture
);
2770 /* Switch to our pbuffer */
2771 pglXMakeCurrent(gdi_display
, object
->drawable
, tmp_context
);
2773 /* Make sure that the prev_binded_texture is set as the current texture state isn't shared between contexts.
2774 * After that upload the pbuffer texture data. */
2775 pglBindTexture(object
->texture_target
, prev_binded_texture
);
2776 pglCopyTexImage2D(object
->texture_target
, 0, object
->use_render_texture
, 0, 0, object
->width
, object
->height
, 0);
2778 /* Switch back to the original drawable and upload the pbuffer-texture */
2779 pglXMakeCurrent(object
->display
, prev_drawable
, prev_context
);
2780 pglXDestroyContext(gdi_display
, tmp_context
);
2781 wine_tsx11_unlock();
2789 * X11DRV_wglReleaseTexImageARB
2791 * WGL_ARB_render_texture: wglReleaseTexImageARB
2793 static GLboolean WINAPI
X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2795 Wine_GLPBuffer
* object
= hPbuffer
;
2796 GLboolean ret
= GL_FALSE
;
2798 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2799 if (NULL
== object
) {
2800 SetLastError(ERROR_INVALID_HANDLE
);
2803 if (!object
->use_render_texture
) {
2804 SetLastError(ERROR_INVALID_HANDLE
);
2807 if (1 == use_render_texture_emulation
) {
2814 * X11DRV_wglGetExtensionsStringEXT
2816 * WGL_EXT_extensions_string: wglGetExtensionsStringEXT
2818 static const char * WINAPI
X11DRV_wglGetExtensionsStringEXT(void) {
2819 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
2820 return WineGLInfo
.wglExtensions
;
2824 * X11DRV_wglGetSwapIntervalEXT
2826 * WGL_EXT_swap_control: wglGetSwapIntervalEXT
2828 static int WINAPI
X11DRV_wglGetSwapIntervalEXT(VOID
) {
2829 /* GLX_SGI_swap_control doesn't have any provisions for getting the swap
2830 * interval, so the swap interval has to be tracked. */
2832 return swap_interval
;
2836 * X11DRV_wglSwapIntervalEXT
2838 * WGL_EXT_swap_control: wglSwapIntervalEXT
2840 static BOOL WINAPI
X11DRV_wglSwapIntervalEXT(int interval
) {
2843 TRACE("(%d)\n", interval
);
2847 SetLastError(ERROR_INVALID_DATA
);
2850 else if (!has_swap_control
&& interval
== 0)
2852 /* wglSwapIntervalEXT considers an interval value of zero to mean that
2853 * vsync should be disabled, but glXSwapIntervalSGI considers such a
2854 * value to be an error. Just silently ignore the request for now. */
2855 WARN("Request to disable vertical sync is not handled\n");
2860 if (pglXSwapIntervalSGI
)
2863 ret
= !pglXSwapIntervalSGI(interval
);
2864 wine_tsx11_unlock();
2867 WARN("GLX_SGI_swap_control extension is not available\n");
2870 swap_interval
= interval
;
2872 SetLastError(ERROR_DC_NOT_FOUND
);
2879 * X11DRV_wglAllocateMemoryNV
2881 * WGL_NV_vertex_array_range: wglAllocateMemoryNV
2883 static void* WINAPI
X11DRV_wglAllocateMemoryNV(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
) {
2885 TRACE("(%d, %f, %f, %f)\n", size
, readfreq
, writefreq
, priority
);
2887 if (pglXAllocateMemoryNV
)
2890 ret
= pglXAllocateMemoryNV(size
, readfreq
, writefreq
, priority
);
2891 wine_tsx11_unlock();
2897 * X11DRV_wglFreeMemoryNV
2899 * WGL_NV_vertex_array_range: wglFreeMemoryNV
2901 static void WINAPI
X11DRV_wglFreeMemoryNV(GLvoid
* pointer
) {
2902 TRACE("(%p)\n", pointer
);
2903 if (pglXFreeMemoryNV
== NULL
)
2907 pglXFreeMemoryNV(pointer
);
2908 wine_tsx11_unlock();
2912 * X11DRV_wglSetPixelFormatWINE
2914 * WGL_WINE_pixel_format_passthrough: wglSetPixelFormatWINE
2915 * This is a WINE-specific wglSetPixelFormat which can set the pixel format multiple times.
2917 static BOOL WINAPI
X11DRV_wglSetPixelFormatWINE(HDC hdc
, int format
)
2919 WineGLPixelFormat
*fmt
;
2923 TRACE("(%p,%d)\n", hdc
, format
);
2925 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, format
, FALSE
/* Offscreen */, &value
);
2928 ERR( "Invalid format %d\n", format
);
2932 hwnd
= WindowFromDC( hdc
);
2933 if (!hwnd
|| hwnd
== GetDesktopWindow())
2935 ERR( "not a valid window DC %p\n", hdc
);
2940 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
2941 wine_tsx11_unlock();
2943 if (!(value
& GLX_WINDOW_BIT
))
2945 WARN( "Pixel format %d is not compatible for window rendering\n", format
);
2949 return SendMessageW(hwnd
, WM_X11DRV_SET_WIN_FORMAT
, fmt
->fmt_id
, 0);
2950 /* DC pixel format will be set by the DCE update */
2954 * glxRequireVersion (internal)
2956 * Check if the supported GLX version matches requiredVersion.
2958 static BOOL
glxRequireVersion(int requiredVersion
)
2960 /* Both requiredVersion and glXVersion[1] contains the minor GLX version */
2961 if(requiredVersion
<= WineGLInfo
.glxVersion
[1])
2967 static BOOL
glxRequireExtension(const char *requiredExtension
)
2969 if (strstr(WineGLInfo
.glxExtensions
, requiredExtension
) == NULL
) {
2976 static void register_extension_string(const char *ext
)
2978 if (WineGLInfo
.wglExtensions
[0])
2979 strcat(WineGLInfo
.wglExtensions
, " ");
2980 strcat(WineGLInfo
.wglExtensions
, ext
);
2982 TRACE("'%s'\n", ext
);
2985 static BOOL
register_extension(const WineGLExtension
* ext
)
2989 assert( WineGLExtensionListSize
< MAX_EXTENSIONS
);
2990 WineGLExtensionList
[WineGLExtensionListSize
++] = ext
;
2992 register_extension_string(ext
->extName
);
2994 for (i
= 0; ext
->extEntryPoints
[i
].funcName
; ++i
)
2995 TRACE(" - '%s'\n", ext
->extEntryPoints
[i
].funcName
);
3000 static const WineGLExtension WGL_internal_functions
=
3004 { "wglFinish", X11DRV_wglFinish
},
3005 { "wglFlush", X11DRV_wglFlush
},
3006 { "wglGetIntegerv", X11DRV_wglGetIntegerv
},
3011 static const WineGLExtension WGL_ARB_create_context
=
3013 "WGL_ARB_create_context",
3015 { "wglCreateContextAttribsARB", (void *)1 /* called through the glxdrv_wgl_funcs driver */ },
3019 static const WineGLExtension WGL_ARB_extensions_string
=
3021 "WGL_ARB_extensions_string",
3023 { "wglGetExtensionsStringARB", X11DRV_wglGetExtensionsStringARB
},
3027 static const WineGLExtension WGL_ARB_make_current_read
=
3029 "WGL_ARB_make_current_read",
3031 { "wglGetCurrentReadDCARB", X11DRV_wglGetCurrentReadDCARB
},
3032 { "wglMakeContextCurrentARB", (void *)1 /* called through the glxdrv_wgl_funcs driver */ },
3036 static const WineGLExtension WGL_ARB_multisample
=
3038 "WGL_ARB_multisample",
3041 static const WineGLExtension WGL_ARB_pbuffer
=
3045 { "wglCreatePbufferARB", X11DRV_wglCreatePbufferARB
},
3046 { "wglDestroyPbufferARB", X11DRV_wglDestroyPbufferARB
},
3047 { "wglGetPbufferDCARB", X11DRV_wglGetPbufferDCARB
},
3048 { "wglQueryPbufferARB", X11DRV_wglQueryPbufferARB
},
3049 { "wglReleasePbufferDCARB", X11DRV_wglReleasePbufferDCARB
},
3050 { "wglSetPbufferAttribARB", X11DRV_wglSetPbufferAttribARB
},
3054 static const WineGLExtension WGL_ARB_pixel_format
=
3056 "WGL_ARB_pixel_format",
3058 { "wglChoosePixelFormatARB", X11DRV_wglChoosePixelFormatARB
},
3059 { "wglGetPixelFormatAttribfvARB", X11DRV_wglGetPixelFormatAttribfvARB
},
3060 { "wglGetPixelFormatAttribivARB", X11DRV_wglGetPixelFormatAttribivARB
},
3064 static const WineGLExtension WGL_ARB_render_texture
=
3066 "WGL_ARB_render_texture",
3068 { "wglBindTexImageARB", X11DRV_wglBindTexImageARB
},
3069 { "wglReleaseTexImageARB", X11DRV_wglReleaseTexImageARB
},
3073 static const WineGLExtension WGL_EXT_extensions_string
=
3075 "WGL_EXT_extensions_string",
3077 { "wglGetExtensionsStringEXT", X11DRV_wglGetExtensionsStringEXT
},
3081 static const WineGLExtension WGL_EXT_swap_control
=
3083 "WGL_EXT_swap_control",
3085 { "wglSwapIntervalEXT", X11DRV_wglSwapIntervalEXT
},
3086 { "wglGetSwapIntervalEXT", X11DRV_wglGetSwapIntervalEXT
},
3090 static const WineGLExtension WGL_NV_vertex_array_range
=
3092 "WGL_NV_vertex_array_range",
3094 { "wglAllocateMemoryNV", X11DRV_wglAllocateMemoryNV
},
3095 { "wglFreeMemoryNV", X11DRV_wglFreeMemoryNV
},
3099 static const WineGLExtension WGL_WINE_pixel_format_passthrough
=
3101 "WGL_WINE_pixel_format_passthrough",
3103 { "wglSetPixelFormatWINE", X11DRV_wglSetPixelFormatWINE
},
3108 * X11DRV_WineGL_LoadExtensions
3110 static void X11DRV_WineGL_LoadExtensions(void)
3112 WineGLInfo
.wglExtensions
[0] = 0;
3114 /* Load Wine internal functions */
3115 register_extension(&WGL_internal_functions
);
3117 /* ARB Extensions */
3119 if(glxRequireExtension("GLX_ARB_create_context"))
3121 register_extension(&WGL_ARB_create_context
);
3123 if(glxRequireExtension("GLX_ARB_create_context_profile"))
3124 register_extension_string("WGL_ARB_create_context_profile");
3127 if(glxRequireExtension("GLX_ARB_fbconfig_float"))
3129 register_extension_string("WGL_ARB_pixel_format_float");
3130 register_extension_string("WGL_ATI_pixel_format_float");
3133 register_extension(&WGL_ARB_extensions_string
);
3135 if (glxRequireVersion(3))
3136 register_extension(&WGL_ARB_make_current_read
);
3138 if (glxRequireExtension("GLX_ARB_multisample"))
3139 register_extension(&WGL_ARB_multisample
);
3141 /* In general pbuffer functionality requires support in the X-server. The functionality is
3142 * available either when the GLX_SGIX_pbuffer is present or when the GLX server version is 1.3.
3144 if ( glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer") )
3145 register_extension(&WGL_ARB_pbuffer
);
3147 register_extension(&WGL_ARB_pixel_format
);
3149 /* Support WGL_ARB_render_texture when there's support or pbuffer based emulation */
3150 if (glxRequireExtension("GLX_ARB_render_texture") ||
3151 (glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer") && use_render_texture_emulation
))
3153 register_extension(&WGL_ARB_render_texture
);
3155 /* The WGL version of GLX_NV_float_buffer requires render_texture */
3156 if(glxRequireExtension("GLX_NV_float_buffer"))
3157 register_extension_string("WGL_NV_float_buffer");
3159 /* Again there's no GLX equivalent for this extension, so depend on the required GL extension */
3160 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_texture_rectangle") != NULL
)
3161 register_extension_string("WGL_NV_texture_rectangle");
3164 /* EXT Extensions */
3166 register_extension(&WGL_EXT_extensions_string
);
3168 /* Load this extension even when it isn't backed by a GLX extension because it is has been around for ages.
3169 * Games like Call of Duty and K.O.T.O.R. rely on it. Further our emulation is good enough. */
3170 register_extension(&WGL_EXT_swap_control
);
3172 if(glxRequireExtension("GLX_EXT_framebuffer_sRGB"))
3173 register_extension_string("WGL_EXT_framebuffer_sRGB");
3175 if(glxRequireExtension("GLX_EXT_fbconfig_packed_float"))
3176 register_extension_string("WGL_EXT_pixel_format_packed_float");
3178 if (glxRequireExtension("GLX_EXT_swap_control"))
3179 has_swap_control
= TRUE
;
3181 /* The OpenGL extension GL_NV_vertex_array_range adds wgl/glX functions which aren't exported as 'real' wgl/glX extensions. */
3182 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_vertex_array_range") != NULL
)
3183 register_extension(&WGL_NV_vertex_array_range
);
3185 /* WINE-specific WGL Extensions */
3187 /* In WineD3D we need the ability to set the pixel format more than once (e.g. after a device reset).
3188 * The default wglSetPixelFormat doesn't allow this, so add our own which allows it.
3190 register_extension(&WGL_WINE_pixel_format_passthrough
);
3194 BOOL
destroy_glxpixmap(Display
*display
, XID glxpixmap
)
3197 pglXDestroyGLXPixmap(display
, glxpixmap
);
3198 wine_tsx11_unlock();
3203 * glxdrv_SwapBuffers
3205 * Swap the buffers of this DC
3207 static BOOL
glxdrv_SwapBuffers(PHYSDEV dev
)
3209 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3210 struct wgl_context
*ctx
= NtCurrentTeb()->glContext
;
3212 TRACE("(%p)\n", dev
->hdc
);
3216 WARN("Using a NULL context, skipping\n");
3217 SetLastError(ERROR_INVALID_HANDLE
);
3221 if (!physdev
->drawable
)
3223 WARN("Using an invalid drawable, skipping\n");
3224 SetLastError(ERROR_INVALID_HANDLE
);
3230 switch (physdev
->type
)
3232 case DC_GL_PIXMAP_WIN
:
3233 if(pglXCopySubBufferMESA
) {
3234 int w
= physdev
->x11dev
->dc_rect
.right
- physdev
->x11dev
->dc_rect
.left
;
3235 int h
= physdev
->x11dev
->dc_rect
.bottom
- physdev
->x11dev
->dc_rect
.top
;
3237 /* (glX)SwapBuffers has an implicit glFlush effect, however
3238 * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before
3242 pglXCopySubBufferMESA(gdi_display
, physdev
->drawable
, 0, 0, w
, h
);
3247 pglXSwapBuffers(gdi_display
, physdev
->drawable
);
3251 flush_gl_drawable( physdev
);
3252 wine_tsx11_unlock();
3257 static long prev_time
, start_time
;
3258 static unsigned long frames
, frames_total
;
3260 DWORD time
= GetTickCount();
3263 /* every 1.5 seconds */
3264 if (time
- prev_time
> 1500) {
3265 TRACE_(fps
)("@ approx %.2ffps, total %.2ffps\n",
3266 1000.0*frames
/(time
- prev_time
), 1000.0*frames_total
/(time
- start_time
));
3269 if(start_time
== 0) start_time
= time
;
3276 XVisualInfo
*visual_from_fbconfig_id( XID fbconfig_id
)
3278 WineGLPixelFormat
*fmt
;
3281 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fbconfig_id
, 0 /* no flags */);
3286 ret
= pglXGetVisualFromFBConfig(gdi_display
, fmt
->fbconfig
);
3287 wine_tsx11_unlock();
3291 static BOOL
create_glx_dc( PHYSDEV
*pdev
)
3293 /* assume that only the main x11 device implements GetDeviceCaps */
3294 X11DRV_PDEVICE
*x11dev
= get_x11drv_dev( GET_NEXT_PHYSDEV( *pdev
, pGetDeviceCaps
));
3295 struct glx_physdev
*physdev
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*physdev
) );
3297 if (!physdev
) return FALSE
;
3298 physdev
->x11dev
= x11dev
;
3299 push_dc_driver( pdev
, &physdev
->dev
, &glxdrv_funcs
);
3303 /**********************************************************************
3306 static BOOL
glxdrv_CreateDC( PHYSDEV
*pdev
, LPCWSTR driver
, LPCWSTR device
,
3307 LPCWSTR output
, const DEVMODEW
* initData
)
3309 return create_glx_dc( pdev
);
3312 /**********************************************************************
3313 * glxdrv_CreateCompatibleDC
3315 static BOOL
glxdrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
3317 if (orig
) /* chain to next driver first */
3319 orig
= GET_NEXT_PHYSDEV( orig
, pCreateCompatibleDC
);
3320 if (!orig
->funcs
->pCreateCompatibleDC( orig
, pdev
)) return FALSE
;
3322 /* otherwise we have been called by x11drv */
3323 return create_glx_dc( pdev
);
3326 /**********************************************************************
3329 static BOOL
glxdrv_DeleteDC( PHYSDEV dev
)
3331 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3332 HeapFree( GetProcessHeap(), 0, physdev
);
3336 /**********************************************************************
3339 static INT
glxdrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_count
, LPCVOID in_data
,
3340 INT out_count
, LPVOID out_data
)
3342 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3344 dev
= GET_NEXT_PHYSDEV( dev
, pExtEscape
);
3346 if (escape
== X11DRV_ESCAPE
&& in_data
&& in_count
>= sizeof(enum x11drv_escape_codes
))
3348 switch (*(const enum x11drv_escape_codes
*)in_data
)
3350 case X11DRV_SET_DRAWABLE
:
3351 if (in_count
>= sizeof(struct x11drv_escape_set_drawable
))
3353 const struct x11drv_escape_set_drawable
*data
= in_data
;
3354 physdev
->pixel_format
= pixelformat_from_fbconfig_id( data
->fbconfig_id
);
3355 physdev
->type
= data
->gl_type
;
3356 physdev
->drawable
= data
->gl_drawable
;
3357 physdev
->pixmap
= data
->pixmap
;
3358 TRACE( "SET_DRAWABLE hdc %p drawable %lx pf %u type %u\n",
3359 dev
->hdc
, physdev
->drawable
, physdev
->pixel_format
, physdev
->type
);
3362 case X11DRV_GET_DRAWABLE
:
3363 if (out_count
>= sizeof(struct x11drv_escape_get_drawable
))
3365 struct x11drv_escape_get_drawable
*data
= out_data
;
3366 data
->pixel_format
= physdev
->pixel_format
;
3367 data
->gl_type
= physdev
->type
;
3368 data
->gl_drawable
= physdev
->drawable
;
3369 data
->pixmap
= physdev
->pixmap
;
3372 case X11DRV_FLUSH_GL_DRAWABLE
:
3373 flush_gl_drawable( physdev
);
3379 return dev
->funcs
->pExtEscape( dev
, escape
, in_count
, in_data
, out_count
, out_data
);
3382 /**********************************************************************
3383 * glxdrv_wine_get_wgl_driver
3385 static const struct wgl_funcs
* glxdrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
3387 if (version
!= WINE_GDI_DRIVER_VERSION
)
3389 ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version
, WINE_GDI_DRIVER_VERSION
);
3393 if (has_opengl()) return &glxdrv_wgl_funcs
;
3395 dev
= GET_NEXT_PHYSDEV( dev
, wine_get_wgl_driver
);
3396 return dev
->funcs
->wine_get_wgl_driver( dev
, version
);
3399 static const struct gdi_dc_funcs glxdrv_funcs
=
3401 NULL
, /* pAbortDoc */
3402 NULL
, /* pAbortPath */
3403 NULL
, /* pAlphaBlend */
3404 NULL
, /* pAngleArc */
3407 NULL
, /* pBeginPath */
3408 NULL
, /* pBlendImage */
3410 NULL
, /* pCloseFigure */
3411 glxdrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
3412 glxdrv_CreateDC
, /* pCreateDC */
3413 glxdrv_DeleteDC
, /* pDeleteDC */
3414 NULL
, /* pDeleteObject */
3415 glxdrv_DescribePixelFormat
, /* pDescribePixelFormat */
3416 NULL
, /* pDeviceCapabilities */
3417 NULL
, /* pEllipse */
3419 NULL
, /* pEndPage */
3420 NULL
, /* pEndPath */
3421 NULL
, /* pEnumFonts */
3422 NULL
, /* pEnumICMProfiles */
3423 NULL
, /* pExcludeClipRect */
3424 NULL
, /* pExtDeviceMode */
3425 glxdrv_ExtEscape
, /* pExtEscape */
3426 NULL
, /* pExtFloodFill */
3427 NULL
, /* pExtSelectClipRgn */
3428 NULL
, /* pExtTextOut */
3429 NULL
, /* pFillPath */
3430 NULL
, /* pFillRgn */
3431 NULL
, /* pFlattenPath */
3432 NULL
, /* pFontIsLinked */
3433 NULL
, /* pFrameRgn */
3434 NULL
, /* pGdiComment */
3435 NULL
, /* pGdiRealizationInfo */
3436 NULL
, /* pGetBoundsRect */
3437 NULL
, /* pGetCharABCWidths */
3438 NULL
, /* pGetCharABCWidthsI */
3439 NULL
, /* pGetCharWidth */
3440 NULL
, /* pGetDeviceCaps */
3441 NULL
, /* pGetDeviceGammaRamp */
3442 NULL
, /* pGetFontData */
3443 NULL
, /* pGetFontUnicodeRanges */
3444 NULL
, /* pGetGlyphIndices */
3445 NULL
, /* pGetGlyphOutline */
3446 NULL
, /* pGetICMProfile */
3447 NULL
, /* pGetImage */
3448 NULL
, /* pGetKerningPairs */
3449 NULL
, /* pGetNearestColor */
3450 NULL
, /* pGetOutlineTextMetrics */
3451 NULL
, /* pGetPixel */
3452 NULL
, /* pGetSystemPaletteEntries */
3453 NULL
, /* pGetTextCharsetInfo */
3454 NULL
, /* pGetTextExtentExPoint */
3455 NULL
, /* pGetTextExtentExPointI */
3456 NULL
, /* pGetTextFace */
3457 NULL
, /* pGetTextMetrics */
3458 NULL
, /* pGradientFill */
3459 NULL
, /* pIntersectClipRect */
3460 NULL
, /* pInvertRgn */
3462 NULL
, /* pModifyWorldTransform */
3464 NULL
, /* pOffsetClipRgn */
3465 NULL
, /* pOffsetViewportOrg */
3466 NULL
, /* pOffsetWindowOrg */
3467 NULL
, /* pPaintRgn */
3470 NULL
, /* pPolyBezier */
3471 NULL
, /* pPolyBezierTo */
3472 NULL
, /* pPolyDraw */
3473 NULL
, /* pPolyPolygon */
3474 NULL
, /* pPolyPolyline */
3475 NULL
, /* pPolygon */
3476 NULL
, /* pPolyline */
3477 NULL
, /* pPolylineTo */
3478 NULL
, /* pPutImage */
3479 NULL
, /* pRealizeDefaultPalette */
3480 NULL
, /* pRealizePalette */
3481 NULL
, /* pRectangle */
3482 NULL
, /* pResetDC */
3483 NULL
, /* pRestoreDC */
3484 NULL
, /* pRoundRect */
3486 NULL
, /* pScaleViewportExt */
3487 NULL
, /* pScaleWindowExt */
3488 NULL
, /* pSelectBitmap */
3489 NULL
, /* pSelectBrush */
3490 NULL
, /* pSelectClipPath */
3491 NULL
, /* pSelectFont */
3492 NULL
, /* pSelectPalette */
3493 NULL
, /* pSelectPen */
3494 NULL
, /* pSetArcDirection */
3495 NULL
, /* pSetBkColor */
3496 NULL
, /* pSetBkMode */
3497 NULL
, /* pSetBoundsRect */
3498 NULL
, /* pSetDCBrushColor */
3499 NULL
, /* pSetDCPenColor */
3500 NULL
, /* pSetDIBitsToDevice */
3501 NULL
, /* pSetDeviceClipping */
3502 NULL
, /* pSetDeviceGammaRamp */
3503 NULL
, /* pSetLayout */
3504 NULL
, /* pSetMapMode */
3505 NULL
, /* pSetMapperFlags */
3506 NULL
, /* pSetPixel */
3507 glxdrv_SetPixelFormat
, /* pSetPixelFormat */
3508 NULL
, /* pSetPolyFillMode */
3509 NULL
, /* pSetROP2 */
3510 NULL
, /* pSetRelAbs */
3511 NULL
, /* pSetStretchBltMode */
3512 NULL
, /* pSetTextAlign */
3513 NULL
, /* pSetTextCharacterExtra */
3514 NULL
, /* pSetTextColor */
3515 NULL
, /* pSetTextJustification */
3516 NULL
, /* pSetViewportExt */
3517 NULL
, /* pSetViewportOrg */
3518 NULL
, /* pSetWindowExt */
3519 NULL
, /* pSetWindowOrg */
3520 NULL
, /* pSetWorldTransform */
3521 NULL
, /* pStartDoc */
3522 NULL
, /* pStartPage */
3523 NULL
, /* pStretchBlt */
3524 NULL
, /* pStretchDIBits */
3525 NULL
, /* pStrokeAndFillPath */
3526 NULL
, /* pStrokePath */
3527 glxdrv_SwapBuffers
, /* pSwapBuffers */
3528 NULL
, /* pUnrealizePalette */
3529 NULL
, /* pWidenPath */
3530 glxdrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
3531 GDI_PRIORITY_GRAPHICS_DRV
+ 20 /* priority */
3534 static const struct wgl_funcs glxdrv_wgl_funcs
=
3536 glxdrv_GetPixelFormat
, /* p_GetPixelFormat */
3537 glxdrv_wglCopyContext
, /* p_wglCopyContext */
3538 glxdrv_wglCreateContext
, /* p_wglCreateContext */
3539 glxdrv_wglCreateContextAttribsARB
, /* p_wglCreateContextAttribsARB */
3540 glxdrv_wglDeleteContext
, /* p_wglDeleteContext */
3541 glxdrv_wglGetCurrentDC
, /* p_wglGetCurrentDC */
3542 glxdrv_wglGetProcAddress
, /* p_wglGetProcAddress */
3543 glxdrv_wglMakeContextCurrentARB
, /* p_wglMakeContextCurrentARB */
3544 glxdrv_wglMakeCurrent
, /* p_wglMakeCurrent */
3545 glxdrv_wglShareLists
, /* p_wglShareLists */
3548 const struct gdi_dc_funcs
*get_glx_driver(void)
3550 return &glxdrv_funcs
;
3553 #else /* no OpenGL includes */
3555 const struct gdi_dc_funcs
*get_glx_driver(void)
3560 void mark_drawable_dirty(Drawable old
, Drawable
new)
3564 Drawable
create_glxpixmap(Display
*display
, XVisualInfo
*vis
, Pixmap parent
)
3570 BOOL
destroy_glxpixmap(Display
*display
, XID glxpixmap
)
3575 XVisualInfo
*visual_from_fbconfig_id( XID fbconfig_id
)
3580 #endif /* defined(SONAME_LIBGL) */