2 * X11DRV OpenGL functions
4 * Copyright 2000 Lionel Ulmer
5 * Copyright 2005 Alex Woods
6 * Copyright 2005 Raphael Junqueira
7 * Copyright 2006 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"
34 #include "wine/library.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wgl
);
38 WINE_DECLARE_DEBUG_CHANNEL(opengl
);
40 #if defined(HAVE_GL_GL_H) && defined(HAVE_GL_GLX_H)
52 #ifdef HAVE_GL_GLEXT_H
53 # include <GL/glext.h>
62 /* Redefines the constants */
63 #define CALLBACK __stdcall
64 #define WINAPI __stdcall
65 #define APIENTRY WINAPI
68 WINE_DECLARE_DEBUG_CHANNEL(fps
);
70 typedef struct wine_glcontext
{
76 X11DRV_PDEVICE
*physDev
;
80 struct wine_glcontext
*next
;
81 struct wine_glcontext
*prev
;
84 typedef struct wine_glpbuffer
{
93 int use_render_texture
;
94 GLuint texture_target
;
95 GLuint texture_bind_target
;
104 typedef struct wine_glextension
{
107 const char *funcName
;
113 const char *glVersion
;
114 const char *glExtensions
;
118 const char *glxServerVersion
;
119 const char *glxServerExtensions
;
121 const char *glxClientVersion
;
122 const char *glxClientExtensions
;
124 const char *glxExtensions
;
127 char wglExtensions
[4096];
130 typedef struct wine_glpixelformat
{
136 static Wine_GLContext
*context_list
;
137 static struct WineGLInfo WineGLInfo
= { 0 };
138 static int use_render_texture_emulation
= 0;
139 static int use_render_texture_ati
= 0;
140 static int swap_interval
= 1;
142 #define MAX_EXTENSIONS 16
143 static const WineGLExtension
*WineGLExtensionList
[MAX_EXTENSIONS
];
144 static int WineGLExtensionListSize
;
146 #define MAX_GLPIXELFORMATS 32
147 static WineGLPixelFormat WineGLPixelFormatList
[MAX_GLPIXELFORMATS
];
148 static int WineGLPixelFormatListSize
= 0;
150 static void X11DRV_WineGL_LoadExtensions(void);
152 static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR
*ppfd
) {
153 TRACE(" - size / version : %d / %d\n", ppfd
->nSize
, ppfd
->nVersion
);
154 TRACE(" - dwFlags : ");
155 #define TEST_AND_DUMP(t,tv) if ((t) & (tv)) TRACE(#tv " ")
156 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DEPTH_DONTCARE
);
157 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER
);
158 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DOUBLEBUFFER_DONTCARE
);
159 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_WINDOW
);
160 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_DRAW_TO_BITMAP
);
161 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_ACCELERATED
);
162 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_GENERIC_FORMAT
);
163 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_PALETTE
);
164 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_NEED_SYSTEM_PALETTE
);
165 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO
);
166 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_STEREO_DONTCARE
);
167 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_GDI
);
168 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SUPPORT_OPENGL
);
169 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_COPY
);
170 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_EXCHANGE
);
171 TEST_AND_DUMP(ppfd
->dwFlags
, PFD_SWAP_LAYER_BUFFERS
);
175 TRACE(" - iPixelType : ");
176 switch (ppfd
->iPixelType
) {
177 case PFD_TYPE_RGBA
: TRACE("PFD_TYPE_RGBA"); break;
178 case PFD_TYPE_COLORINDEX
: TRACE("PFD_TYPE_COLORINDEX"); break;
182 TRACE(" - Color : %d\n", ppfd
->cColorBits
);
183 TRACE(" - Red : %d\n", ppfd
->cRedBits
);
184 TRACE(" - Green : %d\n", ppfd
->cGreenBits
);
185 TRACE(" - Blue : %d\n", ppfd
->cBlueBits
);
186 TRACE(" - Alpha : %d\n", ppfd
->cAlphaBits
);
187 TRACE(" - Accum : %d\n", ppfd
->cAccumBits
);
188 TRACE(" - Depth : %d\n", ppfd
->cDepthBits
);
189 TRACE(" - Stencil : %d\n", ppfd
->cStencilBits
);
190 TRACE(" - Aux : %d\n", ppfd
->cAuxBuffers
);
192 TRACE(" - iLayerType : ");
193 switch (ppfd
->iLayerType
) {
194 case PFD_MAIN_PLANE
: TRACE("PFD_MAIN_PLANE"); break;
195 case PFD_OVERLAY_PLANE
: TRACE("PFD_OVERLAY_PLANE"); break;
196 case (BYTE
)PFD_UNDERLAY_PLANE
: TRACE("PFD_UNDERLAY_PLANE"); break;
201 /* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and
202 include all dependencies
205 #define SONAME_LIBGL "libGL.so"
208 #define PUSH1(attribs,att) do { attribs[nAttribs++] = (att); } while (0)
209 #define PUSH2(attribs,att,value) do { attribs[nAttribs++] = (att); attribs[nAttribs++] = (value); } while(0)
211 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
213 MAKE_FUNCPTR(glXChooseVisual
)
214 MAKE_FUNCPTR(glXCreateContext
)
215 MAKE_FUNCPTR(glXCreateGLXPixmap
)
216 MAKE_FUNCPTR(glXGetCurrentContext
)
217 MAKE_FUNCPTR(glXDestroyContext
)
218 MAKE_FUNCPTR(glXDestroyGLXPixmap
)
219 MAKE_FUNCPTR(glXGetConfig
)
220 MAKE_FUNCPTR(glXIsDirect
)
221 MAKE_FUNCPTR(glXMakeCurrent
)
222 MAKE_FUNCPTR(glXSwapBuffers
)
223 MAKE_FUNCPTR(glXQueryExtension
)
224 MAKE_FUNCPTR(glXQueryVersion
)
225 MAKE_FUNCPTR(glXUseXFont
)
228 MAKE_FUNCPTR(glXGetClientString
)
229 MAKE_FUNCPTR(glXQueryExtensionsString
)
230 MAKE_FUNCPTR(glXQueryServerString
)
233 MAKE_FUNCPTR(glXGetFBConfigs
)
234 MAKE_FUNCPTR(glXChooseFBConfig
)
235 MAKE_FUNCPTR(glXCreatePbuffer
)
236 MAKE_FUNCPTR(glXDestroyPbuffer
)
237 MAKE_FUNCPTR(glXGetFBConfigAttrib
)
238 MAKE_FUNCPTR(glXGetVisualFromFBConfig
)
239 MAKE_FUNCPTR(glXMakeContextCurrent
)
240 MAKE_FUNCPTR(glXQueryDrawable
)
241 MAKE_FUNCPTR(glXGetCurrentReadDrawable
)
244 static void* (*pglXGetProcAddressARB
)(const GLubyte
*);
245 static BOOL (*pglXBindTexImageARB
)(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
);
246 static BOOL (*pglXReleaseTexImageARB
)(Display
*dpy
, GLXPbuffer pbuffer
, int buffer
);
247 static BOOL (*pglXDrawableAttribARB
)(Display
*dpy
, GLXDrawable draw
, const int *attribList
);
248 static int (*pglXSwapIntervalSGI
)(int);
250 /* NV GLX Extension */
251 static void* (*pglXAllocateMemoryNV
)(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
);
252 static void (*pglXFreeMemoryNV
)(GLvoid
*pointer
);
254 /* Standard OpenGL */
255 MAKE_FUNCPTR(glBindTexture
)
256 MAKE_FUNCPTR(glBitmap
)
257 MAKE_FUNCPTR(glCopyTexSubImage1D
)
258 MAKE_FUNCPTR(glCopyTexSubImage2D
)
259 MAKE_FUNCPTR(glDisable
)
260 MAKE_FUNCPTR(glDrawBuffer
)
261 MAKE_FUNCPTR(glEnable
)
262 MAKE_FUNCPTR(glEndList
)
263 MAKE_FUNCPTR(glGetError
)
264 MAKE_FUNCPTR(glGetIntegerv
)
265 MAKE_FUNCPTR(glGetString
)
266 MAKE_FUNCPTR(glIsEnabled
)
267 MAKE_FUNCPTR(glNewList
)
268 MAKE_FUNCPTR(glPixelStorei
)
269 MAKE_FUNCPTR(glScissor
)
270 MAKE_FUNCPTR(glViewport
)
273 static BOOL
X11DRV_WineGL_InitOpenglInfo(void)
275 static BOOL infoInitialized
= FALSE
;
277 int screen
= DefaultScreen(gdi_display
);
278 Window win
= RootWindow(gdi_display
, screen
);
280 XVisualInfo
template;
283 GLXContext ctx
= NULL
;
287 infoInitialized
= TRUE
;
291 visual
= DefaultVisual(gdi_display
, screen
);
292 template.visualid
= XVisualIDFromVisual(visual
);
293 vis
= XGetVisualInfo(gdi_display
, VisualIDMask
, &template, &num
);
295 /* Create a GLX Context. Without one we can't query GL information */
296 ctx
= pglXCreateContext(gdi_display
, vis
, None
, GL_TRUE
);
300 pglXMakeCurrent(gdi_display
, win
, ctx
);
302 ERR(" couldn't initialize OpenGL, expect problems\n");
307 WineGLInfo
.glVersion
= (const char *) pglGetString(GL_VERSION
);
308 WineGLInfo
.glExtensions
= strdup((const char *) pglGetString(GL_EXTENSIONS
));
310 /* Get the common GLX version supported by GLX client and server ( major/minor) */
311 pglXQueryVersion(gdi_display
, &WineGLInfo
.glxVersion
[0], &WineGLInfo
.glxVersion
[1]);
313 WineGLInfo
.glxServerVersion
= pglXQueryServerString(gdi_display
, screen
, GLX_VERSION
);
314 WineGLInfo
.glxServerExtensions
= pglXQueryServerString(gdi_display
, screen
, GLX_EXTENSIONS
);
316 WineGLInfo
.glxClientVersion
= pglXGetClientString(gdi_display
, GLX_VERSION
);
317 WineGLInfo
.glxClientExtensions
= pglXGetClientString(gdi_display
, GLX_EXTENSIONS
);
319 WineGLInfo
.glxExtensions
= pglXQueryExtensionsString(gdi_display
, screen
);
320 WineGLInfo
.glxDirect
= pglXIsDirect(gdi_display
, ctx
);
322 TRACE("GL version : %s.\n", WineGLInfo
.glVersion
);
323 TRACE("GLX version : %d.%d.\n", WineGLInfo
.glxVersion
[0], WineGLInfo
.glxVersion
[1]);
324 TRACE("Server GLX version : %s.\n", WineGLInfo
.glxServerVersion
);
325 TRACE("Client GLX version : %s.\n", WineGLInfo
.glxClientVersion
);
326 TRACE("Direct rendering enabled: %s\n", WineGLInfo
.glxDirect
? "True" : "False");
330 pglXMakeCurrent(gdi_display
, None
, NULL
);
331 pglXDestroyContext(gdi_display
, ctx
);
337 static BOOL
has_opengl(void)
339 static int init_done
;
340 static void *opengl_handle
;
341 const char *glx_extensions
;
343 int error_base
, event_base
;
345 if (init_done
) return (opengl_handle
!= NULL
);
348 opengl_handle
= wine_dlopen(SONAME_LIBGL
, RTLD_NOW
|RTLD_GLOBAL
, NULL
, 0);
349 if (opengl_handle
== NULL
) return FALSE
;
351 pglXGetProcAddressARB
= wine_dlsym(opengl_handle
, "glXGetProcAddressARB", NULL
, 0);
352 if (pglXGetProcAddressARB
== NULL
) {
353 ERR("could not find glXGetProcAddressARB in libGL.\n");
357 #define LOAD_FUNCPTR(f) if((p##f = (void*)pglXGetProcAddressARB((const unsigned char*)#f)) == NULL) goto sym_not_found;
359 LOAD_FUNCPTR(glXChooseVisual
)
360 LOAD_FUNCPTR(glXCreateContext
)
361 LOAD_FUNCPTR(glXCreateGLXPixmap
)
362 LOAD_FUNCPTR(glXGetCurrentContext
)
363 LOAD_FUNCPTR(glXDestroyContext
)
364 LOAD_FUNCPTR(glXDestroyGLXPixmap
)
365 LOAD_FUNCPTR(glXGetConfig
)
366 LOAD_FUNCPTR(glXIsDirect
)
367 LOAD_FUNCPTR(glXMakeCurrent
)
368 LOAD_FUNCPTR(glXSwapBuffers
)
369 LOAD_FUNCPTR(glXQueryExtension
)
370 LOAD_FUNCPTR(glXQueryVersion
)
371 LOAD_FUNCPTR(glXUseXFont
)
374 LOAD_FUNCPTR(glXGetClientString
)
375 LOAD_FUNCPTR(glXQueryExtensionsString
)
376 LOAD_FUNCPTR(glXQueryServerString
)
379 LOAD_FUNCPTR(glXCreatePbuffer
)
380 LOAD_FUNCPTR(glXDestroyPbuffer
)
381 LOAD_FUNCPTR(glXMakeContextCurrent
)
382 LOAD_FUNCPTR(glXGetCurrentReadDrawable
)
383 LOAD_FUNCPTR(glXGetFBConfigs
)
385 /* Standard OpenGL calls */
386 LOAD_FUNCPTR(glBindTexture
)
387 LOAD_FUNCPTR(glBitmap
)
388 LOAD_FUNCPTR(glCopyTexSubImage1D
)
389 LOAD_FUNCPTR(glCopyTexSubImage2D
)
390 LOAD_FUNCPTR(glDisable
)
391 LOAD_FUNCPTR(glDrawBuffer
)
392 LOAD_FUNCPTR(glEnable
)
393 LOAD_FUNCPTR(glEndList
)
394 LOAD_FUNCPTR(glGetError
)
395 LOAD_FUNCPTR(glGetIntegerv
)
396 LOAD_FUNCPTR(glGetString
)
397 LOAD_FUNCPTR(glIsEnabled
)
398 LOAD_FUNCPTR(glNewList
)
399 LOAD_FUNCPTR(glPixelStorei
)
400 LOAD_FUNCPTR(glScissor
)
401 LOAD_FUNCPTR(glViewport
)
404 /* It doesn't matter if these fail. They'll only be used if the driver reports
405 the associated extension is available (and if a driver reports the extension
406 is available but fails to provide the functions, it's quite broken) */
407 #define LOAD_FUNCPTR(f) p##f = (void*)pglXGetProcAddressARB((const unsigned char*)#f);
408 /* NV GLX Extension */
409 LOAD_FUNCPTR(glXAllocateMemoryNV
)
410 LOAD_FUNCPTR(glXFreeMemoryNV
)
413 if(!X11DRV_WineGL_InitOpenglInfo()) {
414 ERR("Intialization of OpenGL info failed, disabling OpenGL!\n");
415 wine_dlclose(opengl_handle
, NULL
, 0);
416 opengl_handle
= NULL
;
421 if (pglXQueryExtension(gdi_display
, &error_base
, &event_base
) == True
) {
422 TRACE("GLX is up and running error_base = %d\n", error_base
);
424 wine_dlclose(opengl_handle
, NULL
, 0);
425 opengl_handle
= NULL
;
428 /* In case of GLX you have direct and indirect rendering. Most of the time direct rendering is used
429 * as in general only that is hardware accelerated. In some cases like in case of remote X indirect
432 * The main problem for our OpenGL code is that we need certain GLX calls but their presence
433 * depends on the reported GLX client / server version and on the client / server extension list.
434 * Those don't have to be the same.
436 * In general the server GLX information should be used in case of indirect rendering. When direct
437 * rendering is used, the OpenGL client library is responsible for which GLX calls are available.
438 * Nvidia's OpenGL drivers are the best in terms of GLX features. At the moment of writing their
439 * 8762 drivers support 1.3 for the server and 1.4 for the client and they support lots of extensions.
440 * Unfortunately it is much more complicated for Mesa/DRI-based drivers and ATI's drivers.
441 * Both sets of drivers report a server version of 1.2 and the client version can be 1.3 or 1.4.
442 * Further, in case of at least ATI's drivers, one crucial extension needed for our pixel format code
443 * is only available in the list of server extensions and not in the client list.
445 * The versioning checks below try to take into account the comments from above.
448 /* Depending on the use of direct or indirect rendering we need either the list of extensions
449 * exported by the client or by the server.
451 if(WineGLInfo
.glxDirect
)
452 glx_extensions
= WineGLInfo
.glxClientExtensions
;
454 glx_extensions
= WineGLInfo
.glxServerExtensions
;
456 /* Based on the default opengl context we decide whether direct or indirect rendering is used.
457 * In case of indirect rendering we check if the GLX version of the server is 1.2 and else
458 * the client version is checked.
460 if ((!WineGLInfo
.glxDirect
&& !strcmp("1.2", WineGLInfo
.glxServerVersion
)) ||
461 (WineGLInfo
.glxDirect
&& !strcmp("1.2", WineGLInfo
.glxClientVersion
)))
463 if (NULL
!= strstr(glx_extensions
, "GLX_SGIX_fbconfig")) {
464 pglXChooseFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfigSGIX");
465 pglXGetFBConfigAttrib
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttribSGIX");
466 pglXGetVisualFromFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfigSGIX");
468 ERR(" glx_version is %s and GLX_SGIX_fbconfig extension is unsupported. Expect problems.\n", WineGLInfo
.glxClientVersion
);
471 pglXChooseFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXChooseFBConfig");
472 pglXGetFBConfigAttrib
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetFBConfigAttrib");
473 pglXGetVisualFromFBConfig
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXGetVisualFromFBConfig");
476 /* The mesa libGL client library seems to forward glXQueryDrawable to the Xserver, so only
477 * enable this function when the Xserver understand GLX 1.3 or newer
479 if (!strcmp("1.2", WineGLInfo
.glxServerVersion
))
480 pglXQueryDrawable
= NULL
;
482 pglXQueryDrawable
= wine_dlsym(RTLD_DEFAULT
, "glXQueryDrawable", NULL
, 0);
484 if (NULL
!= strstr(glx_extensions
, "GLX_ATI_render_texture")) {
485 pglXBindTexImageARB
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXBindTexImageARB");
486 pglXReleaseTexImageARB
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXReleaseTexImageARB");
487 pglXDrawableAttribARB
= (void*)pglXGetProcAddressARB((const GLubyte
*) "glXDrawableAttribARB");
490 X11DRV_WineGL_LoadExtensions();
493 return (opengl_handle
!= NULL
);
496 wine_dlclose(opengl_handle
, NULL
, 0);
497 opengl_handle
= NULL
;
501 static inline Wine_GLContext
*alloc_context(void)
505 if ((ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(Wine_GLContext
))))
507 ret
->next
= context_list
;
508 if (context_list
) context_list
->prev
= ret
;
514 static inline void free_context(Wine_GLContext
*context
)
516 if (context
->next
!= NULL
) context
->next
->prev
= context
->prev
;
517 if (context
->prev
!= NULL
) context
->prev
->next
= context
->next
;
518 else context_list
= context
->next
;
520 HeapFree(GetProcessHeap(), 0, context
);
523 static inline Wine_GLContext
*get_context_from_GLXContext(GLXContext ctx
)
526 if (!ctx
) return NULL
;
527 for (ret
= context_list
; ret
; ret
= ret
->next
) if (ctx
== ret
->ctx
) break;
532 * get_hdc_from_Drawable (internal)
534 * For use by wglGetCurrentReadDCARB.
536 inline static HDC
get_hdc_from_Drawable(GLXDrawable d
)
539 for (ret
= context_list
; ret
; ret
= ret
->next
) {
540 if (d
== ret
->physDev
->drawable
) {
547 inline static BOOL
is_valid_context( Wine_GLContext
*ctx
)
550 for (ptr
= context_list
; ptr
; ptr
= ptr
->next
) if (ptr
== ctx
) break;
551 return (ptr
!= NULL
);
554 static int describeContext(Wine_GLContext
* ctx
) {
557 TRACE(" Context %p have (vis:%p):\n", ctx
, ctx
->vis
);
558 pglXGetFBConfigAttrib(gdi_display
, ctx
->fb_conf
, GLX_FBCONFIG_ID
, &tmp
);
559 TRACE(" - FBCONFIG_ID 0x%x\n", tmp
);
560 pglXGetFBConfigAttrib(gdi_display
, ctx
->fb_conf
, GLX_VISUAL_ID
, &tmp
);
561 TRACE(" - VISUAL_ID 0x%x\n", tmp
);
566 static int describeDrawable(Wine_GLContext
* ctx
, Drawable drawable
) {
569 int attribList
[3] = { GLX_FBCONFIG_ID
, 0, None
};
572 if (pglXQueryDrawable
== NULL
) {
573 /** glXQueryDrawable not available so returns not supported */
577 TRACE(" Drawable %p have :\n", (void*) drawable
);
578 pglXQueryDrawable(gdi_display
, drawable
, GLX_WIDTH
, (unsigned int*) &tmp
);
579 TRACE(" - WIDTH as %d\n", tmp
);
580 pglXQueryDrawable(gdi_display
, drawable
, GLX_HEIGHT
, (unsigned int*) &tmp
);
581 TRACE(" - HEIGHT as %d\n", tmp
);
582 pglXQueryDrawable(gdi_display
, drawable
, GLX_FBCONFIG_ID
, (unsigned int*) &tmp
);
583 TRACE(" - FBCONFIG_ID as 0x%x\n", tmp
);
586 fbCfgs
= pglXChooseFBConfig(gdi_display
, DefaultScreen(gdi_display
), attribList
, &nElements
);
587 if (fbCfgs
== NULL
) {
591 pglXGetFBConfigAttrib(gdi_display
, fbCfgs
[0], GLX_VISUAL_ID
, &tmp
);
592 TRACE(" - VISUAL_ID as 0x%x\n", tmp
);
599 static int ConvertAttribWGLtoGLX(const int* iWGLAttr
, int* oGLXAttr
, Wine_GLPBuffer
* pbuf
) {
605 int wantColorBits
= 0;
608 /* The list of WGL attributes is allowed to be NULL, so don't return -1 (error) but just 0 */
612 while (0 != iWGLAttr
[cur
]) {
613 TRACE("pAttr[%d] = %x\n", cur
, iWGLAttr
[cur
]);
615 switch (iWGLAttr
[cur
]) {
616 case WGL_COLOR_BITS_ARB
:
617 pop
= iWGLAttr
[++cur
];
618 wantColorBits
= pop
; /** see end */
620 case WGL_BLUE_BITS_ARB
:
621 pop
= iWGLAttr
[++cur
];
622 PUSH2(oGLXAttr
, GLX_BLUE_SIZE
, pop
);
623 TRACE("pAttr[%d] = GLX_BLUE_SIZE: %d\n", cur
, pop
);
625 case WGL_RED_BITS_ARB
:
626 pop
= iWGLAttr
[++cur
];
627 PUSH2(oGLXAttr
, GLX_RED_SIZE
, pop
);
628 TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur
, pop
);
630 case WGL_GREEN_BITS_ARB
:
631 pop
= iWGLAttr
[++cur
];
632 PUSH2(oGLXAttr
, GLX_GREEN_SIZE
, pop
);
633 TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur
, pop
);
635 case WGL_ALPHA_BITS_ARB
:
636 pop
= iWGLAttr
[++cur
];
638 PUSH2(oGLXAttr
, GLX_ALPHA_SIZE
, pop
);
639 TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur
, pop
);
641 case WGL_DEPTH_BITS_ARB
:
642 pop
= iWGLAttr
[++cur
];
643 PUSH2(oGLXAttr
, GLX_DEPTH_SIZE
, pop
);
644 TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur
, pop
);
646 case WGL_STENCIL_BITS_ARB
:
647 pop
= iWGLAttr
[++cur
];
648 PUSH2(oGLXAttr
, GLX_STENCIL_SIZE
, pop
);
649 TRACE("pAttr[%d] = GLX_STENCIL_SIZE: %d\n", cur
, pop
);
651 case WGL_DOUBLE_BUFFER_ARB
:
652 pop
= iWGLAttr
[++cur
];
653 PUSH2(oGLXAttr
, GLX_DOUBLEBUFFER
, pop
);
654 TRACE("pAttr[%d] = GLX_DOUBLEBUFFER: %d\n", cur
, pop
);
657 case WGL_PIXEL_TYPE_ARB
:
658 pop
= iWGLAttr
[++cur
];
660 case WGL_TYPE_COLORINDEX_ARB
: pop
= GLX_COLOR_INDEX_BIT
; isColor
= 1; break ;
661 case WGL_TYPE_RGBA_ARB
: pop
= GLX_RGBA_BIT
; break ;
662 case WGL_TYPE_RGBA_FLOAT_ATI
: pop
= GLX_RGBA_FLOAT_ATI_BIT
; break ;
664 ERR("unexpected PixelType(%x)\n", pop
);
667 PUSH2(oGLXAttr
, GLX_RENDER_TYPE
, pop
);
668 TRACE("pAttr[%d] = GLX_RENDER_TYPE: %d\n", cur
, pop
);
671 case WGL_SUPPORT_GDI_ARB
:
672 pop
= iWGLAttr
[++cur
];
673 /* We only support a limited number of formats which are all renderable by X (similar to GDI).
674 * Ignore this attribute to prevent us from not finding a match due to the limited
675 * amount of formats supported right now. This option could be matched to GLX_X_RENDERABLE
676 * but the issue is that when a program asks for no GDI support, there's no format we can return
677 * as all our supported formats are renderable by X.
679 TRACE("pAttr[%d] = WGL_SUPPORT_GDI_ARB: %d\n", cur
, pop
);
682 case WGL_DRAW_TO_BITMAP_ARB
:
683 pop
= iWGLAttr
[++cur
];
684 TRACE("pAttr[%d] = WGL_DRAW_TO_BITMAP_ARB: %d\n", cur
, pop
);
685 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
687 drawattrib
|= GLX_PIXMAP_BIT
;
691 case WGL_DRAW_TO_WINDOW_ARB
:
692 pop
= iWGLAttr
[++cur
];
693 TRACE("pAttr[%d] = WGL_DRAW_TO_WINDOW_ARB: %d\n", cur
, pop
);
694 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
696 drawattrib
|= GLX_WINDOW_BIT
;
700 case WGL_DRAW_TO_PBUFFER_ARB
:
701 pop
= iWGLAttr
[++cur
];
702 TRACE("pAttr[%d] = WGL_DRAW_TO_PBUFFER_ARB: %d\n", cur
, pop
);
703 /* GLX_DRAWABLE_TYPE flags need to be OR'd together. See below. */
705 drawattrib
|= GLX_PBUFFER_BIT
;
709 case WGL_ACCELERATION_ARB
:
710 case WGL_SUPPORT_OPENGL_ARB
:
711 pop
= iWGLAttr
[++cur
];
712 /** nothing to do, if we are here, supposing support Accelerated OpenGL */
713 TRACE("pAttr[%d] = WGL_SUPPORT_OPENGL_ARB: %d\n", cur
, pop
);
716 case WGL_PBUFFER_LARGEST_ARB
:
717 pop
= iWGLAttr
[++cur
];
718 PUSH2(oGLXAttr
, GLX_LARGEST_PBUFFER
, pop
);
719 TRACE("pAttr[%d] = GLX_LARGEST_PBUFFER: %x\n", cur
, pop
);
722 case WGL_SAMPLE_BUFFERS_ARB
:
723 pop
= iWGLAttr
[++cur
];
724 PUSH2(oGLXAttr
, GLX_SAMPLE_BUFFERS_ARB
, pop
);
725 TRACE("pAttr[%d] = GLX_SAMPLE_BUFFERS_ARB: %x\n", cur
, pop
);
728 case WGL_SAMPLES_ARB
:
729 pop
= iWGLAttr
[++cur
];
730 PUSH2(oGLXAttr
, GLX_SAMPLES_ARB
, pop
);
731 TRACE("pAttr[%d] = GLX_SAMPLES_ARB: %x\n", cur
, pop
);
734 case WGL_TEXTURE_FORMAT_ARB
:
735 case WGL_TEXTURE_TARGET_ARB
:
736 case WGL_MIPMAP_TEXTURE_ARB
:
737 TRACE("WGL_render_texture Attributes: %x as %x\n", iWGLAttr
[cur
], iWGLAttr
[cur
+ 1]);
738 pop
= iWGLAttr
[++cur
];
740 ERR("trying to use GLX_Pbuffer Attributes without Pbuffer (was %x)\n", iWGLAttr
[cur
]);
742 if (use_render_texture_ati
) {
743 /** nothing to do here */
745 else if (!use_render_texture_emulation
) {
746 if (WGL_NO_TEXTURE_ARB
!= pop
) {
747 ERR("trying to use WGL_render_texture Attributes without support (was %x)\n", iWGLAttr
[cur
]);
748 return -1; /** error: don't support it */
750 PUSH2(oGLXAttr
, GLX_X_RENDERABLE
, pop
);
751 drawattrib
|= GLX_PBUFFER_BIT
;
756 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
757 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
758 pop
= iWGLAttr
[++cur
];
759 /** cannot be converted, see direct handling on
760 * - wglGetPixelFormatAttribivARB
761 * TODO: wglChoosePixelFormat
766 FIXME("unsupported %x WGL Attribute\n", iWGLAttr
[cur
]);
773 * Trick as WGL_COLOR_BITS_ARB != GLX_BUFFER_SIZE
774 * WGL_COLOR_BITS_ARB + WGL_ALPHA_BITS_ARB == GLX_BUFFER_SIZE
777 * The number of color bitplanes in each color buffer. For RGBA
778 * pixel types, it is the size of the color buffer, excluding the
779 * alpha bitplanes. For color-index pixels, it is the size of the
780 * color index buffer.
783 * This attribute defines the number of bits per color buffer.
784 * For GLX FBConfigs that correspond to a PseudoColor or StaticColor visual,
785 * this is equal to the depth value reported in the X11 visual.
786 * For GLX FBConfigs that correspond to TrueColor or DirectColor visual,
787 * this is the sum of GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_BLUE_SIZE, and GLX_ALPHA_SIZE.
790 if (0 < wantColorBits
) {
792 wantColorBits
+= sz_alpha
;
794 if (32 < wantColorBits
) {
795 ERR("buggy %d GLX_BUFFER_SIZE default to 32\n", wantColorBits
);
798 PUSH2(oGLXAttr
, GLX_BUFFER_SIZE
, wantColorBits
);
799 TRACE("pAttr[%d] = WGL_COLOR_BITS_ARB: %d\n", cur
, wantColorBits
);
802 /* Apply the OR'd drawable type bitmask now. */
804 PUSH2(oGLXAttr
, GLX_DRAWABLE_TYPE
, drawattrib
);
805 TRACE("pAttr[?] = GLX_DRAWABLE_TYPE: %#x\n", drawattrib
);
811 BOOL
get_fbconfig_from_visualid(Display
*display
, Visual
*visual
, int *fmt_id
, int *fmt_index
)
813 GLXFBConfig
* cfgs
= NULL
;
820 if(!display
|| !display
) {
821 ERR("Invalid display or visual\n");
823 visualid
= XVisualIDFromVisual(visual
);
825 /* Get a list of all available framebuffer configurations */
826 cfgs
= pglXGetFBConfigs(display
, DefaultScreen(display
), &nCfgs
);
827 if (NULL
== cfgs
|| 0 == nCfgs
) {
828 ERR("glXChooseFBConfig returns NULL\n");
829 if(cfgs
!= NULL
) XFree(cfgs
);
833 /* Find the requested offscreen format and count the number of offscreen formats */
834 for(i
=0; i
<nCfgs
; i
++) {
835 pglXGetFBConfigAttrib(display
, cfgs
[i
], GLX_VISUAL_ID
, &tmp_vis_id
);
836 pglXGetFBConfigAttrib(display
, cfgs
[i
], GLX_FBCONFIG_ID
, &tmp_fmt_id
);
838 /* We are looking up the GLX index of our main visual and have found it :) */
839 if(visualid
== tmp_vis_id
) {
840 TRACE("Found FBCONFIG_ID 0x%x at index %d for VISUAL_ID 0x%x\n", tmp_fmt_id
, i
, tmp_vis_id
);
842 *fmt_id
= tmp_fmt_id
;
848 ERR("No fbconfig found for Wine's main visual (0x%lx), expect problems!\n", visualid
);
853 static BOOL
init_formats(Display
*display
, int screen
, Visual
*visual
)
855 int fmt_id
, fmt_index
;
857 /* Locate the fbconfig correspondig to our main visual */
858 if(!get_fbconfig_from_visualid(display
, visual
, &fmt_id
, &fmt_index
)) {
859 ERR("Can't get the FBCONFIG_ID for the main visual, expect problems!\n");
863 /* Put Wine's internal format at the first index */
864 WineGLPixelFormatList
[0].iPixelFormat
= 1;
865 WineGLPixelFormatList
[0].fbconfig
= fmt_id
;
866 WineGLPixelFormatList
[0].fmt_index
= fmt_index
;
867 WineGLPixelFormatListSize
= 1;
869 /* In the future test for compatible formats here */
874 /* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
875 * In our WGL implementation we only support a subset of these formats namely the format of
876 * Wine's main visual and offscreen formats (if they are available).
877 * This function converts a WGL format to its corresponding GLX one. It returns the index (zero-based)
878 * into the GLX FB config table and it returns the number of supported WGL formats in fmt_count.
880 static BOOL
ConvertPixelFormatWGLtoGLX(Display
*display
, int iPixelFormat
, int *fmt_index
, int *fmt_count
)
884 /* Init the list of pixel formats when we need it */
885 if(!WineGLPixelFormatListSize
)
886 init_formats(display
, DefaultScreen(display
), visual
);
888 if((iPixelFormat
<= 0) || (iPixelFormat
> WineGLPixelFormatListSize
)) {
889 ERR("invalid iPixelFormat %d\n", iPixelFormat
);
895 *fmt_index
= WineGLPixelFormatList
[iPixelFormat
-1].fmt_index
;
898 *fmt_count
= WineGLPixelFormatListSize
;
899 TRACE("Returning fmt_index=%d, fmt_count=%d for iPixelFormat=%d\n", *fmt_index
, *fmt_count
, iPixelFormat
);
904 /* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
905 static int ConvertPixelFormatGLXtoWGL(Display
*display
, int fbconfig
)
909 /* Init the list of pixel formats when we need it */
910 if(!WineGLPixelFormatListSize
)
911 init_formats(display
, DefaultScreen(display
), visual
);
913 for(i
=0; i
<WineGLPixelFormatListSize
; i
++) {
914 if(WineGLPixelFormatList
[i
].fbconfig
== fbconfig
) {
915 TRACE("Returning iPixelFormat %d for fbconfig 0x%x\n", WineGLPixelFormatList
[i
].iPixelFormat
, fbconfig
);
916 return WineGLPixelFormatList
[i
].iPixelFormat
;
919 TRACE("No compatible format found for FBCONFIG_ID=0x%x\n", fbconfig
);
924 * X11DRV_ChoosePixelFormat
926 * Equivalent to glXChooseVisual.
928 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE
*physDev
,
929 const PIXELFORMATDESCRIPTOR
*ppfd
) {
930 GLXFBConfig
* cfgs
= NULL
;
937 ERR("No libGL on this box - disabling OpenGL support !\n");
941 if (TRACE_ON(opengl
)) {
942 TRACE("(%p,%p)\n", physDev
, ppfd
);
944 dump_PIXELFORMATDESCRIPTOR((const PIXELFORMATDESCRIPTOR
*) ppfd
);
949 ERR("Can't get an opengl visual!\n");
953 /* Get a list containing all supported FB configurations */
954 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
955 if (NULL
== cfgs
|| 0 == nCfgs
) {
956 ERR("glXGetFBConfigs returns NULL (glError: %d)\n", pglGetError());
960 /* In case an fbconfig was found, check if it matches to the requirements of the ppfd */
961 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, 1 /* main visual */, &fmt_index
, &value
)) {
962 ERR("Can't find a matching FBCONFIG_ID for VISUAL_ID 0x%lx!\n", visual
->visualid
);
969 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_RENDER_TYPE
, &value
);
970 if (value
& GLX_RGBA_BIT
)
971 iPixelType
= PFD_TYPE_RGBA
;
973 iPixelType
= PFD_TYPE_COLORINDEX
;
975 if (ppfd
->iPixelType
!= iPixelType
) {
976 TRACE("pixel type mismatch\n");
981 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_DOUBLEBUFFER
, &value
); if (value
) dwFlags
|= PFD_DOUBLEBUFFER
;
982 if (!(ppfd
->dwFlags
& PFD_DOUBLEBUFFER_DONTCARE
) && (ppfd
->dwFlags
& PFD_DOUBLEBUFFER
)) {
983 if (!(dwFlags
& PFD_DOUBLEBUFFER
)) {
984 TRACE("dbl buffer mismatch\n");
990 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_STEREO
, &value
); if (value
) dwFlags
|= PFD_STEREO
;
991 if (!(ppfd
->dwFlags
& PFD_STEREO_DONTCARE
) && (ppfd
->dwFlags
& PFD_STEREO
)) {
992 if (!(dwFlags
& PFD_STEREO
)) {
993 TRACE("stereo mismatch\n");
999 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_ALPHA_SIZE
, &value
);
1000 if (ppfd
->iPixelType
==PFD_TYPE_RGBA
&& ppfd
->cAlphaBits
&& !value
) {
1001 TRACE("alpha mismatch\n");
1006 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_DEPTH_SIZE
, &value
);
1007 if (ppfd
->cDepthBits
&& !value
) {
1008 TRACE("depth mismatch\n");
1013 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_STENCIL_SIZE
, &value
);
1014 if (ppfd
->cStencilBits
&& !value
) {
1015 TRACE("stencil mismatch\n");
1020 pglXGetFBConfigAttrib(gdi_display
, cfgs
[fmt_index
], GLX_AUX_BUFFERS
, &value
);
1021 if (ppfd
->cAuxBuffers
&& !value
) {
1022 TRACE("aux mismatch\n");
1026 /* When we pass all the checks we have found a matching format :) */
1028 TRACE("Successfully found a matching mode, returning index: %d\n", ret
);
1033 TRACE("No matching mode was found returning 0\n");
1035 if (NULL
!= cfgs
) XFree(cfgs
);
1036 wine_tsx11_unlock();
1041 * X11DRV_DescribePixelFormat
1043 * Get the pixel-format descriptor associated to the given id
1045 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE
*physDev
,
1048 PIXELFORMATDESCRIPTOR
*ppfd
) {
1049 /*XVisualInfo *vis;*/
1053 GLXFBConfig
* cfgs
= NULL
;
1061 if (!has_opengl()) {
1062 ERR("No libGL on this box - disabling OpenGL support !\n");
1066 TRACE("(%p,%d,%d,%p)\n", physDev
, iPixelFormat
, nBytes
, ppfd
);
1069 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
1070 wine_tsx11_unlock();
1072 if (NULL
== cfgs
|| 0 == nCfgs
) {
1073 ERR("unexpected iPixelFormat(%d), returns NULL\n", iPixelFormat
);
1074 return 0; /* unespected error */
1077 /* 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 */
1078 res
= ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &fmt_count
);
1081 /* The application is only querying the number of visuals */
1083 if (NULL
!= cfgs
) XFree(cfgs
);
1084 wine_tsx11_unlock();
1086 } else if(res
== FALSE
) {
1087 WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat
, fmt_count
);
1089 if (NULL
!= cfgs
) XFree(cfgs
);
1090 wine_tsx11_unlock();
1094 if (nBytes
< sizeof(PIXELFORMATDESCRIPTOR
)) {
1095 ERR("Wrong structure size !\n");
1096 /* Should set error */
1101 cur
= cfgs
[fmt_index
];
1103 memset(ppfd
, 0, sizeof(PIXELFORMATDESCRIPTOR
));
1104 ppfd
->nSize
= sizeof(PIXELFORMATDESCRIPTOR
);
1107 /* These flags are always the same... */
1108 ppfd
->dwFlags
= PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
;
1109 /* Now the flags extracted from the Visual */
1113 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_CONFIG_CAVEAT
, &value
);
1114 if(value
== GLX_SLOW_CONFIG
)
1115 ppfd
->dwFlags
|= PFD_GENERIC_ACCELERATED
;
1117 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_DOUBLEBUFFER
, &value
); if (value
) ppfd
->dwFlags
|= PFD_DOUBLEBUFFER
;
1118 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_STEREO
, &value
); if (value
) ppfd
->dwFlags
|= PFD_STEREO
;
1121 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_RENDER_TYPE
, &value
);
1122 if (value
& GLX_RGBA_BIT
)
1123 ppfd
->iPixelType
= PFD_TYPE_RGBA
;
1125 ppfd
->iPixelType
= PFD_TYPE_COLORINDEX
;
1128 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_BUFFER_SIZE
, &value
);
1129 ppfd
->cColorBits
= value
;
1131 /* Red, green, blue and alpha bits / shifts */
1132 if (ppfd
->iPixelType
== PFD_TYPE_RGBA
) {
1133 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_RED_SIZE
, &rb
);
1134 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_GREEN_SIZE
, &gb
);
1135 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_BLUE_SIZE
, &bb
);
1136 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_ALPHA_SIZE
, &ab
);
1138 ppfd
->cRedBits
= rb
;
1139 ppfd
->cRedShift
= gb
+ bb
+ ab
;
1140 ppfd
->cBlueBits
= bb
;
1141 ppfd
->cBlueShift
= ab
;
1142 ppfd
->cGreenBits
= gb
;
1143 ppfd
->cGreenShift
= bb
+ ab
;
1144 ppfd
->cAlphaBits
= ab
;
1145 ppfd
->cAlphaShift
= 0;
1148 ppfd
->cRedShift
= 0;
1149 ppfd
->cBlueBits
= 0;
1150 ppfd
->cBlueShift
= 0;
1151 ppfd
->cGreenBits
= 0;
1152 ppfd
->cGreenShift
= 0;
1153 ppfd
->cAlphaBits
= 0;
1154 ppfd
->cAlphaShift
= 0;
1156 /* Accums : to do ... */
1159 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_DEPTH_SIZE
, &value
);
1160 ppfd
->cDepthBits
= value
;
1163 pglXGetFBConfigAttrib(gdi_display
, cur
, GLX_STENCIL_SIZE
, &value
);
1164 ppfd
->cStencilBits
= value
;
1166 wine_tsx11_unlock();
1168 /* Aux : to do ... */
1170 ppfd
->iLayerType
= PFD_MAIN_PLANE
;
1172 if (TRACE_ON(opengl
)) {
1173 dump_PIXELFORMATDESCRIPTOR(ppfd
);
1177 if (NULL
!= cfgs
) XFree(cfgs
);
1178 wine_tsx11_unlock();
1184 * X11DRV_GetPixelFormat
1186 * Get the pixel-format id used by this DC
1188 int X11DRV_GetPixelFormat(X11DRV_PDEVICE
*physDev
) {
1189 TRACE("(%p): returns %d\n", physDev
, physDev
->current_pf
);
1191 return physDev
->current_pf
;
1195 * X11DRV_SetPixelFormat
1197 * Set the pixel-format id used by this DC
1199 BOOL
X11DRV_SetPixelFormat(X11DRV_PDEVICE
*physDev
,
1201 const PIXELFORMATDESCRIPTOR
*ppfd
) {
1205 TRACE("(%p,%d,%p)\n", physDev
, iPixelFormat
, ppfd
);
1207 if (!has_opengl()) {
1208 ERR("No libGL on this box - disabling OpenGL support !\n");
1212 /* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
1213 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &value
)) {
1214 ERR("Invalid iPixelFormat: %d\n", iPixelFormat
);
1218 physDev
->current_pf
= iPixelFormat
;
1220 if (TRACE_ON(opengl
)) {
1222 GLXFBConfig
* cfgs_fmt
= NULL
;
1223 GLXFBConfig cur_cfg
;
1227 * How to test if hdc current drawable is compatible (visual/FBConfig) ?
1229 * in case of root window created HDCs we crash here :(
1231 Drawable drawable = get_drawable( physDev->hdc );
1232 TRACE(" drawable (%p,%p) have :\n", drawable, root_window);
1233 pglXQueryDrawable(gdi_display, drawable, GLX_FBCONFIG_ID, (unsigned int*) &value);
1234 TRACE(" - FBCONFIG_ID as 0x%x\n", tmp);
1235 pglXQueryDrawable(gdi_display, drawable, GLX_VISUAL_ID, (unsigned int*) &value);
1236 TRACE(" - VISUAL_ID as 0x%x\n", tmp);
1237 pglXQueryDrawable(gdi_display, drawable, GLX_WIDTH, (unsigned int*) &value);
1238 TRACE(" - WIDTH as %d\n", tmp);
1239 pglXQueryDrawable(gdi_display, drawable, GLX_HEIGHT, (unsigned int*) &value);
1240 TRACE(" - HEIGHT as %d\n", tmp);
1242 cfgs_fmt
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs_fmt
);
1243 cur_cfg
= cfgs_fmt
[fmt_index
];
1244 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_FBCONFIG_ID
, &value
);
1246 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
1248 TRACE(" FBConfig have :\n");
1249 TRACE(" - FBCONFIG_ID 0x%x\n", value
);
1250 pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_VISUAL_ID
, &value
);
1251 TRACE(" - VISUAL_ID 0x%x\n", value
);
1252 pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_DRAWABLE_TYPE
, &value
);
1253 TRACE(" - DRAWABLE_TYPE 0x%x\n", value
);
1261 * X11DRV_wglCreateContext
1263 * For OpenGL32 wglCreateContext.
1265 HGLRC
X11DRV_wglCreateContext(X11DRV_PDEVICE
*physDev
)
1267 Wine_GLContext
*ret
;
1268 GLXFBConfig
* cfgs_fmt
= NULL
;
1269 GLXFBConfig cur_cfg
;
1270 int hdcPF
= physDev
->current_pf
;
1276 HDC hdc
= physDev
->hdc
;
1278 TRACE("(%p)->(PF:%d)\n", hdc
, hdcPF
);
1280 if (!has_opengl()) {
1281 ERR("No libGL on this box - disabling OpenGL support !\n");
1285 /* First, get the visual in use by the X11DRV */
1286 if (!gdi_display
) return 0;
1288 /* We can only render using the iPixelFormat (1) of Wine's Main visual, we need to get the corresponding GLX format.
1289 * If this fails something is very wrong on the system. */
1290 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, hdcPF
, &fmt_index
, &fmt_count
)) {
1291 ERR("Cannot get FB Config for main iPixelFormat 1, expect problems!\n");
1292 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1296 cfgs_fmt
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs_fmt
);
1297 if (NULL
== cfgs_fmt
|| 0 == nCfgs_fmt
) {
1298 ERR("Cannot get FB Configs, expect problems.\n");
1299 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1303 if (fmt_count
< hdcPF
) {
1304 ERR("(%p): unexpected pixelFormat(%d) > nFormats(%d), returns NULL\n", hdc
, hdcPF
, fmt_count
);
1305 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1309 cur_cfg
= cfgs_fmt
[fmt_index
];
1310 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cur_cfg
, GLX_FBCONFIG_ID
, &value
);
1312 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
1313 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1318 /* The context will be allocated in the wglMakeCurrent call */
1320 ret
= alloc_context();
1321 wine_tsx11_unlock();
1323 ret
->physDev
= physDev
;
1324 ret
->fb_conf
= cur_cfg
;
1326 ret
->vis
= pglXGetVisualFromFBConfig(gdi_display
, cur_cfg
);
1328 TRACE(" creating context %p (GL context creation delayed)\n", ret
);
1333 * X11DRV_wglDeleteContext
1335 * For OpenGL32 wglDeleteContext.
1337 BOOL
X11DRV_wglDeleteContext(HGLRC hglrc
)
1339 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1342 TRACE("(%p)\n", hglrc
);
1344 if (!has_opengl()) {
1345 ERR("No libGL on this box - disabling OpenGL support !\n");
1350 /* A game (Half Life not to name it) deletes twice the same context,
1351 * so make sure it is valid first */
1352 if (is_valid_context( ctx
))
1354 if (ctx
->ctx
) pglXDestroyContext(gdi_display
, ctx
->ctx
);
1359 WARN("Error deleting context !\n");
1360 SetLastError(ERROR_INVALID_HANDLE
);
1363 wine_tsx11_unlock();
1369 * X11DRV_wglGetCurrentReadDCARB
1371 * For OpenGL32 wglGetCurrentReadDCARB.
1373 static HDC WINAPI
X11DRV_wglGetCurrentReadDCARB(void)
1381 gl_d
= pglXGetCurrentReadDrawable();
1382 ret
= get_hdc_from_Drawable(gl_d
);
1383 wine_tsx11_unlock();
1385 TRACE(" returning %p (GL drawable %lu)\n", ret
, gl_d
);
1390 * X11DRV_wglGetProcAddress
1392 * For OpenGL32 wglGetProcAddress.
1394 PROC
X11DRV_wglGetProcAddress(LPCSTR lpszProc
)
1397 const WineGLExtension
*ext
;
1399 int padding
= 32 - strlen(lpszProc
);
1403 if (!has_opengl()) {
1404 ERR("No libGL on this box - disabling OpenGL support !\n");
1408 /* Check the table of WGL extensions to see if we need to return a WGL extension
1409 * or a function pointer to a native OpenGL function. */
1410 if(strncmp(lpszProc
, "wgl", 3) != 0) {
1411 return pglXGetProcAddressARB((const GLubyte
*)lpszProc
);
1413 TRACE("('%s'):%*s", lpszProc
, padding
, " ");
1414 for (i
= 0; i
< WineGLExtensionListSize
; ++i
) {
1415 ext
= WineGLExtensionList
[i
];
1416 for (j
= 0; ext
->extEntryPoints
[j
].funcName
; ++j
) {
1417 if (strcmp(ext
->extEntryPoints
[j
].funcName
, lpszProc
) == 0) {
1418 TRACE("(%p) - WineGL\n", ext
->extEntryPoints
[j
].funcAddress
);
1419 return ext
->extEntryPoints
[j
].funcAddress
;
1425 ERR("(%s) - not found\n", lpszProc
);
1429 /***********************************************************************
1430 * sync_current_drawable
1432 * Adjust the current viewport and scissor in order to position
1433 * and size the current drawable correctly on the parent window.
1435 static void sync_current_drawable(BOOL updatedc
)
1441 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1445 if (ctx
&& ctx
->physDev
)
1448 GetClipBox(ctx
->physDev
->hdc
, &rc
); /* Make sure physDev is up to date */
1450 dy
= ctx
->physDev
->drawable_rect
.bottom
- ctx
->physDev
->drawable_rect
.top
-
1451 ctx
->physDev
->dc_rect
.bottom
;
1452 width
= ctx
->physDev
->dc_rect
.right
- ctx
->physDev
->dc_rect
.left
;
1453 height
= ctx
->physDev
->dc_rect
.bottom
- ctx
->physDev
->dc_rect
.top
;
1457 pglViewport(ctx
->physDev
->dc_rect
.left
+ ctx
->viewport
.left
,
1458 dy
+ ctx
->viewport
.top
,
1459 ctx
->viewport
.right
? (ctx
->viewport
.right
- ctx
->viewport
.left
) : width
,
1460 ctx
->viewport
.bottom
? (ctx
->viewport
.bottom
- ctx
->viewport
.top
) : height
);
1462 pglEnable(GL_SCISSOR_TEST
);
1464 if (ctx
->scissor_enabled
)
1465 pglScissor(ctx
->physDev
->dc_rect
.left
+ min(width
, max(0, ctx
->scissor
.left
)),
1466 dy
+ min(height
, max(0, ctx
->scissor
.top
)),
1467 min(width
, max(0, ctx
->scissor
.right
- ctx
->scissor
.left
)),
1468 min(height
, max(0, ctx
->scissor
.bottom
- ctx
->scissor
.top
)));
1470 pglScissor(ctx
->physDev
->dc_rect
.left
, dy
, width
, height
);
1472 wine_tsx11_unlock();
1477 * X11DRV_wglMakeCurrent
1479 * For OpenGL32 wglMakeCurrent.
1481 BOOL
X11DRV_wglMakeCurrent(X11DRV_PDEVICE
*physDev
, HGLRC hglrc
) {
1483 HDC hdc
= physDev
->hdc
;
1484 DWORD type
= GetObjectType(hdc
);
1486 TRACE("(%p,%p)\n", hdc
, hglrc
);
1488 if (!has_opengl()) {
1489 ERR("No libGL on this box - disabling OpenGL support !\n");
1494 if (hglrc
== NULL
) {
1495 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1496 NtCurrentTeb()->glContext
= NULL
;
1498 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1499 Drawable drawable
= physDev
->drawable
;
1500 if (ctx
->ctx
== NULL
) {
1501 /* The describe lines below are for debugging purposes only */
1502 if (TRACE_ON(wgl
)) {
1503 describeDrawable(ctx
, drawable
);
1504 describeContext(ctx
);
1507 /* Create a GLX context using the same visual as chosen earlier in wglCreateContext.
1508 * We are certain that the drawable and context are compatible as we only allow compatible formats.
1510 TRACE(" Creating GLX Context\n");
1511 ctx
->ctx
= pglXCreateContext(gdi_display
, ctx
->vis
, NULL
, type
== OBJ_MEMDC
? False
: True
);
1512 TRACE(" created a delayed OpenGL context (%p)\n", ctx
->ctx
);
1514 TRACE(" make current for dis %p, drawable %p, ctx %p\n", gdi_display
, (void*) drawable
, ctx
->ctx
);
1515 ret
= pglXMakeCurrent(gdi_display
, drawable
, ctx
->ctx
);
1516 NtCurrentTeb()->glContext
= ctx
;
1519 ctx
->physDev
= physDev
;
1521 if (type
== OBJ_MEMDC
)
1523 ctx
->do_escape
= TRUE
;
1524 pglDrawBuffer(GL_FRONT_LEFT
);
1528 sync_current_drawable(FALSE
);
1532 wine_tsx11_unlock();
1533 TRACE(" returning %s\n", (ret
? "True" : "False"));
1538 * X11DRV_wglMakeContextCurrentARB
1540 * For OpenGL32 wglMakeContextCurrentARB
1542 BOOL
X11DRV_wglMakeContextCurrentARB(X11DRV_PDEVICE
* hDrawDev
, X11DRV_PDEVICE
* hReadDev
, HGLRC hglrc
)
1545 TRACE("(%p,%p,%p)\n", hDrawDev
, hReadDev
, hglrc
);
1547 if (!has_opengl()) {
1548 ERR("No libGL on this box - disabling OpenGL support !\n");
1553 if (hglrc
== NULL
) {
1554 ret
= pglXMakeCurrent(gdi_display
, None
, NULL
);
1555 NtCurrentTeb()->glContext
= NULL
;
1557 if (NULL
== pglXMakeContextCurrent
) {
1560 Wine_GLContext
*ctx
= (Wine_GLContext
*) hglrc
;
1561 Drawable d_draw
= get_glxdrawable(hDrawDev
);
1562 Drawable d_read
= get_glxdrawable(hReadDev
);
1564 if (ctx
->ctx
== NULL
) {
1565 ctx
->ctx
= pglXCreateContext(gdi_display
, ctx
->vis
, NULL
, GetObjectType(hDrawDev
->hdc
) == OBJ_MEMDC
? False
: True
);
1566 TRACE(" created a delayed OpenGL context (%p)\n", ctx
->ctx
);
1568 ret
= pglXMakeContextCurrent(gdi_display
, d_draw
, d_read
, ctx
->ctx
);
1569 NtCurrentTeb()->glContext
= ctx
;
1572 wine_tsx11_unlock();
1574 TRACE(" returning %s\n", (ret
? "True" : "False"));
1579 * X11DRV_wglShareLists
1581 * For OpenGL32 wglShaderLists.
1583 BOOL
X11DRV_wglShareLists(HGLRC hglrc1
, HGLRC hglrc2
) {
1584 Wine_GLContext
*org
= (Wine_GLContext
*) hglrc1
;
1585 Wine_GLContext
*dest
= (Wine_GLContext
*) hglrc2
;
1587 TRACE("(%p, %p)\n", org
, dest
);
1589 if (!has_opengl()) {
1590 ERR("No libGL on this box - disabling OpenGL support !\n");
1594 if (NULL
!= dest
&& dest
->ctx
!= NULL
) {
1595 ERR("Could not share display lists, context already created !\n");
1598 if (org
->ctx
== NULL
) {
1600 describeContext(org
);
1601 org
->ctx
= pglXCreateContext(gdi_display
, org
->vis
, NULL
, GetObjectType(org
->physDev
->hdc
) == OBJ_MEMDC
? False
: True
);
1602 wine_tsx11_unlock();
1603 TRACE(" created a delayed OpenGL context (%p) for Wine context %p\n", org
->ctx
, org
);
1607 describeContext(dest
);
1608 /* Create the destination context with display lists shared */
1609 dest
->ctx
= pglXCreateContext(gdi_display
, dest
->vis
, org
->ctx
, GetObjectType(org
->physDev
->hdc
) == OBJ_MEMDC
? False
: True
);
1610 wine_tsx11_unlock();
1611 TRACE(" created a delayed OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest
->ctx
, dest
, org
->ctx
);
1618 static BOOL
internal_wglUseFontBitmaps(HDC hdc
, DWORD first
, DWORD count
, DWORD listBase
, DWORD (WINAPI
*GetGlyphOutline_ptr
)(HDC
,UINT
,UINT
,LPGLYPHMETRICS
,DWORD
,LPVOID
,const MAT2
*))
1620 /* We are running using client-side rendering fonts... */
1624 void *bitmap
= NULL
, *gl_bitmap
= NULL
;
1628 pglGetIntegerv(GL_UNPACK_ALIGNMENT
, &org_alignment
);
1629 pglPixelStorei(GL_UNPACK_ALIGNMENT
, 4);
1630 wine_tsx11_unlock();
1632 for (glyph
= first
; glyph
< first
+ count
; glyph
++) {
1633 unsigned int needed_size
= GetGlyphOutline_ptr(hdc
, glyph
, GGO_BITMAP
, &gm
, 0, NULL
, NULL
);
1634 int height
, width_int
;
1636 TRACE("Glyph : %3d / List : %d\n", glyph
, listBase
);
1637 if (needed_size
== GDI_ERROR
) {
1638 TRACE(" - needed size : %d (GDI_ERROR)\n", needed_size
);
1641 TRACE(" - needed size : %d\n", needed_size
);
1644 if (needed_size
> size
) {
1646 HeapFree(GetProcessHeap(), 0, bitmap
);
1647 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
1648 bitmap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
1649 gl_bitmap
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
1651 if (GetGlyphOutline_ptr(hdc
, glyph
, GGO_BITMAP
, &gm
, size
, bitmap
, NULL
) == GDI_ERROR
) goto error
;
1652 if (TRACE_ON(opengl
)) {
1653 unsigned int height
, width
, bitmask
;
1654 unsigned char *bitmap_
= (unsigned char *) bitmap
;
1656 TRACE(" - bbox : %d x %d\n", gm
.gmBlackBoxX
, gm
.gmBlackBoxY
);
1657 TRACE(" - origin : (%d , %d)\n", gm
.gmptGlyphOrigin
.x
, gm
.gmptGlyphOrigin
.y
);
1658 TRACE(" - increment : %d - %d\n", gm
.gmCellIncX
, gm
.gmCellIncY
);
1659 if (needed_size
!= 0) {
1660 TRACE(" - bitmap :\n");
1661 for (height
= 0; height
< gm
.gmBlackBoxY
; height
++) {
1663 for (width
= 0, bitmask
= 0x80; width
< gm
.gmBlackBoxX
; width
++, bitmask
>>= 1) {
1668 if (*bitmap_
& bitmask
)
1673 bitmap_
+= (4 - ((UINT_PTR
)bitmap_
& 0x03));
1679 /* In OpenGL, the bitmap is drawn from the bottom to the top... So we need to invert the
1680 * glyph for it to be drawn properly.
1682 if (needed_size
!= 0) {
1683 width_int
= (gm
.gmBlackBoxX
+ 31) / 32;
1684 for (height
= 0; height
< gm
.gmBlackBoxY
; height
++) {
1686 for (width
= 0; width
< width_int
; width
++) {
1687 ((int *) gl_bitmap
)[(gm
.gmBlackBoxY
- height
- 1) * width_int
+ width
] =
1688 ((int *) bitmap
)[height
* width_int
+ width
];
1694 pglNewList(listBase
++, GL_COMPILE
);
1695 if (needed_size
!= 0) {
1696 pglBitmap(gm
.gmBlackBoxX
, gm
.gmBlackBoxY
,
1697 0 - (int) gm
.gmptGlyphOrigin
.x
, (int) gm
.gmBlackBoxY
- (int) gm
.gmptGlyphOrigin
.y
,
1698 gm
.gmCellIncX
, gm
.gmCellIncY
,
1701 /* This is the case of 'empty' glyphs like the space character */
1702 pglBitmap(0, 0, 0, 0, gm
.gmCellIncX
, gm
.gmCellIncY
, NULL
);
1705 wine_tsx11_unlock();
1709 pglPixelStorei(GL_UNPACK_ALIGNMENT
, org_alignment
);
1710 wine_tsx11_unlock();
1712 HeapFree(GetProcessHeap(), 0, bitmap
);
1713 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
1718 pglPixelStorei(GL_UNPACK_ALIGNMENT
, org_alignment
);
1719 wine_tsx11_unlock();
1721 HeapFree(GetProcessHeap(), 0, bitmap
);
1722 HeapFree(GetProcessHeap(), 0, gl_bitmap
);
1727 * X11DRV_wglUseFontBitmapsA
1729 * For OpenGL32 wglUseFontBitmapsA.
1731 BOOL
X11DRV_wglUseFontBitmapsA(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
1733 Font fid
= physDev
->font
;
1735 TRACE("(%p, %d, %d, %d) using font %ld\n", physDev
->hdc
, first
, count
, listBase
, fid
);
1737 if (!has_opengl()) {
1738 ERR("No libGL on this box - disabling OpenGL support !\n");
1743 return internal_wglUseFontBitmaps(physDev
->hdc
, first
, count
, listBase
, GetGlyphOutlineA
);
1747 /* I assume that the glyphs are at the same position for X and for Windows */
1748 pglXUseXFont(fid
, first
, count
, listBase
);
1749 wine_tsx11_unlock();
1754 * X11DRV_wglUseFontBitmapsW
1756 * For OpenGL32 wglUseFontBitmapsW.
1758 BOOL
X11DRV_wglUseFontBitmapsW(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
1760 Font fid
= physDev
->font
;
1762 TRACE("(%p, %d, %d, %d) using font %ld\n", physDev
->hdc
, first
, count
, listBase
, fid
);
1764 if (!has_opengl()) {
1765 ERR("No libGL on this box - disabling OpenGL support !\n");
1770 return internal_wglUseFontBitmaps(physDev
->hdc
, first
, count
, listBase
, GetGlyphOutlineW
);
1773 WARN("Using the glX API for the WCHAR variant - some characters may come out incorrectly !\n");
1776 /* I assume that the glyphs are at the same position for X and for Windows */
1777 pglXUseXFont(fid
, first
, count
, listBase
);
1778 wine_tsx11_unlock();
1782 static void WINAPI
X11DRV_wglDisable(GLenum cap
)
1784 if (cap
== GL_SCISSOR_TEST
)
1786 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1789 ctx
->scissor_enabled
= FALSE
;
1795 wine_tsx11_unlock();
1799 static void WINAPI
X11DRV_wglEnable(GLenum cap
)
1801 if (cap
== GL_SCISSOR_TEST
)
1803 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1806 ctx
->scissor_enabled
= TRUE
;
1812 wine_tsx11_unlock();
1816 /* WGL helper function which handles differences in glGetIntegerv from WGL and GLX */
1817 static void WINAPI
X11DRV_wglGetIntegerv(GLenum pname
, GLint
* params
)
1824 GLXContext gl_ctx
= pglXGetCurrentContext();
1825 Wine_GLContext
* ret
= get_context_from_GLXContext(gl_ctx
);
1827 pglGetIntegerv(pname
, params
);
1829 * if we cannot find a Wine Context
1830 * we only have the default wine desktop context,
1831 * so if we have only a 24 depth say we have 32
1833 if (NULL
== ret
&& 24 == *params
) {
1836 TRACE("returns GL_DEPTH_BITS as '%d'\n", *params
);
1841 GLXContext gl_ctx
= pglXGetCurrentContext();
1842 Wine_GLContext
* ret
= get_context_from_GLXContext(gl_ctx
);
1844 pglXGetFBConfigAttrib(gdi_display
, ret
->fb_conf
, GLX_ALPHA_SIZE
, params
);
1845 TRACE("returns GL_ALPHA_BITS as '%d'\n", *params
);
1849 pglGetIntegerv(pname
, params
);
1852 wine_tsx11_unlock();
1855 static GLboolean WINAPI
X11DRV_wglIsEnabled(GLenum cap
)
1857 GLboolean enabled
= False
;
1859 if (cap
== GL_SCISSOR_TEST
)
1861 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1864 enabled
= ctx
->scissor_enabled
;
1869 enabled
= pglIsEnabled(cap
);
1870 wine_tsx11_unlock();
1875 static void WINAPI
X11DRV_wglScissor(GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1877 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1881 ctx
->scissor
.left
= x
;
1882 ctx
->scissor
.top
= y
;
1883 ctx
->scissor
.right
= x
+ width
;
1884 ctx
->scissor
.bottom
= y
+ height
;
1886 sync_current_drawable(TRUE
);
1890 static void WINAPI
X11DRV_wglViewport(GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1892 Wine_GLContext
*ctx
= (Wine_GLContext
*) NtCurrentTeb()->glContext
;
1896 ctx
->viewport
.left
= x
;
1897 ctx
->viewport
.top
= y
;
1898 ctx
->viewport
.right
= x
+ width
;
1899 ctx
->viewport
.bottom
= y
+ height
;
1901 sync_current_drawable(TRUE
);
1906 * X11DRV_wglGetExtensionsStringARB
1908 * WGL_ARB_extensions_string: wglGetExtensionsStringARB
1910 static const char * WINAPI
X11DRV_wglGetExtensionsStringARB(HDC hdc
) {
1911 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
1912 return WineGLInfo
.wglExtensions
;
1916 * X11DRV_wglCreatePbufferARB
1918 * WGL_ARB_pbuffer: wglCreatePbufferARB
1920 static HPBUFFERARB WINAPI
X11DRV_wglCreatePbufferARB(HDC hdc
, int iPixelFormat
, int iWidth
, int iHeight
, const int *piAttribList
)
1922 Wine_GLPBuffer
* object
= NULL
;
1923 GLXFBConfig
* cfgs
= NULL
;
1929 TRACE("(%p, %d, %d, %d, %p)\n", hdc
, iPixelFormat
, iWidth
, iHeight
, piAttribList
);
1931 if (0 >= iPixelFormat
) {
1932 ERR("(%p): unexpected iPixelFormat(%d) <= 0, returns NULL\n", hdc
, iPixelFormat
);
1933 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1934 return NULL
; /* unexpected error */
1937 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
1939 if (NULL
== cfgs
|| 0 == nCfgs
) {
1940 ERR("(%p): Cannot get FB Configs for iPixelFormat(%d), returns NULL\n", hdc
, iPixelFormat
);
1941 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1942 return NULL
; /* unexpected error */
1945 /* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
1946 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &nCfgs
)) {
1947 ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc
, iPixelFormat
, nCfgs
);
1948 SetLastError(ERROR_INVALID_PIXEL_FORMAT
);
1949 goto create_failed
; /* unexpected error */
1952 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(Wine_GLPBuffer
));
1953 if (NULL
== object
) {
1954 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
1955 goto create_failed
; /* unexpected error */
1958 object
->display
= gdi_display
;
1959 object
->width
= iWidth
;
1960 object
->height
= iHeight
;
1961 object
->pixelFormat
= iPixelFormat
;
1963 nAttribs
= ConvertAttribWGLtoGLX(piAttribList
, attribs
, object
);
1964 if (-1 == nAttribs
) {
1965 WARN("Cannot convert WGL to GLX attributes\n");
1968 PUSH2(attribs
, GLX_PBUFFER_WIDTH
, iWidth
);
1969 PUSH2(attribs
, GLX_PBUFFER_HEIGHT
, iHeight
);
1970 while (piAttribList
&& 0 != *piAttribList
) {
1972 switch (*piAttribList
) {
1973 case WGL_TEXTURE_FORMAT_ARB
: {
1975 attr_v
= *piAttribList
;
1976 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_FORMAT_ARB as %x\n", attr_v
);
1977 if (use_render_texture_ati
) {
1980 case WGL_NO_TEXTURE_ARB
: type
= GLX_NO_TEXTURE_ATI
; break ;
1981 case WGL_TEXTURE_RGB_ARB
: type
= GLX_TEXTURE_RGB_ATI
; break ;
1982 case WGL_TEXTURE_RGBA_ARB
: type
= GLX_TEXTURE_RGBA_ATI
; break ;
1984 SetLastError(ERROR_INVALID_DATA
);
1987 object
->use_render_texture
= 1;
1988 PUSH2(attribs
, GLX_TEXTURE_FORMAT_ATI
, type
);
1990 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
1991 object
->use_render_texture
= 0;
1993 if (!use_render_texture_emulation
) {
1994 SetLastError(ERROR_INVALID_DATA
);
1998 case WGL_TEXTURE_RGB_ARB
:
1999 object
->use_render_texture
= GL_RGB
;
2001 case WGL_TEXTURE_RGBA_ARB
:
2002 object
->use_render_texture
= GL_RGBA
;
2005 SetLastError(ERROR_INVALID_DATA
);
2013 case WGL_TEXTURE_TARGET_ARB
: {
2015 attr_v
= *piAttribList
;
2016 TRACE("WGL_render_texture Attribute: WGL_TEXTURE_TARGET_ARB as %x\n", attr_v
);
2017 if (use_render_texture_ati
) {
2020 case WGL_NO_TEXTURE_ARB
: type
= GLX_NO_TEXTURE_ATI
; break ;
2021 case WGL_TEXTURE_CUBE_MAP_ARB
: type
= GLX_TEXTURE_CUBE_MAP_ATI
; break ;
2022 case WGL_TEXTURE_1D_ARB
: type
= GLX_TEXTURE_1D_ATI
; break ;
2023 case WGL_TEXTURE_2D_ARB
: type
= GLX_TEXTURE_2D_ATI
; break ;
2025 SetLastError(ERROR_INVALID_DATA
);
2028 PUSH2(attribs
, GLX_TEXTURE_TARGET_ATI
, type
);
2030 if (WGL_NO_TEXTURE_ARB
== attr_v
) {
2031 object
->texture_target
= 0;
2033 if (!use_render_texture_emulation
) {
2034 SetLastError(ERROR_INVALID_DATA
);
2038 case WGL_TEXTURE_CUBE_MAP_ARB
: {
2039 if (iWidth
!= iHeight
) {
2040 SetLastError(ERROR_INVALID_DATA
);
2043 object
->texture_target
= GL_TEXTURE_CUBE_MAP
;
2044 object
->texture_bind_target
= GL_TEXTURE_CUBE_MAP
;
2047 case WGL_TEXTURE_1D_ARB
: {
2049 SetLastError(ERROR_INVALID_DATA
);
2052 object
->texture_target
= GL_TEXTURE_1D
;
2053 object
->texture_bind_target
= GL_TEXTURE_1D
;
2056 case WGL_TEXTURE_2D_ARB
: {
2057 object
->texture_target
= GL_TEXTURE_2D
;
2058 object
->texture_bind_target
= GL_TEXTURE_2D
;
2062 SetLastError(ERROR_INVALID_DATA
);
2070 case WGL_MIPMAP_TEXTURE_ARB
: {
2072 attr_v
= *piAttribList
;
2073 TRACE("WGL_render_texture Attribute: WGL_MIPMAP_TEXTURE_ARB as %x\n", attr_v
);
2074 if (use_render_texture_ati
) {
2075 PUSH2(attribs
, GLX_MIPMAP_TEXTURE_ATI
, attr_v
);
2077 if (!use_render_texture_emulation
) {
2078 SetLastError(ERROR_INVALID_DATA
);
2088 PUSH1(attribs
, None
);
2089 object
->drawable
= pglXCreatePbuffer(gdi_display
, cfgs
[fmt_index
], attribs
);
2090 TRACE("new Pbuffer drawable as %p\n", (void*) object
->drawable
);
2091 if (!object
->drawable
) {
2092 SetLastError(ERROR_NO_SYSTEM_RESOURCES
);
2093 goto create_failed
; /* unexpected error */
2095 TRACE("->(%p)\n", object
);
2099 return (HPBUFFERARB
) object
;
2102 if (NULL
!= cfgs
) XFree(cfgs
);
2103 HeapFree(GetProcessHeap(), 0, object
);
2104 TRACE("->(FAILED)\n");
2105 return (HPBUFFERARB
) NULL
;
2109 * X11DRV_wglDestroyPbufferARB
2111 * WGL_ARB_pbuffer: wglDestroyPbufferARB
2113 static GLboolean WINAPI
X11DRV_wglDestroyPbufferARB(HPBUFFERARB hPbuffer
)
2115 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2116 TRACE("(%p)\n", hPbuffer
);
2117 if (NULL
== object
) {
2118 SetLastError(ERROR_INVALID_HANDLE
);
2121 pglXDestroyPbuffer(object
->display
, object
->drawable
);
2122 HeapFree(GetProcessHeap(), 0, object
);
2127 * X11DRV_wglGetPbufferDCARB
2129 * WGL_ARB_pbuffer: wglGetPbufferDCARB
2130 * The function wglGetPbufferDCARB returns a device context for a pbuffer.
2131 * Gdi32 implements the part of this function which creates a device context.
2132 * This part associates the physDev with the X drawable of the pbuffer.
2134 HDC
X11DRV_wglGetPbufferDCARB(X11DRV_PDEVICE
*physDev
, HPBUFFERARB hPbuffer
)
2136 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2137 if (NULL
== object
) {
2138 SetLastError(ERROR_INVALID_HANDLE
);
2142 /* The function wglGetPbufferDCARB returns a DC to which the pbuffer can be connected.
2143 * All formats in our pixelformat list are compatible with each other and the main drawable. */
2144 physDev
->current_pf
= object
->pixelFormat
;
2145 physDev
->drawable
= object
->drawable
;
2147 TRACE("(%p)->(%p)\n", hPbuffer
, physDev
->hdc
);
2148 return physDev
->hdc
;
2152 * X11DRV_wglQueryPbufferARB
2154 * WGL_ARB_pbuffer: wglQueryPbufferARB
2156 static GLboolean WINAPI
X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer
, int iAttribute
, int *piValue
)
2158 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2159 TRACE("(%p, 0x%x, %p)\n", hPbuffer
, iAttribute
, piValue
);
2160 if (NULL
== object
) {
2161 SetLastError(ERROR_INVALID_HANDLE
);
2164 switch (iAttribute
) {
2165 case WGL_PBUFFER_WIDTH_ARB
:
2166 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_WIDTH
, (unsigned int*) piValue
);
2168 case WGL_PBUFFER_HEIGHT_ARB
:
2169 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_HEIGHT
, (unsigned int*) piValue
);
2172 case WGL_PBUFFER_LOST_ARB
:
2173 FIXME("unsupported WGL_PBUFFER_LOST_ARB (need glXSelectEvent/GLX_DAMAGED work)\n");
2176 case WGL_TEXTURE_FORMAT_ARB
:
2177 if (use_render_texture_ati
) {
2179 int type
= WGL_NO_TEXTURE_ARB
;
2180 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_TEXTURE_FORMAT_ATI
, &tmp
);
2182 case GLX_NO_TEXTURE_ATI
: type
= WGL_NO_TEXTURE_ARB
; break ;
2183 case GLX_TEXTURE_RGB_ATI
: type
= WGL_TEXTURE_RGB_ARB
; break ;
2184 case GLX_TEXTURE_RGBA_ATI
: type
= WGL_TEXTURE_RGBA_ARB
; break ;
2188 if (!object
->use_render_texture
) {
2189 *piValue
= WGL_NO_TEXTURE_ARB
;
2191 if (!use_render_texture_emulation
) {
2192 SetLastError(ERROR_INVALID_HANDLE
);
2195 if (GL_RGBA
== object
->use_render_texture
) {
2196 *piValue
= WGL_TEXTURE_RGBA_ARB
;
2198 *piValue
= WGL_TEXTURE_RGB_ARB
;
2204 case WGL_TEXTURE_TARGET_ARB
:
2205 if (use_render_texture_ati
) {
2207 int type
= WGL_NO_TEXTURE_ARB
;
2208 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_TEXTURE_TARGET_ATI
, &tmp
);
2210 case GLX_NO_TEXTURE_ATI
: type
= WGL_NO_TEXTURE_ARB
; break ;
2211 case GLX_TEXTURE_CUBE_MAP_ATI
: type
= WGL_TEXTURE_CUBE_MAP_ARB
; break ;
2212 case GLX_TEXTURE_1D_ATI
: type
= WGL_TEXTURE_1D_ARB
; break ;
2213 case GLX_TEXTURE_2D_ATI
: type
= WGL_TEXTURE_2D_ARB
; break ;
2217 if (!object
->texture_target
) {
2218 *piValue
= WGL_NO_TEXTURE_ARB
;
2220 if (!use_render_texture_emulation
) {
2221 SetLastError(ERROR_INVALID_DATA
);
2224 switch (object
->texture_target
) {
2225 case GL_TEXTURE_1D
: *piValue
= WGL_TEXTURE_CUBE_MAP_ARB
; break;
2226 case GL_TEXTURE_2D
: *piValue
= WGL_TEXTURE_1D_ARB
; break;
2227 case GL_TEXTURE_CUBE_MAP
: *piValue
= WGL_TEXTURE_2D_ARB
; break;
2233 case WGL_MIPMAP_TEXTURE_ARB
:
2234 if (use_render_texture_ati
) {
2235 pglXQueryDrawable(object
->display
, object
->drawable
, GLX_MIPMAP_TEXTURE_ATI
, (unsigned int*) piValue
);
2237 *piValue
= GL_FALSE
; /** don't support that */
2238 FIXME("unsupported WGL_ARB_render_texture attribute query for 0x%x\n", iAttribute
);
2243 FIXME("unexpected attribute %x\n", iAttribute
);
2251 * X11DRV_wglReleasePbufferDCARB
2253 * WGL_ARB_pbuffer: wglReleasePbufferDCARB
2255 static int WINAPI
X11DRV_wglReleasePbufferDCARB(HPBUFFERARB hPbuffer
, HDC hdc
)
2257 TRACE("(%p, %p)\n", hPbuffer
, hdc
);
2263 * X11DRV_wglSetPbufferAttribARB
2265 * WGL_ARB_pbuffer: wglSetPbufferAttribARB
2267 static GLboolean WINAPI
X11DRV_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer
, const int *piAttribList
)
2269 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2270 WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer
, piAttribList
);
2271 if (NULL
== object
) {
2272 SetLastError(ERROR_INVALID_HANDLE
);
2275 if (!object
->use_render_texture
) {
2276 SetLastError(ERROR_INVALID_HANDLE
);
2279 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
2282 if (NULL
!= pglXDrawableAttribARB
) {
2283 if (use_render_texture_ati
) {
2284 FIXME("Need conversion for GLX_ATI_render_texture\n");
2286 return pglXDrawableAttribARB(object
->display
, object
->drawable
, piAttribList
);
2292 * X11DRV_wglChoosePixelFormatARB
2294 * WGL_ARB_pixel_format: wglChoosePixelFormatARB
2296 static GLboolean WINAPI
X11DRV_wglChoosePixelFormatARB(HDC hdc
, const int *piAttribIList
, const FLOAT
*pfAttribFList
, UINT nMaxFormats
, int *piFormats
, UINT
*nNumFormats
)
2301 GLXFBConfig
* cfgs
= NULL
;
2306 GLXFBConfig
* cfgs_fmt
= NULL
;
2312 TRACE("(%p, %p, %p, %d, %p, %p): hackish\n", hdc
, piAttribIList
, pfAttribFList
, nMaxFormats
, piFormats
, nNumFormats
);
2313 if (NULL
!= pfAttribFList
) {
2314 FIXME("unused pfAttribFList\n");
2317 nAttribs
= ConvertAttribWGLtoGLX(piAttribIList
, attribs
, NULL
);
2318 if (-1 == nAttribs
) {
2319 WARN("Cannot convert WGL to GLX attributes\n");
2322 PUSH1(attribs
, None
);
2324 /* Search for FB configurations matching the requirements in attribs */
2325 cfgs
= pglXChooseFBConfig(gdi_display
, DefaultScreen(gdi_display
), attribs
, &nCfgs
);
2327 WARN("Compatible Pixel Format not found\n");
2331 /* Get a list of all FB configurations */
2332 cfgs_fmt
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs_fmt
);
2333 if (NULL
== cfgs_fmt
) {
2334 ERR("Failed to get All FB Configs\n");
2339 /* Loop through all matching formats and check if they are suitable.
2340 * Note that this function should at max return nMaxFormats different formats */
2341 for (it
= 0; pfmt_it
< nMaxFormats
&& it
< nCfgs
; ++it
) {
2342 gl_test
= pglXGetFBConfigAttrib(gdi_display
, cfgs
[it
], GLX_FBCONFIG_ID
, &fmt_id
);
2344 ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
2348 /* Search for the format in our list of compatible formats */
2349 fmt
= ConvertPixelFormatGLXtoWGL(gdi_display
, fmt_id
);
2353 piFormats
[pfmt_it
] = fmt
;
2354 TRACE("at %d/%d found FBCONFIG_ID 0x%x (%d/%d)\n", it
+ 1, nCfgs
, fmt_id
, piFormats
[pfmt_it
], nCfgs_fmt
);
2358 *nNumFormats
= pfmt_it
;
2366 * X11DRV_wglGetPixelFormatAttribivARB
2368 * WGL_ARB_pixel_format: wglGetPixelFormatAttribivARB
2370 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribivARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, int *piValues
)
2373 GLXFBConfig
* cfgs
= NULL
;
2374 GLXFBConfig curCfg
= NULL
;
2379 int nWGLFormats
= 0;
2382 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, piValues
);
2384 if (0 < iLayerPlane
) {
2385 FIXME("unsupported iLayerPlane(%d) > 0, returns FALSE\n", iLayerPlane
);
2389 cfgs
= pglXGetFBConfigs(gdi_display
, DefaultScreen(gdi_display
), &nCfgs
);
2391 ERR("no FB Configs found for display(%p)\n", gdi_display
);
2395 /* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supoprted.
2396 * We don't have to fail yet as a program can specify an invaled iPixelFormat (lets say 0) if it wants to query
2397 * the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
2398 if(!ConvertPixelFormatWGLtoGLX(gdi_display
, iPixelFormat
, &fmt_index
, &nWGLFormats
)) {
2399 WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat
);
2402 for (i
= 0; i
< nAttributes
; ++i
) {
2403 const int curWGLAttr
= piAttributes
[i
];
2404 TRACE("pAttr[%d] = %x\n", i
, curWGLAttr
);
2406 switch (curWGLAttr
) {
2407 case WGL_NUMBER_PIXEL_FORMATS_ARB
:
2408 piValues
[i
] = nWGLFormats
;
2411 case WGL_SUPPORT_OPENGL_ARB
:
2412 piValues
[i
] = GL_TRUE
;
2415 case WGL_ACCELERATION_ARB
:
2416 curGLXAttr
= GLX_CONFIG_CAVEAT
;
2418 if (nCfgs
< iPixelFormat
|| 0 >= iPixelFormat
) goto pix_error
;
2419 curCfg
= cfgs
[iPixelFormat
- 1];
2421 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2422 if (hTest
) goto get_error
;
2424 case GLX_NONE
: piValues
[i
] = WGL_FULL_ACCELERATION_ARB
; break;
2425 case GLX_SLOW_CONFIG
: piValues
[i
] = WGL_NO_ACCELERATION_ARB
; break;
2426 case GLX_NON_CONFORMANT_CONFIG
: piValues
[i
] = WGL_FULL_ACCELERATION_ARB
; break;
2428 ERR("unexpected Config Caveat(%x)\n", tmp
);
2429 piValues
[i
] = WGL_NO_ACCELERATION_ARB
;
2433 case WGL_TRANSPARENT_ARB
:
2434 curGLXAttr
= GLX_TRANSPARENT_TYPE
;
2435 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2436 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2437 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2438 curCfg
= cfgs
[fmt_index
];
2439 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2440 if (hTest
) goto get_error
;
2441 piValues
[i
] = GL_FALSE
;
2442 if (GLX_NONE
!= tmp
) piValues
[i
] = GL_TRUE
;
2445 case WGL_PIXEL_TYPE_ARB
:
2446 curGLXAttr
= GLX_RENDER_TYPE
;
2447 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2448 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2449 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2450 curCfg
= cfgs
[fmt_index
];
2451 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2452 if (hTest
) goto get_error
;
2453 TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp
);
2454 if (tmp
& GLX_RGBA_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_ARB
; }
2455 else if (tmp
& GLX_COLOR_INDEX_BIT
) { piValues
[i
] = WGL_TYPE_COLORINDEX_ARB
; }
2456 else if (tmp
& GLX_RGBA_FLOAT_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2457 else if (tmp
& GLX_RGBA_FLOAT_ATI_BIT
) { piValues
[i
] = WGL_TYPE_RGBA_FLOAT_ATI
; }
2459 ERR("unexpected RenderType(%x)\n", tmp
);
2460 piValues
[i
] = WGL_TYPE_RGBA_ARB
;
2464 case WGL_COLOR_BITS_ARB
:
2465 /** see ConvertAttribWGLtoGLX for explain */
2466 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2467 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2468 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2469 curCfg
= cfgs
[fmt_index
];
2470 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_BUFFER_SIZE
, piValues
+ i
);
2471 if (hTest
) goto get_error
;
2472 TRACE("WGL_COLOR_BITS_ARB: GLX_BUFFER_SIZE = %d\n", piValues
[i
]);
2473 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_ALPHA_SIZE
, &tmp
);
2474 if (hTest
) goto get_error
;
2475 TRACE("WGL_COLOR_BITS_ARB: GLX_ALPHA_SIZE = %d\n", tmp
);
2476 piValues
[i
] = piValues
[i
] - tmp
;
2479 case WGL_BIND_TO_TEXTURE_RGB_ARB
:
2480 if (use_render_texture_ati
) {
2481 curGLXAttr
= GLX_BIND_TO_TEXTURE_RGB_ATI
;
2484 case WGL_BIND_TO_TEXTURE_RGBA_ARB
:
2485 if (use_render_texture_ati
) {
2486 curGLXAttr
= GLX_BIND_TO_TEXTURE_RGBA_ATI
;
2489 if (!use_render_texture_emulation
) {
2490 piValues
[i
] = GL_FALSE
;
2493 curGLXAttr
= GLX_RENDER_TYPE
;
2494 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2495 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2496 if((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
)) goto pix_error
;
2497 curCfg
= cfgs
[fmt_index
];
2498 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, &tmp
);
2499 if (hTest
) goto get_error
;
2500 if (GLX_COLOR_INDEX_BIT
== tmp
) {
2501 piValues
[i
] = GL_FALSE
;
2504 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_DRAWABLE_TYPE
, &tmp
);
2505 if (hTest
) goto get_error
;
2506 piValues
[i
] = (tmp
& GLX_PBUFFER_BIT
) ? GL_TRUE
: GL_FALSE
;
2509 case WGL_BLUE_BITS_ARB
:
2510 curGLXAttr
= GLX_BLUE_SIZE
;
2512 case WGL_RED_BITS_ARB
:
2513 curGLXAttr
= GLX_RED_SIZE
;
2515 case WGL_GREEN_BITS_ARB
:
2516 curGLXAttr
= GLX_GREEN_SIZE
;
2518 case WGL_ALPHA_BITS_ARB
:
2519 curGLXAttr
= GLX_ALPHA_SIZE
;
2521 case WGL_DEPTH_BITS_ARB
:
2522 curGLXAttr
= GLX_DEPTH_SIZE
;
2524 case WGL_STENCIL_BITS_ARB
:
2525 curGLXAttr
= GLX_STENCIL_SIZE
;
2527 case WGL_DOUBLE_BUFFER_ARB
:
2528 curGLXAttr
= GLX_DOUBLEBUFFER
;
2530 case WGL_STEREO_ARB
:
2531 curGLXAttr
= GLX_STEREO
;
2533 case WGL_AUX_BUFFERS_ARB
:
2534 curGLXAttr
= GLX_AUX_BUFFERS
;
2536 case WGL_SUPPORT_GDI_ARB
:
2537 case WGL_DRAW_TO_WINDOW_ARB
:
2538 case WGL_DRAW_TO_BITMAP_ARB
:
2539 /* We only supported a limited number of formats right now which are all renderable by X 'GLX_X_RENDERABLE' */
2540 piValues
[i
] = GL_TRUE
;
2542 case WGL_DRAW_TO_PBUFFER_ARB
:
2543 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, GLX_DRAWABLE_TYPE
, &tmp
);
2544 if (hTest
) goto get_error
;
2545 piValues
[i
] = (tmp
& GLX_PBUFFER_BIT
) ? GL_TRUE
: GL_FALSE
;
2548 case WGL_PBUFFER_LARGEST_ARB
:
2549 curGLXAttr
= GLX_LARGEST_PBUFFER
;
2552 case WGL_SAMPLE_BUFFERS_ARB
:
2553 curGLXAttr
= GLX_SAMPLE_BUFFERS_ARB
;
2556 case WGL_SAMPLES_ARB
:
2557 curGLXAttr
= GLX_SAMPLES_ARB
;
2561 FIXME("unsupported %x WGL Attribute\n", curWGLAttr
);
2564 /* Retrieve a GLX FBConfigAttrib when the attribute to query is valid and
2565 * iPixelFormat != 0. When iPixelFormat is 0 the only value which makes
2566 * sense to query is WGL_NUMBER_PIXEL_FORMATS_ARB.
2568 * TODO: properly test the behavior of wglGetPixelFormatAttrib*v on Windows
2569 * and check which options can work using iPixelFormat=0 and which not.
2570 * A problem would be that this function is an extension. This would
2571 * mean that the behavior could differ between different vendors (ATI, Nvidia, ..).
2573 if (0 != curGLXAttr
&& iPixelFormat
!= 0) {
2574 /* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
2575 * supported WGLFormats and also check if the GLX fmt_index is valid. */
2576 if((iPixelFormat
> 0) && ((iPixelFormat
> nWGLFormats
) || (fmt_index
> nCfgs
))) goto pix_error
;
2577 curCfg
= cfgs
[fmt_index
];
2578 hTest
= pglXGetFBConfigAttrib(gdi_display
, curCfg
, curGLXAttr
, piValues
+ i
);
2579 if (hTest
) goto get_error
;
2582 piValues
[i
] = GL_FALSE
;
2588 ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc
, curGLXAttr
);
2593 ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc
, iPixelFormat
, nCfgs
);
2599 * X11DRV_wglGetPixelFormatAttribfvARB
2601 * WGL_ARB_pixel_format: wglGetPixelFormatAttribfvARB
2603 static GLboolean WINAPI
X11DRV_wglGetPixelFormatAttribfvARB(HDC hdc
, int iPixelFormat
, int iLayerPlane
, UINT nAttributes
, const int *piAttributes
, FLOAT
*pfValues
)
2609 TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, pfValues
);
2611 /* Allocate a temporary array to store integer values */
2612 attr
= HeapAlloc(GetProcessHeap(), 0, nAttributes
* sizeof(int));
2614 ERR("couldn't allocate %d array\n", nAttributes
);
2618 /* Piggy-back on wglGetPixelFormatAttribivARB */
2619 ret
= X11DRV_wglGetPixelFormatAttribivARB(hdc
, iPixelFormat
, iLayerPlane
, nAttributes
, piAttributes
, attr
);
2621 /* Convert integer values to float. Should also check for attributes
2622 that can give decimal values here */
2623 for (i
=0; i
<nAttributes
;i
++) {
2624 pfValues
[i
] = attr
[i
];
2628 HeapFree(GetProcessHeap(), 0, attr
);
2633 * X11DRV_wglBindTexImageARB
2635 * WGL_ARB_render_texture: wglBindTexImageARB
2637 static GLboolean WINAPI
X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2639 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2640 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2641 if (NULL
== object
) {
2642 SetLastError(ERROR_INVALID_HANDLE
);
2645 if (!object
->use_render_texture
) {
2646 SetLastError(ERROR_INVALID_HANDLE
);
2649 /* Disable WGL_ARB_render_texture support until it is implemented properly
2650 * using pbuffers or FBOs */
2652 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
2654 GLint prev_binded_tex
;
2655 pglGetIntegerv(object
->texture_target
, &prev_binded_tex
);
2656 if (NULL
== object
->render_ctx
) {
2657 object
->render_hdc
= X11DRV_wglGetPbufferDCARB(hPbuffer
);
2658 /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */
2659 object
->render_ctx
= wglCreateContext(object
->render_hdc
);
2662 object
->prev_hdc
= wglGetCurrentDC();
2663 object
->prev_ctx
= wglGetCurrentContext();
2664 /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */
2665 wglMakeCurrent(object
->render_hdc
, object
->render_ctx
);
2668 glBindTexture(object->texture_target, object->texture);
2669 if (GL_RGBA == object->use_render_texture) {
2670 glTexImage2D(object->texture_target, 0, GL_RGBA8, object->width, object->height, 0, GL_RGBA, GL_FLOAT, NULL);
2672 glTexImage2D(object->texture_target, 0, GL_RGB8, object->width, object->height, 0, GL_RGB, GL_FLOAT, NULL);
2676 object
->texture
= prev_binded_tex
;
2680 if (NULL
!= pglXBindTexImageARB
) {
2681 return pglXBindTexImageARB(object
->display
, object
->drawable
, iBuffer
);
2687 * X11DRV_wglReleaseTexImageARB
2689 * WGL_ARB_render_texture: wglReleaseTexImageARB
2691 static GLboolean WINAPI
X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer
, int iBuffer
)
2693 Wine_GLPBuffer
* object
= (Wine_GLPBuffer
*) hPbuffer
;
2694 TRACE("(%p, %d)\n", hPbuffer
, iBuffer
);
2695 if (NULL
== object
) {
2696 SetLastError(ERROR_INVALID_HANDLE
);
2699 if (!object
->use_render_texture
) {
2700 SetLastError(ERROR_INVALID_HANDLE
);
2703 if (!use_render_texture_ati
&& 1 == use_render_texture_emulation
) {
2705 GLint prev_binded_tex;
2706 glGetIntegerv(object->texture_target, &prev_binded_tex);
2707 if (GL_TEXTURE_1D == object->texture_target) {
2708 glCopyTexSubImage1D(object->texture_target, object->texture_level, 0, 0, 0, object->width);
2710 glCopyTexSubImage2D(object->texture_target, object->texture_level, 0, 0, 0, 0, object->width, object->height);
2712 glBindTexture(object->texture_target, prev_binded_tex);
2713 SwapBuffers(object->render_hdc);
2715 pglBindTexture(object
->texture_target
, object
->texture
);
2716 if (GL_TEXTURE_1D
== object
->texture_target
) {
2717 pglCopyTexSubImage1D(object
->texture_target
, object
->texture_level
, 0, 0, 0, object
->width
);
2719 pglCopyTexSubImage2D(object
->texture_target
, object
->texture_level
, 0, 0, 0, 0, object
->width
, object
->height
);
2722 /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */
2723 wglMakeCurrent(object
->prev_hdc
, object
->prev_ctx
);
2726 if (NULL
!= pglXReleaseTexImageARB
) {
2727 return pglXReleaseTexImageARB(object
->display
, object
->drawable
, iBuffer
);
2733 * X11DRV_wglGetExtensionsStringEXT
2735 * WGL_EXT_extensions_string: wglGetExtensionsStringEXT
2737 static const char * WINAPI
X11DRV_wglGetExtensionsStringEXT(void) {
2738 TRACE("() returning \"%s\"\n", WineGLInfo
.wglExtensions
);
2739 return WineGLInfo
.wglExtensions
;
2743 * X11DRV_wglGetSwapIntervalEXT
2745 * WGL_EXT_swap_control: wglGetSwapIntervalEXT
2747 static int WINAPI
X11DRV_wglGetSwapIntervalEXT(VOID
) {
2748 FIXME("(),stub!\n");
2749 return swap_interval
;
2753 * X11DRV_wglSwapIntervalEXT
2755 * WGL_EXT_swap_control: wglSwapIntervalEXT
2757 static BOOL WINAPI
X11DRV_wglSwapIntervalEXT(int interval
) {
2758 TRACE("(%d)\n", interval
);
2759 swap_interval
= interval
;
2760 if (NULL
!= pglXSwapIntervalSGI
) {
2761 return 0 == pglXSwapIntervalSGI(interval
);
2763 WARN("(): GLX_SGI_swap_control extension seems not supported\n");
2768 * X11DRV_wglAllocateMemoryNV
2770 * WGL_NV_vertex_array_range: wglAllocateMemoryNV
2772 static void* WINAPI
X11DRV_wglAllocateMemoryNV(GLsizei size
, GLfloat readfreq
, GLfloat writefreq
, GLfloat priority
) {
2773 TRACE("(%d, %f, %f, %f)\n", size
, readfreq
, writefreq
, priority
);
2774 if (pglXAllocateMemoryNV
== NULL
)
2777 return pglXAllocateMemoryNV(size
, readfreq
, writefreq
, priority
);
2781 * X11DRV_wglFreeMemoryNV
2783 * WGL_NV_vertex_array_range: wglFreeMemoryNV
2785 static void WINAPI
X11DRV_wglFreeMemoryNV(GLvoid
* pointer
) {
2786 TRACE("(%p)\n", pointer
);
2787 if (pglXFreeMemoryNV
== NULL
)
2790 pglXFreeMemoryNV(pointer
);
2794 * glxRequireVersion (internal)
2796 * Check if the supported GLX version matches requiredVersion.
2798 static BOOL
glxRequireVersion(int requiredVersion
)
2800 /* Both requiredVersion and glXVersion[1] contains the minor GLX version */
2801 if(requiredVersion
<= WineGLInfo
.glxVersion
[1])
2807 static BOOL
glxRequireExtension(const char *requiredExtension
)
2809 if (strstr(WineGLInfo
.glxClientExtensions
, requiredExtension
) == NULL
) {
2816 static BOOL
register_extension(const WineGLExtension
* ext
)
2820 assert( WineGLExtensionListSize
< MAX_EXTENSIONS
);
2821 WineGLExtensionList
[WineGLExtensionListSize
++] = ext
;
2823 strcat(WineGLInfo
.wglExtensions
, " ");
2824 strcat(WineGLInfo
.wglExtensions
, ext
->extName
);
2826 TRACE("'%s'\n", ext
->extName
);
2828 for (i
= 0; ext
->extEntryPoints
[i
].funcName
; ++i
)
2829 TRACE(" - '%s'\n", ext
->extEntryPoints
[i
].funcName
);
2834 static const WineGLExtension WGL_internal_functions
=
2838 { "wglDisable", X11DRV_wglDisable
},
2839 { "wglEnable", X11DRV_wglEnable
},
2840 { "wglGetIntegerv", X11DRV_wglGetIntegerv
},
2841 { "wglIsEnabled", X11DRV_wglIsEnabled
},
2842 { "wglScissor", X11DRV_wglScissor
},
2843 { "wglViewport", X11DRV_wglViewport
},
2848 static const WineGLExtension WGL_ARB_extensions_string
=
2850 "WGL_ARB_extensions_string",
2852 { "wglGetExtensionsStringARB", X11DRV_wglGetExtensionsStringARB
},
2856 static const WineGLExtension WGL_ARB_make_current_read
=
2858 "WGL_ARB_make_current_read",
2860 { "wglGetCurrentReadDCARB", X11DRV_wglGetCurrentReadDCARB
},
2861 { "wglMakeContextCurrentARB", X11DRV_wglMakeContextCurrentARB
},
2865 static const WineGLExtension WGL_ARB_multisample
=
2867 "WGL_ARB_multisample",
2870 static const WineGLExtension WGL_ARB_pbuffer
=
2874 { "wglCreatePbufferARB", X11DRV_wglCreatePbufferARB
},
2875 { "wglDestroyPbufferARB", X11DRV_wglDestroyPbufferARB
},
2876 { "wglGetPbufferDCARB", X11DRV_wglGetPbufferDCARB
},
2877 { "wglQueryPbufferARB", X11DRV_wglQueryPbufferARB
},
2878 { "wglReleasePbufferDCARB", X11DRV_wglReleasePbufferDCARB
},
2879 { "wglSetPbufferAttribARB", X11DRV_wglSetPbufferAttribARB
},
2883 static const WineGLExtension WGL_ARB_pixel_format
=
2885 "WGL_ARB_pixel_format",
2887 { "wglChoosePixelFormatARB", X11DRV_wglChoosePixelFormatARB
},
2888 { "wglGetPixelFormatAttribfvARB", X11DRV_wglGetPixelFormatAttribfvARB
},
2889 { "wglGetPixelFormatAttribivARB", X11DRV_wglGetPixelFormatAttribivARB
},
2893 static const WineGLExtension WGL_ARB_render_texture
=
2895 "WGL_ARB_render_texture",
2897 { "wglBindTexImageARB", X11DRV_wglBindTexImageARB
},
2898 { "wglReleaseTexImageARB", X11DRV_wglReleaseTexImageARB
},
2902 static const WineGLExtension WGL_EXT_extensions_string
=
2904 "WGL_EXT_extensions_string",
2906 { "wglGetExtensionsStringEXT", X11DRV_wglGetExtensionsStringEXT
},
2910 static const WineGLExtension WGL_EXT_swap_control
=
2912 "WGL_EXT_swap_control",
2914 { "wglSwapIntervalEXT", X11DRV_wglSwapIntervalEXT
},
2915 { "wglGetSwapIntervalEXT", X11DRV_wglGetSwapIntervalEXT
},
2919 static const WineGLExtension WGL_NV_vertex_array_range
=
2921 "WGL_NV_vertex_array_range",
2923 { "wglAllocateMemoryNV", X11DRV_wglAllocateMemoryNV
},
2924 { "wglFreeMemoryNV", X11DRV_wglFreeMemoryNV
},
2929 * X11DRV_WineGL_LoadExtensions
2931 static void X11DRV_WineGL_LoadExtensions(void)
2933 WineGLInfo
.wglExtensions
[0] = 0;
2935 /* Load Wine internal functions */
2936 register_extension(&WGL_internal_functions
);
2938 /* ARB Extensions */
2940 register_extension(&WGL_ARB_extensions_string
);
2942 if (glxRequireVersion(3))
2943 register_extension(&WGL_ARB_make_current_read
);
2945 if (glxRequireExtension("GLX_ARB_multisample"))
2946 register_extension(&WGL_ARB_multisample
);
2948 /* In general pbuffer functionality requires support in the X-server. The functionality is
2949 * available either when the GLX_SGIX_pbuffer is present or when the GLX server version is 1.3.
2950 * All display drivers except for Nvidia's use the GLX module from Xfree86/Xorg which only
2951 * supports GLX 1.2. The endresult is that only Nvidia's drivers support pbuffers.
2953 * The only other drive which has pbuffer support is Ati's FGLRX driver. They provide clientside GLX 1.3 support
2954 * without support in the X-server (which other Mesa based drivers require).
2956 * Support pbuffers when the GLX version is 1.3 and GLX_SGIX_pbuffer is available. Further pbuffers can
2957 * also be supported when GLX_ATI_render_texture is available. This extension depends on pbuffers, so when it
2958 * is available pbuffers must be available too. */
2959 if ( (glxRequireVersion(3) && glxRequireExtension("GLX_SGIX_pbuffer")) || glxRequireExtension("GLX_ATI_render_texture"))
2960 register_extension(&WGL_ARB_pbuffer
);
2962 register_extension(&WGL_ARB_pixel_format
);
2964 if (glxRequireExtension("GLX_ATI_render_texture") ||
2965 glxRequireExtension("GLX_ARB_render_texture"))
2966 register_extension(&WGL_ARB_render_texture
);
2968 /* EXT Extensions */
2970 register_extension(&WGL_EXT_extensions_string
);
2972 if (glxRequireExtension("GLX_SGI_swap_control"))
2973 register_extension(&WGL_EXT_swap_control
);
2975 /* The OpenGL extension GL_NV_vertex_array_range adds wgl/glX functions which aren't exported as 'real' wgl/glX extensions. */
2976 if(strstr(WineGLInfo
.glExtensions
, "GL_NV_vertex_array_range") != NULL
)
2977 register_extension(&WGL_NV_vertex_array_range
);
2981 static XID
create_glxpixmap(X11DRV_PDEVICE
*physDev
)
2985 XVisualInfo
template;
2990 /* Retrieve the visualid from our main visual which is the only visual we can use */
2991 template.visualid
= XVisualIDFromVisual(visual
);
2992 vis
= XGetVisualInfo(gdi_display
, VisualIDMask
, &template, &num
);
2994 ret
= pglXCreateGLXPixmap(gdi_display
, vis
, physDev
->bitmap
->pixmap
);
2996 wine_tsx11_unlock();
2997 TRACE("return %lx\n", ret
);
3001 Drawable
get_glxdrawable(X11DRV_PDEVICE
*physDev
)
3007 if (physDev
->bitmap
->hbitmap
== BITMAP_stock_phys_bitmap
.hbitmap
)
3008 ret
= physDev
->drawable
; /* PBuffer */
3011 if(!physDev
->bitmap
->glxpixmap
)
3012 physDev
->bitmap
->glxpixmap
= create_glxpixmap(physDev
);
3013 ret
= physDev
->bitmap
->glxpixmap
;
3017 ret
= physDev
->drawable
;
3021 BOOL
destroy_glxpixmap(XID glxpixmap
)
3024 pglXDestroyGLXPixmap(gdi_display
, glxpixmap
);
3025 wine_tsx11_unlock();
3030 * X11DRV_SwapBuffers
3032 * Swap the buffers of this DC
3034 BOOL
X11DRV_SwapBuffers(X11DRV_PDEVICE
*physDev
)
3036 GLXDrawable drawable
;
3037 if (!has_opengl()) {
3038 ERR("No libGL on this box - disabling OpenGL support !\n");
3042 TRACE_(opengl
)("(%p)\n", physDev
);
3044 drawable
= get_glxdrawable(physDev
);
3046 pglXSwapBuffers(gdi_display
, drawable
);
3047 wine_tsx11_unlock();
3052 static long prev_time
, frames
;
3054 DWORD time
= GetTickCount();
3056 /* every 1.5 seconds */
3057 if (time
- prev_time
> 1500) {
3058 TRACE_(fps
)("@ approx %.2ffps\n", 1000.0*frames
/(time
- prev_time
));
3067 /***********************************************************************
3068 * X11DRV_setup_opengl_visual
3070 * Setup the default visual used for OpenGL and Direct3D, and the desktop
3071 * window (if it exists). If OpenGL isn't available, the visual is simply
3072 * set to the default visual for the display
3074 XVisualInfo
*X11DRV_setup_opengl_visual( Display
*display
)
3076 XVisualInfo
*visual
= NULL
;
3077 /* In order to support OpenGL or D3D, we require a double-buffered visual and stencil buffer support, */
3078 int dblBuf
[] = {GLX_RGBA
,GLX_DEPTH_SIZE
, 24, GLX_STENCIL_SIZE
, 8, GLX_ALPHA_SIZE
, 8, GLX_DOUBLEBUFFER
, None
};
3079 if (!has_opengl()) return NULL
;
3082 visual
= pglXChooseVisual(display
, DefaultScreen(display
), dblBuf
);
3083 wine_tsx11_unlock();
3084 if (visual
== NULL
) {
3085 /* fallback to 16 bits depth, no alpha */
3086 int dblBuf2
[] = {GLX_RGBA
,GLX_DEPTH_SIZE
, 16, GLX_STENCIL_SIZE
, 8, GLX_DOUBLEBUFFER
, None
};
3087 WARN("Failed to get a visual with at least 24 bits depth\n");
3090 visual
= pglXChooseVisual(display
, DefaultScreen(display
), dblBuf2
);
3091 wine_tsx11_unlock();
3092 if (visual
== NULL
) {
3093 /* fallback to no stencil */
3094 int dblBuf2
[] = {GLX_RGBA
,GLX_DEPTH_SIZE
, 16, GLX_DOUBLEBUFFER
, None
};
3095 WARN("Failed to get a visual with at least 8 bits of stencil\n");
3098 visual
= pglXChooseVisual(display
, DefaultScreen(display
), dblBuf2
);
3099 wine_tsx11_unlock();
3100 if (visual
== NULL
) {
3101 /* This should only happen if we cannot find a match with a depth size 16 */
3102 FIXME("Failed to find a suitable visual\n");
3107 TRACE("Visual ID %lx Chosen\n",visual
->visualid
);
3111 #else /* no OpenGL includes */
3113 /***********************************************************************
3114 * ChoosePixelFormat (X11DRV.@)
3116 int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE
*physDev
,
3117 const PIXELFORMATDESCRIPTOR
*ppfd
) {
3118 ERR("No OpenGL support compiled in.\n");
3123 /***********************************************************************
3124 * DescribePixelFormat (X11DRV.@)
3126 int X11DRV_DescribePixelFormat(X11DRV_PDEVICE
*physDev
,
3129 PIXELFORMATDESCRIPTOR
*ppfd
) {
3130 ERR("No OpenGL support compiled in.\n");
3135 /***********************************************************************
3136 * GetPixelFormat (X11DRV.@)
3138 int X11DRV_GetPixelFormat(X11DRV_PDEVICE
*physDev
) {
3139 ERR("No OpenGL support compiled in.\n");
3144 /***********************************************************************
3145 * SetPixelFormat (X11DRV.@)
3147 BOOL
X11DRV_SetPixelFormat(X11DRV_PDEVICE
*physDev
,
3149 const PIXELFORMATDESCRIPTOR
*ppfd
) {
3150 ERR("No OpenGL support compiled in.\n");
3155 /***********************************************************************
3156 * SwapBuffers (X11DRV.@)
3158 BOOL
X11DRV_SwapBuffers(X11DRV_PDEVICE
*physDev
) {
3159 ERR_(opengl
)("No OpenGL support compiled in.\n");
3165 * X11DRV_wglCreateContext
3167 * For OpenGL32 wglCreateContext.
3169 HGLRC
X11DRV_wglCreateContext(X11DRV_PDEVICE
*physDev
) {
3170 ERR_(opengl
)("No OpenGL support compiled in.\n");
3175 * X11DRV_wglDeleteContext
3177 * For OpenGL32 wglDeleteContext.
3179 BOOL
X11DRV_wglDeleteContext(HGLRC hglrc
) {
3180 ERR_(opengl
)("No OpenGL support compiled in.\n");
3185 * X11DRV_wglGetProcAddress
3187 * For OpenGL32 wglGetProcAddress.
3189 PROC
X11DRV_wglGetProcAddress(LPCSTR lpszProc
) {
3190 ERR_(opengl
)("No OpenGL support compiled in.\n");
3194 HDC
X11DRV_wglGetPbufferDCARB(X11DRV_PDEVICE
*hDevice
, void *hPbuffer
)
3196 ERR_(opengl
)("No OpenGL support compiled in.\n");
3200 BOOL
X11DRV_wglMakeContextCurrentARB(X11DRV_PDEVICE
* hDrawDev
, X11DRV_PDEVICE
* hReadDev
, HGLRC hglrc
) {
3201 ERR_(opengl
)("No OpenGL support compiled in.\n");
3206 * X11DRV_wglMakeCurrent
3208 * For OpenGL32 wglMakeCurrent.
3210 BOOL
X11DRV_wglMakeCurrent(X11DRV_PDEVICE
*physDev
, HGLRC hglrc
) {
3211 ERR_(opengl
)("No OpenGL support compiled in.\n");
3216 * X11DRV_wglShareLists
3218 * For OpenGL32 wglShaderLists.
3220 BOOL
X11DRV_wglShareLists(HGLRC hglrc1
, HGLRC hglrc2
) {
3221 ERR_(opengl
)("No OpenGL support compiled in.\n");
3226 * X11DRV_wglUseFontBitmapsA
3228 * For OpenGL32 wglUseFontBitmapsA.
3230 BOOL
X11DRV_wglUseFontBitmapsA(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
3232 ERR_(opengl
)("No OpenGL support compiled in.\n");
3237 * X11DRV_wglUseFontBitmapsW
3239 * For OpenGL32 wglUseFontBitmapsW.
3241 BOOL
X11DRV_wglUseFontBitmapsW(X11DRV_PDEVICE
*physDev
, DWORD first
, DWORD count
, DWORD listBase
)
3243 ERR_(opengl
)("No OpenGL support compiled in.\n");
3247 XVisualInfo
*X11DRV_setup_opengl_visual( Display
*display
)
3252 Drawable
get_glxdrawable(X11DRV_PDEVICE
*physDev
)
3257 BOOL
destroy_glxpixmap(XID glxpixmap
)
3262 #endif /* defined(HAVE_OPENGL) */