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 */
113 typedef struct wine_glcontext
{
115 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 inline BOOL
is_valid_context( Wine_GLContext
*ctx
)
619 LIST_FOR_EACH_ENTRY( ptr
, &context_list
, struct wine_glcontext
, entry
)
620 if (ptr
== ctx
) return TRUE
;
624 static int describeContext(Wine_GLContext
* ctx
) {
627 TRACE(" Context %p have (vis:%p):\n", ctx
, ctx
->vis
);
628 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_FBCONFIG_ID
, &tmp
);
629 TRACE(" - FBCONFIG_ID 0x%x\n", tmp
);
630 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_VISUAL_ID
, &tmp
);
631 TRACE(" - VISUAL_ID 0x%x\n", tmp
);
636 static int ConvertAttribWGLtoGLX(const int* iWGLAttr
, int* oGLXAttr
, Wine_GLPBuffer
* pbuf
) {
641 int nvfloatattrib
= GLX_DONT_CARE
;
642 int pixelattrib
= GLX_DONT_CARE
;
644 /* The list of WGL attributes is allowed to be NULL. We don't return here for NULL
645 * because we need to do fixups for GLX_DRAWABLE_TYPE/GLX_RENDER_TYPE/GLX_FLOAT_COMPONENTS_NV. */
646 while (iWGLAttr
&& 0 != iWGLAttr
[cur
]) {
647 TRACE("pAttr[%d] = %x\n", cur
, iWGLAttr
[cur
]);
649 switch (iWGLAttr
[cur
]) {
650 case WGL_AUX_BUFFERS_ARB
:
651 pop
= iWGLAttr
[++cur
];
652 PUSH2(oGLXAttr
, GLX_AUX_BUFFERS
, pop
);
653 TRACE("pAttr[%d] = GLX_AUX_BUFFERS: %d\n", cur
, pop
);
655 case WGL_COLOR_BITS_ARB
:
656 pop
= iWGLAttr
[++cur
];
657 PUSH2(oGLXAttr
, GLX_BUFFER_SIZE
, pop
);
658 TRACE("pAttr[%d] = GLX_BUFFER_SIZE: %d\n", cur
, pop
);
660 case WGL_BLUE_BITS_ARB
:
661 pop
= iWGLAttr
[++cur
];
662 PUSH2(oGLXAttr
, GLX_BLUE_SIZE
, pop
);
663 TRACE("pAttr[%d] = GLX_BLUE_SIZE: %d\n", cur
, pop
);
665 case WGL_RED_BITS_ARB
:
666 pop
= iWGLAttr
[++cur
];
667 PUSH2(oGLXAttr
, GLX_RED_SIZE
, pop
);
668 TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur
, pop
);
670 case WGL_GREEN_BITS_ARB
:
671 pop
= iWGLAttr
[++cur
];
672 PUSH2(oGLXAttr
, GLX_GREEN_SIZE
, pop
);
673 TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur
, pop
);
675 case WGL_ALPHA_BITS_ARB
:
676 pop
= iWGLAttr
[++cur
];
677 PUSH2(oGLXAttr
, GLX_ALPHA_SIZE
, pop
);
678 TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur
, pop
);
680 case WGL_DEPTH_BITS_ARB
:
681 pop
= iWGLAttr
[++cur
];
682 PUSH2(oGLXAttr
, GLX_DEPTH_SIZE
, pop
);
683 TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur
, pop
);
685 case WGL_STENCIL_BITS_ARB
:
686 pop
= iWGLAttr
[++cur
];
687 PUSH2(oGLXAttr
, GLX_STENCIL_SIZE
, pop
);
688 TRACE("pAttr[%d] = GLX_STENCIL_SIZE: %d\n", cur
, pop
);
690 case WGL_DOUBLE_BUFFER_ARB
:
691 pop
= iWGLAttr
[++cur
];
692 PUSH2(oGLXAttr
, GLX_DOUBLEBUFFER
, pop
);
693 TRACE("pAttr[%d] = GLX_DOUBLEBUFFER: %d\n", cur
, pop
);
696 pop
= iWGLAttr
[++cur
];
697 PUSH2(oGLXAttr
, GLX_STEREO
, pop
);
698 TRACE("pAttr[%d] = GLX_STEREO: %d\n", cur
, pop
);
701 case WGL_PIXEL_TYPE_ARB
:
702 pop
= iWGLAttr
[++cur
];
703 TRACE("pAttr[%d] = WGL_PIXEL_TYPE_ARB: %d\n", cur
, pop
);
705 case WGL_TYPE_COLORINDEX_ARB
: pixelattrib
= GLX_COLOR_INDEX_BIT
; break ;
706 case WGL_TYPE_RGBA_ARB
: pixelattrib
= GLX_RGBA_BIT
; break ;
707 /* 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 */
708 case WGL_TYPE_RGBA_FLOAT_ATI
: pixelattrib
= GLX_RGBA_FLOAT_BIT
; break ;
709 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
: pixelattrib
= GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
; break ;
711 ERR("unexpected PixelType(%x)\n", pop
);
716 case WGL_SUPPORT_GDI_ARB
:
717 /* This flag is set in a WineGLPixelFormat */
718 pop
= iWGLAttr
[++cur
];
719 TRACE("pAttr[%d] = WGL_SUPPORT_GDI_ARB: %d\n", cur
, pop
);
722 case WGL_DRAW_TO_BITMAP_ARB
:
723 /* This flag is set in a WineGLPixelFormat */
724 pop
= iWGLAttr
[++cur
];
725 TRACE("pAttr[%d] = WGL_DRAW_TO_BITMAP_ARB: %d\n", cur
, pop
);
728 case WGL_DRAW_TO_WINDOW_ARB
:
729 pop
= iWGLAttr
[++cur
];
730 TRACE("pAttr[%d] = WGL_DRAW_TO_WINDOW_ARB: %d\n", cur
, pop
);
731 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
733 drawattrib
|= GLX_WINDOW_BIT
;
737 case WGL_DRAW_TO_PBUFFER_ARB
:
738 pop
= iWGLAttr
[++cur
];
739 TRACE("pAttr[%d] = WGL_DRAW_TO_PBUFFER_ARB: %d\n", cur
, pop
);
740 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
742 drawattrib
|= GLX_PBUFFER_BIT
;
746 case WGL_ACCELERATION_ARB
:
747 /* This flag is set in a WineGLPixelFormat */
748 pop
= iWGLAttr
[++cur
];
749 TRACE("pAttr[%d] = WGL_ACCELERATION_ARB: %d\n", cur
, pop
);
752 case WGL_SUPPORT_OPENGL_ARB
:
753 pop
= iWGLAttr
[++cur
];
754 /** nothing to do, if we are here, supposing support Accelerated OpenGL */
755 TRACE("pAttr[%d] = WGL_SUPPORT_OPENGL_ARB: %d\n", cur
, pop
);
758 case WGL_SWAP_METHOD_ARB
:
759 pop
= iWGLAttr
[++cur
];
760 /* For now we ignore this and just return SWAP_EXCHANGE */
761 TRACE("pAttr[%d] = WGL_SWAP_METHOD_ARB: %#x\n", cur
, pop
);
764 case WGL_PBUFFER_LARGEST_ARB
:
765 pop
= iWGLAttr
[++cur
];
766 PUSH2(oGLXAttr
, GLX_LARGEST_PBUFFER
, pop
);
767 TRACE("pAttr[%d] = GLX_LARGEST_PBUFFER: %x\n", cur
, pop
);
770 case WGL_SAMPLE_BUFFERS_ARB
:
771 pop
= iWGLAttr
[++cur
];
772 PUSH2(oGLXAttr
, GLX_SAMPLE_BUFFERS_ARB
, pop
);
773 TRACE("pAttr[%d] = GLX_SAMPLE_BUFFERS_ARB: %x\n", cur
, pop
);
776 case WGL_SAMPLES_ARB
:
777 pop
= iWGLAttr
[++cur
];
778 PUSH2(oGLXAttr
, GLX_SAMPLES_ARB
, pop
);
779 TRACE("pAttr[%d] = GLX_SAMPLES_ARB: %x\n", cur
, pop
);
782 case WGL_TEXTURE_FORMAT_ARB
:
783 case WGL_TEXTURE_TARGET_ARB
:
784 case WGL_MIPMAP_TEXTURE_ARB
:
785 TRACE("WGL_render_texture Attributes: %x as %x\n", iWGLAttr
[cur
], iWGLAttr
[cur
+ 1]);
786 pop
= iWGLAttr
[++cur
];
788 ERR("trying to use GLX_Pbuffer Attributes without Pbuffer (was %x)\n", iWGLAttr
[cur
]);
790 if (!use_render_texture_emulation
) {
791 if (WGL_NO_TEXTURE_ARB
!= pop
) {
792 ERR("trying to use WGL_render_texture Attributes without support (was %x)\n", iWGLAttr
[cur
]);
793 return -1; /** error: don't support it */
795 drawattrib
|= GLX_PBUFFER_BIT
;
799 case WGL_FLOAT_COMPONENTS_NV
:
800 nvfloatattrib
= iWGLAttr
[++cur
];
801 TRACE("pAttr[%d] = WGL_FLOAT_COMPONENTS_NV: %x\n", cur
, nvfloatattrib
);
803 case WGL_BIND_TO_TEXTURE_DEPTH_NV
:
804 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
805 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
806 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV
:
807 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV
:
808 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV
:
809 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV
:
810 pop
= iWGLAttr
[++cur
];
811 /** cannot be converted, see direct handling on
812 * - wglGetPixelFormatAttribivARB
813 * TODO: wglChoosePixelFormat
816 case WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT
:
817 pop
= iWGLAttr
[++cur
];
818 PUSH2(oGLXAttr
, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
, pop
);
819 TRACE("pAttr[%d] = GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT: %x\n", cur
, pop
);
822 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
:
823 pop
= iWGLAttr
[++cur
];
824 PUSH2(oGLXAttr
, GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
, pop
);
825 TRACE("pAttr[%d] = GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT: %x\n", cur
, pop
);
828 FIXME("unsupported %x WGL Attribute\n", iWGLAttr
[cur
]);
834 /* By default glXChooseFBConfig defaults to GLX_WINDOW_BIT. wglChoosePixelFormatARB searches through
835 * all formats. Unless drawattrib is set to a non-zero value override it with GLX_DONT_CARE, so that
836 * pixmap and pbuffer formats appear as well. */
837 if (!drawattrib
) drawattrib
= GLX_DONT_CARE
;
838 PUSH2(oGLXAttr
, GLX_DRAWABLE_TYPE
, drawattrib
);
839 TRACE("pAttr[?] = GLX_DRAWABLE_TYPE: %#x\n", drawattrib
);
841 /* By default glXChooseFBConfig uses GLX_RGBA_BIT as the default value. Since wglChoosePixelFormatARB
842 * searches in all formats we have to do the same. For this reason we set GLX_RENDER_TYPE to
843 * GLX_DONT_CARE unless it is overridden. */
844 PUSH2(oGLXAttr
, GLX_RENDER_TYPE
, pixelattrib
);
845 TRACE("pAttr[?] = GLX_RENDER_TYPE: %#x\n", pixelattrib
);
847 /* Set GLX_FLOAT_COMPONENTS_NV all the time */
848 if(strstr(WineGLInfo
.glxExtensions
, "GLX_NV_float_buffer")) {
849 PUSH2(oGLXAttr
, GLX_FLOAT_COMPONENTS_NV
, nvfloatattrib
);
850 TRACE("pAttr[?] = GLX_FLOAT_COMPONENTS_NV: %#x\n", nvfloatattrib
);
856 static int get_render_type_from_fbconfig(Display
*display
, GLXFBConfig fbconfig
)
858 int render_type
=0, render_type_bit
;
859 pglXGetFBConfigAttrib(display
, fbconfig
, GLX_RENDER_TYPE
, &render_type_bit
);
860 switch(render_type_bit
)
863 render_type
= GLX_RGBA_TYPE
;
865 case GLX_COLOR_INDEX_BIT
:
866 render_type
= GLX_COLOR_INDEX_TYPE
;
868 case GLX_RGBA_FLOAT_BIT
:
869 render_type
= GLX_RGBA_FLOAT_TYPE
;
871 case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
:
872 render_type
= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
;
875 ERR("Unknown render_type: %x\n", render_type_bit
);
880 /* Check whether a fbconfig is suitable for Windows-style bitmap rendering */
881 static BOOL
check_fbconfig_bitmap_capability(Display
*display
, GLXFBConfig fbconfig
)
884 pglXGetFBConfigAttrib(display
, fbconfig
, GLX_DOUBLEBUFFER
, &dbuf
);
885 pglXGetFBConfigAttrib(gdi_display
, fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
887 /* Windows only supports bitmap rendering on single buffered formats, further the fbconfig needs to have
888 * the GLX_PIXMAP_BIT set. */
889 return !dbuf
&& (value
& GLX_PIXMAP_BIT
);
892 static WineGLPixelFormat
*get_formats(Display
*display
, int *size_ret
, int *onscreen_size_ret
)
894 static WineGLPixelFormat
*list
;
895 static int size
, onscreen_size
;
897 int fmt_id
, nCfgs
, i
, run
, bmp_formats
;
899 XVisualInfo
*visinfo
;
904 cfgs
= pglXGetFBConfigs(display
, DefaultScreen(display
), &nCfgs
);
905 if (NULL
== cfgs
|| 0 == nCfgs
) {
906 if(cfgs
!= NULL
) XFree(cfgs
);
908 ERR("glXChooseFBConfig returns NULL\n");
912 /* Bitmap rendering on Windows implies the use of the Microsoft GDI software renderer.
913 * Further most GLX drivers only offer pixmap rendering using indirect rendering (except for modern drivers which support 'AIGLX' / composite).
914 * Indirect rendering can indicate software rendering (on Nvidia it is hw accelerated)
915 * Since bitmap rendering implies the use of software rendering we can safely use indirect rendering for bitmaps.
917 * Below we count the number of formats which are suitable for bitmap rendering. Windows restricts bitmap rendering to single buffered formats.
919 for(i
=0, bmp_formats
=0; i
<nCfgs
; i
++)
921 if(check_fbconfig_bitmap_capability(display
, cfgs
[i
]))
924 TRACE("Found %d bitmap capable fbconfigs\n", bmp_formats
);
926 list
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (nCfgs
+ bmp_formats
)*sizeof(WineGLPixelFormat
));
928 /* Fill the pixel format list. Put onscreen formats at the top and offscreen ones at the bottom.
929 * Do this as GLX doesn't guarantee that the list is sorted */
930 for(run
=0; run
< 2; run
++)
932 for(i
=0; i
<nCfgs
; i
++) {
933 pglXGetFBConfigAttrib(display
, cfgs
[i
], GLX_FBCONFIG_ID
, &fmt_id
);
934 visinfo
= pglXGetVisualFromFBConfig(display
, cfgs
[i
]);
936 /* The first run we only add onscreen formats (ones which have an associated X Visual).
937 * The second run we only set offscreen formats. */
940 /* We implement child window rendering using offscreen buffers (using composite or an XPixmap).
941 * The contents is copied to the destination using XCopyArea. For the copying to work
942 * the depth of the source and destination window should be the same. In general this should
943 * not be a problem for OpenGL as drivers only advertise formats with a similar depth (or no depth).
944 * As of the introduction of composition managers at least Nvidia now also offers ARGB visuals
945 * with a depth of 32 in addition to the default 24 bit. In order to prevent BadMatch errors we only
946 * list formats with the same depth. */
947 if(visinfo
->depth
!= screen_depth
)
953 TRACE("Found onscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
954 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
955 list
[size
].fbconfig
= cfgs
[i
];
956 list
[size
].fmt_id
= fmt_id
;
957 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
958 list
[size
].offscreenOnly
= FALSE
;
959 list
[size
].dwFlags
= 0;
963 /* Clone a format if it is bitmap capable for indirect rendering to bitmaps */
964 if(check_fbconfig_bitmap_capability(display
, cfgs
[i
]))
966 TRACE("Found bitmap capable format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
967 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
968 list
[size
].fbconfig
= cfgs
[i
];
969 list
[size
].fmt_id
= fmt_id
;
970 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
971 list
[size
].offscreenOnly
= FALSE
;
972 list
[size
].dwFlags
= PFD_DRAW_TO_BITMAP
| PFD_SUPPORT_GDI
| PFD_GENERIC_FORMAT
;
976 } else if(run
&& !visinfo
) {
977 int window_drawable
=0;
978 pglXGetFBConfigAttrib(gdi_display
, cfgs
[i
], GLX_DRAWABLE_TYPE
, &window_drawable
);
980 /* Recent Nvidia drivers and DRI drivers offer window drawable formats without a visual.
981 * This are formats like 16-bit rgb on a 24-bit desktop. In order to support these formats
982 * onscreen we would have to use glXCreateWindow instead of XCreateWindow. Further it will
983 * likely make our child window opengl rendering more complicated since likely you can't use
984 * XCopyArea on a GLX Window.
985 * For now ignore fbconfigs which are window drawable but lack a visual. */
986 if(window_drawable
& GLX_WINDOW_BIT
)
988 TRACE("Skipping FBCONFIG_ID 0x%x as an offscreen format because it is window_drawable\n", fmt_id
);
992 TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
993 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
994 list
[size
].fbconfig
= cfgs
[i
];
995 list
[size
].fmt_id
= fmt_id
;
996 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
997 list
[size
].offscreenOnly
= TRUE
;
998 list
[size
].dwFlags
= 0;
1002 if (visinfo
) XFree(visinfo
);
1009 if (size_ret
) *size_ret
= size
;
1010 if (onscreen_size_ret
) *onscreen_size_ret
= onscreen_size
;
1011 wine_tsx11_unlock();
1015 /* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
1016 * In our WGL implementation we only support a subset of these formats namely the format of
1017 * Wine's main visual and offscreen formats (if they are available).
1018 * This function converts a WGL format to its corresponding GLX one. It returns a WineGLPixelFormat
1019 * and it returns the number of supported WGL formats in fmt_count.
1021 static WineGLPixelFormat
* ConvertPixelFormatWGLtoGLX(Display
*display
, int iPixelFormat
, BOOL AllowOffscreen
, int *fmt_count
)
1023 WineGLPixelFormat
*list
, *res
= NULL
;
1024 int size
, onscreen_size
;
1026 if (!(list
= get_formats(display
, &size
, &onscreen_size
))) return NULL
;
1028 /* Check if the pixelformat is valid. Note that it is legal to pass an invalid
1029 * iPixelFormat in case of probing the number of pixelformats.
1031 if((iPixelFormat
> 0) && (iPixelFormat
<= size
) &&
1032 (!list
[iPixelFormat
-1].offscreenOnly
|| AllowOffscreen
)) {
1033 res
= &list
[iPixelFormat
-1];
1034 TRACE("Returning fmt_id=%#x for iPixelFormat=%d\n", res
->fmt_id
, iPixelFormat
);
1040 *fmt_count
= onscreen_size
;
1042 TRACE("Number of returned pixelformats=%d\n", *fmt_count
);
1047 /* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
1048 static WineGLPixelFormat
* ConvertPixelFormatGLXtoWGL(Display
*display
, int fmt_id
, DWORD dwFlags
)
1050 WineGLPixelFormat
*list
;
1053 if (!(list
= get_formats(display
, &size
, NULL
))) return NULL
;
1055 for(i
=0; i
<size
; i
++) {
1056 /* A GLX format can appear multiple times in the pixel format list due to fake formats for bitmap rendering.
1057 * Fake formats might get selected when the user passes the proper flags using the dwFlags parameter. */
1058 if( (list
[i
].fmt_id
== fmt_id
) && ((list
[i
].dwFlags
& dwFlags
) == dwFlags
) ) {
1059 TRACE("Returning iPixelFormat %d for fmt_id 0x%x\n", list
[i
].iPixelFormat
, fmt_id
);
1063 TRACE("No compatible format found for fmt_id 0x%x\n", fmt_id
);
1067 static int pixelformat_from_fbconfig_id(XID fbconfig_id
)
1069 WineGLPixelFormat
*fmt
;
1071 if (!fbconfig_id
) return 0;
1073 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fbconfig_id
, 0 /* no flags */);
1075 return fmt
->iPixelFormat
;
1076 /* This will happen on hwnds without a pixel format set; it's ok */
1081 /* Mark any allocated context using the glx drawable 'old' to use 'new' */
1082 void mark_drawable_dirty(Drawable old
, Drawable
new)
1084 Wine_GLContext
*ctx
;
1085 LIST_FOR_EACH_ENTRY( ctx
, &context_list
, struct wine_glcontext
, entry
)
1087 if (old
== ctx
->drawables
[0]) {
1088 ctx
->drawables
[0] = new;
1089 ctx
->refresh_drawables
= TRUE
;
1091 if (old
== ctx
->drawables
[1]) {
1092 ctx
->drawables
[1] = new;
1093 ctx
->refresh_drawables
= TRUE
;
1098 /* Given the current context, make sure its drawable is sync'd */
1099 static inline void sync_context(Wine_GLContext
*context
)
1101 if(context
&& context
->refresh_drawables
) {
1102 if (glxRequireVersion(3))
1103 pglXMakeContextCurrent(gdi_display
, context
->drawables
[0],
1104 context
->drawables
[1], context
->ctx
);
1106 pglXMakeCurrent(gdi_display
, context
->drawables
[0], context
->ctx
);
1107 context
->refresh_drawables
= FALSE
;
1112 static GLXContext
create_glxcontext(Display
*display
, Wine_GLContext
*context
, GLXContext shareList
)
1116 /* We use indirect rendering for rendering to bitmaps. See get_formats for a comment about this. */
1117 BOOL indirect
= (context
->fmt
->dwFlags
& PFD_DRAW_TO_BITMAP
) ? FALSE
: TRUE
;
1119 if(context
->gl3_context
)
1121 if(context
->numAttribs
)
1122 ctx
= pglXCreateContextAttribsARB(gdi_display
, context
->fmt
->fbconfig
, shareList
, indirect
, context
->attribList
);
1124 ctx
= pglXCreateContextAttribsARB(gdi_display
, context
->fmt
->fbconfig
, shareList
, indirect
, NULL
);
1126 else if(context
->vis
)
1127 ctx
= pglXCreateContext(gdi_display
, context
->vis
, shareList
, indirect
);
1128 else /* Create a GLX Context for a pbuffer */
1129 ctx
= pglXCreateNewContext(gdi_display
, context
->fmt
->fbconfig
, context
->fmt
->render_type
, shareList
, TRUE
);
1135 Drawable
create_glxpixmap(Display
*display
, XVisualInfo
*vis
, Pixmap parent
)
1137 return pglXCreateGLXPixmap(display
, vis
, parent
);
1142 * glxdrv_DescribePixelFormat
1144 * Get the pixel-format descriptor associated to the given id
1146 static int glxdrv_DescribePixelFormat(PHYSDEV dev
, int iPixelFormat
,
1147 UINT nBytes
, PIXELFORMATDESCRIPTOR
*ppfd
)
1149 /*XVisualInfo *vis;*/
1152 WineGLPixelFormat
*fmt
;
1156 if (!has_opengl()) return 0;
1158 TRACE("(%p,%d,%d,%p)\n", dev
->hdc
, iPixelFormat
, nBytes
, ppfd
);
1160 /* 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 */
1161 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, FALSE
/* Offscreen */, &fmt_count
);
1163 /* The application is only querying the number of pixelformats */
1165 } else if(fmt
== NULL
) {
1166 WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat
, fmt_count
);
1170 if (nBytes
< sizeof(PIXELFORMATDESCRIPTOR
)) {
1171 ERR("Wrong structure size !\n");
1172 /* Should set error */
1178 memset(ppfd
, 0, sizeof(PIXELFORMATDESCRIPTOR
));
1179 ppfd
->nSize
= sizeof(PIXELFORMATDESCRIPTOR
);
1182 /* These flags are always the same... */
1183 ppfd
->dwFlags
= PFD_SUPPORT_OPENGL
;
1184 /* Now the flags extracted from the Visual */
1188 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1189 if(value
& GLX_WINDOW_BIT
)
1190 ppfd
->dwFlags
|= PFD_DRAW_TO_WINDOW
;
1192 /* On Windows bitmap rendering is only offered using the GDI Software renderer. We reserve some formats (see get_formats for more info)
1193 * for bitmap rendering since we require indirect rendering for this. Further pixel format logs of a GeforceFX, Geforce8800GT, Radeon HD3400 and a
1194 * 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
1195 * offered the GDI bit either. */
1196 ppfd
->dwFlags
|= fmt
->dwFlags
& (PFD_DRAW_TO_BITMAP
| PFD_SUPPORT_GDI
);
1198 /* PFD_GENERIC_FORMAT - gdi software rendering
1199 * PFD_GENERIC_ACCELERATED - some parts are accelerated by a display driver (MCD e.g. 3dfx minigl)
1200 * none set - full hardware accelerated by a ICD
1202 * We only set PFD_GENERIC_FORMAT on bitmap formats (see get_formats) as that's what ATI and Nvidia Windows drivers do */
1203 ppfd
->dwFlags
|= fmt
->dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
);
1205 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DOUBLEBUFFER
, &value
);
1207 ppfd
->dwFlags
|= PFD_DOUBLEBUFFER
;
1208 ppfd
->dwFlags
&= ~PFD_SUPPORT_GDI
;
1210 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STEREO
, &value
); if (value
) ppfd
->dwFlags
|= PFD_STEREO
;
1213 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_RENDER_TYPE
, &value
);
1214 if (value
& GLX_RGBA_BIT
)
1215 ppfd
->iPixelType
= PFD_TYPE_RGBA
;
1217 ppfd
->iPixelType
= PFD_TYPE_COLORINDEX
;
1220 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_BUFFER_SIZE
, &value
);
1221 ppfd
->cColorBits
= value
;
1223 /* Red, green, blue and alpha bits / shifts */
1224 if (ppfd
->iPixelType
== PFD_TYPE_RGBA
) {
1225 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_RED_SIZE
, &rb
);
1226 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_GREEN_SIZE
, &gb
);
1227 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_BLUE_SIZE
, &bb
);
1228 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ALPHA_SIZE
, &ab
);
1230 ppfd
->cRedBits
= rb
;
1231 ppfd
->cRedShift
= gb
+ bb
+ ab
;
1232 ppfd
->cBlueBits
= bb
;
1233 ppfd
->cBlueShift
= ab
;
1234 ppfd
->cGreenBits
= gb
;
1235 ppfd
->cGreenShift
= bb
+ ab
;
1236 ppfd
->cAlphaBits
= ab
;
1237 ppfd
->cAlphaShift
= 0;
1240 ppfd
->cRedShift
= 0;
1241 ppfd
->cBlueBits
= 0;
1242 ppfd
->cBlueShift
= 0;
1243 ppfd
->cGreenBits
= 0;
1244 ppfd
->cGreenShift
= 0;
1245 ppfd
->cAlphaBits
= 0;
1246 ppfd
->cAlphaShift
= 0;
1249 /* Accum RGBA bits */
1250 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_RED_SIZE
, &rb
);
1251 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_GREEN_SIZE
, &gb
);
1252 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_BLUE_SIZE
, &bb
);
1253 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_ALPHA_SIZE
, &ab
);
1255 ppfd
->cAccumBits
= rb
+gb
+bb
+ab
;
1256 ppfd
->cAccumRedBits
= rb
;
1257 ppfd
->cAccumGreenBits
= gb
;
1258 ppfd
->cAccumBlueBits
= bb
;
1259 ppfd
->cAccumAlphaBits
= ab
;
1262 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_AUX_BUFFERS
, &value
);
1263 ppfd
->cAuxBuffers
= value
;
1266 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DEPTH_SIZE
, &value
);
1267 ppfd
->cDepthBits
= value
;
1270 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STENCIL_SIZE
, &value
);
1271 ppfd
->cStencilBits
= value
;
1273 wine_tsx11_unlock();
1275 ppfd
->iLayerType
= PFD_MAIN_PLANE
;
1277 if (TRACE_ON(wgl
)) {
1278 dump_PIXELFORMATDESCRIPTOR(ppfd
);
1285 * glxdrv_GetPixelFormat
1287 * Get the pixel-format id used by this DC
1289 static int glxdrv_GetPixelFormat(PHYSDEV dev
)
1291 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1292 WineGLPixelFormat
*fmt
;
1295 if (!physdev
->pixel_format
) return 0; /* not set yet */
1297 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, physdev
->pixel_format
, TRUE
, &tmp
);
1300 ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", physdev
->pixel_format
);
1303 else if(fmt
->offscreenOnly
)
1305 /* Offscreen formats can't be used with traditional WGL calls.
1306 * As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
1307 TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt
->iPixelFormat
);
1311 TRACE("(%p): returns %d\n", dev
->hdc
, physdev
->pixel_format
);
1312 return physdev
->pixel_format
;
1316 * glxdrv_SetPixelFormat
1318 * Set the pixel-format id used by this DC
1320 static BOOL
glxdrv_SetPixelFormat(PHYSDEV dev
, int iPixelFormat
, const PIXELFORMATDESCRIPTOR
*ppfd
)
1322 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1323 WineGLPixelFormat
*fmt
;
1327 TRACE("(%p,%d,%p)\n", dev
->hdc
, iPixelFormat
, ppfd
);
1329 if (!has_opengl()) return FALSE
;
1331 if(physdev
->pixel_format
) /* cannot change it if already set */
1332 return (physdev
->pixel_format
== iPixelFormat
);
1334 /* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */
1335 if(physdev
->x11dev
->drawable
== root_window
)
1337 ERR("Invalid operation on root_window\n");
1341 /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
1342 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, FALSE
/* Offscreen */, &value
);
1344 ERR("Invalid iPixelFormat: %d\n", iPixelFormat
);
1349 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1350 wine_tsx11_unlock();
1352 hwnd
= WindowFromDC(physdev
->dev
.hdc
);
1354 if(!(value
&GLX_WINDOW_BIT
)) {
1355 WARN("Pixel format %d is not compatible for window rendering\n", iPixelFormat
);
1359 if(!SendMessageW(hwnd
, WM_X11DRV_SET_WIN_FORMAT
, fmt
->fmt_id
, 0)) {
1360 ERR("Couldn't set format of the window, returning failure\n");
1363 /* physDev->current_pf will be set by the DCE update */
1365 else if (GetObjectType( physdev
->dev
.hdc
) == OBJ_MEMDC
) {
1366 if(!(value
&GLX_PIXMAP_BIT
)) {
1367 WARN("Pixel format %d is not compatible for bitmap rendering\n", iPixelFormat
);
1371 physdev
->pixel_format
= iPixelFormat
;
1372 physdev
->type
= DC_GL_BITMAP
;
1375 FIXME("called on a non-window, non-bitmap object?\n");
1378 if (TRACE_ON(wgl
)) {
1382 gl_test
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_FBCONFIG_ID
, &value
);
1384 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
1386 TRACE(" FBConfig have :\n");
1387 TRACE(" - FBCONFIG_ID 0x%x\n", value
);
1388 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_VISUAL_ID
, &value
);
1389 TRACE(" - VISUAL_ID 0x%x\n", value
);
1390 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1391 TRACE(" - DRAWABLE_TYPE 0x%x\n", value
);
1393 wine_tsx11_unlock();
1398 /***********************************************************************
1399 * glxdrv_wglCopyContext
1401 static BOOL
glxdrv_wglCopyContext(HGLRC hglrcSrc
, HGLRC hglrcDst
, UINT mask
)
1403 Wine_GLContext
*src
= (Wine_GLContext
*)hglrcSrc
;
1404 Wine_GLContext
*dst
= (Wine_GLContext
*)hglrcDst
;
1406 TRACE("hglrcSrc: (%p), hglrcDst: (%p), mask: %#x\n", hglrcSrc
, hglrcDst
, mask
);
1409 pglXCopyContext(gdi_display
, src
->ctx
, dst
->ctx
, mask
);
1410 wine_tsx11_unlock();
1412 /* As opposed to wglCopyContext, glXCopyContext doesn't return anything, so hopefully we passed */
1417 * X11DRV_wglCreateContext
1419 * For OpenGL32 wglCreateContext.
1421 static HGLRC
glxdrv_wglCreateContext(PHYSDEV dev
)
1423 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1424 Wine_GLContext
*ret
;
1425 WineGLPixelFormat
*fmt
;
1428 TRACE("(%p)->(PF:%d)\n", dev
->hdc
, physdev
->pixel_format
);
1430 if (!has_opengl()) return 0;
1432 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, physdev
->pixel_format
, TRUE
/* Offscreen */, &fmt_count
);
1433 /* We can render using the iPixelFormat (1) of Wine's Main visual AND using some offscreen formats.
1434 * Note that standard WGL-calls don't recognize offscreen-only formats. For that reason pbuffers
1435 * use a sort of 'proxy' HDC (wglGetPbufferDCARB).
1436 * If this fails something is very wrong on the system. */
1438 ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", physdev
->pixel_format
);
1439 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1443 if (!(ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
)))) return 0;
1445 ret
->hdc
= dev
->hdc
;
1447 ret
->has_been_current
= FALSE
;
1448 ret
->sharing
= FALSE
;
1451 ret
->vis
= pglXGetVisualFromFBConfig(gdi_display
, fmt
->fbconfig
);
1452 ret
->ctx
= create_glxcontext(gdi_display
, ret
, NULL
);
1453 list_add_head( &context_list
, &ret
->entry
);
1454 wine_tsx11_unlock();
1456 TRACE(" creating context %p (GL context creation delayed)\n", ret
);
1460 /***********************************************************************
1461 * glxdrv_wglDeleteContext
1463 static BOOL
glxdrv_wglDeleteContext(HGLRC hglrc
)
1465 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1467 TRACE("(%p)\n", hglrc
);
1469 if (!is_valid_context(ctx
))
1471 WARN("Error deleting context !\n");
1472 SetLastError(ERROR_INVALID_HANDLE
);
1476 /* WGL doesn't allow deletion of a context which is current in another thread */
1477 if (ctx
->tid
!= 0 && ctx
->tid
!= GetCurrentThreadId())
1479 TRACE("Cannot delete context=%p because it is current in another thread.\n", ctx
);
1480 SetLastError(ERROR_BUSY
);
1484 /* WGL makes a context not current if it is active before deletion. GLX waits until the context is not current. */
1485 if (ctx
== NtCurrentTeb()->glContext
)
1488 pglXMakeCurrent(gdi_display
, None
, NULL
);
1489 wine_tsx11_unlock();
1490 NtCurrentTeb()->glContext
= NULL
;
1494 list_remove( &ctx
->entry
);
1495 if (ctx
->ctx
) pglXDestroyContext( gdi_display
, ctx
->ctx
);
1496 if (ctx
->glxpixmap
) pglXDestroyGLXPixmap( gdi_display
, ctx
->glxpixmap
);
1497 if (ctx
->pixmap
) XFreePixmap( gdi_display
, ctx
->pixmap
);
1498 if (ctx
->vis
) XFree( ctx
->vis
);
1499 wine_tsx11_unlock();
1501 HeapFree( GetProcessHeap(), 0, ctx
);
1506 * X11DRV_wglGetCurrentReadDCARB
1508 * For OpenGL32 wglGetCurrentReadDCARB.
1510 static HDC WINAPI
X11DRV_wglGetCurrentReadDCARB(void)
1513 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
1515 if (ctx
) ret
= ctx
->read_hdc
;
1517 TRACE(" returning %p (GL drawable %lu)\n", ret
, ctx
? ctx
->drawables
[1] : 0);
1522 * glxdrv_wglGetProcAddress
1524 * For OpenGL32 wglGetProcAddress.
1526 static PROC
glxdrv_wglGetProcAddress(LPCSTR lpszProc
)
1529 const WineGLExtension
*ext
;
1531 int padding
= 32 - strlen(lpszProc
);
1535 if (!has_opengl()) return NULL
;
1537 /* Check the table of WGL extensions to see if we need to return a WGL extension
1538 * or a function pointer to a native OpenGL function. */
1539 if(strncmp(lpszProc
, "wgl", 3) != 0) {
1540 return pglXGetProcAddressARB((const GLubyte
*)lpszProc
);
1542 TRACE("('%s'):%*s", lpszProc
, padding
, " ");
1543 for (i
= 0; i
< WineGLExtensionListSize
; ++i
) {
1544 ext
= WineGLExtensionList
[i
];
1545 for (j
= 0; ext
->extEntryPoints
[j
].funcName
; ++j
) {
1546 if (strcmp(ext
->extEntryPoints
[j
].funcName
, lpszProc
) == 0) {
1547 TRACE("(%p) - WineGL\n", ext
->extEntryPoints
[j
].funcAddress
);
1548 return ext
->extEntryPoints
[j
].funcAddress
;
1554 WARN("(%s) - not found\n", lpszProc
);
1558 static GLXPixmap
get_context_pixmap( HDC hdc
, struct wine_glcontext
*ctx
)
1564 GetObjectW( GetCurrentObject( hdc
, OBJ_BITMAP
), sizeof(bmp
), &bmp
);
1567 ctx
->pixmap
= XCreatePixmap( gdi_display
, root_window
,
1568 bmp
.bmWidth
, bmp
.bmHeight
, ctx
->vis
->depth
);
1569 ctx
->glxpixmap
= pglXCreateGLXPixmap( gdi_display
, ctx
->vis
, ctx
->pixmap
);
1570 wine_tsx11_unlock();
1571 ctx
->pixmap_size
.cx
= bmp
.bmWidth
;
1572 ctx
->pixmap_size
.cy
= bmp
.bmHeight
;
1574 return ctx
->glxpixmap
;
1577 /***********************************************************************
1578 * glxdrv_wglMakeCurrent
1580 static BOOL
glxdrv_wglMakeCurrent(HDC hdc
, HGLRC hglrc
)
1583 Wine_GLContext
*prev_ctx
= NtCurrentTeb()->glContext
;
1584 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1585 struct x11drv_escape_get_drawable escape
;
1587 TRACE("(%p,%p)\n", hdc
, hglrc
);
1591 if (prev_ctx
) prev_ctx
->tid
= 0;
1594 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1595 wine_tsx11_unlock();
1596 NtCurrentTeb()->glContext
= NULL
;
1600 escape
.code
= X11DRV_GET_DRAWABLE
;
1601 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
.code
), (LPCSTR
)&escape
.code
,
1602 sizeof(escape
), (LPSTR
)&escape
))
1605 if (!escape
.pixel_format
)
1607 WARN("Trying to use an invalid drawable\n");
1608 SetLastError(ERROR_INVALID_HANDLE
);
1611 if (ctx
->fmt
->iPixelFormat
!= escape
.pixel_format
)
1613 WARN( "mismatched pixel format hdc %p %u ctx %p %u\n",
1614 hdc
, escape
.pixel_format
, ctx
, ctx
->fmt
->iPixelFormat
);
1615 SetLastError( ERROR_INVALID_PIXEL_FORMAT
);
1620 if (escape
.gl_type
== DC_GL_BITMAP
) escape
.drawable
= get_context_pixmap( hdc
, ctx
);
1624 if (TRACE_ON(wgl
)) {
1626 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_VISUAL_ID
, &vis_id
);
1627 describeContext(ctx
);
1628 TRACE("hdc %p drawable %lx fmt %u vis %x ctx %p\n", hdc
,
1629 escape
.drawable
, escape
.pixel_format
, vis_id
, ctx
->ctx
);
1632 ret
= pglXMakeCurrent(gdi_display
, escape
.drawable
, ctx
->ctx
);
1636 if (prev_ctx
) prev_ctx
->tid
= 0;
1637 NtCurrentTeb()->glContext
= ctx
;
1639 ctx
->has_been_current
= TRUE
;
1640 ctx
->tid
= GetCurrentThreadId();
1642 ctx
->read_hdc
= hdc
;
1643 ctx
->drawables
[0] = escape
.drawable
;
1644 ctx
->drawables
[1] = escape
.drawable
;
1645 ctx
->refresh_drawables
= FALSE
;
1647 if (escape
.gl_type
== DC_GL_BITMAP
) pglDrawBuffer(GL_FRONT_LEFT
);
1650 SetLastError(ERROR_INVALID_HANDLE
);
1651 wine_tsx11_unlock();
1653 TRACE(" returning %s\n", (ret
? "True" : "False"));
1657 /***********************************************************************
1658 * glxdrv_wglMakeContextCurrentARB
1660 static BOOL
glxdrv_wglMakeContextCurrentARB( HDC draw_hdc
, HDC read_hdc
, HGLRC hglrc
)
1662 Wine_GLContext
*ctx
= (Wine_GLContext
*)hglrc
;
1663 Wine_GLContext
*prev_ctx
= NtCurrentTeb()->glContext
;
1664 struct x11drv_escape_get_drawable escape_draw
, escape_read
;
1667 TRACE("(%p,%p,%p)\n", draw_hdc
, read_hdc
, hglrc
);
1671 if (prev_ctx
) prev_ctx
->tid
= 0;
1674 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1675 wine_tsx11_unlock();
1676 NtCurrentTeb()->glContext
= NULL
;
1679 escape_draw
.code
= X11DRV_GET_DRAWABLE
;
1680 if (!ExtEscape( draw_hdc
, X11DRV_ESCAPE
, sizeof(escape_draw
.code
), (LPCSTR
)&escape_draw
.code
,
1681 sizeof(escape_draw
), (LPSTR
)&escape_draw
))
1684 escape_read
.code
= X11DRV_GET_DRAWABLE
;
1685 if (!ExtEscape( read_hdc
, X11DRV_ESCAPE
, sizeof(escape_read
.code
), (LPCSTR
)&escape_read
.code
,
1686 sizeof(escape_read
), (LPSTR
)&escape_read
))
1689 if (!escape_draw
.pixel_format
)
1691 WARN("Trying to use an invalid drawable\n");
1692 SetLastError(ERROR_INVALID_HANDLE
);
1697 if (!pglXMakeContextCurrent
) return FALSE
;
1699 if (escape_draw
.gl_type
== DC_GL_BITMAP
) escape_draw
.drawable
= get_context_pixmap( draw_hdc
, ctx
);
1700 if (escape_read
.gl_type
== DC_GL_BITMAP
) escape_read
.drawable
= get_context_pixmap( read_hdc
, ctx
);
1703 ret
= pglXMakeContextCurrent(gdi_display
, escape_draw
.drawable
, escape_read
.drawable
, ctx
->ctx
);
1706 if (prev_ctx
) prev_ctx
->tid
= 0;
1708 ctx
->has_been_current
= TRUE
;
1709 ctx
->tid
= GetCurrentThreadId();
1710 ctx
->hdc
= draw_hdc
;
1711 ctx
->read_hdc
= read_hdc
;
1712 ctx
->drawables
[0] = escape_draw
.drawable
;
1713 ctx
->drawables
[1] = escape_read
.drawable
;
1714 ctx
->refresh_drawables
= FALSE
;
1715 NtCurrentTeb()->glContext
= ctx
;
1718 SetLastError(ERROR_INVALID_HANDLE
);
1719 wine_tsx11_unlock();
1722 TRACE(" returning %s\n", (ret
? "True" : "False"));
1726 /***********************************************************************
1727 * glxdrv_wglShareLists
1729 static BOOL
glxdrv_wglShareLists(HGLRC hglrc1
, HGLRC hglrc2
)
1731 Wine_GLContext
*org
= (Wine_GLContext
*) hglrc1
;
1732 Wine_GLContext
*dest
= (Wine_GLContext
*) hglrc2
;
1734 TRACE("(%p, %p)\n", org
, dest
);
1736 /* Sharing of display lists works differently in GLX and WGL. In case of GLX it is done
1737 * at context creation time but in case of WGL it is done using wglShareLists.
1738 * In the past we tried to emulate wglShareLists by delaying GLX context creation until
1739 * either a wglMakeCurrent or wglShareLists. This worked fine for most apps but it causes
1740 * issues for OpenGL 3 because there wglCreateContextAttribsARB can fail in a lot of cases,
1741 * so there delaying context creation doesn't work.
1743 * The new approach is to create a GLX context in wglCreateContext / wglCreateContextAttribsARB
1744 * and when a program requests sharing we recreate the destination context if it hasn't been made
1745 * current or when it hasn't shared display lists before.
1748 if((org
->has_been_current
&& dest
->has_been_current
) || dest
->has_been_current
)
1750 ERR("Could not share display lists, one of the contexts has been current already !\n");
1753 else if(dest
->sharing
)
1755 ERR("Could not share display lists because hglrc2 has already shared lists before\n");
1760 if((GetObjectType(org
->hdc
) == OBJ_MEMDC
) ^ (GetObjectType(dest
->hdc
) == OBJ_MEMDC
))
1762 WARN("Attempting to share a context between a direct and indirect rendering context, expect issues!\n");
1766 describeContext(org
);
1767 describeContext(dest
);
1769 /* Re-create the GLX context and share display lists */
1770 pglXDestroyContext(gdi_display
, dest
->ctx
);
1771 dest
->ctx
= create_glxcontext(gdi_display
, dest
, org
->ctx
);
1772 wine_tsx11_unlock();
1773 TRACE(" re-created an OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest
->ctx
, dest
, org
->ctx
);
1775 org
->sharing
= TRUE
;
1776 dest
->sharing
= TRUE
;
1782 /***********************************************************************
1783 * X11DRV_wglGetCurrentContext
1785 static HGLRC WINAPI
X11DRV_wglGetCurrentContext(void)
1787 return NtCurrentTeb()->glContext
;
1790 /***********************************************************************
1791 * glxdrv_wglGetCurrentDC
1793 static HDC
glxdrv_wglGetCurrentDC(void)
1795 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
1797 if (!ctx
) return NULL
;
1798 TRACE("hdc %p\n", ctx
->hdc
);
1802 /* WGL helper function which handles differences in glGetIntegerv from WGL and GLX */
1803 static void WINAPI
X11DRV_wglGetIntegerv(GLenum pname
, GLint
* params
)
1810 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
1812 pglGetIntegerv(pname
, params
);
1814 * if we cannot find a Wine Context
1815 * we only have the default wine desktop context,
1816 * so if we have only a 24 depth say we have 32
1818 if (!ctx
&& *params
== 24) {
1821 TRACE("returns GL_DEPTH_BITS as '%d'\n", *params
);
1826 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
1828 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_ALPHA_SIZE
, params
);
1829 TRACE("returns GL_ALPHA_BITS as '%d'\n", *params
);
1833 pglGetIntegerv(pname
, params
);
1836 wine_tsx11_unlock();
1839 static void flush_pixmap( struct wine_glcontext
*ctx
)
1841 char buffer
[FIELD_OFFSET( BITMAPINFO
, bmiColors
[256] )];
1842 BITMAPINFO
*info
= (BITMAPINFO
*)buffer
;
1843 struct gdi_image_bits bits
;
1845 if (!get_pixmap_image( ctx
->pixmap
, ctx
->pixmap_size
.cx
, ctx
->pixmap_size
.cy
, ctx
->vis
, info
, &bits
))
1847 HBITMAP bitmap
= GetCurrentObject( ctx
->hdc
, OBJ_BITMAP
);
1848 SetDIBits( 0, bitmap
, 0, ctx
->pixmap_size
.cy
, bits
.ptr
, info
, DIB_RGB_COLORS
);
1849 if (bits
.free
) bits
.free( &bits
);
1853 static void flush_gl_drawable( struct glx_physdev
*physdev
)
1856 int w
= physdev
->x11dev
->dc_rect
.right
- physdev
->x11dev
->dc_rect
.left
;
1857 int h
= physdev
->x11dev
->dc_rect
.bottom
- physdev
->x11dev
->dc_rect
.top
;
1858 Drawable src
= physdev
->drawable
;
1860 if (w
<= 0 || h
<= 0) return;
1862 switch (physdev
->type
)
1864 case DC_GL_PIXMAP_WIN
:
1865 src
= physdev
->pixmap
;
1867 case DC_GL_CHILD_WIN
:
1868 /* The GL drawable may be lagged behind if we don't flush first, so
1869 * flush the display make sure we copy up-to-date data */
1871 XFlush(gdi_display
);
1872 XSetFunction(gdi_display
, physdev
->x11dev
->gc
, GXcopy
);
1873 XCopyArea(gdi_display
, src
, physdev
->x11dev
->drawable
, physdev
->x11dev
->gc
, 0, 0, w
, h
,
1874 physdev
->x11dev
->dc_rect
.left
, physdev
->x11dev
->dc_rect
.top
);
1875 wine_tsx11_unlock();
1876 SetRect( &rect
, 0, 0, w
, h
);
1877 add_device_bounds( physdev
->x11dev
, &rect
);
1884 static void WINAPI
X11DRV_wglFinish(void)
1886 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
1887 enum x11drv_escape_codes code
= X11DRV_FLUSH_GL_DRAWABLE
;
1892 wine_tsx11_unlock();
1895 if (ctx
->pixmap
) flush_pixmap( ctx
);
1896 else ExtEscape( ctx
->hdc
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, 0, NULL
);
1900 static void WINAPI
X11DRV_wglFlush(void)
1902 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
1903 enum x11drv_escape_codes code
= X11DRV_FLUSH_GL_DRAWABLE
;
1908 wine_tsx11_unlock();
1911 if (ctx
->pixmap
) flush_pixmap( ctx
);
1912 else ExtEscape( ctx
->hdc
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, 0, NULL
);
1916 /***********************************************************************
1917 * glxdrv_wglCreateContextAttribsARB
1919 static HGLRC
glxdrv_wglCreateContextAttribsARB( HDC hdc
, HGLRC hShareContext
, const int* attribList
)
1921 struct x11drv_escape_get_drawable escape
;
1922 Wine_GLContext
*ret
;
1923 WineGLPixelFormat
*fmt
;
1926 TRACE("(%p %p %p)\n", hdc
, hShareContext
, attribList
);
1928 escape
.code
= X11DRV_GET_DRAWABLE
;
1929 if (!ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
.code
), (LPCSTR
)&escape
.code
,
1930 sizeof(escape
), (LPSTR
)&escape
))
1933 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, escape
.pixel_format
, TRUE
/* Offscreen */, &fmt_count
);
1934 /* wglCreateContextAttribsARB supports ALL pixel formats, so also offscreen ones.
1935 * If this fails something is very wrong on the system. */
1938 ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", escape
.pixel_format
);
1939 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1943 if (!(ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
)))) return 0;
1947 ret
->vis
= NULL
; /* glXCreateContextAttribsARB requires a fbconfig instead of a visual */
1948 ret
->gl3_context
= TRUE
;
1950 ret
->numAttribs
= 0;
1953 int *pAttribList
= (int*)attribList
;
1954 int *pContextAttribList
= &ret
->attribList
[0];
1955 /* attribList consists of pairs {token, value] terminated with 0 */
1956 while(pAttribList
[0] != 0)
1958 TRACE("%#x %#x\n", pAttribList
[0], pAttribList
[1]);
1959 switch(pAttribList
[0])
1961 case WGL_CONTEXT_MAJOR_VERSION_ARB
:
1962 pContextAttribList
[0] = GLX_CONTEXT_MAJOR_VERSION_ARB
;
1963 pContextAttribList
[1] = pAttribList
[1];
1965 case WGL_CONTEXT_MINOR_VERSION_ARB
:
1966 pContextAttribList
[0] = GLX_CONTEXT_MINOR_VERSION_ARB
;
1967 pContextAttribList
[1] = pAttribList
[1];
1969 case WGL_CONTEXT_LAYER_PLANE_ARB
:
1971 case WGL_CONTEXT_FLAGS_ARB
:
1972 pContextAttribList
[0] = GLX_CONTEXT_FLAGS_ARB
;
1973 pContextAttribList
[1] = pAttribList
[1];
1975 case WGL_CONTEXT_PROFILE_MASK_ARB
:
1976 pContextAttribList
[0] = GLX_CONTEXT_PROFILE_MASK_ARB
;
1977 pContextAttribList
[1] = pAttribList
[1];
1980 ERR("Unhandled attribList pair: %#x %#x\n", pAttribList
[0], pAttribList
[1]);
1985 pContextAttribList
+= 2;
1990 X11DRV_expect_error(gdi_display
, GLXErrorHandler
, NULL
);
1991 ret
->ctx
= create_glxcontext(gdi_display
, ret
, NULL
);
1993 XSync(gdi_display
, False
);
1994 if(X11DRV_check_error() || !ret
->ctx
)
1996 /* In the future we should convert the GLX error to a win32 one here if needed */
1997 ERR("Context creation failed\n");
1998 HeapFree( GetProcessHeap(), 0, ret
);
1999 wine_tsx11_unlock();
2003 list_add_head( &context_list
, &ret
->entry
);
2004 wine_tsx11_unlock();
2005 TRACE(" creating context %p\n", ret
);
2010 * X11DRV_wglGetExtensionsStringARB
2012 * WGL_ARB_extensions_string: wglGetExtensionsStringARB
2014 static const char * WINAPI
X11DRV_wglGetExtensionsStringARB(HDC hdc
) {
2015 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
2016 return WineGLInfo
.wglExtensions
;
2020 * X11DRV_wglCreatePbufferARB
2022 * WGL_ARB_pbuffer: wglCreatePbufferARB
2024 static HPBUFFERARB WINAPI
X11DRV_wglCreatePbufferARB(HDC hdc
, int iPixelFormat
, int iWidth
, int iHeight
, const int *piAttribList
)
2026 Wine_GLPBuffer
* object
= NULL
;
2027 WineGLPixelFormat
*fmt
= NULL
;
2032 TRACE("(%p, %d, %d, %d, %p)\n", hdc
, iPixelFormat
, iWidth
, iHeight
, piAttribList
);
2034 if (0 >= iPixelFormat
) {
2035 ERR("(%p): unexpected iPixelFormat(%d) <= 0, returns NULL\n", hdc
, iPixelFormat
);
2036 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
2037 return NULL
; /* unexpected error */
2040 /* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
2041 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, TRUE
/* Offscreen */, &nCfgs
);
2043 ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc
, iPixelFormat
, nCfgs
);
2044 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
2045 goto create_failed
; /* unexpected error */
2048 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(Wine_GLPBuffer
));
2049 if (NULL
== object
) {
2050 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
2051 goto create_failed
; /* unexpected error */
2054 object
->display
= gdi_display
;
2055 object
->width
= iWidth
;
2056 object
->height
= iHeight
;
2059 PUSH2(attribs
, GLX_PBUFFER_WIDTH
, iWidth
);
2060 PUSH2(attribs
, GLX_PBUFFER_HEIGHT
, iHeight
);
2061 while (piAttribList
&& 0 != *piAttribList
) {
2063 switch (*piAttribList
) {
2064 case WGL_PBUFFER_LARGEST_ARB
: {
2066 attr_v
= *piAttribList
;
2067 TRACE("WGL_LARGEST_PBUFFER_ARB = %d\n", attr_v
);
2068 PUSH2(attribs
, GLX_LARGEST_PBUFFER
, attr_v
);
2072 case WGL_TEXTURE_FORMAT_ARB
: {
2074 attr_v
= *piAttribList
;
2075 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_FORMAT_ARB as %x\n", attr_v
);
2076 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2077 object
->use_render_texture
= 0;
2079 if (!use_render_texture_emulation
) {
2080 SetLastError(ERROR_INVALID_DATA
);
2084 case WGL_TEXTURE_RGB_ARB
:
2085 object
->use_render_texture
= GL_RGB
;
2086 object
->texture_bpp
= 3;
2087 object
->texture_format
= GL_RGB
;
2088 object
->texture_type
= GL_UNSIGNED_BYTE
;
2090 case WGL_TEXTURE_RGBA_ARB
:
2091 object
->use_render_texture
= GL_RGBA
;
2092 object
->texture_bpp
= 4;
2093 object
->texture_format
= GL_RGBA
;
2094 object
->texture_type
= GL_UNSIGNED_BYTE
;
2097 /* WGL_FLOAT_COMPONENTS_NV */
2098 case WGL_TEXTURE_FLOAT_R_NV
:
2099 object
->use_render_texture
= GL_FLOAT_R_NV
;
2100 object
->texture_bpp
= 4;
2101 object
->texture_format
= GL_RED
;
2102 object
->texture_type
= GL_FLOAT
;
2104 case WGL_TEXTURE_FLOAT_RG_NV
:
2105 object
->use_render_texture
= GL_FLOAT_RG_NV
;
2106 object
->texture_bpp
= 8;
2107 object
->texture_format
= GL_LUMINANCE_ALPHA
;
2108 object
->texture_type
= GL_FLOAT
;
2110 case WGL_TEXTURE_FLOAT_RGB_NV
:
2111 object
->use_render_texture
= GL_FLOAT_RGB_NV
;
2112 object
->texture_bpp
= 12;
2113 object
->texture_format
= GL_RGB
;
2114 object
->texture_type
= GL_FLOAT
;
2116 case WGL_TEXTURE_FLOAT_RGBA_NV
:
2117 object
->use_render_texture
= GL_FLOAT_RGBA_NV
;
2118 object
->texture_bpp
= 16;
2119 object
->texture_format
= GL_RGBA
;
2120 object
->texture_type
= GL_FLOAT
;
2123 ERR("Unknown texture format: %x\n", attr_v
);
2124 SetLastError(ERROR_INVALID_DATA
);
2131 case WGL_TEXTURE_TARGET_ARB
: {
2133 attr_v
= *piAttribList
;
2134 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_TARGET_ARB as %x\n", attr_v
);
2135 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2136 object
->texture_target
= 0;
2138 if (!use_render_texture_emulation
) {
2139 SetLastError(ERROR_INVALID_DATA
);
2143 case WGL_TEXTURE_CUBE_MAP_ARB
: {
2144 if (iWidth
!= iHeight
) {
2145 SetLastError(ERROR_INVALID_DATA
);
2148 object
->texture_target
= GL_TEXTURE_CUBE_MAP
;
2149 object
->texture_bind_target
= GL_TEXTURE_BINDING_CUBE_MAP
;
2152 case WGL_TEXTURE_1D_ARB
: {
2154 SetLastError(ERROR_INVALID_DATA
);
2157 object
->texture_target
= GL_TEXTURE_1D
;
2158 object
->texture_bind_target
= GL_TEXTURE_BINDING_1D
;
2161 case WGL_TEXTURE_2D_ARB
: {
2162 object
->texture_target
= GL_TEXTURE_2D
;
2163 object
->texture_bind_target
= GL_TEXTURE_BINDING_2D
;
2166 case WGL_TEXTURE_RECTANGLE_NV
: {
2167 object
->texture_target
= GL_TEXTURE_RECTANGLE_NV
;
2168 object
->texture_bind_target
= GL_TEXTURE_BINDING_RECTANGLE_NV
;
2172 ERR("Unknown texture target: %x\n", attr_v
);
2173 SetLastError(ERROR_INVALID_DATA
);
2180 case WGL_MIPMAP_TEXTURE_ARB
: {
2182 attr_v
= *piAttribList
;
2183 TRACE("WGL_render_texture Attribute: WGL_MIPMAP_TEXTURE_ARB as %x\n", attr_v
);
2184 if (!use_render_texture_emulation
) {
2185 SetLastError(ERROR_INVALID_DATA
);
2194 PUSH1(attribs
, None
);
2196 object
->drawable
= pglXCreatePbuffer(gdi_display
, fmt
->fbconfig
, attribs
);
2197 wine_tsx11_unlock();
2198 TRACE("new Pbuffer drawable as %lx\n", object
->drawable
);
2199 if (!object
->drawable
) {
2200 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
2201 goto create_failed
; /* unexpected error */
2203 TRACE("->(%p)\n", object
);
2207 HeapFree(GetProcessHeap(), 0, object
);
2208 TRACE("->(FAILED)\n");
2213 * X11DRV_wglDestroyPbufferARB
2215 * WGL_ARB_pbuffer: wglDestroyPbufferARB
2217 static GLboolean WINAPI
X11DRV_wglDestroyPbufferARB(HPBUFFERARB hPbuffer
)
2219 Wine_GLPBuffer
* object
= hPbuffer
;
2220 TRACE("(%p)\n", hPbuffer
);
2221 if (NULL
== object
) {
2222 SetLastError(ERROR_INVALID_HANDLE
);
2226 pglXDestroyPbuffer(object
->display
, object
->drawable
);
2227 wine_tsx11_unlock();
2228 HeapFree(GetProcessHeap(), 0, object
);
2233 * X11DRV_wglGetPbufferDCARB
2235 * WGL_ARB_pbuffer: wglGetPbufferDCARB
2237 static HDC WINAPI
X11DRV_wglGetPbufferDCARB(HPBUFFERARB hPbuffer
)
2239 struct x11drv_escape_set_drawable escape
;
2240 Wine_GLPBuffer
* object
= hPbuffer
;
2243 if (NULL
== object
) {
2244 SetLastError(ERROR_INVALID_HANDLE
);
2248 hdc
= CreateDCA( "DISPLAY", NULL
, NULL
, NULL
);
2251 escape
.code
= X11DRV_SET_DRAWABLE
;
2252 escape
.drawable
= object
->drawable
;
2253 escape
.mode
= IncludeInferiors
;
2254 SetRect( &escape
.drawable_rect
, 0, 0, object
->width
, object
->height
);
2255 escape
.dc_rect
= escape
.drawable_rect
;
2256 escape
.fbconfig_id
= object
->fmt
->fmt_id
;
2257 escape
.gl_drawable
= object
->drawable
;
2259 escape
.gl_type
= DC_GL_PBUFFER
;
2260 ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPSTR
)&escape
, 0, NULL
);
2262 TRACE( "(%p)->(%p)\n", hPbuffer
, hdc
);
2267 * X11DRV_wglQueryPbufferARB
2269 * WGL_ARB_pbuffer: wglQueryPbufferARB
2271 static GLboolean WINAPI
X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer
, int iAttribute
, int *piValue
)
2273 Wine_GLPBuffer
* object
= hPbuffer
;
2274 TRACE("(%p, 0x%x, %p)\n", hPbuffer
, iAttribute
, piValue
);
2275 if (NULL
== object
) {
2276 SetLastError(ERROR_INVALID_HANDLE
);
2279 switch (iAttribute
) {
2280 case WGL_PBUFFER_WIDTH_ARB
:
2282 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_WIDTH
, (unsigned int*) piValue
);
2283 wine_tsx11_unlock();
2285 case WGL_PBUFFER_HEIGHT_ARB
:
2287 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_HEIGHT
, (unsigned int*) piValue
);
2288 wine_tsx11_unlock();
2291 case WGL_PBUFFER_LOST_ARB
:
2292 /* GLX Pbuffers cannot be lost by default. We can support this by
2293 * setting GLX_PRESERVED_CONTENTS to False and using glXSelectEvent
2294 * to receive pixel buffer clobber events, however that may or may
2295 * not give any benefit */
2296 *piValue
= GL_FALSE
;
2299 case WGL_TEXTURE_FORMAT_ARB
:
2300 if (!object
->use_render_texture
) {
2301 *piValue
= WGL_NO_TEXTURE_ARB
;
2303 if (!use_render_texture_emulation
) {
2304 SetLastError(ERROR_INVALID_HANDLE
);
2307 switch(object
->use_render_texture
) {
2309 *piValue
= WGL_TEXTURE_RGB_ARB
;
2312 *piValue
= WGL_TEXTURE_RGBA_ARB
;
2314 /* WGL_FLOAT_COMPONENTS_NV */
2316 *piValue
= WGL_TEXTURE_FLOAT_R_NV
;
2318 case GL_FLOAT_RG_NV
:
2319 *piValue
= WGL_TEXTURE_FLOAT_RG_NV
;
2321 case GL_FLOAT_RGB_NV
:
2322 *piValue
= WGL_TEXTURE_FLOAT_RGB_NV
;
2324 case GL_FLOAT_RGBA_NV
:
2325 *piValue
= WGL_TEXTURE_FLOAT_RGBA_NV
;
2328 ERR("Unknown texture format: %x\n", object
->use_render_texture
);
2333 case WGL_TEXTURE_TARGET_ARB
:
2334 if (!object
->texture_target
){
2335 *piValue
= WGL_NO_TEXTURE_ARB
;
2337 if (!use_render_texture_emulation
) {
2338 SetLastError(ERROR_INVALID_DATA
);
2341 switch (object
->texture_target
) {
2342 case GL_TEXTURE_1D
: *piValue
= WGL_TEXTURE_1D_ARB
; break;
2343 case GL_TEXTURE_2D
: *piValue
= WGL_TEXTURE_2D_ARB
; break;
2344 case GL_TEXTURE_CUBE_MAP
: *piValue
= WGL_TEXTURE_CUBE_MAP_ARB
; break;
2345 case GL_TEXTURE_RECTANGLE_NV
: *piValue
= WGL_TEXTURE_RECTANGLE_NV
; break;
2350 case WGL_MIPMAP_TEXTURE_ARB
:
2351 *piValue
= GL_FALSE
; /** don't support that */
2352 FIXME("unsupported WGL_ARB_render_texture attribute query for 0x%x\n", iAttribute
);
2356 FIXME("unexpected attribute %x\n", iAttribute
);
2364 * X11DRV_wglReleasePbufferDCARB
2366 * WGL_ARB_pbuffer: wglReleasePbufferDCARB
2368 static int WINAPI
X11DRV_wglReleasePbufferDCARB(HPBUFFERARB hPbuffer
, HDC hdc
)
2370 TRACE("(%p, %p)\n", hPbuffer
, hdc
);
2371 return DeleteDC(hdc
);
2375 * X11DRV_wglSetPbufferAttribARB
2377 * WGL_ARB_pbuffer: wglSetPbufferAttribARB
2379 static GLboolean WINAPI
X11DRV_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer
, const int *piAttribList
)
2381 Wine_GLPBuffer
* object
= hPbuffer
;
2382 GLboolean ret
= GL_FALSE
;
2384 WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer
, piAttribList
);
2385 if (NULL
== object
) {
2386 SetLastError(ERROR_INVALID_HANDLE
);
2389 if (!object
->use_render_texture
) {
2390 SetLastError(ERROR_INVALID_HANDLE
);
2393 if (1 == use_render_texture_emulation
) {
2400 * X11DRV_wglChoosePixelFormatARB
2402 * WGL_ARB_pixel_format: wglChoosePixelFormatARB
2404 static GLboolean WINAPI
X11DRV_wglChoosePixelFormatARB(HDC hdc
, const int *piAttribIList
, const FLOAT
*pfAttribFList
, UINT nMaxFormats
, int *piFormats
, UINT
*nNumFormats
)
2409 GLXFBConfig
* cfgs
= NULL
;
2413 WineGLPixelFormat
*fmt
;
2419 TRACE("(%p, %p, %p, %d, %p, %p): hackish\n", hdc
, piAttribIList
, pfAttribFList
, nMaxFormats
, piFormats
, nNumFormats
);
2420 if (NULL
!= pfAttribFList
) {
2421 FIXME("unused pfAttribFList\n");
2424 nAttribs
= ConvertAttribWGLtoGLX(piAttribIList
, attribs
, NULL
);
2425 if (-1 == nAttribs
) {
2426 WARN("Cannot convert WGL to GLX attributes\n");
2429 PUSH1(attribs
, None
);
2431 /* There is no 1:1 mapping between GLX and WGL formats because we duplicate some GLX formats for bitmap rendering (see get_formats).
2432 * Flags like PFD_SUPPORT_GDI, PFD_DRAW_TO_BITMAP and others are a property of the WineGLPixelFormat. We don't query these attributes
2433 * using glXChooseFBConfig but we filter the result of glXChooseFBConfig later on by passing a dwFlags to 'ConvertPixelFormatGLXtoWGL'. */
2434 for(i
=0; piAttribIList
[i
] != 0; i
+=2)
2436 switch(piAttribIList
[i
])
2438 case WGL_DRAW_TO_BITMAP_ARB
:
2439 if(piAttribIList
[i
+1])
2440 dwFlags
|= PFD_DRAW_TO_BITMAP
;
2442 case WGL_ACCELERATION_ARB
:
2443 switch(piAttribIList
[i
+1])
2445 case WGL_NO_ACCELERATION_ARB
:
2446 dwFlags
|= PFD_GENERIC_FORMAT
;
2448 case WGL_GENERIC_ACCELERATION_ARB
:
2449 dwFlags
|= PFD_GENERIC_ACCELERATED
;
2451 case WGL_FULL_ACCELERATION_ARB
:
2456 case WGL_SUPPORT_GDI_ARB
:
2457 if(piAttribIList
[i
+1])
2458 dwFlags
|= PFD_SUPPORT_GDI
;
2463 /* Search for FB configurations matching the requirements in attribs */
2465 cfgs
= pglXChooseFBConfig(gdi_display
, DefaultScreen(gdi_display
), attribs
, &nCfgs
);
2467 wine_tsx11_unlock();
2468 WARN("Compatible Pixel Format not found\n");
2472 /* Loop through all matching formats and check if they are suitable.
2473 * Note that this function should at max return nMaxFormats different formats */
2474 for(run
=0; run
< 2; run
++)
2476 for (it
= 0; it
< nCfgs
&& pfmt_it
< nMaxFormats
; ++it
)
2478 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cfgs
[it
], GLX_FBCONFIG_ID
, &fmt_id
);
2480 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
2484 /* Search for the format in our list of compatible formats */
2485 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fmt_id
, dwFlags
);
2489 /* During the first run we only want onscreen formats and during the second only offscreen 'XOR' */
2490 if( ((run
== 0) && fmt
->offscreenOnly
) || ((run
== 1) && !fmt
->offscreenOnly
) )
2493 piFormats
[pfmt_it
] = fmt
->iPixelFormat
;
2494 TRACE("at %d/%d found FBCONFIG_ID 0x%x (%d)\n", it
+ 1, nCfgs
, fmt_id
, piFormats
[pfmt_it
]);
2499 *nNumFormats
= pfmt_it
;
2502 wine_tsx11_unlock();
2507 * X11DRV_wglGetPixelFormatAttribivARB
2509 * WGL_ARB_pixel_format: wglGetPixelFormatAttribivARB
2511 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribivARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, int *piValues
)
2514 WineGLPixelFormat
*fmt
= NULL
;
2518 int nWGLFormats
= 0;
2520 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, piValues
);
2522 if (0 < iLayerPlane
) {
2523 FIXME("unsupported iLayerPlane(%d) > 0, returns FALSE\n", iLayerPlane
);
2527 /* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supported.
2528 * We don't have to fail yet as a program can specify an invalid iPixelFormat (lets say 0) if it wants to query
2529 * the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
2530 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, TRUE
/* Offscreen */, &nWGLFormats
);
2532 WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat
);
2536 for (i
= 0; i
< nAttributes
; ++i
) {
2537 const int curWGLAttr
= piAttributes
[i
];
2538 TRACE("pAttr[%d] = %x\n", i
, curWGLAttr
);
2540 switch (curWGLAttr
) {
2541 case WGL_NUMBER_PIXEL_FORMATS_ARB
:
2542 piValues
[i
] = nWGLFormats
;
2545 case WGL_SUPPORT_OPENGL_ARB
:
2546 piValues
[i
] = GL_TRUE
;
2549 case WGL_ACCELERATION_ARB
:
2550 curGLXAttr
= GLX_CONFIG_CAVEAT
;
2551 if (!fmt
) goto pix_error
;
2552 if(fmt
->dwFlags
& PFD_GENERIC_FORMAT
)
2553 piValues
[i
] = WGL_NO_ACCELERATION_ARB
;
2554 else if(fmt
->dwFlags
& PFD_GENERIC_ACCELERATED
)
2555 piValues
[i
] = WGL_GENERIC_ACCELERATION_ARB
;
2557 piValues
[i
] = WGL_FULL_ACCELERATION_ARB
;
2560 case WGL_TRANSPARENT_ARB
:
2561 curGLXAttr
= GLX_TRANSPARENT_TYPE
;
2562 if (!fmt
) goto pix_error
;
2563 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
2564 if (hTest
) goto get_error
;
2565 piValues
[i
] = GL_FALSE
;
2566 if (GLX_NONE
!= tmp
) piValues
[i
] = GL_TRUE
;
2569 case WGL_PIXEL_TYPE_ARB
:
2570 curGLXAttr
= GLX_RENDER_TYPE
;
2571 if (!fmt
) goto pix_error
;
2572 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
2573 if (hTest
) goto get_error
;
2574 TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp
);
2575 if (tmp
& GLX_RGBA_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_ARB
; }
2576 else if (tmp
& GLX_COLOR_INDEX_BIT
) { piValues
[i
] = WGL_TYPE_COLORINDEX_ARB
; }
2577 else if (tmp
& GLX_RGBA_FLOAT_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2578 else if (tmp
& GLX_RGBA_FLOAT_ATI_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2579 else if (tmp
& GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
) { piValues
[i
] = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
; }
2581 ERR("unexpected RenderType(%x)\n", tmp
);
2582 piValues
[i
] = WGL_TYPE_RGBA_ARB
;
2586 case WGL_COLOR_BITS_ARB
:
2587 curGLXAttr
= GLX_BUFFER_SIZE
;
2590 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
2591 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
2592 if (!use_render_texture_emulation
) {
2593 piValues
[i
] = GL_FALSE
;
2596 curGLXAttr
= GLX_RENDER_TYPE
;
2597 if (!fmt
) goto pix_error
;
2598 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
2599 if (hTest
) goto get_error
;
2600 if (GLX_COLOR_INDEX_BIT
== tmp
) {
2601 piValues
[i
] = GL_FALSE
;
2604 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &tmp
);
2605 if (hTest
) goto get_error
;
2606 piValues
[i
] = (tmp
& GLX_PBUFFER_BIT
) ? GL_TRUE
: GL_FALSE
;
2609 case WGL_BLUE_BITS_ARB
:
2610 curGLXAttr
= GLX_BLUE_SIZE
;
2612 case WGL_RED_BITS_ARB
:
2613 curGLXAttr
= GLX_RED_SIZE
;
2615 case WGL_GREEN_BITS_ARB
:
2616 curGLXAttr
= GLX_GREEN_SIZE
;
2618 case WGL_ALPHA_BITS_ARB
:
2619 curGLXAttr
= GLX_ALPHA_SIZE
;
2621 case WGL_DEPTH_BITS_ARB
:
2622 curGLXAttr
= GLX_DEPTH_SIZE
;
2624 case WGL_STENCIL_BITS_ARB
:
2625 curGLXAttr
= GLX_STENCIL_SIZE
;
2627 case WGL_DOUBLE_BUFFER_ARB
:
2628 curGLXAttr
= GLX_DOUBLEBUFFER
;
2630 case WGL_STEREO_ARB
:
2631 curGLXAttr
= GLX_STEREO
;
2633 case WGL_AUX_BUFFERS_ARB
:
2634 curGLXAttr
= GLX_AUX_BUFFERS
;
2637 case WGL_SUPPORT_GDI_ARB
:
2638 if (!fmt
) goto pix_error
;
2639 piValues
[i
] = (fmt
->dwFlags
& PFD_SUPPORT_GDI
) ? TRUE
: FALSE
;
2642 case WGL_DRAW_TO_BITMAP_ARB
:
2643 if (!fmt
) goto pix_error
;
2644 piValues
[i
] = (fmt
->dwFlags
& PFD_DRAW_TO_BITMAP
) ? TRUE
: FALSE
;
2647 case WGL_DRAW_TO_WINDOW_ARB
:
2648 case WGL_DRAW_TO_PBUFFER_ARB
:
2649 if (!fmt
) goto pix_error
;
2650 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &tmp
);
2651 if (hTest
) goto get_error
;
2652 if((curWGLAttr
== WGL_DRAW_TO_WINDOW_ARB
&& (tmp
&GLX_WINDOW_BIT
)) ||
2653 (curWGLAttr
== WGL_DRAW_TO_PBUFFER_ARB
&& (tmp
&GLX_PBUFFER_BIT
)))
2654 piValues
[i
] = GL_TRUE
;
2656 piValues
[i
] = GL_FALSE
;
2659 case WGL_SWAP_METHOD_ARB
:
2660 /* For now return SWAP_EXCHANGE_ARB which is the best type of buffer switch available.
2661 * Later on we can also use GLX_OML_swap_method on drivers which support this. At this
2662 * point only ATI offers this.
2664 piValues
[i
] = WGL_SWAP_EXCHANGE_ARB
;
2667 case WGL_PBUFFER_LARGEST_ARB
:
2668 curGLXAttr
= GLX_LARGEST_PBUFFER
;
2671 case WGL_SAMPLE_BUFFERS_ARB
:
2672 curGLXAttr
= GLX_SAMPLE_BUFFERS_ARB
;
2675 case WGL_SAMPLES_ARB
:
2676 curGLXAttr
= GLX_SAMPLES_ARB
;
2679 case WGL_FLOAT_COMPONENTS_NV
:
2680 curGLXAttr
= GLX_FLOAT_COMPONENTS_NV
;
2683 case WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT
:
2684 curGLXAttr
= GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
;
2687 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
:
2688 curGLXAttr
= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
;
2691 case WGL_ACCUM_RED_BITS_ARB
:
2692 curGLXAttr
= GLX_ACCUM_RED_SIZE
;
2694 case WGL_ACCUM_GREEN_BITS_ARB
:
2695 curGLXAttr
= GLX_ACCUM_GREEN_SIZE
;
2697 case WGL_ACCUM_BLUE_BITS_ARB
:
2698 curGLXAttr
= GLX_ACCUM_BLUE_SIZE
;
2700 case WGL_ACCUM_ALPHA_BITS_ARB
:
2701 curGLXAttr
= GLX_ACCUM_ALPHA_SIZE
;
2703 case WGL_ACCUM_BITS_ARB
:
2704 if (!fmt
) goto pix_error
;
2705 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_RED_SIZE
, &tmp
);
2706 if (hTest
) goto get_error
;
2708 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_GREEN_SIZE
, &tmp
);
2709 if (hTest
) goto get_error
;
2711 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_BLUE_SIZE
, &tmp
);
2712 if (hTest
) goto get_error
;
2714 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_ALPHA_SIZE
, &tmp
);
2715 if (hTest
) goto get_error
;
2720 FIXME("unsupported %x WGL Attribute\n", curWGLAttr
);
2723 /* Retrieve a GLX FBConfigAttrib when the attribute to query is valid and
2724 * iPixelFormat != 0. When iPixelFormat is 0 the only value which makes
2725 * sense to query is WGL_NUMBER_PIXEL_FORMATS_ARB.
2727 * TODO: properly test the behavior of wglGetPixelFormatAttrib*v on Windows
2728 * and check which options can work using iPixelFormat=0 and which not.
2729 * A problem would be that this function is an extension. This would
2730 * mean that the behavior could differ between different vendors (ATI, Nvidia, ..).
2732 if (0 != curGLXAttr
&& iPixelFormat
!= 0) {
2733 if (!fmt
) goto pix_error
;
2734 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, piValues
+ i
);
2735 if (hTest
) goto get_error
;
2738 piValues
[i
] = GL_FALSE
;
2741 wine_tsx11_unlock();
2745 wine_tsx11_unlock();
2746 ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc
, curGLXAttr
);
2750 wine_tsx11_unlock();
2751 ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc
, iPixelFormat
, nWGLFormats
);
2756 * X11DRV_wglGetPixelFormatAttribfvARB
2758 * WGL_ARB_pixel_format: wglGetPixelFormatAttribfvARB
2760 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribfvARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, FLOAT
*pfValues
)
2766 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, pfValues
);
2768 /* Allocate a temporary array to store integer values */
2769 attr
= HeapAlloc(GetProcessHeap(), 0, nAttributes
* sizeof(int));
2771 ERR("couldn't allocate %d array\n", nAttributes
);
2775 /* Piggy-back on wglGetPixelFormatAttribivARB */
2776 ret
= X11DRV_wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, attr
);
2778 /* Convert integer values to float. Should also check for attributes
2779 that can give decimal values here */
2780 for (i
=0; i
<nAttributes
;i
++) {
2781 pfValues
[i
] = attr
[i
];
2785 HeapFree(GetProcessHeap(), 0, attr
);
2790 * X11DRV_wglBindTexImageARB
2792 * WGL_ARB_render_texture: wglBindTexImageARB
2794 static GLboolean WINAPI
X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2796 Wine_GLPBuffer
* object
= hPbuffer
;
2797 GLboolean ret
= GL_FALSE
;
2799 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2800 if (NULL
== object
) {
2801 SetLastError(ERROR_INVALID_HANDLE
);
2804 if (!object
->use_render_texture
) {
2805 SetLastError(ERROR_INVALID_HANDLE
);
2809 if (1 == use_render_texture_emulation
) {
2810 static int init
= 0;
2811 int prev_binded_texture
= 0;
2812 GLXContext prev_context
;
2813 Drawable prev_drawable
;
2814 GLXContext tmp_context
;
2817 prev_context
= pglXGetCurrentContext();
2818 prev_drawable
= pglXGetCurrentDrawable();
2820 /* Our render_texture emulation is basic and lacks some features (1D/Cube support).
2821 This is mostly due to lack of demos/games using them. Further the use of glReadPixels
2822 isn't ideal performance wise but I wasn't able to get other ways working.
2825 init
= 1; /* Only show the FIXME once for performance reasons */
2826 FIXME("partial stub!\n");
2829 TRACE("drawable=%lx, context=%p\n", object
->drawable
, prev_context
);
2830 tmp_context
= pglXCreateNewContext(gdi_display
, object
->fmt
->fbconfig
, object
->fmt
->render_type
, prev_context
, True
);
2832 pglGetIntegerv(object
->texture_bind_target
, &prev_binded_texture
);
2834 /* Switch to our pbuffer */
2835 pglXMakeCurrent(gdi_display
, object
->drawable
, tmp_context
);
2837 /* Make sure that the prev_binded_texture is set as the current texture state isn't shared between contexts.
2838 * After that upload the pbuffer texture data. */
2839 pglBindTexture(object
->texture_target
, prev_binded_texture
);
2840 pglCopyTexImage2D(object
->texture_target
, 0, object
->use_render_texture
, 0, 0, object
->width
, object
->height
, 0);
2842 /* Switch back to the original drawable and upload the pbuffer-texture */
2843 pglXMakeCurrent(object
->display
, prev_drawable
, prev_context
);
2844 pglXDestroyContext(gdi_display
, tmp_context
);
2845 wine_tsx11_unlock();
2853 * X11DRV_wglReleaseTexImageARB
2855 * WGL_ARB_render_texture: wglReleaseTexImageARB
2857 static GLboolean WINAPI
X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2859 Wine_GLPBuffer
* object
= hPbuffer
;
2860 GLboolean ret
= GL_FALSE
;
2862 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2863 if (NULL
== object
) {
2864 SetLastError(ERROR_INVALID_HANDLE
);
2867 if (!object
->use_render_texture
) {
2868 SetLastError(ERROR_INVALID_HANDLE
);
2871 if (1 == use_render_texture_emulation
) {
2878 * X11DRV_wglGetExtensionsStringEXT
2880 * WGL_EXT_extensions_string: wglGetExtensionsStringEXT
2882 static const char * WINAPI
X11DRV_wglGetExtensionsStringEXT(void) {
2883 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
2884 return WineGLInfo
.wglExtensions
;
2888 * X11DRV_wglGetSwapIntervalEXT
2890 * WGL_EXT_swap_control: wglGetSwapIntervalEXT
2892 static int WINAPI
X11DRV_wglGetSwapIntervalEXT(VOID
) {
2893 /* GLX_SGI_swap_control doesn't have any provisions for getting the swap
2894 * interval, so the swap interval has to be tracked. */
2896 return swap_interval
;
2900 * X11DRV_wglSwapIntervalEXT
2902 * WGL_EXT_swap_control: wglSwapIntervalEXT
2904 static BOOL WINAPI
X11DRV_wglSwapIntervalEXT(int interval
) {
2907 TRACE("(%d)\n", interval
);
2911 SetLastError(ERROR_INVALID_DATA
);
2914 else if (!has_swap_control
&& interval
== 0)
2916 /* wglSwapIntervalEXT considers an interval value of zero to mean that
2917 * vsync should be disabled, but glXSwapIntervalSGI considers such a
2918 * value to be an error. Just silently ignore the request for now. */
2919 WARN("Request to disable vertical sync is not handled\n");
2924 if (pglXSwapIntervalSGI
)
2927 ret
= !pglXSwapIntervalSGI(interval
);
2928 wine_tsx11_unlock();
2931 WARN("GLX_SGI_swap_control extension is not available\n");
2934 swap_interval
= interval
;
2936 SetLastError(ERROR_DC_NOT_FOUND
);
2943 * X11DRV_wglAllocateMemoryNV
2945 * WGL_NV_vertex_array_range: wglAllocateMemoryNV
2947 static void* WINAPI
X11DRV_wglAllocateMemoryNV(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
) {
2949 TRACE("(%d, %f, %f, %f)\n", size
, readfreq
, writefreq
, priority
);
2951 if (pglXAllocateMemoryNV
)
2954 ret
= pglXAllocateMemoryNV(size
, readfreq
, writefreq
, priority
);
2955 wine_tsx11_unlock();
2961 * X11DRV_wglFreeMemoryNV
2963 * WGL_NV_vertex_array_range: wglFreeMemoryNV
2965 static void WINAPI
X11DRV_wglFreeMemoryNV(GLvoid
* pointer
) {
2966 TRACE("(%p)\n", pointer
);
2967 if (pglXFreeMemoryNV
== NULL
)
2971 pglXFreeMemoryNV(pointer
);
2972 wine_tsx11_unlock();
2976 * X11DRV_wglSetPixelFormatWINE
2978 * WGL_WINE_pixel_format_passthrough: wglSetPixelFormatWINE
2979 * This is a WINE-specific wglSetPixelFormat which can set the pixel format multiple times.
2981 static BOOL WINAPI
X11DRV_wglSetPixelFormatWINE(HDC hdc
, int format
)
2983 WineGLPixelFormat
*fmt
;
2987 TRACE("(%p,%d)\n", hdc
, format
);
2989 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, format
, FALSE
/* Offscreen */, &value
);
2992 ERR( "Invalid format %d\n", format
);
2996 hwnd
= WindowFromDC( hdc
);
2997 if (!hwnd
|| hwnd
== GetDesktopWindow())
2999 ERR( "not a valid window DC %p\n", hdc
);
3004 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
3005 wine_tsx11_unlock();
3007 if (!(value
& GLX_WINDOW_BIT
))
3009 WARN( "Pixel format %d is not compatible for window rendering\n", format
);
3013 return SendMessageW(hwnd
, WM_X11DRV_SET_WIN_FORMAT
, fmt
->fmt_id
, 0);
3014 /* DC pixel format will be set by the DCE update */
3018 * glxRequireVersion (internal)
3020 * Check if the supported GLX version matches requiredVersion.
3022 static BOOL
glxRequireVersion(int requiredVersion
)
3024 /* Both requiredVersion and glXVersion[1] contains the minor GLX version */
3025 if(requiredVersion
<= WineGLInfo
.glxVersion
[1])
3031 static BOOL
glxRequireExtension(const char *requiredExtension
)
3033 if (strstr(WineGLInfo
.glxExtensions
, requiredExtension
) == NULL
) {
3040 static void register_extension_string(const char *ext
)
3042 if (WineGLInfo
.wglExtensions
[0])
3043 strcat(WineGLInfo
.wglExtensions
, " ");
3044 strcat(WineGLInfo
.wglExtensions
, ext
);
3046 TRACE("'%s'\n", ext
);
3049 static BOOL
register_extension(const WineGLExtension
* ext
)
3053 assert( WineGLExtensionListSize
< MAX_EXTENSIONS
);
3054 WineGLExtensionList
[WineGLExtensionListSize
++] = ext
;
3056 register_extension_string(ext
->extName
);
3058 for (i
= 0; ext
->extEntryPoints
[i
].funcName
; ++i
)
3059 TRACE(" - '%s'\n", ext
->extEntryPoints
[i
].funcName
);
3064 static const WineGLExtension WGL_internal_functions
=
3068 { "wglFinish", X11DRV_wglFinish
},
3069 { "wglFlush", X11DRV_wglFlush
},
3070 { "wglGetCurrentContext", X11DRV_wglGetCurrentContext
},
3071 { "wglGetIntegerv", X11DRV_wglGetIntegerv
},
3076 static const WineGLExtension WGL_ARB_create_context
=
3078 "WGL_ARB_create_context",
3080 { "wglCreateContextAttribsARB", (void *)1 /* called through the glxdrv_wgl_funcs driver */ },
3084 static const WineGLExtension WGL_ARB_extensions_string
=
3086 "WGL_ARB_extensions_string",
3088 { "wglGetExtensionsStringARB", X11DRV_wglGetExtensionsStringARB
},
3092 static const WineGLExtension WGL_ARB_make_current_read
=
3094 "WGL_ARB_make_current_read",
3096 { "wglGetCurrentReadDCARB", X11DRV_wglGetCurrentReadDCARB
},
3097 { "wglMakeContextCurrentARB", (void *)1 /* called through the glxdrv_wgl_funcs driver */ },
3101 static const WineGLExtension WGL_ARB_multisample
=
3103 "WGL_ARB_multisample",
3106 static const WineGLExtension WGL_ARB_pbuffer
=
3110 { "wglCreatePbufferARB", X11DRV_wglCreatePbufferARB
},
3111 { "wglDestroyPbufferARB", X11DRV_wglDestroyPbufferARB
},
3112 { "wglGetPbufferDCARB", X11DRV_wglGetPbufferDCARB
},
3113 { "wglQueryPbufferARB", X11DRV_wglQueryPbufferARB
},
3114 { "wglReleasePbufferDCARB", X11DRV_wglReleasePbufferDCARB
},
3115 { "wglSetPbufferAttribARB", X11DRV_wglSetPbufferAttribARB
},
3119 static const WineGLExtension WGL_ARB_pixel_format
=
3121 "WGL_ARB_pixel_format",
3123 { "wglChoosePixelFormatARB", X11DRV_wglChoosePixelFormatARB
},
3124 { "wglGetPixelFormatAttribfvARB", X11DRV_wglGetPixelFormatAttribfvARB
},
3125 { "wglGetPixelFormatAttribivARB", X11DRV_wglGetPixelFormatAttribivARB
},
3129 static const WineGLExtension WGL_ARB_render_texture
=
3131 "WGL_ARB_render_texture",
3133 { "wglBindTexImageARB", X11DRV_wglBindTexImageARB
},
3134 { "wglReleaseTexImageARB", X11DRV_wglReleaseTexImageARB
},
3138 static const WineGLExtension WGL_EXT_extensions_string
=
3140 "WGL_EXT_extensions_string",
3142 { "wglGetExtensionsStringEXT", X11DRV_wglGetExtensionsStringEXT
},
3146 static const WineGLExtension WGL_EXT_swap_control
=
3148 "WGL_EXT_swap_control",
3150 { "wglSwapIntervalEXT", X11DRV_wglSwapIntervalEXT
},
3151 { "wglGetSwapIntervalEXT", X11DRV_wglGetSwapIntervalEXT
},
3155 static const WineGLExtension WGL_NV_vertex_array_range
=
3157 "WGL_NV_vertex_array_range",
3159 { "wglAllocateMemoryNV", X11DRV_wglAllocateMemoryNV
},
3160 { "wglFreeMemoryNV", X11DRV_wglFreeMemoryNV
},
3164 static const WineGLExtension WGL_WINE_pixel_format_passthrough
=
3166 "WGL_WINE_pixel_format_passthrough",
3168 { "wglSetPixelFormatWINE", X11DRV_wglSetPixelFormatWINE
},
3173 * X11DRV_WineGL_LoadExtensions
3175 static void X11DRV_WineGL_LoadExtensions(void)
3177 WineGLInfo
.wglExtensions
[0] = 0;
3179 /* Load Wine internal functions */
3180 register_extension(&WGL_internal_functions
);
3182 /* ARB Extensions */
3184 if(glxRequireExtension("GLX_ARB_create_context"))
3186 register_extension(&WGL_ARB_create_context
);
3188 if(glxRequireExtension("GLX_ARB_create_context_profile"))
3189 register_extension_string("WGL_ARB_create_context_profile");
3192 if(glxRequireExtension("GLX_ARB_fbconfig_float"))
3194 register_extension_string("WGL_ARB_pixel_format_float");
3195 register_extension_string("WGL_ATI_pixel_format_float");
3198 register_extension(&WGL_ARB_extensions_string
);
3200 if (glxRequireVersion(3))
3201 register_extension(&WGL_ARB_make_current_read
);
3203 if (glxRequireExtension("GLX_ARB_multisample"))
3204 register_extension(&WGL_ARB_multisample
);
3206 /* In general pbuffer functionality requires support in the X-server. The functionality is
3207 * available either when the GLX_SGIX_pbuffer is present or when the GLX server version is 1.3.
3209 if ( glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer") )
3210 register_extension(&WGL_ARB_pbuffer
);
3212 register_extension(&WGL_ARB_pixel_format
);
3214 /* Support WGL_ARB_render_texture when there's support or pbuffer based emulation */
3215 if (glxRequireExtension("GLX_ARB_render_texture") ||
3216 (glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer") && use_render_texture_emulation
))
3218 register_extension(&WGL_ARB_render_texture
);
3220 /* The WGL version of GLX_NV_float_buffer requires render_texture */
3221 if(glxRequireExtension("GLX_NV_float_buffer"))
3222 register_extension_string("WGL_NV_float_buffer");
3224 /* Again there's no GLX equivalent for this extension, so depend on the required GL extension */
3225 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_texture_rectangle") != NULL
)
3226 register_extension_string("WGL_NV_texture_rectangle");
3229 /* EXT Extensions */
3231 register_extension(&WGL_EXT_extensions_string
);
3233 /* Load this extension even when it isn't backed by a GLX extension because it is has been around for ages.
3234 * Games like Call of Duty and K.O.T.O.R. rely on it. Further our emulation is good enough. */
3235 register_extension(&WGL_EXT_swap_control
);
3237 if(glxRequireExtension("GLX_EXT_framebuffer_sRGB"))
3238 register_extension_string("WGL_EXT_framebuffer_sRGB");
3240 if(glxRequireExtension("GLX_EXT_fbconfig_packed_float"))
3241 register_extension_string("WGL_EXT_pixel_format_packed_float");
3243 if (glxRequireExtension("GLX_EXT_swap_control"))
3244 has_swap_control
= TRUE
;
3246 /* The OpenGL extension GL_NV_vertex_array_range adds wgl/glX functions which aren't exported as 'real' wgl/glX extensions. */
3247 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_vertex_array_range") != NULL
)
3248 register_extension(&WGL_NV_vertex_array_range
);
3250 /* WINE-specific WGL Extensions */
3252 /* In WineD3D we need the ability to set the pixel format more than once (e.g. after a device reset).
3253 * The default wglSetPixelFormat doesn't allow this, so add our own which allows it.
3255 register_extension(&WGL_WINE_pixel_format_passthrough
);
3259 BOOL
destroy_glxpixmap(Display
*display
, XID glxpixmap
)
3262 pglXDestroyGLXPixmap(display
, glxpixmap
);
3263 wine_tsx11_unlock();
3268 * glxdrv_SwapBuffers
3270 * Swap the buffers of this DC
3272 static BOOL
glxdrv_SwapBuffers(PHYSDEV dev
)
3274 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3275 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
3277 TRACE("(%p)\n", dev
->hdc
);
3281 WARN("Using a NULL context, skipping\n");
3282 SetLastError(ERROR_INVALID_HANDLE
);
3286 if (!physdev
->drawable
)
3288 WARN("Using an invalid drawable, skipping\n");
3289 SetLastError(ERROR_INVALID_HANDLE
);
3295 switch (physdev
->type
)
3297 case DC_GL_PIXMAP_WIN
:
3298 if(pglXCopySubBufferMESA
) {
3299 int w
= physdev
->x11dev
->dc_rect
.right
- physdev
->x11dev
->dc_rect
.left
;
3300 int h
= physdev
->x11dev
->dc_rect
.bottom
- physdev
->x11dev
->dc_rect
.top
;
3302 /* (glX)SwapBuffers has an implicit glFlush effect, however
3303 * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before
3307 pglXCopySubBufferMESA(gdi_display
, physdev
->drawable
, 0, 0, w
, h
);
3312 pglXSwapBuffers(gdi_display
, physdev
->drawable
);
3316 flush_gl_drawable( physdev
);
3317 wine_tsx11_unlock();
3322 static long prev_time
, start_time
;
3323 static unsigned long frames
, frames_total
;
3325 DWORD time
= GetTickCount();
3328 /* every 1.5 seconds */
3329 if (time
- prev_time
> 1500) {
3330 TRACE_(fps
)("@ approx %.2ffps, total %.2ffps\n",
3331 1000.0*frames
/(time
- prev_time
), 1000.0*frames_total
/(time
- start_time
));
3334 if(start_time
== 0) start_time
= time
;
3341 XVisualInfo
*visual_from_fbconfig_id( XID fbconfig_id
)
3343 WineGLPixelFormat
*fmt
;
3346 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fbconfig_id
, 0 /* no flags */);
3351 ret
= pglXGetVisualFromFBConfig(gdi_display
, fmt
->fbconfig
);
3352 wine_tsx11_unlock();
3356 static BOOL
create_glx_dc( PHYSDEV
*pdev
)
3358 /* assume that only the main x11 device implements GetDeviceCaps */
3359 X11DRV_PDEVICE
*x11dev
= get_x11drv_dev( GET_NEXT_PHYSDEV( *pdev
, pGetDeviceCaps
));
3360 struct glx_physdev
*physdev
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*physdev
) );
3362 if (!physdev
) return FALSE
;
3363 physdev
->x11dev
= x11dev
;
3364 push_dc_driver( pdev
, &physdev
->dev
, &glxdrv_funcs
);
3368 /**********************************************************************
3371 static BOOL
glxdrv_CreateDC( PHYSDEV
*pdev
, LPCWSTR driver
, LPCWSTR device
,
3372 LPCWSTR output
, const DEVMODEW
* initData
)
3374 return create_glx_dc( pdev
);
3377 /**********************************************************************
3378 * glxdrv_CreateCompatibleDC
3380 static BOOL
glxdrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
3382 if (orig
) /* chain to next driver first */
3384 orig
= GET_NEXT_PHYSDEV( orig
, pCreateCompatibleDC
);
3385 if (!orig
->funcs
->pCreateCompatibleDC( orig
, pdev
)) return FALSE
;
3387 /* otherwise we have been called by x11drv */
3388 return create_glx_dc( pdev
);
3391 /**********************************************************************
3394 static BOOL
glxdrv_DeleteDC( PHYSDEV dev
)
3396 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3397 HeapFree( GetProcessHeap(), 0, physdev
);
3401 /**********************************************************************
3404 static INT
glxdrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_count
, LPCVOID in_data
,
3405 INT out_count
, LPVOID out_data
)
3407 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3409 dev
= GET_NEXT_PHYSDEV( dev
, pExtEscape
);
3411 if (escape
== X11DRV_ESCAPE
&& in_data
&& in_count
>= sizeof(enum x11drv_escape_codes
))
3413 switch (*(const enum x11drv_escape_codes
*)in_data
)
3415 case X11DRV_SET_DRAWABLE
:
3416 if (in_count
>= sizeof(struct x11drv_escape_set_drawable
))
3418 const struct x11drv_escape_set_drawable
*data
= in_data
;
3419 physdev
->pixel_format
= pixelformat_from_fbconfig_id( data
->fbconfig_id
);
3420 physdev
->type
= data
->gl_type
;
3421 physdev
->drawable
= data
->gl_drawable
;
3422 physdev
->pixmap
= data
->pixmap
;
3423 TRACE( "SET_DRAWABLE hdc %p drawable %lx pf %u type %u\n",
3424 dev
->hdc
, physdev
->drawable
, physdev
->pixel_format
, physdev
->type
);
3427 case X11DRV_GET_DRAWABLE
:
3428 if (out_count
>= sizeof(struct x11drv_escape_get_drawable
))
3430 struct x11drv_escape_get_drawable
*data
= out_data
;
3431 data
->pixel_format
= physdev
->pixel_format
;
3432 data
->gl_type
= physdev
->type
;
3433 data
->gl_drawable
= physdev
->drawable
;
3434 data
->pixmap
= physdev
->pixmap
;
3437 case X11DRV_FLUSH_GL_DRAWABLE
:
3438 flush_gl_drawable( physdev
);
3444 return dev
->funcs
->pExtEscape( dev
, escape
, in_count
, in_data
, out_count
, out_data
);
3447 /**********************************************************************
3448 * glxdrv_wine_get_wgl_driver
3450 static const struct wgl_funcs
* glxdrv_wine_get_wgl_driver( PHYSDEV dev
, UINT version
)
3452 if (version
!= WINE_GDI_DRIVER_VERSION
)
3454 ERR( "version mismatch, opengl32 wants %u but driver has %u\n", version
, WINE_GDI_DRIVER_VERSION
);
3457 if (!has_opengl()) return NULL
;
3458 return &glxdrv_wgl_funcs
;
3461 static const struct gdi_dc_funcs glxdrv_funcs
=
3463 NULL
, /* pAbortDoc */
3464 NULL
, /* pAbortPath */
3465 NULL
, /* pAlphaBlend */
3466 NULL
, /* pAngleArc */
3469 NULL
, /* pBeginPath */
3470 NULL
, /* pBlendImage */
3471 NULL
, /* pChoosePixelFormat */
3473 NULL
, /* pCloseFigure */
3474 glxdrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
3475 glxdrv_CreateDC
, /* pCreateDC */
3476 glxdrv_DeleteDC
, /* pDeleteDC */
3477 NULL
, /* pDeleteObject */
3478 glxdrv_DescribePixelFormat
, /* pDescribePixelFormat */
3479 NULL
, /* pDeviceCapabilities */
3480 NULL
, /* pEllipse */
3482 NULL
, /* pEndPage */
3483 NULL
, /* pEndPath */
3484 NULL
, /* pEnumFonts */
3485 NULL
, /* pEnumICMProfiles */
3486 NULL
, /* pExcludeClipRect */
3487 NULL
, /* pExtDeviceMode */
3488 glxdrv_ExtEscape
, /* pExtEscape */
3489 NULL
, /* pExtFloodFill */
3490 NULL
, /* pExtSelectClipRgn */
3491 NULL
, /* pExtTextOut */
3492 NULL
, /* pFillPath */
3493 NULL
, /* pFillRgn */
3494 NULL
, /* pFlattenPath */
3495 NULL
, /* pFontIsLinked */
3496 NULL
, /* pFrameRgn */
3497 NULL
, /* pGdiComment */
3498 NULL
, /* pGdiRealizationInfo */
3499 NULL
, /* pGetBoundsRect */
3500 NULL
, /* pGetCharABCWidths */
3501 NULL
, /* pGetCharABCWidthsI */
3502 NULL
, /* pGetCharWidth */
3503 NULL
, /* pGetDeviceCaps */
3504 NULL
, /* pGetDeviceGammaRamp */
3505 NULL
, /* pGetFontData */
3506 NULL
, /* pGetFontUnicodeRanges */
3507 NULL
, /* pGetGlyphIndices */
3508 NULL
, /* pGetGlyphOutline */
3509 NULL
, /* pGetICMProfile */
3510 NULL
, /* pGetImage */
3511 NULL
, /* pGetKerningPairs */
3512 NULL
, /* pGetNearestColor */
3513 NULL
, /* pGetOutlineTextMetrics */
3514 NULL
, /* pGetPixel */
3515 glxdrv_GetPixelFormat
, /* pGetPixelFormat */
3516 NULL
, /* pGetSystemPaletteEntries */
3517 NULL
, /* pGetTextCharsetInfo */
3518 NULL
, /* pGetTextExtentExPoint */
3519 NULL
, /* pGetTextExtentExPointI */
3520 NULL
, /* pGetTextFace */
3521 NULL
, /* pGetTextMetrics */
3522 NULL
, /* pGradientFill */
3523 NULL
, /* pIntersectClipRect */
3524 NULL
, /* pInvertRgn */
3526 NULL
, /* pModifyWorldTransform */
3528 NULL
, /* pOffsetClipRgn */
3529 NULL
, /* pOffsetViewportOrg */
3530 NULL
, /* pOffsetWindowOrg */
3531 NULL
, /* pPaintRgn */
3534 NULL
, /* pPolyBezier */
3535 NULL
, /* pPolyBezierTo */
3536 NULL
, /* pPolyDraw */
3537 NULL
, /* pPolyPolygon */
3538 NULL
, /* pPolyPolyline */
3539 NULL
, /* pPolygon */
3540 NULL
, /* pPolyline */
3541 NULL
, /* pPolylineTo */
3542 NULL
, /* pPutImage */
3543 NULL
, /* pRealizeDefaultPalette */
3544 NULL
, /* pRealizePalette */
3545 NULL
, /* pRectangle */
3546 NULL
, /* pResetDC */
3547 NULL
, /* pRestoreDC */
3548 NULL
, /* pRoundRect */
3550 NULL
, /* pScaleViewportExt */
3551 NULL
, /* pScaleWindowExt */
3552 NULL
, /* pSelectBitmap */
3553 NULL
, /* pSelectBrush */
3554 NULL
, /* pSelectClipPath */
3555 NULL
, /* pSelectFont */
3556 NULL
, /* pSelectPalette */
3557 NULL
, /* pSelectPen */
3558 NULL
, /* pSetArcDirection */
3559 NULL
, /* pSetBkColor */
3560 NULL
, /* pSetBkMode */
3561 NULL
, /* pSetBoundsRect */
3562 NULL
, /* pSetDCBrushColor */
3563 NULL
, /* pSetDCPenColor */
3564 NULL
, /* pSetDIBitsToDevice */
3565 NULL
, /* pSetDeviceClipping */
3566 NULL
, /* pSetDeviceGammaRamp */
3567 NULL
, /* pSetLayout */
3568 NULL
, /* pSetMapMode */
3569 NULL
, /* pSetMapperFlags */
3570 NULL
, /* pSetPixel */
3571 glxdrv_SetPixelFormat
, /* pSetPixelFormat */
3572 NULL
, /* pSetPolyFillMode */
3573 NULL
, /* pSetROP2 */
3574 NULL
, /* pSetRelAbs */
3575 NULL
, /* pSetStretchBltMode */
3576 NULL
, /* pSetTextAlign */
3577 NULL
, /* pSetTextCharacterExtra */
3578 NULL
, /* pSetTextColor */
3579 NULL
, /* pSetTextJustification */
3580 NULL
, /* pSetViewportExt */
3581 NULL
, /* pSetViewportOrg */
3582 NULL
, /* pSetWindowExt */
3583 NULL
, /* pSetWindowOrg */
3584 NULL
, /* pSetWorldTransform */
3585 NULL
, /* pStartDoc */
3586 NULL
, /* pStartPage */
3587 NULL
, /* pStretchBlt */
3588 NULL
, /* pStretchDIBits */
3589 NULL
, /* pStrokeAndFillPath */
3590 NULL
, /* pStrokePath */
3591 glxdrv_SwapBuffers
, /* pSwapBuffers */
3592 NULL
, /* pUnrealizePalette */
3593 NULL
, /* pWidenPath */
3594 glxdrv_wglCreateContext
, /* pwglCreateContext */
3595 NULL
, /* pwglCreateContextAttribsARB */
3596 glxdrv_wglGetProcAddress
, /* pwglGetProcAddress */
3597 glxdrv_wine_get_wgl_driver
, /* wine_get_wgl_driver */
3598 GDI_PRIORITY_GRAPHICS_DRV
+ 20 /* priority */
3601 static const struct wgl_funcs glxdrv_wgl_funcs
=
3603 glxdrv_wglCopyContext
, /* p_wglCopyContext */
3604 glxdrv_wglCreateContextAttribsARB
, /* p_wglCreateContextAttribsARB */
3605 glxdrv_wglDeleteContext
, /* p_wglDeleteContext */
3606 glxdrv_wglGetCurrentDC
, /* p_wglGetCurrentDC */
3607 glxdrv_wglMakeContextCurrentARB
, /* p_wglMakeContextCurrentARB */
3608 glxdrv_wglMakeCurrent
, /* p_wglMakeCurrent */
3609 glxdrv_wglShareLists
, /* p_wglShareLists */
3612 const struct gdi_dc_funcs
*get_glx_driver(void)
3614 return &glxdrv_funcs
;
3617 #else /* no OpenGL includes */
3619 const struct gdi_dc_funcs
*get_glx_driver(void)
3624 void mark_drawable_dirty(Drawable old
, Drawable
new)
3628 Drawable
create_glxpixmap(Display
*display
, XVisualInfo
*vis
, Pixmap parent
)
3634 BOOL
destroy_glxpixmap(Display
*display
, XID glxpixmap
)
3639 XVisualInfo
*visual_from_fbconfig_id( XID fbconfig_id
)
3644 #endif /* defined(SONAME_LIBGL) */