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
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/port.h"
32 #ifdef HAVE_SYS_SOCKET_H
33 #include <sys/socket.h>
41 #include "wine/library.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(wgl
);
48 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
67 /* Redefines the constants */
68 #define CALLBACK __stdcall
69 #define WINAPI __stdcall
70 #define APIENTRY WINAPI
73 WINE_DECLARE_DEBUG_CHANNEL(fps
);
75 typedef struct wine_glextension
{
84 const char *glVersion
;
89 const char *glxServerVersion
;
90 const char *glxServerVendor
;
91 const char *glxServerExtensions
;
93 const char *glxClientVersion
;
94 const char *glxClientVendor
;
95 const char *glxClientExtensions
;
97 const char *glxExtensions
;
100 char wglExtensions
[4096];
103 typedef struct wine_glpixelformat
{
105 GLXFBConfig fbconfig
;
109 DWORD dwFlags
; /* We store some PFD_* flags in here for emulated bitmap formats */
112 typedef struct wine_glcontext
{
114 BOOL has_been_current
;
119 WineGLPixelFormat
*fmt
;
120 int numAttribs
; /* This is needed for delaying wglCreateContextAttribsARB */
121 int attribList
[16]; /* This is needed for delaying wglCreateContextAttribsARB */
124 Drawable drawables
[2];
125 BOOL refresh_drawables
;
126 Pixmap pixmap
; /* pixmap for memory DCs */
127 GLXPixmap glxpixmap
; /* GLX pixmap for memory DCs */
128 SIZE pixmap_size
; /* pixmap size for memory DCs */
132 typedef struct wine_glpbuffer
{
135 WineGLPixelFormat
* fmt
;
141 int use_render_texture
; /* This is also the internal texture format */
142 int texture_bind_target
;
144 GLint texture_format
;
145 GLuint texture_target
;
153 struct gdi_physdev dev
;
154 X11DRV_PDEVICE
*x11dev
;
155 enum dc_gl_type type
; /* type of GL device context */
158 Pixmap pixmap
; /* pixmap for a DL_GL_PIXMAP_WIN drawable */
161 static const struct gdi_dc_funcs glxdrv_funcs
;
163 static inline struct glx_physdev
*get_glxdrv_dev( PHYSDEV dev
)
165 return (struct glx_physdev
*)dev
;
168 static struct list context_list
= LIST_INIT( context_list
);
169 static struct WineGLInfo WineGLInfo
= { 0 };
170 static int use_render_texture_emulation
= 1;
171 static int use_render_texture_ati
= 0;
172 static BOOL has_swap_control
;
173 static int swap_interval
= 1;
175 #define MAX_EXTENSIONS 16
176 static const WineGLExtension
*WineGLExtensionList
[MAX_EXTENSIONS
];
177 static int WineGLExtensionListSize
;
179 static void X11DRV_WineGL_LoadExtensions(void);
180 static WineGLPixelFormat
* ConvertPixelFormatWGLtoGLX(Display
*display
, int iPixelFormat
, BOOL AllowOffscreen
, int *fmt_count
);
181 static BOOL
glxRequireVersion(int requiredVersion
);
182 static BOOL
glxRequireExtension(const char *requiredExtension
);
184 static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR
*ppfd
) {
185 TRACE(" - size / version : %d / %d\n", ppfd
->nSize
, ppfd
->nVersion
);
186 TRACE(" - dwFlags : ");
187 #define TEST_AND_DUMP(t,tv) if ((t) & (tv)) TRACE(#tv " ")
188 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DEPTH_DONTCARE
);
189 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER
);
190 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER_DONTCARE
);
191 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_WINDOW
);
192 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_BITMAP
);
193 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_ACCELERATED
);
194 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_FORMAT
);
195 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_PALETTE
);
196 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_SYSTEM_PALETTE
);
197 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO
);
198 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO_DONTCARE
);
199 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_GDI
);
200 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_OPENGL
);
201 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_COPY
);
202 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_EXCHANGE
);
203 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_LAYER_BUFFERS
);
204 /* PFD_SUPPORT_COMPOSITION is new in Vista, it is similar to composition
205 * under X e.g. COMPOSITE + GLX_EXT_TEXTURE_FROM_PIXMAP. */
206 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_COMPOSITION
);
210 TRACE(" - iPixelType : ");
211 switch (ppfd
->iPixelType
) {
212 case PFD_TYPE_RGBA
: TRACE("PFD_TYPE_RGBA"); break;
213 case PFD_TYPE_COLORINDEX
: TRACE("PFD_TYPE_COLORINDEX"); break;
217 TRACE(" - Color : %d\n", ppfd
->cColorBits
);
218 TRACE(" - Red : %d\n", ppfd
->cRedBits
);
219 TRACE(" - Green : %d\n", ppfd
->cGreenBits
);
220 TRACE(" - Blue : %d\n", ppfd
->cBlueBits
);
221 TRACE(" - Alpha : %d\n", ppfd
->cAlphaBits
);
222 TRACE(" - Accum : %d\n", ppfd
->cAccumBits
);
223 TRACE(" - Depth : %d\n", ppfd
->cDepthBits
);
224 TRACE(" - Stencil : %d\n", ppfd
->cStencilBits
);
225 TRACE(" - Aux : %d\n", ppfd
->cAuxBuffers
);
227 TRACE(" - iLayerType : ");
228 switch (ppfd
->iLayerType
) {
229 case PFD_MAIN_PLANE
: TRACE("PFD_MAIN_PLANE"); break;
230 case PFD_OVERLAY_PLANE
: TRACE("PFD_OVERLAY_PLANE"); break;
231 case (BYTE
)PFD_UNDERLAY_PLANE
: TRACE("PFD_UNDERLAY_PLANE"); break;
236 #define PUSH1(attribs,att) do { attribs[nAttribs++] = (att); } while (0)
237 #define PUSH2(attribs,att,value) do { attribs[nAttribs++] = (att); attribs[nAttribs++] = (value); } while(0)
239 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
241 MAKE_FUNCPTR(glXChooseVisual
)
242 MAKE_FUNCPTR(glXCopyContext
)
243 MAKE_FUNCPTR(glXCreateContext
)
244 MAKE_FUNCPTR(glXCreateGLXPixmap
)
245 MAKE_FUNCPTR(glXGetCurrentContext
)
246 MAKE_FUNCPTR(glXGetCurrentDrawable
)
247 MAKE_FUNCPTR(glXDestroyContext
)
248 MAKE_FUNCPTR(glXDestroyGLXPixmap
)
249 MAKE_FUNCPTR(glXGetConfig
)
250 MAKE_FUNCPTR(glXIsDirect
)
251 MAKE_FUNCPTR(glXMakeCurrent
)
252 MAKE_FUNCPTR(glXSwapBuffers
)
253 MAKE_FUNCPTR(glXQueryExtension
)
254 MAKE_FUNCPTR(glXQueryVersion
)
257 MAKE_FUNCPTR(glXGetClientString
)
258 MAKE_FUNCPTR(glXQueryExtensionsString
)
259 MAKE_FUNCPTR(glXQueryServerString
)
262 MAKE_FUNCPTR(glXGetFBConfigs
)
263 MAKE_FUNCPTR(glXChooseFBConfig
)
264 MAKE_FUNCPTR(glXCreatePbuffer
)
265 MAKE_FUNCPTR(glXCreateNewContext
)
266 MAKE_FUNCPTR(glXDestroyPbuffer
)
267 MAKE_FUNCPTR(glXGetFBConfigAttrib
)
268 MAKE_FUNCPTR(glXGetVisualFromFBConfig
)
269 MAKE_FUNCPTR(glXMakeContextCurrent
)
270 MAKE_FUNCPTR(glXQueryDrawable
)
271 MAKE_FUNCPTR(glXGetCurrentReadDrawable
)
274 static GLXContext (*pglXCreateContextAttribsARB
)(Display
*dpy
, GLXFBConfig config
, GLXContext share_context
, Bool direct
, const int *attrib_list
);
275 static void* (*pglXGetProcAddressARB
)(const GLubyte
*);
276 static int (*pglXSwapIntervalSGI
)(int);
278 /* ATI GLX Extensions */
279 static BOOL (*pglXBindTexImageATI
)(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
);
280 static BOOL (*pglXReleaseTexImageATI
)(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
);
281 static BOOL (*pglXDrawableAttribATI
)(Display
*dpy
, GLXDrawable draw
, const int *attribList
);
283 /* NV GLX Extension */
284 static void* (*pglXAllocateMemoryNV
)(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
);
285 static void (*pglXFreeMemoryNV
)(GLvoid
*pointer
);
287 /* MESA GLX Extensions */
288 static void (*pglXCopySubBufferMESA
)(Display
*dpy
, GLXDrawable drawable
, int x
, int y
, int width
, int height
);
290 /* Standard OpenGL */
291 MAKE_FUNCPTR(glBindTexture
)
292 MAKE_FUNCPTR(glBitmap
)
293 MAKE_FUNCPTR(glCopyTexSubImage1D
)
294 MAKE_FUNCPTR(glCopyTexImage2D
)
295 MAKE_FUNCPTR(glCopyTexSubImage2D
)
296 MAKE_FUNCPTR(glDrawBuffer
)
297 MAKE_FUNCPTR(glEndList
)
298 MAKE_FUNCPTR(glGetError
)
299 MAKE_FUNCPTR(glGetIntegerv
)
300 MAKE_FUNCPTR(glGetString
)
301 MAKE_FUNCPTR(glNewList
)
302 MAKE_FUNCPTR(glPixelStorei
)
303 MAKE_FUNCPTR(glReadPixels
)
304 MAKE_FUNCPTR(glTexImage2D
)
305 MAKE_FUNCPTR(glFinish
)
306 MAKE_FUNCPTR(glFlush
)
309 static int GLXErrorHandler(Display
*dpy
, XErrorEvent
*event
, void *arg
)
311 /* In the future we might want to find the exact X or GLX error to report back to the app */
315 static BOOL infoInitialized
= FALSE
;
316 static BOOL
X11DRV_WineGL_InitOpenglInfo(void)
318 int screen
= DefaultScreen(gdi_display
);
319 Window win
= 0, root
= 0;
320 const char *gl_renderer
;
323 GLXContext ctx
= NULL
;
324 XSetWindowAttributes attr
;
326 int attribList
[] = {GLX_RGBA
, GLX_DOUBLEBUFFER
, None
};
330 infoInitialized
= TRUE
;
332 attr
.override_redirect
= True
;
333 attr
.colormap
= None
;
334 attr
.border_pixel
= 0;
338 vis
= pglXChooseVisual(gdi_display
, screen
, attribList
);
341 WORD old_fs
= wine_get_fs();
342 /* Create a GLX Context. Without one we can't query GL information */
343 ctx
= pglXCreateContext(gdi_display
, vis
, None
, GL_TRUE
);
344 if (wine_get_fs() != old_fs
)
346 wine_set_fs( old_fs
);
347 ERR( "%%fs register corrupted, probably broken ATI driver, disabling OpenGL.\n" );
348 ERR( "You need to set the \"UseFastTls\" option to \"2\" in your X config file.\n" );
352 ctx
= pglXCreateContext(gdi_display
, vis
, None
, GL_TRUE
);
357 root
= RootWindow( gdi_display
, vis
->screen
);
358 if (vis
->visual
!= DefaultVisual( gdi_display
, vis
->screen
))
359 attr
.colormap
= XCreateColormap( gdi_display
, root
, vis
->visual
, AllocNone
);
360 if ((win
= XCreateWindow( gdi_display
, root
, -1, -1, 1, 1, 0, vis
->depth
, InputOutput
,
361 vis
->visual
, CWBorderPixel
| CWOverrideRedirect
| CWColormap
, &attr
)))
362 XMapWindow( gdi_display
, win
);
366 if(pglXMakeCurrent(gdi_display
, win
, ctx
) == 0)
368 ERR_(winediag
)( "Unable to activate OpenGL context, most likely your OpenGL drivers haven't been installed correctly\n" );
371 gl_renderer
= (const char *)pglGetString(GL_RENDERER
);
372 WineGLInfo
.glVersion
= (const char *) pglGetString(GL_VERSION
);
373 str
= (const char *) pglGetString(GL_EXTENSIONS
);
374 WineGLInfo
.glExtensions
= HeapAlloc(GetProcessHeap(), 0, strlen(str
)+1);
375 strcpy(WineGLInfo
.glExtensions
, str
);
377 /* Get the common GLX version supported by GLX client and server ( major/minor) */
378 pglXQueryVersion(gdi_display
, &WineGLInfo
.glxVersion
[0], &WineGLInfo
.glxVersion
[1]);
380 WineGLInfo
.glxServerVersion
= pglXQueryServerString(gdi_display
, screen
, GLX_VERSION
);
381 WineGLInfo
.glxServerVendor
= pglXQueryServerString(gdi_display
, screen
, GLX_VENDOR
);
382 WineGLInfo
.glxServerExtensions
= pglXQueryServerString(gdi_display
, screen
, GLX_EXTENSIONS
);
384 WineGLInfo
.glxClientVersion
= pglXGetClientString(gdi_display
, GLX_VERSION
);
385 WineGLInfo
.glxClientVendor
= pglXGetClientString(gdi_display
, GLX_VENDOR
);
386 WineGLInfo
.glxClientExtensions
= pglXGetClientString(gdi_display
, GLX_EXTENSIONS
);
388 WineGLInfo
.glxExtensions
= pglXQueryExtensionsString(gdi_display
, screen
);
389 WineGLInfo
.glxDirect
= pglXIsDirect(gdi_display
, ctx
);
391 TRACE("GL version : %s.\n", WineGLInfo
.glVersion
);
392 TRACE("GL renderer : %s.\n", gl_renderer
);
393 TRACE("GLX version : %d.%d.\n", WineGLInfo
.glxVersion
[0], WineGLInfo
.glxVersion
[1]);
394 TRACE("Server GLX version : %s.\n", WineGLInfo
.glxServerVersion
);
395 TRACE("Server GLX vendor: : %s.\n", WineGLInfo
.glxServerVendor
);
396 TRACE("Client GLX version : %s.\n", WineGLInfo
.glxClientVersion
);
397 TRACE("Client GLX vendor: : %s.\n", WineGLInfo
.glxClientVendor
);
398 TRACE("Direct rendering enabled: %s\n", WineGLInfo
.glxDirect
? "True" : "False");
400 if(!WineGLInfo
.glxDirect
)
402 int fd
= ConnectionNumber(gdi_display
);
403 struct sockaddr_un uaddr
;
404 unsigned int uaddrlen
= sizeof(struct sockaddr_un
);
406 /* In general indirect rendering on a local X11 server indicates a driver problem.
407 * Detect a local X11 server by checking whether the X11 socket is a Unix socket.
409 if(!getsockname(fd
, (struct sockaddr
*)&uaddr
, &uaddrlen
) && uaddr
.sun_family
== AF_UNIX
)
410 ERR_(winediag
)("Direct rendering is disabled, most likely your OpenGL drivers "
411 "haven't been installed correctly (using GL renderer %s, version %s).\n",
412 debugstr_a(gl_renderer
), debugstr_a(WineGLInfo
.glVersion
));
416 /* In general you would expect that if direct rendering is returned, that you receive hardware
417 * accelerated OpenGL rendering. The definition of direct rendering is that rendering is performed
418 * client side without sending all GL commands to X using the GLX protocol. When Mesa falls back to
419 * software rendering, it shows direct rendering.
421 * Depending on the cause of software rendering a different rendering string is shown. In case Mesa fails
422 * to load a DRI module 'Software Rasterizer' is returned. When Mesa is compiled as a OpenGL reference driver
423 * it shows 'Mesa X11'.
425 if(!strcmp(gl_renderer
, "Software Rasterizer") || !strcmp(gl_renderer
, "Mesa X11"))
426 ERR_(winediag
)("The Mesa OpenGL driver is using software rendering, most likely your OpenGL "
427 "drivers haven't been installed correctly (using GL renderer %s, version %s).\n",
428 debugstr_a(gl_renderer
), debugstr_a(WineGLInfo
.glVersion
));
435 pglXMakeCurrent(gdi_display
, None
, NULL
);
436 pglXDestroyContext(gdi_display
, ctx
);
438 if (win
!= root
) XDestroyWindow( gdi_display
, win
);
439 if (attr
.colormap
) XFreeColormap( gdi_display
, attr
.colormap
);
441 if (!ret
) ERR(" couldn't initialize OpenGL, expect problems\n");
445 static BOOL
has_opengl(void)
447 static int init_done
;
448 static void *opengl_handle
;
451 int error_base
, event_base
;
453 if (init_done
) return (opengl_handle
!= NULL
);
456 /* No need to load any other libraries as according to the ABI, libGL should be self-sufficient
457 and include all dependencies */
458 opengl_handle
= wine_dlopen(SONAME_LIBGL
, RTLD_NOW
|RTLD_GLOBAL
, buffer
, sizeof(buffer
));
459 if (opengl_handle
== NULL
)
461 ERR( "Failed to load libGL: %s\n", buffer
);
462 ERR( "OpenGL support is disabled.\n");
466 pglXGetProcAddressARB
= wine_dlsym(opengl_handle
, "glXGetProcAddressARB", NULL
, 0);
467 if (pglXGetProcAddressARB
== NULL
) {
468 ERR("Could not find glXGetProcAddressARB in libGL, disabling OpenGL.\n");
472 #define LOAD_FUNCPTR(f) do if((p##f = (void*)pglXGetProcAddressARB((const unsigned char*)#f)) == NULL) \
474 ERR( "%s not found in libGL, disabling OpenGL.\n", #f ); \
479 LOAD_FUNCPTR(glXChooseVisual
);
480 LOAD_FUNCPTR(glXCopyContext
);
481 LOAD_FUNCPTR(glXCreateContext
);
482 LOAD_FUNCPTR(glXCreateGLXPixmap
);
483 LOAD_FUNCPTR(glXGetCurrentContext
);
484 LOAD_FUNCPTR(glXGetCurrentDrawable
);
485 LOAD_FUNCPTR(glXDestroyContext
);
486 LOAD_FUNCPTR(glXDestroyGLXPixmap
);
487 LOAD_FUNCPTR(glXGetConfig
);
488 LOAD_FUNCPTR(glXIsDirect
);
489 LOAD_FUNCPTR(glXMakeCurrent
);
490 LOAD_FUNCPTR(glXSwapBuffers
);
491 LOAD_FUNCPTR(glXQueryExtension
);
492 LOAD_FUNCPTR(glXQueryVersion
);
495 LOAD_FUNCPTR(glXGetClientString
);
496 LOAD_FUNCPTR(glXQueryExtensionsString
);
497 LOAD_FUNCPTR(glXQueryServerString
);
500 LOAD_FUNCPTR(glXCreatePbuffer
);
501 LOAD_FUNCPTR(glXCreateNewContext
);
502 LOAD_FUNCPTR(glXDestroyPbuffer
);
503 LOAD_FUNCPTR(glXMakeContextCurrent
);
504 LOAD_FUNCPTR(glXGetCurrentReadDrawable
);
505 LOAD_FUNCPTR(glXGetFBConfigs
);
507 /* Standard OpenGL calls */
508 LOAD_FUNCPTR(glBindTexture
);
509 LOAD_FUNCPTR(glBitmap
);
510 LOAD_FUNCPTR(glCopyTexSubImage1D
);
511 LOAD_FUNCPTR(glCopyTexImage2D
);
512 LOAD_FUNCPTR(glCopyTexSubImage2D
);
513 LOAD_FUNCPTR(glDrawBuffer
);
514 LOAD_FUNCPTR(glEndList
);
515 LOAD_FUNCPTR(glGetError
);
516 LOAD_FUNCPTR(glGetIntegerv
);
517 LOAD_FUNCPTR(glGetString
);
518 LOAD_FUNCPTR(glNewList
);
519 LOAD_FUNCPTR(glPixelStorei
);
520 LOAD_FUNCPTR(glReadPixels
);
521 LOAD_FUNCPTR(glTexImage2D
);
522 LOAD_FUNCPTR(glFinish
);
523 LOAD_FUNCPTR(glFlush
);
526 /* It doesn't matter if these fail. They'll only be used if the driver reports
527 the associated extension is available (and if a driver reports the extension
528 is available but fails to provide the functions, it's quite broken) */
529 #define LOAD_FUNCPTR(f) p##f = pglXGetProcAddressARB((const GLubyte *)#f)
530 /* ARB GLX Extension */
531 LOAD_FUNCPTR(glXCreateContextAttribsARB
);
532 /* SGI GLX Extension */
533 LOAD_FUNCPTR(glXSwapIntervalSGI
);
534 /* NV GLX Extension */
535 LOAD_FUNCPTR(glXAllocateMemoryNV
);
536 LOAD_FUNCPTR(glXFreeMemoryNV
);
539 if(!X11DRV_WineGL_InitOpenglInfo()) goto failed
;
542 if (pglXQueryExtension(gdi_display
, &error_base
, &event_base
)) {
543 TRACE("GLX is up and running error_base = %d\n", error_base
);
546 ERR( "GLX extension is missing, disabling OpenGL.\n" );
550 /* In case of GLX you have direct and indirect rendering. Most of the time direct rendering is used
551 * as in general only that is hardware accelerated. In some cases like in case of remote X indirect
554 * The main problem for our OpenGL code is that we need certain GLX calls but their presence
555 * depends on the reported GLX client / server version and on the client / server extension list.
556 * Those don't have to be the same.
558 * In general the server GLX information lists the capabilities in case of indirect rendering.
559 * When direct rendering is used, the OpenGL client library is responsible for which GLX calls are
560 * available and in that case the client GLX informat can be used.
561 * OpenGL programs should use the 'intersection' of both sets of information which is advertised
562 * in the GLX version/extension list. When a program does this it works for certain for both
563 * direct and indirect rendering.
565 * The problem we are having in this area is that ATI's Linux drivers are broken. For some reason
566 * they haven't added some very important GLX extensions like GLX_SGIX_fbconfig to their client
567 * extension list which causes this extension not to be listed. (Wine requires this extension).
568 * ATI advertises a GLX client version of 1.3 which implies that this fbconfig extension among
569 * pbuffers is around.
571 * In order to provide users of Ati's proprietary drivers with OpenGL support, we need to detect
572 * the ATI drivers and from then on use GLX client information for them.
575 if(glxRequireVersion(3)) {
576 pglXChooseFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfig");
577 pglXGetFBConfigAttrib
= pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttrib");
578 pglXGetVisualFromFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfig");
579 pglXQueryDrawable
= pglXGetProcAddressARB((const GLubyte
*) "glXQueryDrawable");
580 } else if(glxRequireExtension("GLX_SGIX_fbconfig")) {
581 pglXChooseFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfigSGIX");
582 pglXGetFBConfigAttrib
= pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttribSGIX");
583 pglXGetVisualFromFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfigSGIX");
585 /* The mesa libGL client library seems to forward glXQueryDrawable to the Xserver, so only
586 * enable this function when the Xserver understand GLX 1.3 or newer
588 pglXQueryDrawable
= NULL
;
589 } else if(strcmp("ATI", WineGLInfo
.glxClientVendor
) == 0) {
590 TRACE("Overriding ATI GLX capabilities!\n");
591 pglXChooseFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfig");
592 pglXGetFBConfigAttrib
= pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttrib");
593 pglXGetVisualFromFBConfig
= pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfig");
594 pglXQueryDrawable
= pglXGetProcAddressARB((const GLubyte
*) "glXQueryDrawable");
596 /* Use client GLX information in case of the ATI drivers. We override the
597 * capabilities over here and not somewhere else as ATI might better their
598 * life in the future. In case they release proper drivers this block of
599 * code won't be called. */
600 WineGLInfo
.glxExtensions
= WineGLInfo
.glxClientExtensions
;
602 ERR(" glx_version is %s and GLX_SGIX_fbconfig extension is unsupported. Expect problems.\n", WineGLInfo
.glxServerVersion
);
605 if(glxRequireExtension("GLX_ATI_render_texture")) {
606 use_render_texture_ati
= 1;
607 pglXBindTexImageATI
= pglXGetProcAddressARB((const GLubyte
*) "glXBindTexImageATI");
608 pglXReleaseTexImageATI
= pglXGetProcAddressARB((const GLubyte
*) "glXReleaseTexImageATI");
609 pglXDrawableAttribATI
= pglXGetProcAddressARB((const GLubyte
*) "glXDrawableAttribATI");
612 if(glxRequireExtension("GLX_MESA_copy_sub_buffer")) {
613 pglXCopySubBufferMESA
= pglXGetProcAddressARB((const GLubyte
*) "glXCopySubBufferMESA");
616 X11DRV_WineGL_LoadExtensions();
622 wine_dlclose(opengl_handle
, NULL
, 0);
623 opengl_handle
= NULL
;
627 static inline BOOL
is_valid_context( Wine_GLContext
*ctx
)
630 LIST_FOR_EACH_ENTRY( ptr
, &context_list
, struct wine_glcontext
, entry
)
631 if (ptr
== ctx
) return TRUE
;
635 static int describeContext(Wine_GLContext
* ctx
) {
638 TRACE(" Context %p have (vis:%p):\n", ctx
, ctx
->vis
);
639 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_FBCONFIG_ID
, &tmp
);
640 TRACE(" - FBCONFIG_ID 0x%x\n", tmp
);
641 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_VISUAL_ID
, &tmp
);
642 TRACE(" - VISUAL_ID 0x%x\n", tmp
);
647 static BOOL
describeDrawable( struct glx_physdev
*physdev
)
650 WineGLPixelFormat
*fmt
;
653 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, physdev
->pixel_format
, TRUE
/* Offscreen */, &fmt_count
);
654 if(!fmt
) return FALSE
;
656 TRACE(" HDC %p has:\n", physdev
->dev
.hdc
);
657 TRACE(" - iPixelFormat %d\n", fmt
->iPixelFormat
);
658 TRACE(" - Drawable %lx\n", physdev
->drawable
);
659 TRACE(" - FBCONFIG_ID 0x%x\n", fmt
->fmt_id
);
661 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_VISUAL_ID
, &tmp
);
662 TRACE(" - VISUAL_ID 0x%x\n", tmp
);
667 static int ConvertAttribWGLtoGLX(const int* iWGLAttr
, int* oGLXAttr
, Wine_GLPBuffer
* pbuf
) {
672 int nvfloatattrib
= GLX_DONT_CARE
;
673 int pixelattrib
= GLX_DONT_CARE
;
675 /* The list of WGL attributes is allowed to be NULL. We don't return here for NULL
676 * because we need to do fixups for GLX_DRAWABLE_TYPE/GLX_RENDER_TYPE/GLX_FLOAT_COMPONENTS_NV. */
677 while (iWGLAttr
&& 0 != iWGLAttr
[cur
]) {
678 TRACE("pAttr[%d] = %x\n", cur
, iWGLAttr
[cur
]);
680 switch (iWGLAttr
[cur
]) {
681 case WGL_AUX_BUFFERS_ARB
:
682 pop
= iWGLAttr
[++cur
];
683 PUSH2(oGLXAttr
, GLX_AUX_BUFFERS
, pop
);
684 TRACE("pAttr[%d] = GLX_AUX_BUFFERS: %d\n", cur
, pop
);
686 case WGL_COLOR_BITS_ARB
:
687 pop
= iWGLAttr
[++cur
];
688 PUSH2(oGLXAttr
, GLX_BUFFER_SIZE
, pop
);
689 TRACE("pAttr[%d] = GLX_BUFFER_SIZE: %d\n", cur
, pop
);
691 case WGL_BLUE_BITS_ARB
:
692 pop
= iWGLAttr
[++cur
];
693 PUSH2(oGLXAttr
, GLX_BLUE_SIZE
, pop
);
694 TRACE("pAttr[%d] = GLX_BLUE_SIZE: %d\n", cur
, pop
);
696 case WGL_RED_BITS_ARB
:
697 pop
= iWGLAttr
[++cur
];
698 PUSH2(oGLXAttr
, GLX_RED_SIZE
, pop
);
699 TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur
, pop
);
701 case WGL_GREEN_BITS_ARB
:
702 pop
= iWGLAttr
[++cur
];
703 PUSH2(oGLXAttr
, GLX_GREEN_SIZE
, pop
);
704 TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur
, pop
);
706 case WGL_ALPHA_BITS_ARB
:
707 pop
= iWGLAttr
[++cur
];
708 PUSH2(oGLXAttr
, GLX_ALPHA_SIZE
, pop
);
709 TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur
, pop
);
711 case WGL_DEPTH_BITS_ARB
:
712 pop
= iWGLAttr
[++cur
];
713 PUSH2(oGLXAttr
, GLX_DEPTH_SIZE
, pop
);
714 TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur
, pop
);
716 case WGL_STENCIL_BITS_ARB
:
717 pop
= iWGLAttr
[++cur
];
718 PUSH2(oGLXAttr
, GLX_STENCIL_SIZE
, pop
);
719 TRACE("pAttr[%d] = GLX_STENCIL_SIZE: %d\n", cur
, pop
);
721 case WGL_DOUBLE_BUFFER_ARB
:
722 pop
= iWGLAttr
[++cur
];
723 PUSH2(oGLXAttr
, GLX_DOUBLEBUFFER
, pop
);
724 TRACE("pAttr[%d] = GLX_DOUBLEBUFFER: %d\n", cur
, pop
);
727 pop
= iWGLAttr
[++cur
];
728 PUSH2(oGLXAttr
, GLX_STEREO
, pop
);
729 TRACE("pAttr[%d] = GLX_STEREO: %d\n", cur
, pop
);
732 case WGL_PIXEL_TYPE_ARB
:
733 pop
= iWGLAttr
[++cur
];
734 TRACE("pAttr[%d] = WGL_PIXEL_TYPE_ARB: %d\n", cur
, pop
);
736 case WGL_TYPE_COLORINDEX_ARB
: pixelattrib
= GLX_COLOR_INDEX_BIT
; break ;
737 case WGL_TYPE_RGBA_ARB
: pixelattrib
= GLX_RGBA_BIT
; break ;
738 /* 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 */
739 case WGL_TYPE_RGBA_FLOAT_ATI
: pixelattrib
= GLX_RGBA_FLOAT_BIT
; break ;
740 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
: pixelattrib
= GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
; break ;
742 ERR("unexpected PixelType(%x)\n", pop
);
747 case WGL_SUPPORT_GDI_ARB
:
748 /* This flag is set in a WineGLPixelFormat */
749 pop
= iWGLAttr
[++cur
];
750 TRACE("pAttr[%d] = WGL_SUPPORT_GDI_ARB: %d\n", cur
, pop
);
753 case WGL_DRAW_TO_BITMAP_ARB
:
754 /* This flag is set in a WineGLPixelFormat */
755 pop
= iWGLAttr
[++cur
];
756 TRACE("pAttr[%d] = WGL_DRAW_TO_BITMAP_ARB: %d\n", cur
, pop
);
759 case WGL_DRAW_TO_WINDOW_ARB
:
760 pop
= iWGLAttr
[++cur
];
761 TRACE("pAttr[%d] = WGL_DRAW_TO_WINDOW_ARB: %d\n", cur
, pop
);
762 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
764 drawattrib
|= GLX_WINDOW_BIT
;
768 case WGL_DRAW_TO_PBUFFER_ARB
:
769 pop
= iWGLAttr
[++cur
];
770 TRACE("pAttr[%d] = WGL_DRAW_TO_PBUFFER_ARB: %d\n", cur
, pop
);
771 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
773 drawattrib
|= GLX_PBUFFER_BIT
;
777 case WGL_ACCELERATION_ARB
:
778 /* This flag is set in a WineGLPixelFormat */
779 pop
= iWGLAttr
[++cur
];
780 TRACE("pAttr[%d] = WGL_ACCELERATION_ARB: %d\n", cur
, pop
);
783 case WGL_SUPPORT_OPENGL_ARB
:
784 pop
= iWGLAttr
[++cur
];
785 /** nothing to do, if we are here, supposing support Accelerated OpenGL */
786 TRACE("pAttr[%d] = WGL_SUPPORT_OPENGL_ARB: %d\n", cur
, pop
);
789 case WGL_SWAP_METHOD_ARB
:
790 pop
= iWGLAttr
[++cur
];
791 /* For now we ignore this and just return SWAP_EXCHANGE */
792 TRACE("pAttr[%d] = WGL_SWAP_METHOD_ARB: %#x\n", cur
, pop
);
795 case WGL_PBUFFER_LARGEST_ARB
:
796 pop
= iWGLAttr
[++cur
];
797 PUSH2(oGLXAttr
, GLX_LARGEST_PBUFFER
, pop
);
798 TRACE("pAttr[%d] = GLX_LARGEST_PBUFFER: %x\n", cur
, pop
);
801 case WGL_SAMPLE_BUFFERS_ARB
:
802 pop
= iWGLAttr
[++cur
];
803 PUSH2(oGLXAttr
, GLX_SAMPLE_BUFFERS_ARB
, pop
);
804 TRACE("pAttr[%d] = GLX_SAMPLE_BUFFERS_ARB: %x\n", cur
, pop
);
807 case WGL_SAMPLES_ARB
:
808 pop
= iWGLAttr
[++cur
];
809 PUSH2(oGLXAttr
, GLX_SAMPLES_ARB
, pop
);
810 TRACE("pAttr[%d] = GLX_SAMPLES_ARB: %x\n", cur
, pop
);
813 case WGL_TEXTURE_FORMAT_ARB
:
814 case WGL_TEXTURE_TARGET_ARB
:
815 case WGL_MIPMAP_TEXTURE_ARB
:
816 TRACE("WGL_render_texture Attributes: %x as %x\n", iWGLAttr
[cur
], iWGLAttr
[cur
+ 1]);
817 pop
= iWGLAttr
[++cur
];
819 ERR("trying to use GLX_Pbuffer Attributes without Pbuffer (was %x)\n", iWGLAttr
[cur
]);
821 if (use_render_texture_ati
) {
822 /** nothing to do here */
824 else if (!use_render_texture_emulation
) {
825 if (WGL_NO_TEXTURE_ARB
!= pop
) {
826 ERR("trying to use WGL_render_texture Attributes without support (was %x)\n", iWGLAttr
[cur
]);
827 return -1; /** error: don't support it */
829 drawattrib
|= GLX_PBUFFER_BIT
;
833 case WGL_FLOAT_COMPONENTS_NV
:
834 nvfloatattrib
= iWGLAttr
[++cur
];
835 TRACE("pAttr[%d] = WGL_FLOAT_COMPONENTS_NV: %x\n", cur
, nvfloatattrib
);
837 case WGL_BIND_TO_TEXTURE_DEPTH_NV
:
838 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
839 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
840 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV
:
841 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV
:
842 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV
:
843 case WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV
:
844 pop
= iWGLAttr
[++cur
];
845 /** cannot be converted, see direct handling on
846 * - wglGetPixelFormatAttribivARB
847 * TODO: wglChoosePixelFormat
850 case WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT
:
851 pop
= iWGLAttr
[++cur
];
852 PUSH2(oGLXAttr
, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
, pop
);
853 TRACE("pAttr[%d] = GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT: %x\n", cur
, pop
);
856 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
:
857 pop
= iWGLAttr
[++cur
];
858 PUSH2(oGLXAttr
, GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
, pop
);
859 TRACE("pAttr[%d] = GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT: %x\n", cur
, pop
);
862 FIXME("unsupported %x WGL Attribute\n", iWGLAttr
[cur
]);
868 /* By default glXChooseFBConfig defaults to GLX_WINDOW_BIT. wglChoosePixelFormatARB searches through
869 * all formats. Unless drawattrib is set to a non-zero value override it with GLX_DONT_CARE, so that
870 * pixmap and pbuffer formats appear as well. */
871 if (!drawattrib
) drawattrib
= GLX_DONT_CARE
;
872 PUSH2(oGLXAttr
, GLX_DRAWABLE_TYPE
, drawattrib
);
873 TRACE("pAttr[?] = GLX_DRAWABLE_TYPE: %#x\n", drawattrib
);
875 /* By default glXChooseFBConfig uses GLX_RGBA_BIT as the default value. Since wglChoosePixelFormatARB
876 * searches in all formats we have to do the same. For this reason we set GLX_RENDER_TYPE to
877 * GLX_DONT_CARE unless it is overridden. */
878 PUSH2(oGLXAttr
, GLX_RENDER_TYPE
, pixelattrib
);
879 TRACE("pAttr[?] = GLX_RENDER_TYPE: %#x\n", pixelattrib
);
881 /* Set GLX_FLOAT_COMPONENTS_NV all the time */
882 if(strstr(WineGLInfo
.glxExtensions
, "GLX_NV_float_buffer")) {
883 PUSH2(oGLXAttr
, GLX_FLOAT_COMPONENTS_NV
, nvfloatattrib
);
884 TRACE("pAttr[?] = GLX_FLOAT_COMPONENTS_NV: %#x\n", nvfloatattrib
);
890 static int get_render_type_from_fbconfig(Display
*display
, GLXFBConfig fbconfig
)
892 int render_type
=0, render_type_bit
;
893 pglXGetFBConfigAttrib(display
, fbconfig
, GLX_RENDER_TYPE
, &render_type_bit
);
894 switch(render_type_bit
)
897 render_type
= GLX_RGBA_TYPE
;
899 case GLX_COLOR_INDEX_BIT
:
900 render_type
= GLX_COLOR_INDEX_TYPE
;
902 case GLX_RGBA_FLOAT_BIT
:
903 render_type
= GLX_RGBA_FLOAT_TYPE
;
905 case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
:
906 render_type
= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
;
909 ERR("Unknown render_type: %x\n", render_type_bit
);
914 /* Check whether a fbconfig is suitable for Windows-style bitmap rendering */
915 static BOOL
check_fbconfig_bitmap_capability(Display
*display
, GLXFBConfig fbconfig
)
918 pglXGetFBConfigAttrib(display
, fbconfig
, GLX_DOUBLEBUFFER
, &dbuf
);
919 pglXGetFBConfigAttrib(gdi_display
, fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
921 /* Windows only supports bitmap rendering on single buffered formats, further the fbconfig needs to have
922 * the GLX_PIXMAP_BIT set. */
923 return !dbuf
&& (value
& GLX_PIXMAP_BIT
);
926 static WineGLPixelFormat
*get_formats(Display
*display
, int *size_ret
, int *onscreen_size_ret
)
928 static WineGLPixelFormat
*list
;
929 static int size
, onscreen_size
;
931 int fmt_id
, nCfgs
, i
, run
, bmp_formats
;
933 XVisualInfo
*visinfo
;
938 cfgs
= pglXGetFBConfigs(display
, DefaultScreen(display
), &nCfgs
);
939 if (NULL
== cfgs
|| 0 == nCfgs
) {
940 if(cfgs
!= NULL
) XFree(cfgs
);
942 ERR("glXChooseFBConfig returns NULL\n");
946 /* Bitmap rendering on Windows implies the use of the Microsoft GDI software renderer.
947 * Further most GLX drivers only offer pixmap rendering using indirect rendering (except for modern drivers which support 'AIGLX' / composite).
948 * Indirect rendering can indicate software rendering (on Nvidia it is hw accelerated)
949 * Since bitmap rendering implies the use of software rendering we can safely use indirect rendering for bitmaps.
951 * Below we count the number of formats which are suitable for bitmap rendering. Windows restricts bitmap rendering to single buffered formats.
953 for(i
=0, bmp_formats
=0; i
<nCfgs
; i
++)
955 if(check_fbconfig_bitmap_capability(display
, cfgs
[i
]))
958 TRACE("Found %d bitmap capable fbconfigs\n", bmp_formats
);
960 list
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, (nCfgs
+ bmp_formats
)*sizeof(WineGLPixelFormat
));
962 /* Fill the pixel format list. Put onscreen formats at the top and offscreen ones at the bottom.
963 * Do this as GLX doesn't guarantee that the list is sorted */
964 for(run
=0; run
< 2; run
++)
966 for(i
=0; i
<nCfgs
; i
++) {
967 pglXGetFBConfigAttrib(display
, cfgs
[i
], GLX_FBCONFIG_ID
, &fmt_id
);
968 visinfo
= pglXGetVisualFromFBConfig(display
, cfgs
[i
]);
970 /* The first run we only add onscreen formats (ones which have an associated X Visual).
971 * The second run we only set offscreen formats. */
974 /* We implement child window rendering using offscreen buffers (using composite or an XPixmap).
975 * The contents is copied to the destination using XCopyArea. For the copying to work
976 * the depth of the source and destination window should be the same. In general this should
977 * not be a problem for OpenGL as drivers only advertise formats with a similar depth (or no depth).
978 * As of the introduction of composition managers at least Nvidia now also offers ARGB visuals
979 * with a depth of 32 in addition to the default 24 bit. In order to prevent BadMatch errors we only
980 * list formats with the same depth. */
981 if(visinfo
->depth
!= screen_depth
)
987 TRACE("Found onscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
988 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
989 list
[size
].fbconfig
= cfgs
[i
];
990 list
[size
].fmt_id
= fmt_id
;
991 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
992 list
[size
].offscreenOnly
= FALSE
;
993 list
[size
].dwFlags
= 0;
997 /* Clone a format if it is bitmap capable for indirect rendering to bitmaps */
998 if(check_fbconfig_bitmap_capability(display
, cfgs
[i
]))
1000 TRACE("Found bitmap capable format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
1001 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
1002 list
[size
].fbconfig
= cfgs
[i
];
1003 list
[size
].fmt_id
= fmt_id
;
1004 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
1005 list
[size
].offscreenOnly
= FALSE
;
1006 list
[size
].dwFlags
= PFD_DRAW_TO_BITMAP
| PFD_SUPPORT_GDI
| PFD_GENERIC_FORMAT
;
1010 } else if(run
&& !visinfo
) {
1011 int window_drawable
=0;
1012 pglXGetFBConfigAttrib(gdi_display
, cfgs
[i
], GLX_DRAWABLE_TYPE
, &window_drawable
);
1014 /* Recent Nvidia drivers and DRI drivers offer window drawable formats without a visual.
1015 * This are formats like 16-bit rgb on a 24-bit desktop. In order to support these formats
1016 * onscreen we would have to use glXCreateWindow instead of XCreateWindow. Further it will
1017 * likely make our child window opengl rendering more complicated since likely you can't use
1018 * XCopyArea on a GLX Window.
1019 * For now ignore fbconfigs which are window drawable but lack a visual. */
1020 if(window_drawable
& GLX_WINDOW_BIT
)
1022 TRACE("Skipping FBCONFIG_ID 0x%x as an offscreen format because it is window_drawable\n", fmt_id
);
1026 TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", fmt_id
, size
+1, i
);
1027 list
[size
].iPixelFormat
= size
+1; /* The index starts at 1 */
1028 list
[size
].fbconfig
= cfgs
[i
];
1029 list
[size
].fmt_id
= fmt_id
;
1030 list
[size
].render_type
= get_render_type_from_fbconfig(display
, cfgs
[i
]);
1031 list
[size
].offscreenOnly
= TRUE
;
1032 list
[size
].dwFlags
= 0;
1036 if (visinfo
) XFree(visinfo
);
1043 if (size_ret
) *size_ret
= size
;
1044 if (onscreen_size_ret
) *onscreen_size_ret
= onscreen_size
;
1045 wine_tsx11_unlock();
1049 /* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
1050 * In our WGL implementation we only support a subset of these formats namely the format of
1051 * Wine's main visual and offscreen formats (if they are available).
1052 * This function converts a WGL format to its corresponding GLX one. It returns a WineGLPixelFormat
1053 * and it returns the number of supported WGL formats in fmt_count.
1055 static WineGLPixelFormat
* ConvertPixelFormatWGLtoGLX(Display
*display
, int iPixelFormat
, BOOL AllowOffscreen
, int *fmt_count
)
1057 WineGLPixelFormat
*list
, *res
= NULL
;
1058 int size
, onscreen_size
;
1060 if (!(list
= get_formats(display
, &size
, &onscreen_size
))) return NULL
;
1062 /* Check if the pixelformat is valid. Note that it is legal to pass an invalid
1063 * iPixelFormat in case of probing the number of pixelformats.
1065 if((iPixelFormat
> 0) && (iPixelFormat
<= size
) &&
1066 (!list
[iPixelFormat
-1].offscreenOnly
|| AllowOffscreen
)) {
1067 res
= &list
[iPixelFormat
-1];
1068 TRACE("Returning fmt_id=%#x for iPixelFormat=%d\n", res
->fmt_id
, iPixelFormat
);
1074 *fmt_count
= onscreen_size
;
1076 TRACE("Number of returned pixelformats=%d\n", *fmt_count
);
1081 /* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
1082 static WineGLPixelFormat
* ConvertPixelFormatGLXtoWGL(Display
*display
, int fmt_id
, DWORD dwFlags
)
1084 WineGLPixelFormat
*list
;
1087 if (!(list
= get_formats(display
, &size
, NULL
))) return NULL
;
1089 for(i
=0; i
<size
; i
++) {
1090 /* A GLX format can appear multiple times in the pixel format list due to fake formats for bitmap rendering.
1091 * Fake formats might get selected when the user passes the proper flags using the dwFlags parameter. */
1092 if( (list
[i
].fmt_id
== fmt_id
) && ((list
[i
].dwFlags
& dwFlags
) == dwFlags
) ) {
1093 TRACE("Returning iPixelFormat %d for fmt_id 0x%x\n", list
[i
].iPixelFormat
, fmt_id
);
1097 TRACE("No compatible format found for fmt_id 0x%x\n", fmt_id
);
1101 static int pixelformat_from_fbconfig_id(XID fbconfig_id
)
1103 WineGLPixelFormat
*fmt
;
1105 if (!fbconfig_id
) return 0;
1107 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fbconfig_id
, 0 /* no flags */);
1109 return fmt
->iPixelFormat
;
1110 /* This will happen on hwnds without a pixel format set; it's ok */
1115 /* Mark any allocated context using the glx drawable 'old' to use 'new' */
1116 void mark_drawable_dirty(Drawable old
, Drawable
new)
1118 Wine_GLContext
*ctx
;
1119 LIST_FOR_EACH_ENTRY( ctx
, &context_list
, struct wine_glcontext
, entry
)
1121 if (old
== ctx
->drawables
[0]) {
1122 ctx
->drawables
[0] = new;
1123 ctx
->refresh_drawables
= TRUE
;
1125 if (old
== ctx
->drawables
[1]) {
1126 ctx
->drawables
[1] = new;
1127 ctx
->refresh_drawables
= TRUE
;
1132 /* Given the current context, make sure its drawable is sync'd */
1133 static inline void sync_context(Wine_GLContext
*context
)
1135 if(context
&& context
->refresh_drawables
) {
1136 if (glxRequireVersion(3))
1137 pglXMakeContextCurrent(gdi_display
, context
->drawables
[0],
1138 context
->drawables
[1], context
->ctx
);
1140 pglXMakeCurrent(gdi_display
, context
->drawables
[0], context
->ctx
);
1141 context
->refresh_drawables
= FALSE
;
1146 static GLXContext
create_glxcontext(Display
*display
, Wine_GLContext
*context
, GLXContext shareList
)
1150 /* We use indirect rendering for rendering to bitmaps. See get_formats for a comment about this. */
1151 BOOL indirect
= (context
->fmt
->dwFlags
& PFD_DRAW_TO_BITMAP
) ? FALSE
: TRUE
;
1153 if(context
->gl3_context
)
1155 if(context
->numAttribs
)
1156 ctx
= pglXCreateContextAttribsARB(gdi_display
, context
->fmt
->fbconfig
, shareList
, indirect
, context
->attribList
);
1158 ctx
= pglXCreateContextAttribsARB(gdi_display
, context
->fmt
->fbconfig
, shareList
, indirect
, NULL
);
1160 else if(context
->vis
)
1161 ctx
= pglXCreateContext(gdi_display
, context
->vis
, shareList
, indirect
);
1162 else /* Create a GLX Context for a pbuffer */
1163 ctx
= pglXCreateNewContext(gdi_display
, context
->fmt
->fbconfig
, context
->fmt
->render_type
, shareList
, TRUE
);
1169 Drawable
create_glxpixmap(Display
*display
, XVisualInfo
*vis
, Pixmap parent
)
1171 return pglXCreateGLXPixmap(display
, vis
, parent
);
1176 * glxdrv_ChoosePixelFormat
1178 * Equivalent to glXChooseVisual.
1180 static int glxdrv_ChoosePixelFormat(PHYSDEV dev
, const PIXELFORMATDESCRIPTOR
*ppfd
)
1182 WineGLPixelFormat
*list
;
1187 int bestFormat
= -1;
1188 int bestDBuffer
= -1;
1189 int bestStereo
= -1;
1193 int bestStencil
= -1;
1196 if (!has_opengl()) return 0;
1198 if (TRACE_ON(wgl
)) {
1199 TRACE("(%p,%p)\n", dev
->hdc
, ppfd
);
1201 dump_PIXELFORMATDESCRIPTOR(ppfd
);
1204 if (!(list
= get_formats(gdi_display
, NULL
, &onscreen_size
))) return 0;
1207 for(i
=0; i
<onscreen_size
; i
++)
1211 int alpha
=0, color
=0, depth
=0, stencil
=0, aux
=0;
1212 WineGLPixelFormat
*fmt
= &list
[i
];
1215 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_RENDER_TYPE
, &value
);
1216 if (value
& GLX_RGBA_BIT
)
1217 iPixelType
= PFD_TYPE_RGBA
;
1219 iPixelType
= PFD_TYPE_COLORINDEX
;
1221 if (ppfd
->iPixelType
!= iPixelType
)
1223 TRACE("pixel type mismatch for iPixelFormat=%d\n", i
+1);
1227 /* Only use bitmap capable for formats for bitmap rendering.
1228 * See get_formats for more info. */
1229 if( (ppfd
->dwFlags
& PFD_DRAW_TO_BITMAP
) != (fmt
->dwFlags
& PFD_DRAW_TO_BITMAP
))
1231 TRACE("PFD_DRAW_TO_BITMAP mismatch for iPixelFormat=%d\n", i
+1);
1235 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DOUBLEBUFFER
, &value
);
1236 if (value
) dwFlags
|= PFD_DOUBLEBUFFER
;
1237 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STEREO
, &value
);
1238 if (value
) dwFlags
|= PFD_STEREO
;
1239 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_BUFFER_SIZE
, &color
); /* cColorBits */
1240 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ALPHA_SIZE
, &alpha
); /* cAlphaBits */
1241 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DEPTH_SIZE
, &depth
); /* cDepthBits */
1242 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STENCIL_SIZE
, &stencil
); /* cStencilBits */
1243 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_AUX_BUFFERS
, &aux
); /* cAuxBuffers */
1245 /* The behavior of PDF_STEREO/PFD_STEREO_DONTCARE and PFD_DOUBLEBUFFER / PFD_DOUBLEBUFFER_DONTCARE
1246 * is not very clear on MSDN. They specify that ChoosePixelFormat tries to match pixel formats
1247 * with the flag (PFD_STEREO / PFD_DOUBLEBUFFERING) set. Otherwise it says that it tries to match
1248 * formats without the given flag set.
1249 * A test on Windows using a Radeon 9500pro on WinXP (the driver doesn't support Stereo)
1250 * has indicated that a format without stereo is returned when stereo is unavailable.
1251 * So in case PFD_STEREO is set, formats that support it should have priority above formats
1252 * without. In case PFD_STEREO_DONTCARE is set, stereo is ignored.
1254 * To summarize the following is most likely the correct behavior:
1255 * stereo not set -> prefer no-stereo formats, else also accept stereo formats
1256 * stereo set -> prefer stereo formats, else also accept no-stereo formats
1257 * stereo don't care -> it doesn't matter whether we get stereo or not
1259 * In Wine we will treat no-stereo the same way as don't care because it makes
1260 * format selection even more complicated and second drivers with Stereo advertise
1261 * each format twice anyway.
1264 /* Doublebuffer, see the comments above */
1265 if( !(ppfd
->dwFlags
& PFD_DOUBLEBUFFER_DONTCARE
) ) {
1266 if( ((ppfd
->dwFlags
& PFD_DOUBLEBUFFER
) != bestDBuffer
) &&
1267 ((dwFlags
& PFD_DOUBLEBUFFER
) == (ppfd
->dwFlags
& PFD_DOUBLEBUFFER
)) )
1270 if(bestDBuffer
!= -1 && (dwFlags
& PFD_DOUBLEBUFFER
) != bestDBuffer
)
1274 /* Stereo, see the comments above. */
1275 if( !(ppfd
->dwFlags
& PFD_STEREO_DONTCARE
) ) {
1276 if( ((ppfd
->dwFlags
& PFD_STEREO
) != bestStereo
) &&
1277 ((dwFlags
& PFD_STEREO
) == (ppfd
->dwFlags
& PFD_STEREO
)) )
1280 if(bestStereo
!= -1 && (dwFlags
& PFD_STEREO
) != bestStereo
)
1284 /* Below we will do a number of checks to select the 'best' pixelformat.
1285 * We assume the precedence cColorBits > cAlphaBits > cDepthBits > cStencilBits -> cAuxBuffers.
1286 * The code works by trying to match the most important options as close as possible.
1287 * When a reasonable format is found, we will try to match more options.
1288 * It appears (see the opengl32 test) that Windows opengl drivers ignore options
1289 * like cColorBits, cAlphaBits and friends if they are set to 0, so they are considered
1290 * as DONTCARE. At least Serious Sam TSE relies on this behavior. */
1292 if(ppfd
->cColorBits
) {
1293 if( ((ppfd
->cColorBits
> bestColor
) && (color
> bestColor
)) ||
1294 ((color
>= ppfd
->cColorBits
) && (color
< bestColor
)) )
1297 if(bestColor
!= color
) { /* Do further checks if the format is compatible */
1298 TRACE("color mismatch for iPixelFormat=%d\n", i
+1);
1303 if(ppfd
->cAlphaBits
) {
1304 if( ((ppfd
->cAlphaBits
> bestAlpha
) && (alpha
> bestAlpha
)) ||
1305 ((alpha
>= ppfd
->cAlphaBits
) && (alpha
< bestAlpha
)) )
1308 if(bestAlpha
!= alpha
) {
1309 TRACE("alpha mismatch for iPixelFormat=%d\n", i
+1);
1314 if(ppfd
->cDepthBits
) {
1315 if( ((ppfd
->cDepthBits
> bestDepth
) && (depth
> bestDepth
)) ||
1316 ((depth
>= ppfd
->cDepthBits
) && (depth
< bestDepth
)) )
1319 if(bestDepth
!= depth
) {
1320 TRACE("depth mismatch for iPixelFormat=%d\n", i
+1);
1325 if(ppfd
->cStencilBits
) {
1326 if( ((ppfd
->cStencilBits
> bestStencil
) && (stencil
> bestStencil
)) ||
1327 ((stencil
>= ppfd
->cStencilBits
) && (stencil
< bestStencil
)) )
1330 if(bestStencil
!= stencil
) {
1331 TRACE("stencil mismatch for iPixelFormat=%d\n", i
+1);
1336 if(ppfd
->cAuxBuffers
) {
1337 if( ((ppfd
->cAuxBuffers
> bestAux
) && (aux
> bestAux
)) ||
1338 ((aux
>= ppfd
->cAuxBuffers
) && (aux
< bestAux
)) )
1341 if(bestAux
!= aux
) {
1342 TRACE("aux mismatch for iPixelFormat=%d\n", i
+1);
1349 bestDBuffer
= dwFlags
& PFD_DOUBLEBUFFER
;
1350 bestStereo
= dwFlags
& PFD_STEREO
;
1354 bestStencil
= stencil
;
1359 if(bestFormat
== -1) {
1360 TRACE("No matching mode was found returning 0\n");
1364 ret
= bestFormat
+1; /* the return value should be a 1-based index */
1365 TRACE("Successfully found a matching mode, returning index: %d %x\n", ret
, list
[bestFormat
].fmt_id
);
1368 wine_tsx11_unlock();
1374 * glxdrv_DescribePixelFormat
1376 * Get the pixel-format descriptor associated to the given id
1378 static int glxdrv_DescribePixelFormat(PHYSDEV dev
, int iPixelFormat
,
1379 UINT nBytes
, PIXELFORMATDESCRIPTOR
*ppfd
)
1381 /*XVisualInfo *vis;*/
1384 WineGLPixelFormat
*fmt
;
1388 if (!has_opengl()) return 0;
1390 TRACE("(%p,%d,%d,%p)\n", dev
->hdc
, iPixelFormat
, nBytes
, ppfd
);
1392 /* 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 */
1393 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, FALSE
/* Offscreen */, &fmt_count
);
1395 /* The application is only querying the number of pixelformats */
1397 } else if(fmt
== NULL
) {
1398 WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat
, fmt_count
);
1402 if (nBytes
< sizeof(PIXELFORMATDESCRIPTOR
)) {
1403 ERR("Wrong structure size !\n");
1404 /* Should set error */
1410 memset(ppfd
, 0, sizeof(PIXELFORMATDESCRIPTOR
));
1411 ppfd
->nSize
= sizeof(PIXELFORMATDESCRIPTOR
);
1414 /* These flags are always the same... */
1415 ppfd
->dwFlags
= PFD_SUPPORT_OPENGL
;
1416 /* Now the flags extracted from the Visual */
1420 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1421 if(value
& GLX_WINDOW_BIT
)
1422 ppfd
->dwFlags
|= PFD_DRAW_TO_WINDOW
;
1424 /* On Windows bitmap rendering is only offered using the GDI Software renderer. We reserve some formats (see get_formats for more info)
1425 * for bitmap rendering since we require indirect rendering for this. Further pixel format logs of a GeforceFX, Geforce8800GT, Radeon HD3400 and a
1426 * 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
1427 * offered the GDI bit either. */
1428 ppfd
->dwFlags
|= fmt
->dwFlags
& (PFD_DRAW_TO_BITMAP
| PFD_SUPPORT_GDI
);
1430 /* PFD_GENERIC_FORMAT - gdi software rendering
1431 * PFD_GENERIC_ACCELERATED - some parts are accelerated by a display driver (MCD e.g. 3dfx minigl)
1432 * none set - full hardware accelerated by a ICD
1434 * We only set PFD_GENERIC_FORMAT on bitmap formats (see get_formats) as that's what ATI and Nvidia Windows drivers do */
1435 ppfd
->dwFlags
|= fmt
->dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
);
1437 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DOUBLEBUFFER
, &value
);
1439 ppfd
->dwFlags
|= PFD_DOUBLEBUFFER
;
1440 ppfd
->dwFlags
&= ~PFD_SUPPORT_GDI
;
1442 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STEREO
, &value
); if (value
) ppfd
->dwFlags
|= PFD_STEREO
;
1445 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_RENDER_TYPE
, &value
);
1446 if (value
& GLX_RGBA_BIT
)
1447 ppfd
->iPixelType
= PFD_TYPE_RGBA
;
1449 ppfd
->iPixelType
= PFD_TYPE_COLORINDEX
;
1452 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_BUFFER_SIZE
, &value
);
1453 ppfd
->cColorBits
= value
;
1455 /* Red, green, blue and alpha bits / shifts */
1456 if (ppfd
->iPixelType
== PFD_TYPE_RGBA
) {
1457 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_RED_SIZE
, &rb
);
1458 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_GREEN_SIZE
, &gb
);
1459 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_BLUE_SIZE
, &bb
);
1460 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ALPHA_SIZE
, &ab
);
1462 ppfd
->cRedBits
= rb
;
1463 ppfd
->cRedShift
= gb
+ bb
+ ab
;
1464 ppfd
->cBlueBits
= bb
;
1465 ppfd
->cBlueShift
= ab
;
1466 ppfd
->cGreenBits
= gb
;
1467 ppfd
->cGreenShift
= bb
+ ab
;
1468 ppfd
->cAlphaBits
= ab
;
1469 ppfd
->cAlphaShift
= 0;
1472 ppfd
->cRedShift
= 0;
1473 ppfd
->cBlueBits
= 0;
1474 ppfd
->cBlueShift
= 0;
1475 ppfd
->cGreenBits
= 0;
1476 ppfd
->cGreenShift
= 0;
1477 ppfd
->cAlphaBits
= 0;
1478 ppfd
->cAlphaShift
= 0;
1481 /* Accum RGBA bits */
1482 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_RED_SIZE
, &rb
);
1483 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_GREEN_SIZE
, &gb
);
1484 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_BLUE_SIZE
, &bb
);
1485 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_ALPHA_SIZE
, &ab
);
1487 ppfd
->cAccumBits
= rb
+gb
+bb
+ab
;
1488 ppfd
->cAccumRedBits
= rb
;
1489 ppfd
->cAccumGreenBits
= gb
;
1490 ppfd
->cAccumBlueBits
= bb
;
1491 ppfd
->cAccumAlphaBits
= ab
;
1494 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_AUX_BUFFERS
, &value
);
1495 ppfd
->cAuxBuffers
= value
;
1498 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DEPTH_SIZE
, &value
);
1499 ppfd
->cDepthBits
= value
;
1502 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_STENCIL_SIZE
, &value
);
1503 ppfd
->cStencilBits
= value
;
1505 wine_tsx11_unlock();
1507 ppfd
->iLayerType
= PFD_MAIN_PLANE
;
1509 if (TRACE_ON(wgl
)) {
1510 dump_PIXELFORMATDESCRIPTOR(ppfd
);
1517 * glxdrv_GetPixelFormat
1519 * Get the pixel-format id used by this DC
1521 static int glxdrv_GetPixelFormat(PHYSDEV dev
)
1523 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1524 WineGLPixelFormat
*fmt
;
1527 if (!physdev
->pixel_format
) return 0; /* not set yet */
1529 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, physdev
->pixel_format
, TRUE
, &tmp
);
1532 ERR("Unable to find a WineGLPixelFormat for iPixelFormat=%d\n", physdev
->pixel_format
);
1535 else if(fmt
->offscreenOnly
)
1537 /* Offscreen formats can't be used with traditional WGL calls.
1538 * As has been verified on Windows GetPixelFormat doesn't fail but returns iPixelFormat=1. */
1539 TRACE("Returning iPixelFormat=1 for offscreen format: %d\n", fmt
->iPixelFormat
);
1543 TRACE("(%p): returns %d\n", dev
->hdc
, physdev
->pixel_format
);
1544 return physdev
->pixel_format
;
1547 /* This function is the core of X11DRV_SetPixelFormat and X11DRV_SetPixelFormatWINE.
1548 * Both functions are the same except that X11DRV_SetPixelFormatWINE allows you to
1549 * set the pixel format multiple times. */
1550 static BOOL
internal_SetPixelFormat( struct glx_physdev
*physdev
,
1552 const PIXELFORMATDESCRIPTOR
*ppfd
)
1554 WineGLPixelFormat
*fmt
;
1558 /* SetPixelFormat is not allowed on the X root_window e.g. GetDC(0) */
1559 if(physdev
->x11dev
->drawable
== root_window
)
1561 ERR("Invalid operation on root_window\n");
1565 /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
1566 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, FALSE
/* Offscreen */, &value
);
1568 ERR("Invalid iPixelFormat: %d\n", iPixelFormat
);
1573 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1574 wine_tsx11_unlock();
1576 hwnd
= WindowFromDC(physdev
->dev
.hdc
);
1578 if(!(value
&GLX_WINDOW_BIT
)) {
1579 WARN("Pixel format %d is not compatible for window rendering\n", iPixelFormat
);
1583 if(!SendMessageW(hwnd
, WM_X11DRV_SET_WIN_FORMAT
, fmt
->fmt_id
, 0)) {
1584 ERR("Couldn't set format of the window, returning failure\n");
1587 /* physDev->current_pf will be set by the DCE update */
1589 else if(physdev
->x11dev
->bitmap
) {
1590 if(!(value
&GLX_PIXMAP_BIT
)) {
1591 WARN("Pixel format %d is not compatible for bitmap rendering\n", iPixelFormat
);
1595 physdev
->pixel_format
= iPixelFormat
;
1596 physdev
->type
= DC_GL_BITMAP
;
1599 FIXME("called on a non-window, non-bitmap object?\n");
1602 if (TRACE_ON(wgl
)) {
1606 gl_test
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_FBCONFIG_ID
, &value
);
1608 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
1610 TRACE(" FBConfig have :\n");
1611 TRACE(" - FBCONFIG_ID 0x%x\n", value
);
1612 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_VISUAL_ID
, &value
);
1613 TRACE(" - VISUAL_ID 0x%x\n", value
);
1614 pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &value
);
1615 TRACE(" - DRAWABLE_TYPE 0x%x\n", value
);
1617 wine_tsx11_unlock();
1624 * glxdrv_SetPixelFormat
1626 * Set the pixel-format id used by this DC
1628 static BOOL
glxdrv_SetPixelFormat(PHYSDEV dev
, int iPixelFormat
, const PIXELFORMATDESCRIPTOR
*ppfd
)
1630 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1632 TRACE("(%p,%d,%p)\n", dev
->hdc
, iPixelFormat
, ppfd
);
1634 if (!has_opengl()) return FALSE
;
1636 if(physdev
->pixel_format
) /* cannot change it if already set */
1637 return (physdev
->pixel_format
== iPixelFormat
);
1639 return internal_SetPixelFormat(physdev
, iPixelFormat
, ppfd
);
1643 * glxdrv_wglCopyContext
1645 * For OpenGL32 wglCopyContext.
1647 static BOOL
glxdrv_wglCopyContext(HGLRC hglrcSrc
, HGLRC hglrcDst
, UINT mask
)
1649 Wine_GLContext
*src
= (Wine_GLContext
*)hglrcSrc
;
1650 Wine_GLContext
*dst
= (Wine_GLContext
*)hglrcDst
;
1652 TRACE("hglrcSrc: (%p), hglrcDst: (%p), mask: %#x\n", hglrcSrc
, hglrcDst
, mask
);
1655 pglXCopyContext(gdi_display
, src
->ctx
, dst
->ctx
, mask
);
1656 wine_tsx11_unlock();
1658 /* As opposed to wglCopyContext, glXCopyContext doesn't return anything, so hopefully we passed */
1663 * X11DRV_wglCreateContext
1665 * For OpenGL32 wglCreateContext.
1667 static HGLRC
glxdrv_wglCreateContext(PHYSDEV dev
)
1669 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1670 Wine_GLContext
*ret
;
1671 WineGLPixelFormat
*fmt
;
1674 TRACE("(%p)->(PF:%d)\n", dev
->hdc
, physdev
->pixel_format
);
1676 if (!has_opengl()) return 0;
1678 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, physdev
->pixel_format
, TRUE
/* Offscreen */, &fmt_count
);
1679 /* We can render using the iPixelFormat (1) of Wine's Main visual AND using some offscreen formats.
1680 * Note that standard WGL-calls don't recognize offscreen-only formats. For that reason pbuffers
1681 * use a sort of 'proxy' HDC (wglGetPbufferDCARB).
1682 * If this fails something is very wrong on the system. */
1684 ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", physdev
->pixel_format
);
1685 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1689 if (!(ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
)))) return 0;
1691 ret
->hdc
= dev
->hdc
;
1693 ret
->has_been_current
= FALSE
;
1694 ret
->sharing
= FALSE
;
1697 ret
->vis
= pglXGetVisualFromFBConfig(gdi_display
, fmt
->fbconfig
);
1698 ret
->ctx
= create_glxcontext(gdi_display
, ret
, NULL
);
1699 list_add_head( &context_list
, &ret
->entry
);
1700 wine_tsx11_unlock();
1702 TRACE(" creating context %p (GL context creation delayed)\n", ret
);
1707 * glxdrv_wglDeleteContext
1709 * For OpenGL32 wglDeleteContext.
1711 static BOOL
glxdrv_wglDeleteContext(HGLRC hglrc
)
1713 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1715 TRACE("(%p)\n", hglrc
);
1717 if (!has_opengl()) return 0;
1719 if (!is_valid_context(ctx
))
1721 WARN("Error deleting context !\n");
1722 SetLastError(ERROR_INVALID_HANDLE
);
1726 /* WGL doesn't allow deletion of a context which is current in another thread */
1727 if (ctx
->tid
!= 0 && ctx
->tid
!= GetCurrentThreadId())
1729 TRACE("Cannot delete context=%p because it is current in another thread.\n", ctx
);
1730 SetLastError(ERROR_BUSY
);
1734 /* WGL makes a context not current if it is active before deletion. GLX waits until the context is not current. */
1735 if (ctx
== NtCurrentTeb()->glContext
)
1736 wglMakeCurrent(ctx
->hdc
, NULL
);
1739 list_remove( &ctx
->entry
);
1740 if (ctx
->ctx
) pglXDestroyContext( gdi_display
, ctx
->ctx
);
1741 if (ctx
->glxpixmap
) pglXDestroyGLXPixmap( gdi_display
, ctx
->glxpixmap
);
1742 if (ctx
->pixmap
) XFreePixmap( gdi_display
, ctx
->pixmap
);
1743 if (ctx
->vis
) XFree( ctx
->vis
);
1744 wine_tsx11_unlock();
1746 HeapFree( GetProcessHeap(), 0, ctx
);
1751 * X11DRV_wglGetCurrentReadDCARB
1753 * For OpenGL32 wglGetCurrentReadDCARB.
1755 static HDC WINAPI
X11DRV_wglGetCurrentReadDCARB(void)
1758 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
1760 if (ctx
) ret
= ctx
->read_hdc
;
1762 TRACE(" returning %p (GL drawable %lu)\n", ret
, ctx
? ctx
->drawables
[1] : 0);
1767 * glxdrv_wglGetProcAddress
1769 * For OpenGL32 wglGetProcAddress.
1771 static PROC
glxdrv_wglGetProcAddress(LPCSTR lpszProc
)
1774 const WineGLExtension
*ext
;
1776 int padding
= 32 - strlen(lpszProc
);
1780 if (!has_opengl()) return NULL
;
1782 /* Check the table of WGL extensions to see if we need to return a WGL extension
1783 * or a function pointer to a native OpenGL function. */
1784 if(strncmp(lpszProc
, "wgl", 3) != 0) {
1785 return pglXGetProcAddressARB((const GLubyte
*)lpszProc
);
1787 TRACE("('%s'):%*s", lpszProc
, padding
, " ");
1788 for (i
= 0; i
< WineGLExtensionListSize
; ++i
) {
1789 ext
= WineGLExtensionList
[i
];
1790 for (j
= 0; ext
->extEntryPoints
[j
].funcName
; ++j
) {
1791 if (strcmp(ext
->extEntryPoints
[j
].funcName
, lpszProc
) == 0) {
1792 TRACE("(%p) - WineGL\n", ext
->extEntryPoints
[j
].funcAddress
);
1793 return ext
->extEntryPoints
[j
].funcAddress
;
1799 WARN("(%s) - not found\n", lpszProc
);
1803 static GLXPixmap
get_context_pixmap( struct glx_physdev
*physdev
, struct wine_glcontext
*ctx
)
1809 GetObjectW( GetCurrentObject( physdev
->dev
.hdc
, OBJ_BITMAP
), sizeof(bmp
), &bmp
);
1812 ctx
->pixmap
= XCreatePixmap( gdi_display
, root_window
,
1813 bmp
.bmWidth
, bmp
.bmHeight
, ctx
->vis
->depth
);
1814 ctx
->glxpixmap
= pglXCreateGLXPixmap( gdi_display
, ctx
->vis
, ctx
->pixmap
);
1815 wine_tsx11_unlock();
1816 ctx
->pixmap_size
.cx
= bmp
.bmWidth
;
1817 ctx
->pixmap_size
.cy
= bmp
.bmHeight
;
1819 return ctx
->glxpixmap
;
1823 * glxdrv_wglMakeCurrent
1825 * For OpenGL32 wglMakeCurrent.
1827 static BOOL
glxdrv_wglMakeCurrent(PHYSDEV dev
, HGLRC hglrc
)
1829 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
1831 Wine_GLContext
*prev_ctx
= NtCurrentTeb()->glContext
;
1832 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1834 TRACE("(%p,%p)\n", dev
->hdc
, hglrc
);
1836 if (!has_opengl()) return FALSE
;
1840 if (prev_ctx
) prev_ctx
->tid
= 0;
1843 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1844 wine_tsx11_unlock();
1845 NtCurrentTeb()->glContext
= NULL
;
1847 else if (!physdev
->pixel_format
)
1849 WARN("Trying to use an invalid drawable\n");
1850 SetLastError(ERROR_INVALID_HANDLE
);
1853 else if (ctx
->fmt
->iPixelFormat
!= physdev
->pixel_format
)
1855 WARN( "mismatched pixel format hdc %p %u ctx %p %u\n",
1856 dev
->hdc
, physdev
->pixel_format
, ctx
, ctx
->fmt
->iPixelFormat
);
1857 SetLastError( ERROR_INVALID_PIXEL_FORMAT
);
1862 Drawable drawable
= physdev
->drawable
;
1864 if (physdev
->type
== DC_GL_BITMAP
) drawable
= get_context_pixmap( physdev
, ctx
);
1868 if (TRACE_ON(wgl
)) {
1869 describeDrawable( physdev
);
1870 describeContext(ctx
);
1873 TRACE(" make current for drawable %lx, ctx %p\n", drawable
, ctx
->ctx
);
1875 ret
= pglXMakeCurrent(gdi_display
, drawable
, ctx
->ctx
);
1879 if (prev_ctx
) prev_ctx
->tid
= 0;
1880 NtCurrentTeb()->glContext
= ctx
;
1882 ctx
->has_been_current
= TRUE
;
1883 ctx
->tid
= GetCurrentThreadId();
1884 ctx
->hdc
= dev
->hdc
;
1885 ctx
->read_hdc
= dev
->hdc
;
1886 ctx
->drawables
[0] = drawable
;
1887 ctx
->drawables
[1] = drawable
;
1888 ctx
->refresh_drawables
= FALSE
;
1890 if (physdev
->type
== DC_GL_BITMAP
) pglDrawBuffer(GL_FRONT_LEFT
);
1893 SetLastError(ERROR_INVALID_HANDLE
);
1894 wine_tsx11_unlock();
1896 TRACE(" returning %s\n", (ret
? "True" : "False"));
1901 * glxdrv_wglMakeContextCurrentARB
1903 * For OpenGL32 wglMakeContextCurrentARB
1905 static BOOL
glxdrv_wglMakeContextCurrentARB( PHYSDEV draw_dev
, PHYSDEV read_dev
, HGLRC hglrc
)
1907 Wine_GLContext
*prev_ctx
= NtCurrentTeb()->glContext
;
1908 struct glx_physdev
*draw_physdev
= get_glxdrv_dev( draw_dev
);
1909 struct glx_physdev
*read_physdev
= get_glxdrv_dev( read_dev
);
1912 TRACE("(%p,%p,%p)\n", draw_dev
->hdc
, read_dev
->hdc
, hglrc
);
1914 if (!has_opengl()) return 0;
1918 if (prev_ctx
) prev_ctx
->tid
= 0;
1921 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1922 wine_tsx11_unlock();
1923 NtCurrentTeb()->glContext
= NULL
;
1925 else if (!draw_physdev
->pixel_format
)
1927 WARN("Trying to use an invalid drawable\n");
1928 SetLastError(ERROR_INVALID_HANDLE
);
1933 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1934 Drawable draw_drawable
= draw_physdev
->drawable
;
1935 Drawable read_drawable
= read_physdev
->drawable
;
1937 if (!pglXMakeContextCurrent
) return FALSE
;
1939 if (draw_physdev
->type
== DC_GL_BITMAP
) draw_drawable
= get_context_pixmap( draw_physdev
, ctx
);
1940 if (read_physdev
->type
== DC_GL_BITMAP
) read_drawable
= get_context_pixmap( read_physdev
, ctx
);
1943 ret
= pglXMakeContextCurrent(gdi_display
, draw_drawable
, read_drawable
, ctx
->ctx
);
1946 if (prev_ctx
) prev_ctx
->tid
= 0;
1948 ctx
->has_been_current
= TRUE
;
1949 ctx
->tid
= GetCurrentThreadId();
1950 ctx
->hdc
= draw_dev
->hdc
;
1951 ctx
->read_hdc
= read_dev
->hdc
;
1952 ctx
->drawables
[0] = draw_drawable
;
1953 ctx
->drawables
[1] = read_drawable
;
1954 ctx
->refresh_drawables
= FALSE
;
1955 NtCurrentTeb()->glContext
= ctx
;
1958 SetLastError(ERROR_INVALID_HANDLE
);
1959 wine_tsx11_unlock();
1962 TRACE(" returning %s\n", (ret
? "True" : "False"));
1967 * glxdrv_wglShareLists
1969 * For OpenGL32 wglShareLists.
1971 static BOOL
glxdrv_wglShareLists(HGLRC hglrc1
, HGLRC hglrc2
)
1973 Wine_GLContext
*org
= (Wine_GLContext
*) hglrc1
;
1974 Wine_GLContext
*dest
= (Wine_GLContext
*) hglrc2
;
1976 TRACE("(%p, %p)\n", org
, dest
);
1978 if (!has_opengl()) return FALSE
;
1980 /* Sharing of display lists works differently in GLX and WGL. In case of GLX it is done
1981 * at context creation time but in case of WGL it is done using wglShareLists.
1982 * In the past we tried to emulate wglShareLists by delaying GLX context creation until
1983 * either a wglMakeCurrent or wglShareLists. This worked fine for most apps but it causes
1984 * issues for OpenGL 3 because there wglCreateContextAttribsARB can fail in a lot of cases,
1985 * so there delaying context creation doesn't work.
1987 * The new approach is to create a GLX context in wglCreateContext / wglCreateContextAttribsARB
1988 * and when a program requests sharing we recreate the destination context if it hasn't been made
1989 * current or when it hasn't shared display lists before.
1992 if((org
->has_been_current
&& dest
->has_been_current
) || dest
->has_been_current
)
1994 ERR("Could not share display lists, one of the contexts has been current already !\n");
1997 else if(dest
->sharing
)
1999 ERR("Could not share display lists because hglrc2 has already shared lists before\n");
2004 if((GetObjectType(org
->hdc
) == OBJ_MEMDC
) ^ (GetObjectType(dest
->hdc
) == OBJ_MEMDC
))
2006 WARN("Attempting to share a context between a direct and indirect rendering context, expect issues!\n");
2010 describeContext(org
);
2011 describeContext(dest
);
2013 /* Re-create the GLX context and share display lists */
2014 pglXDestroyContext(gdi_display
, dest
->ctx
);
2015 dest
->ctx
= create_glxcontext(gdi_display
, dest
, org
->ctx
);
2016 wine_tsx11_unlock();
2017 TRACE(" re-created an OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest
->ctx
, dest
, org
->ctx
);
2019 org
->sharing
= TRUE
;
2020 dest
->sharing
= TRUE
;
2026 static BOOL
internal_wglUseFontBitmaps(HDC hdc
, DWORD first
, DWORD count
, DWORD listBase
, DWORD (WINAPI
*GetGlyphOutline_ptr
)(HDC
,UINT
,UINT
,LPGLYPHMETRICS
,DWORD
,LPVOID
,const MAT2
*))
2028 /* We are running using client-side rendering fonts... */
2030 unsigned int glyph
, size
= 0;
2031 void *bitmap
= NULL
, *gl_bitmap
= NULL
;
2035 pglGetIntegerv(GL_UNPACK_ALIGNMENT
, &org_alignment
);
2036 pglPixelStorei(GL_UNPACK_ALIGNMENT
, 4);
2037 wine_tsx11_unlock();
2039 for (glyph
= first
; glyph
< first
+ count
; glyph
++) {
2040 static const MAT2 identity
= { {0,1},{0,0},{0,0},{0,1} };
2041 unsigned int needed_size
= GetGlyphOutline_ptr(hdc
, glyph
, GGO_BITMAP
, &gm
, 0, NULL
, &identity
);
2042 unsigned int height
, width_int
;
2044 TRACE("Glyph : %3d / List : %d\n", glyph
, listBase
);
2045 if (needed_size
== GDI_ERROR
) {
2046 TRACE(" - needed size : %d (GDI_ERROR)\n", needed_size
);
2049 TRACE(" - needed size : %d\n", needed_size
);
2052 if (needed_size
> size
) {
2054 HeapFree(GetProcessHeap(), 0, bitmap
);
2055 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
2056 bitmap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
2057 gl_bitmap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
2059 if (GetGlyphOutline_ptr(hdc
, glyph
, GGO_BITMAP
, &gm
, size
, bitmap
, &identity
) == GDI_ERROR
)
2061 if (TRACE_ON(wgl
)) {
2062 unsigned int height
, width
, bitmask
;
2063 unsigned char *bitmap_
= bitmap
;
2065 TRACE(" - bbox : %d x %d\n", gm
.gmBlackBoxX
, gm
.gmBlackBoxY
);
2066 TRACE(" - origin : (%d , %d)\n", gm
.gmptGlyphOrigin
.x
, gm
.gmptGlyphOrigin
.y
);
2067 TRACE(" - increment : %d - %d\n", gm
.gmCellIncX
, gm
.gmCellIncY
);
2068 if (needed_size
!= 0) {
2069 TRACE(" - bitmap :\n");
2070 for (height
= 0; height
< gm
.gmBlackBoxY
; height
++) {
2072 for (width
= 0, bitmask
= 0x80; width
< gm
.gmBlackBoxX
; width
++, bitmask
>>= 1) {
2077 if (*bitmap_
& bitmask
)
2082 bitmap_
+= (4 - ((UINT_PTR
)bitmap_
& 0x03));
2088 /* In OpenGL, the bitmap is drawn from the bottom to the top... So we need to invert the
2089 * glyph for it to be drawn properly.
2091 if (needed_size
!= 0) {
2092 width_int
= (gm
.gmBlackBoxX
+ 31) / 32;
2093 for (height
= 0; height
< gm
.gmBlackBoxY
; height
++) {
2095 for (width
= 0; width
< width_int
; width
++) {
2096 ((int *) gl_bitmap
)[(gm
.gmBlackBoxY
- height
- 1) * width_int
+ width
] =
2097 ((int *) bitmap
)[height
* width_int
+ width
];
2103 pglNewList(listBase
++, GL_COMPILE
);
2104 if (needed_size
!= 0) {
2105 pglBitmap(gm
.gmBlackBoxX
, gm
.gmBlackBoxY
,
2106 0 - gm
.gmptGlyphOrigin
.x
, (int) gm
.gmBlackBoxY
- gm
.gmptGlyphOrigin
.y
,
2107 gm
.gmCellIncX
, gm
.gmCellIncY
,
2110 /* This is the case of 'empty' glyphs like the space character */
2111 pglBitmap(0, 0, 0, 0, gm
.gmCellIncX
, gm
.gmCellIncY
, NULL
);
2114 wine_tsx11_unlock();
2118 pglPixelStorei(GL_UNPACK_ALIGNMENT
, org_alignment
);
2119 wine_tsx11_unlock();
2121 HeapFree(GetProcessHeap(), 0, bitmap
);
2122 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
2127 pglPixelStorei(GL_UNPACK_ALIGNMENT
, org_alignment
);
2128 wine_tsx11_unlock();
2130 HeapFree(GetProcessHeap(), 0, bitmap
);
2131 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
2136 * glxdrv_wglUseFontBitmapsA
2138 * For OpenGL32 wglUseFontBitmapsA.
2140 static BOOL
glxdrv_wglUseFontBitmapsA(PHYSDEV dev
, DWORD first
, DWORD count
, DWORD listBase
)
2142 TRACE("(%p, %d, %d, %d)\n", dev
->hdc
, first
, count
, listBase
);
2144 if (!has_opengl()) return FALSE
;
2145 return internal_wglUseFontBitmaps(dev
->hdc
, first
, count
, listBase
, GetGlyphOutlineA
);
2149 * glxdrv_wglUseFontBitmapsW
2151 * For OpenGL32 wglUseFontBitmapsW.
2153 static BOOL
glxdrv_wglUseFontBitmapsW(PHYSDEV dev
, DWORD first
, DWORD count
, DWORD listBase
)
2155 TRACE("(%p, %d, %d, %d)\n", dev
->hdc
, first
, count
, listBase
);
2157 if (!has_opengl()) return FALSE
;
2158 return internal_wglUseFontBitmaps(dev
->hdc
, first
, count
, listBase
, GetGlyphOutlineW
);
2161 /* WGL helper function which handles differences in glGetIntegerv from WGL and GLX */
2162 static void WINAPI
X11DRV_wglGetIntegerv(GLenum pname
, GLint
* params
)
2169 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
2171 pglGetIntegerv(pname
, params
);
2173 * if we cannot find a Wine Context
2174 * we only have the default wine desktop context,
2175 * so if we have only a 24 depth say we have 32
2177 if (!ctx
&& *params
== 24) {
2180 TRACE("returns GL_DEPTH_BITS as '%d'\n", *params
);
2185 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
2187 pglXGetFBConfigAttrib(gdi_display
, ctx
->fmt
->fbconfig
, GLX_ALPHA_SIZE
, params
);
2188 TRACE("returns GL_ALPHA_BITS as '%d'\n", *params
);
2192 pglGetIntegerv(pname
, params
);
2195 wine_tsx11_unlock();
2198 static void flush_pixmap( struct wine_glcontext
*ctx
)
2200 char buffer
[FIELD_OFFSET( BITMAPINFO
, bmiColors
[256] )];
2201 BITMAPINFO
*info
= (BITMAPINFO
*)buffer
;
2203 struct gdi_image_bits src_bits
, bits
;
2204 struct bitblt_coords coords
;
2206 BOOL is_r8g8b8
= FALSE
;
2207 const XPixmapFormatValues
*format
= pixmap_formats
[ctx
->vis
->depth
];
2211 coords
.width
= ctx
->pixmap_size
.cx
;
2212 coords
.height
= ctx
->pixmap_size
.cy
;
2213 SetRect( &coords
.visrect
, 0, 0, coords
.width
, coords
.height
);
2215 info
->bmiHeader
.biSize
= sizeof(info
->bmiHeader
);
2216 info
->bmiHeader
.biWidth
= coords
.width
;
2217 info
->bmiHeader
.biHeight
= -coords
.height
;
2218 info
->bmiHeader
.biPlanes
= 1;
2219 info
->bmiHeader
.biBitCount
= format
->bits_per_pixel
;
2220 info
->bmiHeader
.biCompression
= BI_RGB
;
2221 info
->bmiHeader
.biClrUsed
= 0;
2222 switch (info
->bmiHeader
.biBitCount
)
2225 masks
= (DWORD
*)info
->bmiColors
;
2226 masks
[0] = ctx
->vis
->red_mask
;
2227 masks
[1] = ctx
->vis
->green_mask
;
2228 masks
[2] = ctx
->vis
->blue_mask
;
2229 info
->bmiHeader
.biCompression
= BI_BITFIELDS
;
2232 is_r8g8b8
= (ctx
->vis
->red_mask
== 0xff0000 && ctx
->vis
->blue_mask
== 0x0000ff);
2235 masks
= (DWORD
*)info
->bmiColors
;
2236 masks
[0] = ctx
->vis
->red_mask
;
2237 masks
[1] = ctx
->vis
->green_mask
;
2238 masks
[2] = ctx
->vis
->blue_mask
;
2239 if (masks
[0] != 0xff0000 || masks
[1] != 0x00ff00 || masks
[2] != 0x0000ff)
2240 info
->bmiHeader
.biCompression
= BI_BITFIELDS
;
2243 FIXME( "depth %u not supported\n", info
->bmiHeader
.biBitCount
);
2248 image
= XGetImage( gdi_display
, ctx
->pixmap
, 0, 0, coords
.width
, coords
.height
, AllPlanes
, ZPixmap
);
2249 wine_tsx11_unlock();
2252 src_bits
.ptr
= image
->data
;
2253 src_bits
.is_copy
= TRUE
;
2254 if (!copy_image_bits( info
, is_r8g8b8
, image
, &src_bits
, &bits
, &coords
, NULL
, ~0u ))
2256 HBITMAP bitmap
= GetCurrentObject( ctx
->hdc
, OBJ_BITMAP
);
2257 TRACE( "drawable %lx -> hdc %p bitmap %p\n", ctx
->pixmap
, ctx
->hdc
, bitmap
);
2258 SetDIBits( 0, bitmap
, 0, coords
.height
, bits
.ptr
, info
, DIB_RGB_COLORS
);
2259 if (bits
.free
) bits
.free( &bits
);
2262 XDestroyImage( image
);
2263 wine_tsx11_unlock();
2266 static void flush_gl_drawable( struct glx_physdev
*physdev
)
2269 int w
= physdev
->x11dev
->dc_rect
.right
- physdev
->x11dev
->dc_rect
.left
;
2270 int h
= physdev
->x11dev
->dc_rect
.bottom
- physdev
->x11dev
->dc_rect
.top
;
2271 Drawable src
= physdev
->drawable
;
2273 if (w
<= 0 || h
<= 0) return;
2275 switch (physdev
->type
)
2277 case DC_GL_PIXMAP_WIN
:
2278 src
= physdev
->pixmap
;
2280 case DC_GL_CHILD_WIN
:
2281 /* The GL drawable may be lagged behind if we don't flush first, so
2282 * flush the display make sure we copy up-to-date data */
2284 XFlush(gdi_display
);
2285 XSetFunction(gdi_display
, physdev
->x11dev
->gc
, GXcopy
);
2286 XCopyArea(gdi_display
, src
, physdev
->x11dev
->drawable
, physdev
->x11dev
->gc
, 0, 0, w
, h
,
2287 physdev
->x11dev
->dc_rect
.left
, physdev
->x11dev
->dc_rect
.top
);
2288 wine_tsx11_unlock();
2289 SetRect( &rect
, 0, 0, w
, h
);
2290 add_device_bounds( physdev
->x11dev
, &rect
);
2297 static void WINAPI
X11DRV_wglFinish(void)
2299 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
2300 enum x11drv_escape_codes code
= X11DRV_FLUSH_GL_DRAWABLE
;
2305 wine_tsx11_unlock();
2308 if (ctx
->pixmap
) flush_pixmap( ctx
);
2309 else ExtEscape( ctx
->hdc
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, 0, NULL
);
2313 static void WINAPI
X11DRV_wglFlush(void)
2315 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
2316 enum x11drv_escape_codes code
= X11DRV_FLUSH_GL_DRAWABLE
;
2321 wine_tsx11_unlock();
2324 if (ctx
->pixmap
) flush_pixmap( ctx
);
2325 else ExtEscape( ctx
->hdc
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, 0, NULL
);
2330 * glxdrv_wglCreateContextAttribsARB
2332 * WGL_ARB_create_context: wglCreateContextAttribsARB
2334 static HGLRC
glxdrv_wglCreateContextAttribsARB(PHYSDEV dev
, HGLRC hShareContext
, const int* attribList
)
2336 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
2337 Wine_GLContext
*ret
;
2338 WineGLPixelFormat
*fmt
;
2341 TRACE("(%p %p %p)\n", dev
->hdc
, hShareContext
, attribList
);
2343 if (!has_opengl()) return 0;
2345 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, physdev
->pixel_format
, TRUE
/* Offscreen */, &fmt_count
);
2346 /* wglCreateContextAttribsARB supports ALL pixel formats, so also offscreen ones.
2347 * If this fails something is very wrong on the system. */
2350 ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", physdev
->pixel_format
);
2351 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
2355 if (!(ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
)))) return 0;
2357 ret
->hdc
= dev
->hdc
;
2359 ret
->vis
= NULL
; /* glXCreateContextAttribsARB requires a fbconfig instead of a visual */
2360 ret
->gl3_context
= TRUE
;
2362 ret
->numAttribs
= 0;
2365 int *pAttribList
= (int*)attribList
;
2366 int *pContextAttribList
= &ret
->attribList
[0];
2367 /* attribList consists of pairs {token, value] terminated with 0 */
2368 while(pAttribList
[0] != 0)
2370 TRACE("%#x %#x\n", pAttribList
[0], pAttribList
[1]);
2371 switch(pAttribList
[0])
2373 case WGL_CONTEXT_MAJOR_VERSION_ARB
:
2374 pContextAttribList
[0] = GLX_CONTEXT_MAJOR_VERSION_ARB
;
2375 pContextAttribList
[1] = pAttribList
[1];
2377 case WGL_CONTEXT_MINOR_VERSION_ARB
:
2378 pContextAttribList
[0] = GLX_CONTEXT_MINOR_VERSION_ARB
;
2379 pContextAttribList
[1] = pAttribList
[1];
2381 case WGL_CONTEXT_LAYER_PLANE_ARB
:
2383 case WGL_CONTEXT_FLAGS_ARB
:
2384 pContextAttribList
[0] = GLX_CONTEXT_FLAGS_ARB
;
2385 pContextAttribList
[1] = pAttribList
[1];
2387 case WGL_CONTEXT_PROFILE_MASK_ARB
:
2388 pContextAttribList
[0] = GLX_CONTEXT_PROFILE_MASK_ARB
;
2389 pContextAttribList
[1] = pAttribList
[1];
2392 ERR("Unhandled attribList pair: %#x %#x\n", pAttribList
[0], pAttribList
[1]);
2397 pContextAttribList
+= 2;
2402 X11DRV_expect_error(gdi_display
, GLXErrorHandler
, NULL
);
2403 ret
->ctx
= create_glxcontext(gdi_display
, ret
, NULL
);
2405 XSync(gdi_display
, False
);
2406 if(X11DRV_check_error() || !ret
->ctx
)
2408 /* In the future we should convert the GLX error to a win32 one here if needed */
2409 ERR("Context creation failed\n");
2410 HeapFree( GetProcessHeap(), 0, ret
);
2411 wine_tsx11_unlock();
2415 list_add_head( &context_list
, &ret
->entry
);
2416 wine_tsx11_unlock();
2417 TRACE(" creating context %p\n", ret
);
2422 * X11DRV_wglGetExtensionsStringARB
2424 * WGL_ARB_extensions_string: wglGetExtensionsStringARB
2426 static const char * WINAPI
X11DRV_wglGetExtensionsStringARB(HDC hdc
) {
2427 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
2428 return WineGLInfo
.wglExtensions
;
2432 * X11DRV_wglCreatePbufferARB
2434 * WGL_ARB_pbuffer: wglCreatePbufferARB
2436 static HPBUFFERARB WINAPI
X11DRV_wglCreatePbufferARB(HDC hdc
, int iPixelFormat
, int iWidth
, int iHeight
, const int *piAttribList
)
2438 Wine_GLPBuffer
* object
= NULL
;
2439 WineGLPixelFormat
*fmt
= NULL
;
2444 TRACE("(%p, %d, %d, %d, %p)\n", hdc
, iPixelFormat
, iWidth
, iHeight
, piAttribList
);
2446 if (0 >= iPixelFormat
) {
2447 ERR("(%p): unexpected iPixelFormat(%d) <= 0, returns NULL\n", hdc
, iPixelFormat
);
2448 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
2449 return NULL
; /* unexpected error */
2452 /* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
2453 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, TRUE
/* Offscreen */, &nCfgs
);
2455 ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc
, iPixelFormat
, nCfgs
);
2456 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
2457 goto create_failed
; /* unexpected error */
2460 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(Wine_GLPBuffer
));
2461 if (NULL
== object
) {
2462 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
2463 goto create_failed
; /* unexpected error */
2466 object
->display
= gdi_display
;
2467 object
->width
= iWidth
;
2468 object
->height
= iHeight
;
2471 PUSH2(attribs
, GLX_PBUFFER_WIDTH
, iWidth
);
2472 PUSH2(attribs
, GLX_PBUFFER_HEIGHT
, iHeight
);
2473 while (piAttribList
&& 0 != *piAttribList
) {
2475 switch (*piAttribList
) {
2476 case WGL_PBUFFER_LARGEST_ARB
: {
2478 attr_v
= *piAttribList
;
2479 TRACE("WGL_LARGEST_PBUFFER_ARB = %d\n", attr_v
);
2480 PUSH2(attribs
, GLX_LARGEST_PBUFFER
, attr_v
);
2484 case WGL_TEXTURE_FORMAT_ARB
: {
2486 attr_v
= *piAttribList
;
2487 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_FORMAT_ARB as %x\n", attr_v
);
2488 if (use_render_texture_ati
) {
2491 case WGL_NO_TEXTURE_ARB
: type
= GLX_NO_TEXTURE_ATI
; break ;
2492 case WGL_TEXTURE_RGB_ARB
: type
= GLX_TEXTURE_RGB_ATI
; break ;
2493 case WGL_TEXTURE_RGBA_ARB
: type
= GLX_TEXTURE_RGBA_ATI
; break ;
2495 SetLastError(ERROR_INVALID_DATA
);
2498 object
->use_render_texture
= 1;
2499 PUSH2(attribs
, GLX_TEXTURE_FORMAT_ATI
, type
);
2501 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2502 object
->use_render_texture
= 0;
2504 if (!use_render_texture_emulation
) {
2505 SetLastError(ERROR_INVALID_DATA
);
2509 case WGL_TEXTURE_RGB_ARB
:
2510 object
->use_render_texture
= GL_RGB
;
2511 object
->texture_bpp
= 3;
2512 object
->texture_format
= GL_RGB
;
2513 object
->texture_type
= GL_UNSIGNED_BYTE
;
2515 case WGL_TEXTURE_RGBA_ARB
:
2516 object
->use_render_texture
= GL_RGBA
;
2517 object
->texture_bpp
= 4;
2518 object
->texture_format
= GL_RGBA
;
2519 object
->texture_type
= GL_UNSIGNED_BYTE
;
2522 /* WGL_FLOAT_COMPONENTS_NV */
2523 case WGL_TEXTURE_FLOAT_R_NV
:
2524 object
->use_render_texture
= GL_FLOAT_R_NV
;
2525 object
->texture_bpp
= 4;
2526 object
->texture_format
= GL_RED
;
2527 object
->texture_type
= GL_FLOAT
;
2529 case WGL_TEXTURE_FLOAT_RG_NV
:
2530 object
->use_render_texture
= GL_FLOAT_RG_NV
;
2531 object
->texture_bpp
= 8;
2532 object
->texture_format
= GL_LUMINANCE_ALPHA
;
2533 object
->texture_type
= GL_FLOAT
;
2535 case WGL_TEXTURE_FLOAT_RGB_NV
:
2536 object
->use_render_texture
= GL_FLOAT_RGB_NV
;
2537 object
->texture_bpp
= 12;
2538 object
->texture_format
= GL_RGB
;
2539 object
->texture_type
= GL_FLOAT
;
2541 case WGL_TEXTURE_FLOAT_RGBA_NV
:
2542 object
->use_render_texture
= GL_FLOAT_RGBA_NV
;
2543 object
->texture_bpp
= 16;
2544 object
->texture_format
= GL_RGBA
;
2545 object
->texture_type
= GL_FLOAT
;
2548 ERR("Unknown texture format: %x\n", attr_v
);
2549 SetLastError(ERROR_INVALID_DATA
);
2557 case WGL_TEXTURE_TARGET_ARB
: {
2559 attr_v
= *piAttribList
;
2560 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_TARGET_ARB as %x\n", attr_v
);
2561 if (use_render_texture_ati
) {
2564 case WGL_NO_TEXTURE_ARB
: type
= GLX_NO_TEXTURE_ATI
; break ;
2565 case WGL_TEXTURE_CUBE_MAP_ARB
: type
= GLX_TEXTURE_CUBE_MAP_ATI
; break ;
2566 case WGL_TEXTURE_1D_ARB
: type
= GLX_TEXTURE_1D_ATI
; break ;
2567 case WGL_TEXTURE_2D_ARB
: type
= GLX_TEXTURE_2D_ATI
; break ;
2569 SetLastError(ERROR_INVALID_DATA
);
2572 PUSH2(attribs
, GLX_TEXTURE_TARGET_ATI
, type
);
2574 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2575 object
->texture_target
= 0;
2577 if (!use_render_texture_emulation
) {
2578 SetLastError(ERROR_INVALID_DATA
);
2582 case WGL_TEXTURE_CUBE_MAP_ARB
: {
2583 if (iWidth
!= iHeight
) {
2584 SetLastError(ERROR_INVALID_DATA
);
2587 object
->texture_target
= GL_TEXTURE_CUBE_MAP
;
2588 object
->texture_bind_target
= GL_TEXTURE_BINDING_CUBE_MAP
;
2591 case WGL_TEXTURE_1D_ARB
: {
2593 SetLastError(ERROR_INVALID_DATA
);
2596 object
->texture_target
= GL_TEXTURE_1D
;
2597 object
->texture_bind_target
= GL_TEXTURE_BINDING_1D
;
2600 case WGL_TEXTURE_2D_ARB
: {
2601 object
->texture_target
= GL_TEXTURE_2D
;
2602 object
->texture_bind_target
= GL_TEXTURE_BINDING_2D
;
2605 case WGL_TEXTURE_RECTANGLE_NV
: {
2606 object
->texture_target
= GL_TEXTURE_RECTANGLE_NV
;
2607 object
->texture_bind_target
= GL_TEXTURE_BINDING_RECTANGLE_NV
;
2611 ERR("Unknown texture target: %x\n", attr_v
);
2612 SetLastError(ERROR_INVALID_DATA
);
2620 case WGL_MIPMAP_TEXTURE_ARB
: {
2622 attr_v
= *piAttribList
;
2623 TRACE("WGL_render_texture Attribute: WGL_MIPMAP_TEXTURE_ARB as %x\n", attr_v
);
2624 if (use_render_texture_ati
) {
2625 PUSH2(attribs
, GLX_MIPMAP_TEXTURE_ATI
, attr_v
);
2627 if (!use_render_texture_emulation
) {
2628 SetLastError(ERROR_INVALID_DATA
);
2638 PUSH1(attribs
, None
);
2640 object
->drawable
= pglXCreatePbuffer(gdi_display
, fmt
->fbconfig
, attribs
);
2641 wine_tsx11_unlock();
2642 TRACE("new Pbuffer drawable as %lx\n", object
->drawable
);
2643 if (!object
->drawable
) {
2644 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
2645 goto create_failed
; /* unexpected error */
2647 TRACE("->(%p)\n", object
);
2651 HeapFree(GetProcessHeap(), 0, object
);
2652 TRACE("->(FAILED)\n");
2657 * X11DRV_wglDestroyPbufferARB
2659 * WGL_ARB_pbuffer: wglDestroyPbufferARB
2661 static GLboolean WINAPI
X11DRV_wglDestroyPbufferARB(HPBUFFERARB hPbuffer
)
2663 Wine_GLPBuffer
* object
= hPbuffer
;
2664 TRACE("(%p)\n", hPbuffer
);
2665 if (NULL
== object
) {
2666 SetLastError(ERROR_INVALID_HANDLE
);
2670 pglXDestroyPbuffer(object
->display
, object
->drawable
);
2671 wine_tsx11_unlock();
2672 HeapFree(GetProcessHeap(), 0, object
);
2677 * X11DRV_wglGetPbufferDCARB
2679 * WGL_ARB_pbuffer: wglGetPbufferDCARB
2681 static HDC WINAPI
X11DRV_wglGetPbufferDCARB(HPBUFFERARB hPbuffer
)
2683 struct x11drv_escape_set_drawable escape
;
2684 Wine_GLPBuffer
* object
= hPbuffer
;
2687 if (NULL
== object
) {
2688 SetLastError(ERROR_INVALID_HANDLE
);
2692 hdc
= CreateDCA( "DISPLAY", NULL
, NULL
, NULL
);
2695 escape
.code
= X11DRV_SET_DRAWABLE
;
2696 escape
.drawable
= object
->drawable
;
2697 escape
.mode
= IncludeInferiors
;
2698 SetRect( &escape
.drawable_rect
, 0, 0, object
->width
, object
->height
);
2699 escape
.dc_rect
= escape
.drawable_rect
;
2700 escape
.fbconfig_id
= object
->fmt
->fmt_id
;
2701 escape
.gl_drawable
= object
->drawable
;
2703 escape
.gl_type
= DC_GL_PBUFFER
;
2704 ExtEscape( hdc
, X11DRV_ESCAPE
, sizeof(escape
), (LPSTR
)&escape
, 0, NULL
);
2706 TRACE( "(%p)->(%p)\n", hPbuffer
, hdc
);
2711 * X11DRV_wglQueryPbufferARB
2713 * WGL_ARB_pbuffer: wglQueryPbufferARB
2715 static GLboolean WINAPI
X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer
, int iAttribute
, int *piValue
)
2717 Wine_GLPBuffer
* object
= hPbuffer
;
2718 TRACE("(%p, 0x%x, %p)\n", hPbuffer
, iAttribute
, piValue
);
2719 if (NULL
== object
) {
2720 SetLastError(ERROR_INVALID_HANDLE
);
2723 switch (iAttribute
) {
2724 case WGL_PBUFFER_WIDTH_ARB
:
2726 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_WIDTH
, (unsigned int*) piValue
);
2727 wine_tsx11_unlock();
2729 case WGL_PBUFFER_HEIGHT_ARB
:
2731 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_HEIGHT
, (unsigned int*) piValue
);
2732 wine_tsx11_unlock();
2735 case WGL_PBUFFER_LOST_ARB
:
2736 /* GLX Pbuffers cannot be lost by default. We can support this by
2737 * setting GLX_PRESERVED_CONTENTS to False and using glXSelectEvent
2738 * to receive pixel buffer clobber events, however that may or may
2739 * not give any benefit */
2740 *piValue
= GL_FALSE
;
2743 case WGL_TEXTURE_FORMAT_ARB
:
2744 if (use_render_texture_ati
) {
2746 int type
= WGL_NO_TEXTURE_ARB
;
2748 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_TEXTURE_FORMAT_ATI
, &tmp
);
2749 wine_tsx11_unlock();
2751 case GLX_NO_TEXTURE_ATI
: type
= WGL_NO_TEXTURE_ARB
; break ;
2752 case GLX_TEXTURE_RGB_ATI
: type
= WGL_TEXTURE_RGB_ARB
; break ;
2753 case GLX_TEXTURE_RGBA_ATI
: type
= WGL_TEXTURE_RGBA_ARB
; break ;
2757 if (!object
->use_render_texture
) {
2758 *piValue
= WGL_NO_TEXTURE_ARB
;
2760 if (!use_render_texture_emulation
) {
2761 SetLastError(ERROR_INVALID_HANDLE
);
2764 switch(object
->use_render_texture
) {
2766 *piValue
= WGL_TEXTURE_RGB_ARB
;
2769 *piValue
= WGL_TEXTURE_RGBA_ARB
;
2771 /* WGL_FLOAT_COMPONENTS_NV */
2773 *piValue
= WGL_TEXTURE_FLOAT_R_NV
;
2775 case GL_FLOAT_RG_NV
:
2776 *piValue
= WGL_TEXTURE_FLOAT_RG_NV
;
2778 case GL_FLOAT_RGB_NV
:
2779 *piValue
= WGL_TEXTURE_FLOAT_RGB_NV
;
2781 case GL_FLOAT_RGBA_NV
:
2782 *piValue
= WGL_TEXTURE_FLOAT_RGBA_NV
;
2785 ERR("Unknown texture format: %x\n", object
->use_render_texture
);
2791 case WGL_TEXTURE_TARGET_ARB
:
2792 if (use_render_texture_ati
) {
2794 int type
= WGL_NO_TEXTURE_ARB
;
2796 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_TEXTURE_TARGET_ATI
, &tmp
);
2797 wine_tsx11_unlock();
2799 case GLX_NO_TEXTURE_ATI
: type
= WGL_NO_TEXTURE_ARB
; break ;
2800 case GLX_TEXTURE_CUBE_MAP_ATI
: type
= WGL_TEXTURE_CUBE_MAP_ARB
; break ;
2801 case GLX_TEXTURE_1D_ATI
: type
= WGL_TEXTURE_1D_ARB
; break ;
2802 case GLX_TEXTURE_2D_ATI
: type
= WGL_TEXTURE_2D_ARB
; break ;
2806 if (!object
->texture_target
) {
2807 *piValue
= WGL_NO_TEXTURE_ARB
;
2809 if (!use_render_texture_emulation
) {
2810 SetLastError(ERROR_INVALID_DATA
);
2813 switch (object
->texture_target
) {
2814 case GL_TEXTURE_1D
: *piValue
= WGL_TEXTURE_1D_ARB
; break;
2815 case GL_TEXTURE_2D
: *piValue
= WGL_TEXTURE_2D_ARB
; break;
2816 case GL_TEXTURE_CUBE_MAP
: *piValue
= WGL_TEXTURE_CUBE_MAP_ARB
; break;
2817 case GL_TEXTURE_RECTANGLE_NV
: *piValue
= WGL_TEXTURE_RECTANGLE_NV
; break;
2823 case WGL_MIPMAP_TEXTURE_ARB
:
2824 if (use_render_texture_ati
) {
2826 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_MIPMAP_TEXTURE_ATI
, (unsigned int*) piValue
);
2827 wine_tsx11_unlock();
2829 *piValue
= GL_FALSE
; /** don't support that */
2830 FIXME("unsupported WGL_ARB_render_texture attribute query for 0x%x\n", iAttribute
);
2835 FIXME("unexpected attribute %x\n", iAttribute
);
2843 * X11DRV_wglReleasePbufferDCARB
2845 * WGL_ARB_pbuffer: wglReleasePbufferDCARB
2847 static int WINAPI
X11DRV_wglReleasePbufferDCARB(HPBUFFERARB hPbuffer
, HDC hdc
)
2849 TRACE("(%p, %p)\n", hPbuffer
, hdc
);
2850 return DeleteDC(hdc
);
2854 * X11DRV_wglSetPbufferAttribARB
2856 * WGL_ARB_pbuffer: wglSetPbufferAttribARB
2858 static GLboolean WINAPI
X11DRV_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer
, const int *piAttribList
)
2860 Wine_GLPBuffer
* object
= hPbuffer
;
2861 GLboolean ret
= GL_FALSE
;
2863 WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer
, piAttribList
);
2864 if (NULL
== object
) {
2865 SetLastError(ERROR_INVALID_HANDLE
);
2868 if (!object
->use_render_texture
) {
2869 SetLastError(ERROR_INVALID_HANDLE
);
2872 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
2875 if (NULL
!= pglXDrawableAttribATI
) {
2876 if (use_render_texture_ati
) {
2877 FIXME("Need conversion for GLX_ATI_render_texture\n");
2880 ret
= pglXDrawableAttribATI(object
->display
, object
->drawable
, piAttribList
);
2881 wine_tsx11_unlock();
2887 * X11DRV_wglChoosePixelFormatARB
2889 * WGL_ARB_pixel_format: wglChoosePixelFormatARB
2891 static GLboolean WINAPI
X11DRV_wglChoosePixelFormatARB(HDC hdc
, const int *piAttribIList
, const FLOAT
*pfAttribFList
, UINT nMaxFormats
, int *piFormats
, UINT
*nNumFormats
)
2896 GLXFBConfig
* cfgs
= NULL
;
2900 WineGLPixelFormat
*fmt
;
2906 TRACE("(%p, %p, %p, %d, %p, %p): hackish\n", hdc
, piAttribIList
, pfAttribFList
, nMaxFormats
, piFormats
, nNumFormats
);
2907 if (NULL
!= pfAttribFList
) {
2908 FIXME("unused pfAttribFList\n");
2911 nAttribs
= ConvertAttribWGLtoGLX(piAttribIList
, attribs
, NULL
);
2912 if (-1 == nAttribs
) {
2913 WARN("Cannot convert WGL to GLX attributes\n");
2916 PUSH1(attribs
, None
);
2918 /* There is no 1:1 mapping between GLX and WGL formats because we duplicate some GLX formats for bitmap rendering (see get_formats).
2919 * Flags like PFD_SUPPORT_GDI, PFD_DRAW_TO_BITMAP and others are a property of the WineGLPixelFormat. We don't query these attributes
2920 * using glXChooseFBConfig but we filter the result of glXChooseFBConfig later on by passing a dwFlags to 'ConvertPixelFormatGLXtoWGL'. */
2921 for(i
=0; piAttribIList
[i
] != 0; i
+=2)
2923 switch(piAttribIList
[i
])
2925 case WGL_DRAW_TO_BITMAP_ARB
:
2926 if(piAttribIList
[i
+1])
2927 dwFlags
|= PFD_DRAW_TO_BITMAP
;
2929 case WGL_ACCELERATION_ARB
:
2930 switch(piAttribIList
[i
+1])
2932 case WGL_NO_ACCELERATION_ARB
:
2933 dwFlags
|= PFD_GENERIC_FORMAT
;
2935 case WGL_GENERIC_ACCELERATION_ARB
:
2936 dwFlags
|= PFD_GENERIC_ACCELERATED
;
2938 case WGL_FULL_ACCELERATION_ARB
:
2943 case WGL_SUPPORT_GDI_ARB
:
2944 if(piAttribIList
[i
+1])
2945 dwFlags
|= PFD_SUPPORT_GDI
;
2950 /* Search for FB configurations matching the requirements in attribs */
2952 cfgs
= pglXChooseFBConfig(gdi_display
, DefaultScreen(gdi_display
), attribs
, &nCfgs
);
2954 wine_tsx11_unlock();
2955 WARN("Compatible Pixel Format not found\n");
2959 /* Loop through all matching formats and check if they are suitable.
2960 * Note that this function should at max return nMaxFormats different formats */
2961 for(run
=0; run
< 2; run
++)
2963 for (it
= 0; it
< nCfgs
; ++it
) {
2964 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cfgs
[it
], GLX_FBCONFIG_ID
, &fmt_id
);
2966 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
2970 /* Search for the format in our list of compatible formats */
2971 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fmt_id
, dwFlags
);
2975 /* During the first run we only want onscreen formats and during the second only offscreen 'XOR' */
2976 if( ((run
== 0) && fmt
->offscreenOnly
) || ((run
== 1) && !fmt
->offscreenOnly
) )
2979 if(pfmt_it
< nMaxFormats
) {
2980 piFormats
[pfmt_it
] = fmt
->iPixelFormat
;
2981 TRACE("at %d/%d found FBCONFIG_ID 0x%x (%d)\n", it
+ 1, nCfgs
, fmt_id
, piFormats
[pfmt_it
]);
2987 *nNumFormats
= pfmt_it
;
2990 wine_tsx11_unlock();
2995 * X11DRV_wglGetPixelFormatAttribivARB
2997 * WGL_ARB_pixel_format: wglGetPixelFormatAttribivARB
2999 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribivARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, int *piValues
)
3002 WineGLPixelFormat
*fmt
= NULL
;
3006 int nWGLFormats
= 0;
3008 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, piValues
);
3010 if (0 < iLayerPlane
) {
3011 FIXME("unsupported iLayerPlane(%d) > 0, returns FALSE\n", iLayerPlane
);
3015 /* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supported.
3016 * We don't have to fail yet as a program can specify an invalid iPixelFormat (lets say 0) if it wants to query
3017 * the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
3018 fmt
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, TRUE
/* Offscreen */, &nWGLFormats
);
3020 WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat
);
3024 for (i
= 0; i
< nAttributes
; ++i
) {
3025 const int curWGLAttr
= piAttributes
[i
];
3026 TRACE("pAttr[%d] = %x\n", i
, curWGLAttr
);
3028 switch (curWGLAttr
) {
3029 case WGL_NUMBER_PIXEL_FORMATS_ARB
:
3030 piValues
[i
] = nWGLFormats
;
3033 case WGL_SUPPORT_OPENGL_ARB
:
3034 piValues
[i
] = GL_TRUE
;
3037 case WGL_ACCELERATION_ARB
:
3038 curGLXAttr
= GLX_CONFIG_CAVEAT
;
3039 if (!fmt
) goto pix_error
;
3040 if(fmt
->dwFlags
& PFD_GENERIC_FORMAT
)
3041 piValues
[i
] = WGL_NO_ACCELERATION_ARB
;
3042 else if(fmt
->dwFlags
& PFD_GENERIC_ACCELERATED
)
3043 piValues
[i
] = WGL_GENERIC_ACCELERATION_ARB
;
3045 piValues
[i
] = WGL_FULL_ACCELERATION_ARB
;
3048 case WGL_TRANSPARENT_ARB
:
3049 curGLXAttr
= GLX_TRANSPARENT_TYPE
;
3050 if (!fmt
) goto pix_error
;
3051 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
3052 if (hTest
) goto get_error
;
3053 piValues
[i
] = GL_FALSE
;
3054 if (GLX_NONE
!= tmp
) piValues
[i
] = GL_TRUE
;
3057 case WGL_PIXEL_TYPE_ARB
:
3058 curGLXAttr
= GLX_RENDER_TYPE
;
3059 if (!fmt
) goto pix_error
;
3060 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
3061 if (hTest
) goto get_error
;
3062 TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp
);
3063 if (tmp
& GLX_RGBA_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_ARB
; }
3064 else if (tmp
& GLX_COLOR_INDEX_BIT
) { piValues
[i
] = WGL_TYPE_COLORINDEX_ARB
; }
3065 else if (tmp
& GLX_RGBA_FLOAT_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
3066 else if (tmp
& GLX_RGBA_FLOAT_ATI_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
3067 else if (tmp
& GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT
) { piValues
[i
] = WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
; }
3069 ERR("unexpected RenderType(%x)\n", tmp
);
3070 piValues
[i
] = WGL_TYPE_RGBA_ARB
;
3074 case WGL_COLOR_BITS_ARB
:
3075 curGLXAttr
= GLX_BUFFER_SIZE
;
3078 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
3079 if (use_render_texture_ati
) {
3080 curGLXAttr
= GLX_BIND_TO_TEXTURE_RGB_ATI
;
3083 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
3084 if (use_render_texture_ati
) {
3085 curGLXAttr
= GLX_BIND_TO_TEXTURE_RGBA_ATI
;
3088 if (!use_render_texture_emulation
) {
3089 piValues
[i
] = GL_FALSE
;
3092 curGLXAttr
= GLX_RENDER_TYPE
;
3093 if (!fmt
) goto pix_error
;
3094 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, &tmp
);
3095 if (hTest
) goto get_error
;
3096 if (GLX_COLOR_INDEX_BIT
== tmp
) {
3097 piValues
[i
] = GL_FALSE
;
3100 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &tmp
);
3101 if (hTest
) goto get_error
;
3102 piValues
[i
] = (tmp
& GLX_PBUFFER_BIT
) ? GL_TRUE
: GL_FALSE
;
3105 case WGL_BLUE_BITS_ARB
:
3106 curGLXAttr
= GLX_BLUE_SIZE
;
3108 case WGL_RED_BITS_ARB
:
3109 curGLXAttr
= GLX_RED_SIZE
;
3111 case WGL_GREEN_BITS_ARB
:
3112 curGLXAttr
= GLX_GREEN_SIZE
;
3114 case WGL_ALPHA_BITS_ARB
:
3115 curGLXAttr
= GLX_ALPHA_SIZE
;
3117 case WGL_DEPTH_BITS_ARB
:
3118 curGLXAttr
= GLX_DEPTH_SIZE
;
3120 case WGL_STENCIL_BITS_ARB
:
3121 curGLXAttr
= GLX_STENCIL_SIZE
;
3123 case WGL_DOUBLE_BUFFER_ARB
:
3124 curGLXAttr
= GLX_DOUBLEBUFFER
;
3126 case WGL_STEREO_ARB
:
3127 curGLXAttr
= GLX_STEREO
;
3129 case WGL_AUX_BUFFERS_ARB
:
3130 curGLXAttr
= GLX_AUX_BUFFERS
;
3133 case WGL_SUPPORT_GDI_ARB
:
3134 if (!fmt
) goto pix_error
;
3135 piValues
[i
] = (fmt
->dwFlags
& PFD_SUPPORT_GDI
) ? TRUE
: FALSE
;
3138 case WGL_DRAW_TO_BITMAP_ARB
:
3139 if (!fmt
) goto pix_error
;
3140 piValues
[i
] = (fmt
->dwFlags
& PFD_DRAW_TO_BITMAP
) ? TRUE
: FALSE
;
3143 case WGL_DRAW_TO_WINDOW_ARB
:
3144 case WGL_DRAW_TO_PBUFFER_ARB
:
3145 if (!fmt
) goto pix_error
;
3146 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_DRAWABLE_TYPE
, &tmp
);
3147 if (hTest
) goto get_error
;
3148 if((curWGLAttr
== WGL_DRAW_TO_WINDOW_ARB
&& (tmp
&GLX_WINDOW_BIT
)) ||
3149 (curWGLAttr
== WGL_DRAW_TO_PBUFFER_ARB
&& (tmp
&GLX_PBUFFER_BIT
)))
3150 piValues
[i
] = GL_TRUE
;
3152 piValues
[i
] = GL_FALSE
;
3155 case WGL_SWAP_METHOD_ARB
:
3156 /* For now return SWAP_EXCHANGE_ARB which is the best type of buffer switch available.
3157 * Later on we can also use GLX_OML_swap_method on drivers which support this. At this
3158 * point only ATI offers this.
3160 piValues
[i
] = WGL_SWAP_EXCHANGE_ARB
;
3163 case WGL_PBUFFER_LARGEST_ARB
:
3164 curGLXAttr
= GLX_LARGEST_PBUFFER
;
3167 case WGL_SAMPLE_BUFFERS_ARB
:
3168 curGLXAttr
= GLX_SAMPLE_BUFFERS_ARB
;
3171 case WGL_SAMPLES_ARB
:
3172 curGLXAttr
= GLX_SAMPLES_ARB
;
3175 case WGL_FLOAT_COMPONENTS_NV
:
3176 curGLXAttr
= GLX_FLOAT_COMPONENTS_NV
;
3179 case WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT
:
3180 curGLXAttr
= GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
;
3183 case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT
:
3184 curGLXAttr
= GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT
;
3187 case WGL_ACCUM_RED_BITS_ARB
:
3188 curGLXAttr
= GLX_ACCUM_RED_SIZE
;
3190 case WGL_ACCUM_GREEN_BITS_ARB
:
3191 curGLXAttr
= GLX_ACCUM_GREEN_SIZE
;
3193 case WGL_ACCUM_BLUE_BITS_ARB
:
3194 curGLXAttr
= GLX_ACCUM_BLUE_SIZE
;
3196 case WGL_ACCUM_ALPHA_BITS_ARB
:
3197 curGLXAttr
= GLX_ACCUM_ALPHA_SIZE
;
3199 case WGL_ACCUM_BITS_ARB
:
3200 if (!fmt
) goto pix_error
;
3201 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_RED_SIZE
, &tmp
);
3202 if (hTest
) goto get_error
;
3204 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_GREEN_SIZE
, &tmp
);
3205 if (hTest
) goto get_error
;
3207 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_BLUE_SIZE
, &tmp
);
3208 if (hTest
) goto get_error
;
3210 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, GLX_ACCUM_ALPHA_SIZE
, &tmp
);
3211 if (hTest
) goto get_error
;
3216 FIXME("unsupported %x WGL Attribute\n", curWGLAttr
);
3219 /* Retrieve a GLX FBConfigAttrib when the attribute to query is valid and
3220 * iPixelFormat != 0. When iPixelFormat is 0 the only value which makes
3221 * sense to query is WGL_NUMBER_PIXEL_FORMATS_ARB.
3223 * TODO: properly test the behavior of wglGetPixelFormatAttrib*v on Windows
3224 * and check which options can work using iPixelFormat=0 and which not.
3225 * A problem would be that this function is an extension. This would
3226 * mean that the behavior could differ between different vendors (ATI, Nvidia, ..).
3228 if (0 != curGLXAttr
&& iPixelFormat
!= 0) {
3229 if (!fmt
) goto pix_error
;
3230 hTest
= pglXGetFBConfigAttrib(gdi_display
, fmt
->fbconfig
, curGLXAttr
, piValues
+ i
);
3231 if (hTest
) goto get_error
;
3234 piValues
[i
] = GL_FALSE
;
3237 wine_tsx11_unlock();
3241 wine_tsx11_unlock();
3242 ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc
, curGLXAttr
);
3246 wine_tsx11_unlock();
3247 ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc
, iPixelFormat
, nWGLFormats
);
3252 * X11DRV_wglGetPixelFormatAttribfvARB
3254 * WGL_ARB_pixel_format: wglGetPixelFormatAttribfvARB
3256 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribfvARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, FLOAT
*pfValues
)
3262 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, pfValues
);
3264 /* Allocate a temporary array to store integer values */
3265 attr
= HeapAlloc(GetProcessHeap(), 0, nAttributes
* sizeof(int));
3267 ERR("couldn't allocate %d array\n", nAttributes
);
3271 /* Piggy-back on wglGetPixelFormatAttribivARB */
3272 ret
= X11DRV_wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, attr
);
3274 /* Convert integer values to float. Should also check for attributes
3275 that can give decimal values here */
3276 for (i
=0; i
<nAttributes
;i
++) {
3277 pfValues
[i
] = attr
[i
];
3281 HeapFree(GetProcessHeap(), 0, attr
);
3286 * X11DRV_wglBindTexImageARB
3288 * WGL_ARB_render_texture: wglBindTexImageARB
3290 static GLboolean WINAPI
X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
3292 Wine_GLPBuffer
* object
= hPbuffer
;
3293 GLboolean ret
= GL_FALSE
;
3295 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
3296 if (NULL
== object
) {
3297 SetLastError(ERROR_INVALID_HANDLE
);
3300 if (!object
->use_render_texture
) {
3301 SetLastError(ERROR_INVALID_HANDLE
);
3305 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
3306 static int init
= 0;
3307 int prev_binded_texture
= 0;
3308 GLXContext prev_context
;
3309 Drawable prev_drawable
;
3310 GLXContext tmp_context
;
3313 prev_context
= pglXGetCurrentContext();
3314 prev_drawable
= pglXGetCurrentDrawable();
3316 /* Our render_texture emulation is basic and lacks some features (1D/Cube support).
3317 This is mostly due to lack of demos/games using them. Further the use of glReadPixels
3318 isn't ideal performance wise but I wasn't able to get other ways working.
3321 init
= 1; /* Only show the FIXME once for performance reasons */
3322 FIXME("partial stub!\n");
3325 TRACE("drawable=%lx, context=%p\n", object
->drawable
, prev_context
);
3326 tmp_context
= pglXCreateNewContext(gdi_display
, object
->fmt
->fbconfig
, object
->fmt
->render_type
, prev_context
, True
);
3328 pglGetIntegerv(object
->texture_bind_target
, &prev_binded_texture
);
3330 /* Switch to our pbuffer */
3331 pglXMakeCurrent(gdi_display
, object
->drawable
, tmp_context
);
3333 /* Make sure that the prev_binded_texture is set as the current texture state isn't shared between contexts.
3334 * After that upload the pbuffer texture data. */
3335 pglBindTexture(object
->texture_target
, prev_binded_texture
);
3336 pglCopyTexImage2D(object
->texture_target
, 0, object
->use_render_texture
, 0, 0, object
->width
, object
->height
, 0);
3338 /* Switch back to the original drawable and upload the pbuffer-texture */
3339 pglXMakeCurrent(object
->display
, prev_drawable
, prev_context
);
3340 pglXDestroyContext(gdi_display
, tmp_context
);
3341 wine_tsx11_unlock();
3345 if (NULL
!= pglXBindTexImageATI
) {
3350 case WGL_FRONT_LEFT_ARB
:
3351 buffer
= GLX_FRONT_LEFT_ATI
;
3353 case WGL_FRONT_RIGHT_ARB
:
3354 buffer
= GLX_FRONT_RIGHT_ATI
;
3356 case WGL_BACK_LEFT_ARB
:
3357 buffer
= GLX_BACK_LEFT_ATI
;
3359 case WGL_BACK_RIGHT_ARB
:
3360 buffer
= GLX_BACK_RIGHT_ATI
;
3363 ERR("Unknown iBuffer=%#x\n", iBuffer
);
3367 /* In the sample 'ogl_offscreen_rendering_3' from codesampler.net I get garbage on the screen.
3368 * I'm not sure if that's a bug in the ATI extension or in the program. I think that the program
3369 * expected a single buffering format since it didn't ask for double buffering. A buffer swap
3370 * fixed the program. I don't know what the correct behavior is. On the other hand that demo
3371 * works fine using our pbuffer emulation path.
3374 ret
= pglXBindTexImageATI(object
->display
, object
->drawable
, buffer
);
3375 wine_tsx11_unlock();
3381 * X11DRV_wglReleaseTexImageARB
3383 * WGL_ARB_render_texture: wglReleaseTexImageARB
3385 static GLboolean WINAPI
X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
3387 Wine_GLPBuffer
* object
= hPbuffer
;
3388 GLboolean ret
= GL_FALSE
;
3390 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
3391 if (NULL
== object
) {
3392 SetLastError(ERROR_INVALID_HANDLE
);
3395 if (!object
->use_render_texture
) {
3396 SetLastError(ERROR_INVALID_HANDLE
);
3399 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
3402 if (NULL
!= pglXReleaseTexImageATI
) {
3407 case WGL_FRONT_LEFT_ARB
:
3408 buffer
= GLX_FRONT_LEFT_ATI
;
3410 case WGL_FRONT_RIGHT_ARB
:
3411 buffer
= GLX_FRONT_RIGHT_ATI
;
3413 case WGL_BACK_LEFT_ARB
:
3414 buffer
= GLX_BACK_LEFT_ATI
;
3416 case WGL_BACK_RIGHT_ARB
:
3417 buffer
= GLX_BACK_RIGHT_ATI
;
3420 ERR("Unknown iBuffer=%#x\n", iBuffer
);
3424 ret
= pglXReleaseTexImageATI(object
->display
, object
->drawable
, buffer
);
3425 wine_tsx11_unlock();
3431 * X11DRV_wglGetExtensionsStringEXT
3433 * WGL_EXT_extensions_string: wglGetExtensionsStringEXT
3435 static const char * WINAPI
X11DRV_wglGetExtensionsStringEXT(void) {
3436 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
3437 return WineGLInfo
.wglExtensions
;
3441 * X11DRV_wglGetSwapIntervalEXT
3443 * WGL_EXT_swap_control: wglGetSwapIntervalEXT
3445 static int WINAPI
X11DRV_wglGetSwapIntervalEXT(VOID
) {
3446 /* GLX_SGI_swap_control doesn't have any provisions for getting the swap
3447 * interval, so the swap interval has to be tracked. */
3449 return swap_interval
;
3453 * X11DRV_wglSwapIntervalEXT
3455 * WGL_EXT_swap_control: wglSwapIntervalEXT
3457 static BOOL WINAPI
X11DRV_wglSwapIntervalEXT(int interval
) {
3460 TRACE("(%d)\n", interval
);
3464 SetLastError(ERROR_INVALID_DATA
);
3467 else if (!has_swap_control
&& interval
== 0)
3469 /* wglSwapIntervalEXT considers an interval value of zero to mean that
3470 * vsync should be disabled, but glXSwapIntervalSGI considers such a
3471 * value to be an error. Just silently ignore the request for now. */
3472 WARN("Request to disable vertical sync is not handled\n");
3477 if (pglXSwapIntervalSGI
)
3480 ret
= !pglXSwapIntervalSGI(interval
);
3481 wine_tsx11_unlock();
3484 WARN("GLX_SGI_swap_control extension is not available\n");
3487 swap_interval
= interval
;
3489 SetLastError(ERROR_DC_NOT_FOUND
);
3496 * X11DRV_wglAllocateMemoryNV
3498 * WGL_NV_vertex_array_range: wglAllocateMemoryNV
3500 static void* WINAPI
X11DRV_wglAllocateMemoryNV(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
) {
3502 TRACE("(%d, %f, %f, %f)\n", size
, readfreq
, writefreq
, priority
);
3504 if (pglXAllocateMemoryNV
)
3507 ret
= pglXAllocateMemoryNV(size
, readfreq
, writefreq
, priority
);
3508 wine_tsx11_unlock();
3514 * X11DRV_wglFreeMemoryNV
3516 * WGL_NV_vertex_array_range: wglFreeMemoryNV
3518 static void WINAPI
X11DRV_wglFreeMemoryNV(GLvoid
* pointer
) {
3519 TRACE("(%p)\n", pointer
);
3520 if (pglXFreeMemoryNV
== NULL
)
3524 pglXFreeMemoryNV(pointer
);
3525 wine_tsx11_unlock();
3529 * glxdrv_wglSetPixelFormatWINE
3531 * WGL_WINE_pixel_format_passthrough: wglSetPixelFormatWINE
3532 * This is a WINE-specific wglSetPixelFormat which can set the pixel format multiple times.
3534 static BOOL
glxdrv_wglSetPixelFormatWINE(PHYSDEV dev
, int iPixelFormat
, const PIXELFORMATDESCRIPTOR
*ppfd
)
3536 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3538 TRACE("(%p,%d,%p)\n", dev
->hdc
, iPixelFormat
, ppfd
);
3540 if (!has_opengl()) return FALSE
;
3542 if (physdev
->pixel_format
== iPixelFormat
) return TRUE
;
3544 /* Relay to the core SetPixelFormat */
3545 TRACE("Changing iPixelFormat from %d to %d\n", physdev
->pixel_format
, iPixelFormat
);
3546 return internal_SetPixelFormat(physdev
, iPixelFormat
, ppfd
);
3550 * glxRequireVersion (internal)
3552 * Check if the supported GLX version matches requiredVersion.
3554 static BOOL
glxRequireVersion(int requiredVersion
)
3556 /* Both requiredVersion and glXVersion[1] contains the minor GLX version */
3557 if(requiredVersion
<= WineGLInfo
.glxVersion
[1])
3563 static BOOL
glxRequireExtension(const char *requiredExtension
)
3565 if (strstr(WineGLInfo
.glxExtensions
, requiredExtension
) == NULL
) {
3572 static void register_extension_string(const char *ext
)
3574 if (WineGLInfo
.wglExtensions
[0])
3575 strcat(WineGLInfo
.wglExtensions
, " ");
3576 strcat(WineGLInfo
.wglExtensions
, ext
);
3578 TRACE("'%s'\n", ext
);
3581 static BOOL
register_extension(const WineGLExtension
* ext
)
3585 assert( WineGLExtensionListSize
< MAX_EXTENSIONS
);
3586 WineGLExtensionList
[WineGLExtensionListSize
++] = ext
;
3588 register_extension_string(ext
->extName
);
3590 for (i
= 0; ext
->extEntryPoints
[i
].funcName
; ++i
)
3591 TRACE(" - '%s'\n", ext
->extEntryPoints
[i
].funcName
);
3596 static const WineGLExtension WGL_internal_functions
=
3600 { "wglGetIntegerv", X11DRV_wglGetIntegerv
},
3601 { "wglFinish", X11DRV_wglFinish
},
3602 { "wglFlush", X11DRV_wglFlush
},
3607 static const WineGLExtension WGL_ARB_create_context
=
3609 "WGL_ARB_create_context",
3611 { "wglCreateContextAttribsARB", (void *)1 /* not called directly */ },
3615 static const WineGLExtension WGL_ARB_extensions_string
=
3617 "WGL_ARB_extensions_string",
3619 { "wglGetExtensionsStringARB", X11DRV_wglGetExtensionsStringARB
},
3623 static const WineGLExtension WGL_ARB_make_current_read
=
3625 "WGL_ARB_make_current_read",
3627 { "wglGetCurrentReadDCARB", X11DRV_wglGetCurrentReadDCARB
},
3628 { "wglMakeContextCurrentARB", (void *)1 /* not called directly */ },
3632 static const WineGLExtension WGL_ARB_multisample
=
3634 "WGL_ARB_multisample",
3637 static const WineGLExtension WGL_ARB_pbuffer
=
3641 { "wglCreatePbufferARB", X11DRV_wglCreatePbufferARB
},
3642 { "wglDestroyPbufferARB", X11DRV_wglDestroyPbufferARB
},
3643 { "wglGetPbufferDCARB", X11DRV_wglGetPbufferDCARB
},
3644 { "wglQueryPbufferARB", X11DRV_wglQueryPbufferARB
},
3645 { "wglReleasePbufferDCARB", X11DRV_wglReleasePbufferDCARB
},
3646 { "wglSetPbufferAttribARB", X11DRV_wglSetPbufferAttribARB
},
3650 static const WineGLExtension WGL_ARB_pixel_format
=
3652 "WGL_ARB_pixel_format",
3654 { "wglChoosePixelFormatARB", X11DRV_wglChoosePixelFormatARB
},
3655 { "wglGetPixelFormatAttribfvARB", X11DRV_wglGetPixelFormatAttribfvARB
},
3656 { "wglGetPixelFormatAttribivARB", X11DRV_wglGetPixelFormatAttribivARB
},
3660 static const WineGLExtension WGL_ARB_render_texture
=
3662 "WGL_ARB_render_texture",
3664 { "wglBindTexImageARB", X11DRV_wglBindTexImageARB
},
3665 { "wglReleaseTexImageARB", X11DRV_wglReleaseTexImageARB
},
3669 static const WineGLExtension WGL_EXT_extensions_string
=
3671 "WGL_EXT_extensions_string",
3673 { "wglGetExtensionsStringEXT", X11DRV_wglGetExtensionsStringEXT
},
3677 static const WineGLExtension WGL_EXT_swap_control
=
3679 "WGL_EXT_swap_control",
3681 { "wglSwapIntervalEXT", X11DRV_wglSwapIntervalEXT
},
3682 { "wglGetSwapIntervalEXT", X11DRV_wglGetSwapIntervalEXT
},
3686 static const WineGLExtension WGL_NV_vertex_array_range
=
3688 "WGL_NV_vertex_array_range",
3690 { "wglAllocateMemoryNV", X11DRV_wglAllocateMemoryNV
},
3691 { "wglFreeMemoryNV", X11DRV_wglFreeMemoryNV
},
3695 static const WineGLExtension WGL_WINE_pixel_format_passthrough
=
3697 "WGL_WINE_pixel_format_passthrough",
3699 { "wglSetPixelFormatWINE", (void *)1 /* not called directly */ },
3704 * X11DRV_WineGL_LoadExtensions
3706 static void X11DRV_WineGL_LoadExtensions(void)
3708 WineGLInfo
.wglExtensions
[0] = 0;
3710 /* Load Wine internal functions */
3711 register_extension(&WGL_internal_functions
);
3713 /* ARB Extensions */
3715 if(glxRequireExtension("GLX_ARB_create_context"))
3717 register_extension(&WGL_ARB_create_context
);
3719 if(glxRequireExtension("GLX_ARB_create_context_profile"))
3720 register_extension_string("WGL_ARB_create_context_profile");
3723 if(glxRequireExtension("GLX_ARB_fbconfig_float"))
3725 register_extension_string("WGL_ARB_pixel_format_float");
3726 register_extension_string("WGL_ATI_pixel_format_float");
3729 register_extension(&WGL_ARB_extensions_string
);
3731 if (glxRequireVersion(3))
3732 register_extension(&WGL_ARB_make_current_read
);
3734 if (glxRequireExtension("GLX_ARB_multisample"))
3735 register_extension(&WGL_ARB_multisample
);
3737 /* In general pbuffer functionality requires support in the X-server. The functionality is
3738 * available either when the GLX_SGIX_pbuffer is present or when the GLX server version is 1.3.
3739 * All display drivers except for Nvidia's use the GLX module from Xfree86/Xorg which only
3740 * supports GLX 1.2. The endresult is that only Nvidia's drivers support pbuffers.
3742 * The only other drive which has pbuffer support is Ati's FGLRX driver. They provide clientside GLX 1.3 support
3743 * without support in the X-server (which other Mesa based drivers require).
3745 * Support pbuffers when the GLX version is 1.3 and GLX_SGIX_pbuffer is available. Further pbuffers can
3746 * also be supported when GLX_ATI_render_texture is available. This extension depends on pbuffers, so when it
3747 * is available pbuffers must be available too. */
3748 if ( (glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer")) || glxRequireExtension("GLX_ATI_render_texture"))
3749 register_extension(&WGL_ARB_pbuffer
);
3751 register_extension(&WGL_ARB_pixel_format
);
3753 /* Support WGL_ARB_render_texture when there's support or pbuffer based emulation */
3754 if (glxRequireExtension("GLX_ATI_render_texture") ||
3755 glxRequireExtension("GLX_ARB_render_texture") ||
3756 (glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer") && use_render_texture_emulation
))
3758 register_extension(&WGL_ARB_render_texture
);
3760 /* The WGL version of GLX_NV_float_buffer requires render_texture */
3761 if(glxRequireExtension("GLX_NV_float_buffer"))
3762 register_extension_string("WGL_NV_float_buffer");
3764 /* Again there's no GLX equivalent for this extension, so depend on the required GL extension */
3765 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_texture_rectangle") != NULL
)
3766 register_extension_string("WGL_NV_texture_rectangle");
3769 /* EXT Extensions */
3771 register_extension(&WGL_EXT_extensions_string
);
3773 /* Load this extension even when it isn't backed by a GLX extension because it is has been around for ages.
3774 * Games like Call of Duty and K.O.T.O.R. rely on it. Further our emulation is good enough. */
3775 register_extension(&WGL_EXT_swap_control
);
3777 if(glxRequireExtension("GLX_EXT_framebuffer_sRGB"))
3778 register_extension_string("WGL_EXT_framebuffer_sRGB");
3780 if(glxRequireExtension("GLX_EXT_fbconfig_packed_float"))
3781 register_extension_string("WGL_EXT_pixel_format_packed_float");
3783 if (glxRequireExtension("GLX_EXT_swap_control"))
3784 has_swap_control
= TRUE
;
3786 /* The OpenGL extension GL_NV_vertex_array_range adds wgl/glX functions which aren't exported as 'real' wgl/glX extensions. */
3787 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_vertex_array_range") != NULL
)
3788 register_extension(&WGL_NV_vertex_array_range
);
3790 /* WINE-specific WGL Extensions */
3792 /* In WineD3D we need the ability to set the pixel format more than once (e.g. after a device reset).
3793 * The default wglSetPixelFormat doesn't allow this, so add our own which allows it.
3795 register_extension(&WGL_WINE_pixel_format_passthrough
);
3799 BOOL
destroy_glxpixmap(Display
*display
, XID glxpixmap
)
3802 pglXDestroyGLXPixmap(display
, glxpixmap
);
3803 wine_tsx11_unlock();
3808 * glxdrv_SwapBuffers
3810 * Swap the buffers of this DC
3812 static BOOL
glxdrv_SwapBuffers(PHYSDEV dev
)
3814 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3815 Wine_GLContext
*ctx
= NtCurrentTeb()->glContext
;
3817 if (!has_opengl()) return FALSE
;
3819 TRACE("(%p)\n", dev
->hdc
);
3823 WARN("Using a NULL context, skipping\n");
3824 SetLastError(ERROR_INVALID_HANDLE
);
3828 if (!physdev
->drawable
)
3830 WARN("Using an invalid drawable, skipping\n");
3831 SetLastError(ERROR_INVALID_HANDLE
);
3837 switch (physdev
->type
)
3839 case DC_GL_PIXMAP_WIN
:
3840 if(pglXCopySubBufferMESA
) {
3841 int w
= physdev
->x11dev
->dc_rect
.right
- physdev
->x11dev
->dc_rect
.left
;
3842 int h
= physdev
->x11dev
->dc_rect
.bottom
- physdev
->x11dev
->dc_rect
.top
;
3844 /* (glX)SwapBuffers has an implicit glFlush effect, however
3845 * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before
3849 pglXCopySubBufferMESA(gdi_display
, physdev
->drawable
, 0, 0, w
, h
);
3854 pglXSwapBuffers(gdi_display
, physdev
->drawable
);
3858 flush_gl_drawable( physdev
);
3859 wine_tsx11_unlock();
3864 static long prev_time
, start_time
;
3865 static unsigned long frames
, frames_total
;
3867 DWORD time
= GetTickCount();
3870 /* every 1.5 seconds */
3871 if (time
- prev_time
> 1500) {
3872 TRACE_(fps
)("@ approx %.2ffps, total %.2ffps\n",
3873 1000.0*frames
/(time
- prev_time
), 1000.0*frames_total
/(time
- start_time
));
3876 if(start_time
== 0) start_time
= time
;
3883 XVisualInfo
*visual_from_fbconfig_id( XID fbconfig_id
)
3885 WineGLPixelFormat
*fmt
;
3888 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fbconfig_id
, 0 /* no flags */);
3893 ret
= pglXGetVisualFromFBConfig(gdi_display
, fmt
->fbconfig
);
3894 wine_tsx11_unlock();
3898 static BOOL
create_glx_dc( PHYSDEV
*pdev
)
3900 /* assume that only the main x11 device implements GetDeviceCaps */
3901 X11DRV_PDEVICE
*x11dev
= get_x11drv_dev( GET_NEXT_PHYSDEV( *pdev
, pGetDeviceCaps
));
3902 struct glx_physdev
*physdev
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*physdev
) );
3904 if (!physdev
) return FALSE
;
3905 physdev
->x11dev
= x11dev
;
3906 push_dc_driver( pdev
, &physdev
->dev
, &glxdrv_funcs
);
3910 /**********************************************************************
3913 static BOOL
glxdrv_CreateDC( PHYSDEV
*pdev
, LPCWSTR driver
, LPCWSTR device
,
3914 LPCWSTR output
, const DEVMODEW
* initData
)
3916 return create_glx_dc( pdev
);
3919 /**********************************************************************
3920 * glxdrv_CreateCompatibleDC
3922 static BOOL
glxdrv_CreateCompatibleDC( PHYSDEV orig
, PHYSDEV
*pdev
)
3924 if (orig
) /* chain to next driver first */
3926 orig
= GET_NEXT_PHYSDEV( orig
, pCreateCompatibleDC
);
3927 if (!orig
->funcs
->pCreateCompatibleDC( orig
, pdev
)) return FALSE
;
3929 /* otherwise we have been called by x11drv */
3930 return create_glx_dc( pdev
);
3933 /**********************************************************************
3936 static BOOL
glxdrv_DeleteDC( PHYSDEV dev
)
3938 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3939 HeapFree( GetProcessHeap(), 0, physdev
);
3943 /**********************************************************************
3946 static INT
glxdrv_ExtEscape( PHYSDEV dev
, INT escape
, INT in_count
, LPCVOID in_data
,
3947 INT out_count
, LPVOID out_data
)
3949 struct glx_physdev
*physdev
= get_glxdrv_dev( dev
);
3951 dev
= GET_NEXT_PHYSDEV( dev
, pExtEscape
);
3953 if (escape
== X11DRV_ESCAPE
&& in_data
&& in_count
>= sizeof(enum x11drv_escape_codes
))
3955 switch (*(const enum x11drv_escape_codes
*)in_data
)
3957 case X11DRV_SET_DRAWABLE
:
3958 if (in_count
>= sizeof(struct x11drv_escape_set_drawable
))
3960 const struct x11drv_escape_set_drawable
*data
= in_data
;
3961 physdev
->pixel_format
= pixelformat_from_fbconfig_id( data
->fbconfig_id
);
3962 physdev
->type
= data
->gl_type
;
3963 physdev
->drawable
= data
->gl_drawable
;
3964 physdev
->pixmap
= data
->pixmap
;
3965 TRACE( "SET_DRAWABLE hdc %p drawable %lx pf %u type %u\n",
3966 dev
->hdc
, physdev
->drawable
, physdev
->pixel_format
, physdev
->type
);
3969 case X11DRV_FLUSH_GL_DRAWABLE
:
3970 flush_gl_drawable( physdev
);
3976 return dev
->funcs
->pExtEscape( dev
, escape
, in_count
, in_data
, out_count
, out_data
);
3979 static const struct gdi_dc_funcs glxdrv_funcs
=
3981 NULL
, /* pAbortDoc */
3982 NULL
, /* pAbortPath */
3983 NULL
, /* pAlphaBlend */
3984 NULL
, /* pAngleArc */
3987 NULL
, /* pBeginPath */
3988 NULL
, /* pBlendImage */
3989 glxdrv_ChoosePixelFormat
, /* pChoosePixelFormat */
3991 NULL
, /* pCloseFigure */
3992 NULL
, /* pCopyBitmap */
3993 NULL
, /* pCreateBitmap */
3994 glxdrv_CreateCompatibleDC
, /* pCreateCompatibleDC */
3995 glxdrv_CreateDC
, /* pCreateDC */
3996 NULL
, /* pDeleteBitmap */
3997 glxdrv_DeleteDC
, /* pDeleteDC */
3998 NULL
, /* pDeleteObject */
3999 glxdrv_DescribePixelFormat
, /* pDescribePixelFormat */
4000 NULL
, /* pDeviceCapabilities */
4001 NULL
, /* pEllipse */
4003 NULL
, /* pEndPage */
4004 NULL
, /* pEndPath */
4005 NULL
, /* pEnumFonts */
4006 NULL
, /* pEnumICMProfiles */
4007 NULL
, /* pExcludeClipRect */
4008 NULL
, /* pExtDeviceMode */
4009 glxdrv_ExtEscape
, /* pExtEscape */
4010 NULL
, /* pExtFloodFill */
4011 NULL
, /* pExtSelectClipRgn */
4012 NULL
, /* pExtTextOut */
4013 NULL
, /* pFillPath */
4014 NULL
, /* pFillRgn */
4015 NULL
, /* pFlattenPath */
4016 NULL
, /* pFontIsLinked */
4017 NULL
, /* pFrameRgn */
4018 NULL
, /* pGdiComment */
4019 NULL
, /* pGdiRealizationInfo */
4020 NULL
, /* pGetBoundsRect */
4021 NULL
, /* pGetCharABCWidths */
4022 NULL
, /* pGetCharABCWidthsI */
4023 NULL
, /* pGetCharWidth */
4024 NULL
, /* pGetDeviceCaps */
4025 NULL
, /* pGetDeviceGammaRamp */
4026 NULL
, /* pGetFontData */
4027 NULL
, /* pGetFontUnicodeRanges */
4028 NULL
, /* pGetGlyphIndices */
4029 NULL
, /* pGetGlyphOutline */
4030 NULL
, /* pGetICMProfile */
4031 NULL
, /* pGetImage */
4032 NULL
, /* pGetKerningPairs */
4033 NULL
, /* pGetNearestColor */
4034 NULL
, /* pGetOutlineTextMetrics */
4035 NULL
, /* pGetPixel */
4036 glxdrv_GetPixelFormat
, /* pGetPixelFormat */
4037 NULL
, /* pGetSystemPaletteEntries */
4038 NULL
, /* pGetTextCharsetInfo */
4039 NULL
, /* pGetTextExtentExPoint */
4040 NULL
, /* pGetTextExtentExPointI */
4041 NULL
, /* pGetTextFace */
4042 NULL
, /* pGetTextMetrics */
4043 NULL
, /* pGradientFill */
4044 NULL
, /* pIntersectClipRect */
4045 NULL
, /* pInvertRgn */
4047 NULL
, /* pModifyWorldTransform */
4049 NULL
, /* pOffsetClipRgn */
4050 NULL
, /* pOffsetViewportOrg */
4051 NULL
, /* pOffsetWindowOrg */
4052 NULL
, /* pPaintRgn */
4055 NULL
, /* pPolyBezier */
4056 NULL
, /* pPolyBezierTo */
4057 NULL
, /* pPolyDraw */
4058 NULL
, /* pPolyPolygon */
4059 NULL
, /* pPolyPolyline */
4060 NULL
, /* pPolygon */
4061 NULL
, /* pPolyline */
4062 NULL
, /* pPolylineTo */
4063 NULL
, /* pPutImage */
4064 NULL
, /* pRealizeDefaultPalette */
4065 NULL
, /* pRealizePalette */
4066 NULL
, /* pRectangle */
4067 NULL
, /* pResetDC */
4068 NULL
, /* pRestoreDC */
4069 NULL
, /* pRoundRect */
4071 NULL
, /* pScaleViewportExt */
4072 NULL
, /* pScaleWindowExt */
4073 NULL
, /* pSelectBitmap */
4074 NULL
, /* pSelectBrush */
4075 NULL
, /* pSelectClipPath */
4076 NULL
, /* pSelectFont */
4077 NULL
, /* pSelectPalette */
4078 NULL
, /* pSelectPen */
4079 NULL
, /* pSetArcDirection */
4080 NULL
, /* pSetBkColor */
4081 NULL
, /* pSetBkMode */
4082 NULL
, /* pSetBoundsRect */
4083 NULL
, /* pSetDCBrushColor */
4084 NULL
, /* pSetDCPenColor */
4085 NULL
, /* pSetDIBitsToDevice */
4086 NULL
, /* pSetDeviceClipping */
4087 NULL
, /* pSetDeviceGammaRamp */
4088 NULL
, /* pSetLayout */
4089 NULL
, /* pSetMapMode */
4090 NULL
, /* pSetMapperFlags */
4091 NULL
, /* pSetPixel */
4092 glxdrv_SetPixelFormat
, /* pSetPixelFormat */
4093 NULL
, /* pSetPolyFillMode */
4094 NULL
, /* pSetROP2 */
4095 NULL
, /* pSetRelAbs */
4096 NULL
, /* pSetStretchBltMode */
4097 NULL
, /* pSetTextAlign */
4098 NULL
, /* pSetTextCharacterExtra */
4099 NULL
, /* pSetTextColor */
4100 NULL
, /* pSetTextJustification */
4101 NULL
, /* pSetViewportExt */
4102 NULL
, /* pSetViewportOrg */
4103 NULL
, /* pSetWindowExt */
4104 NULL
, /* pSetWindowOrg */
4105 NULL
, /* pSetWorldTransform */
4106 NULL
, /* pStartDoc */
4107 NULL
, /* pStartPage */
4108 NULL
, /* pStretchBlt */
4109 NULL
, /* pStretchDIBits */
4110 NULL
, /* pStrokeAndFillPath */
4111 NULL
, /* pStrokePath */
4112 glxdrv_SwapBuffers
, /* pSwapBuffers */
4113 NULL
, /* pUnrealizePalette */
4114 NULL
, /* pWidenPath */
4115 glxdrv_wglCopyContext
, /* pwglCopyContext */
4116 glxdrv_wglCreateContext
, /* pwglCreateContext */
4117 glxdrv_wglCreateContextAttribsARB
, /* pwglCreateContextAttribsARB */
4118 glxdrv_wglDeleteContext
, /* pwglDeleteContext */
4119 glxdrv_wglGetProcAddress
, /* pwglGetProcAddress */
4120 glxdrv_wglMakeContextCurrentARB
, /* pwglMakeContextCurrentARB */
4121 glxdrv_wglMakeCurrent
, /* pwglMakeCurrent */
4122 glxdrv_wglSetPixelFormatWINE
, /* pwglSetPixelFormatWINE */
4123 glxdrv_wglShareLists
, /* pwglShareLists */
4124 glxdrv_wglUseFontBitmapsA
, /* pwglUseFontBitmapsA */
4125 glxdrv_wglUseFontBitmapsW
, /* pwglUseFontBitmapsW */
4126 GDI_PRIORITY_GRAPHICS_DRV
+ 20 /* priority */
4129 const struct gdi_dc_funcs
*get_glx_driver(void)
4131 return &glxdrv_funcs
;
4134 #else /* no OpenGL includes */
4136 const struct gdi_dc_funcs
*get_glx_driver(void)
4141 void mark_drawable_dirty(Drawable old
, Drawable
new)
4145 Drawable
create_glxpixmap(Display
*display
, XVisualInfo
*vis
, Pixmap parent
)
4151 BOOL
destroy_glxpixmap(Display
*display
, XID glxpixmap
)
4156 XVisualInfo
*visual_from_fbconfig_id( XID fbconfig_id
)
4161 #endif /* defined(SONAME_LIBGL) */