From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/opengl.c | 291 ++++++++++++-------------------------- 1 file changed, 92 insertions(+), 199 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 829045c2353..01b7e5e0638 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -45,8 +45,6 @@ #include "winternl.h" #include "wine/debug.h"
-#ifdef SONAME_LIBGL - WINE_DEFAULT_DEBUG_CHANNEL(wgl); WINE_DECLARE_DEBUG_CHANNEL(winediag);
@@ -160,41 +158,8 @@ static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) { TRACE("\n"); }
-/* GLX 1.0 */ -static XVisualInfo* (*pglXChooseVisual)( Display *dpy, int screen, int *attribList ); -static GLXContext (*pglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct ); -static void (*pglXDestroyContext)( Display *dpy, GLXContext ctx ); -static Bool (*pglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx); -static void (*pglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, unsigned long mask ); -static void (*pglXSwapBuffers)( Display *dpy, GLXDrawable drawable ); -static Bool (*pglXQueryVersion)( Display *dpy, int *maj, int *min ); -static Bool (*pglXIsDirect)( Display *dpy, GLXContext ctx ); -static GLXContext (*pglXGetCurrentContext)( void ); -static GLXDrawable (*pglXGetCurrentDrawable)( void ); - -/* GLX 1.1 */ -static const char *(*pglXQueryExtensionsString)( Display *dpy, int screen ); -static const char *(*pglXQueryServerString)( Display *dpy, int screen, int name ); -static const char *(*pglXGetClientString)( Display *dpy, int name ); - -/* GLX 1.3 */ -static GLXFBConfig *(*pglXChooseFBConfig)( Display *dpy, int screen, const int *attribList, int *nitems ); -static int (*pglXGetFBConfigAttrib)( Display *dpy, GLXFBConfig config, int attribute, int *value ); -static GLXFBConfig *(*pglXGetFBConfigs)( Display *dpy, int screen, int *nelements ); -static XVisualInfo *(*pglXGetVisualFromFBConfig)( Display *dpy, GLXFBConfig config ); -static GLXPbuffer (*pglXCreatePbuffer)( Display *dpy, GLXFBConfig config, const int *attribList ); -static void (*pglXDestroyPbuffer)( Display *dpy, GLXPbuffer pbuf ); -static void (*pglXQueryDrawable)( Display *dpy, GLXDrawable draw, int attribute, unsigned int *value ); -static GLXContext (*pglXCreateNewContext)( Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct ); -static Bool (*pglXMakeContextCurrent)( Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx ); -static GLXPixmap (*pglXCreatePixmap)( Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list ); -static void (*pglXDestroyPixmap)( Display *dpy, GLXPixmap pixmap ); -static GLXWindow (*pglXCreateWindow)( Display *dpy, GLXFBConfig config, Window win, const int *attrib_list ); -static void (*pglXDestroyWindow)( Display *dpy, GLXWindow win ); - /* GLX Extensions */ static GLXContext (*pglXCreateContextAttribsARB)(Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); -static void* (*pglXGetProcAddressARB)(const GLubyte *); static void (*pglXSwapIntervalEXT)(Display *dpy, GLXDrawable drawable, int interval); static int (*pglXSwapIntervalSGI)(int);
@@ -261,13 +226,13 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) attr.colormap = None; attr.border_pixel = 0;
- vis = pglXChooseVisual(gdi_display, screen, attribList); - if (vis) { + if ((vis = funcs->p_glXChooseVisual( gdi_display, screen, attribList ))) + { #ifdef __i386__ WORD old_fs, new_fs; __asm__( "mov %%fs,%0" : "=r" (old_fs) ); /* Create a GLX Context. Without one we can't query GL information */ - ctx = pglXCreateContext(gdi_display, vis, None, GL_TRUE); + ctx = funcs->p_glXCreateContext( gdi_display, vis, None, GL_TRUE ); __asm__( "mov %%fs,%0" : "=r" (new_fs) ); __asm__( "mov %0,%%fs" :: "r" (old_fs) ); if (old_fs != new_fs) @@ -277,7 +242,7 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) goto done; } #else - ctx = pglXCreateContext(gdi_display, vis, None, GL_TRUE); + ctx = funcs->p_glXCreateContext( gdi_display, vis, None, GL_TRUE ); #endif } if (!ctx) goto done; @@ -291,7 +256,7 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) else win = root;
- if(pglXMakeCurrent(gdi_display, win, ctx) == 0) + if (funcs->p_glXMakeCurrent( gdi_display, win, ctx ) == 0) { ERR_(winediag)( "Unable to activate OpenGL context, most likely your %s OpenGL drivers haven't been " "installed correctly\n", is_win64 ? "64-bit" : "32-bit" ); @@ -302,18 +267,18 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void) glExtensions = (const char *) pglGetString(GL_EXTENSIONS);
/* Get the common GLX version supported by GLX client and server ( major/minor) */ - pglXQueryVersion( gdi_display, &glx_version[0], &glx_version[1] ); + funcs->p_glXQueryVersion( gdi_display, &glx_version[0], &glx_version[1] );
- glxExtensions = pglXQueryExtensionsString(gdi_display, screen); - glx_direct = pglXIsDirect(gdi_display, ctx); + glxExtensions = funcs->p_glXQueryExtensionsString( gdi_display, screen ); + glx_direct = funcs->p_glXIsDirect( gdi_display, ctx );
TRACE("GL version : %s.\n", gl_version); TRACE("GL renderer : %s.\n", gl_renderer); TRACE( "GLX version : %d.%d.\n", glx_version[0], glx_version[1] ); - TRACE("Server GLX version : %s.\n", pglXQueryServerString(gdi_display, screen, GLX_VERSION)); - TRACE("Server GLX vendor: : %s.\n", pglXQueryServerString(gdi_display, screen, GLX_VENDOR)); - TRACE("Client GLX version : %s.\n", pglXGetClientString(gdi_display, GLX_VERSION)); - TRACE("Client GLX vendor: : %s.\n", pglXGetClientString(gdi_display, GLX_VENDOR)); + TRACE( "Server GLX version : %s.\n", funcs->p_glXQueryServerString( gdi_display, screen, GLX_VERSION ) ); + TRACE( "Server GLX vendor: : %s.\n", funcs->p_glXQueryServerString( gdi_display, screen, GLX_VENDOR ) ); + TRACE( "Client GLX version : %s.\n", funcs->p_glXGetClientString( gdi_display, GLX_VERSION ) ); + TRACE( "Client GLX vendor: : %s.\n", funcs->p_glXGetClientString( gdi_display, GLX_VENDOR ) ); TRACE("Direct rendering enabled: %s\n", glx_direct ? "True" : "False");
if(!glx_direct) @@ -352,9 +317,10 @@ static BOOL X11DRV_WineGL_InitOpenglInfo(void)
done: if(vis) XFree(vis); - if(ctx) { - pglXMakeCurrent(gdi_display, None, NULL); - pglXDestroyContext(gdi_display, ctx); + if (ctx) + { + funcs->p_glXMakeCurrent( gdi_display, None, NULL ); + funcs->p_glXDestroyContext( gdi_display, ctx ); } if (win != root) XDestroyWindow( gdi_display, win ); if (attr.colormap) XFreeColormap( gdi_display, attr.colormap ); @@ -395,52 +361,10 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c LOAD_FUNCPTR( glGetString ); #undef LOAD_FUNCPTR
- pglXGetProcAddressARB = dlsym( funcs->opengl_handle, "glXGetProcAddressARB" ); - if (pglXGetProcAddressARB == NULL) { - ERR("Could not find glXGetProcAddressARB in libGL, disabling OpenGL.\n"); - return STATUS_NOT_SUPPORTED; - } - -#define LOAD_FUNCPTR( f ) \ - if (!(p##f = (void *)pglXGetProcAddressARB( (const GLubyte *)#f ))) \ - { \ - ERR( "%s not found in libGL, disabling OpenGL.\n", #f ); \ - return STATUS_NOT_SUPPORTED; \ - } - - /* GLX 1.0 */ - LOAD_FUNCPTR(glXChooseVisual); - LOAD_FUNCPTR(glXCopyContext); - LOAD_FUNCPTR(glXCreateContext); - LOAD_FUNCPTR(glXGetCurrentContext); - LOAD_FUNCPTR(glXGetCurrentDrawable); - LOAD_FUNCPTR(glXDestroyContext); - LOAD_FUNCPTR(glXIsDirect); - LOAD_FUNCPTR(glXMakeCurrent); - LOAD_FUNCPTR(glXSwapBuffers); - LOAD_FUNCPTR(glXQueryVersion); - - /* GLX 1.1 */ - LOAD_FUNCPTR(glXGetClientString); - LOAD_FUNCPTR(glXQueryExtensionsString); - LOAD_FUNCPTR(glXQueryServerString); - - /* GLX 1.3 */ - LOAD_FUNCPTR(glXCreatePbuffer); - LOAD_FUNCPTR(glXCreateNewContext); - LOAD_FUNCPTR(glXDestroyPbuffer); - LOAD_FUNCPTR(glXMakeContextCurrent); - LOAD_FUNCPTR(glXGetFBConfigs); - LOAD_FUNCPTR(glXCreatePixmap); - LOAD_FUNCPTR(glXDestroyPixmap); - LOAD_FUNCPTR(glXCreateWindow); - LOAD_FUNCPTR(glXDestroyWindow); -#undef LOAD_FUNCPTR - /* It doesn't matter if these fail. They'll only be used if the driver reports the associated extension is available (and if a driver reports the extension is available but fails to provide the functions, it's quite broken) */ -#define LOAD_FUNCPTR(f) p##f = pglXGetProcAddressARB((const GLubyte *)#f) +#define LOAD_FUNCPTR( f ) p##f = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)#f ) /* ARB GLX Extension */ LOAD_FUNCPTR(glXCreateContextAttribsARB); /* EXT GLX Extension */ @@ -465,30 +389,23 @@ UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, c gl_hwnd_context = XUniqueContext(); gl_pbuffer_context = XUniqueContext();
- pglXChooseFBConfig = pglXGetProcAddressARB( (const GLubyte *)"glXChooseFBConfig" ); - pglXGetFBConfigAttrib = pglXGetProcAddressARB( (const GLubyte *)"glXGetFBConfigAttrib" ); - pglXGetVisualFromFBConfig = pglXGetProcAddressARB( (const GLubyte - *)"glXGetVisualFromFBConfig" ); - pglXQueryDrawable = pglXGetProcAddressARB( (const GLubyte *)"glXQueryDrawable" ); - - if (has_extension( glxExtensions, "GLX_MESA_copy_sub_buffer")) { - pglXCopySubBufferMESA = pglXGetProcAddressARB((const GLubyte *) "glXCopySubBufferMESA"); + if (has_extension( glxExtensions, "GLX_MESA_copy_sub_buffer" )) + { + pglXCopySubBufferMESA = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)"glXCopySubBufferMESA" ); }
if (has_extension( glxExtensions, "GLX_MESA_query_renderer" )) { - pglXQueryCurrentRendererIntegerMESA = pglXGetProcAddressARB( - (const GLubyte *)"glXQueryCurrentRendererIntegerMESA" ); - pglXQueryCurrentRendererStringMESA = pglXGetProcAddressARB( - (const GLubyte *)"glXQueryCurrentRendererStringMESA" ); - pglXQueryRendererIntegerMESA = pglXGetProcAddressARB( (const GLubyte *)"glXQueryRendererIntegerMESA" ); - pglXQueryRendererStringMESA = pglXGetProcAddressARB( (const GLubyte *)"glXQueryRendererStringMESA" ); + pglXQueryCurrentRendererIntegerMESA = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)"glXQueryCurrentRendererIntegerMESA" ); + pglXQueryCurrentRendererStringMESA = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)"glXQueryCurrentRendererStringMESA" ); + pglXQueryRendererIntegerMESA = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)"glXQueryRendererIntegerMESA" ); + pglXQueryRendererStringMESA = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)"glXQueryRendererStringMESA" ); }
if (has_extension( glxExtensions, "GLX_OML_sync_control" )) { - pglXWaitForSbcOML = pglXGetProcAddressARB( (const GLubyte *)"glXWaitForSbcOML" ); - pglXSwapBuffersMscOML = pglXGetProcAddressARB( (const GLubyte *)"glXSwapBuffersMscOML" ); + pglXWaitForSbcOML = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)"glXWaitForSbcOML" ); + pglXSwapBuffersMscOML = (void *)funcs->p_glXGetProcAddress( (const GLubyte *)"glXSwapBuffersMscOML" ); }
*driver_funcs = &x11drv_driver_funcs; @@ -499,17 +416,16 @@ static const char *debugstr_fbconfig( GLXFBConfig fbconfig ) { int id, visual, drawable;
- if (pglXGetFBConfigAttrib( gdi_display, fbconfig, GLX_FBCONFIG_ID, &id )) - return "*** invalid fbconfig"; - pglXGetFBConfigAttrib( gdi_display, fbconfig, GLX_VISUAL_ID, &visual ); - pglXGetFBConfigAttrib( gdi_display, fbconfig, GLX_DRAWABLE_TYPE, &drawable ); + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fbconfig, GLX_FBCONFIG_ID, &id )) return "*** invalid fbconfig"; + funcs->p_glXGetFBConfigAttrib( gdi_display, fbconfig, GLX_VISUAL_ID, &visual ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fbconfig, GLX_DRAWABLE_TYPE, &drawable ); return wine_dbg_sprintf( "fbconfig %#x visual id %#x drawable type %#x", id, visual, drawable ); }
static int get_render_type_from_fbconfig(Display *display, GLXFBConfig fbconfig) { int render_type, render_type_bit; - pglXGetFBConfigAttrib(display, fbconfig, GLX_RENDER_TYPE, &render_type_bit); + funcs->p_glXGetFBConfigAttrib( display, fbconfig, GLX_RENDER_TYPE, &render_type_bit ); switch(render_type_bit) { case GLX_RGBA_BIT: @@ -535,8 +451,8 @@ static int get_render_type_from_fbconfig(Display *display, GLXFBConfig fbconfig) static BOOL check_fbconfig_bitmap_capability(Display *display, GLXFBConfig fbconfig) { int dbuf, value; - pglXGetFBConfigAttrib(display, fbconfig, GLX_DOUBLEBUFFER, &dbuf); - pglXGetFBConfigAttrib(gdi_display, fbconfig, GLX_DRAWABLE_TYPE, &value); + funcs->p_glXGetFBConfigAttrib( display, fbconfig, GLX_DOUBLEBUFFER, &dbuf ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fbconfig, GLX_DRAWABLE_TYPE, &value );
/* Windows only supports bitmap rendering on single buffered formats, further the fbconfig needs to have * the GLX_PIXMAP_BIT set. */ @@ -551,7 +467,7 @@ static UINT x11drv_init_pixel_formats( UINT *onscreen_count ) GLXFBConfig* cfgs; XVisualInfo *visinfo;
- cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs); + cfgs = funcs->p_glXGetFBConfigs( gdi_display, DefaultScreen( gdi_display ), &nCfgs ); if (NULL == cfgs || 0 == nCfgs) { if(cfgs != NULL) XFree(cfgs); ERR("glXChooseFBConfig returns NULL\n"); @@ -579,8 +495,8 @@ static UINT x11drv_init_pixel_formats( UINT *onscreen_count ) for(run=0; run < 2; run++) { for(i=0; i<nCfgs; i++) { - pglXGetFBConfigAttrib(gdi_display, cfgs[i], GLX_FBCONFIG_ID, &fmt_id); - visinfo = pglXGetVisualFromFBConfig(gdi_display, cfgs[i]); + funcs->p_glXGetFBConfigAttrib( gdi_display, cfgs[i], GLX_FBCONFIG_ID, &fmt_id ); + visinfo = funcs->p_glXGetVisualFromFBConfig( gdi_display, cfgs[i] );
/* The first run we only add onscreen formats (ones which have an associated X Visual). * The second run we only set offscreen formats. */ @@ -622,7 +538,7 @@ static UINT x11drv_init_pixel_formats( UINT *onscreen_count ) } } else if(run && !visinfo) { int window_drawable=0; - pglXGetFBConfigAttrib(gdi_display, cfgs[i], GLX_DRAWABLE_TYPE, &window_drawable); + funcs->p_glXGetFBConfigAttrib( gdi_display, cfgs[i], GLX_DRAWABLE_TYPE, &window_drawable );
/* Recent Nvidia drivers and DRI drivers offer window drawable formats without a visual. * This are formats like 16-bit rgb on a 24-bit desktop. In order to support these formats @@ -701,18 +617,18 @@ static void release_gl_drawable( struct gl_drawable *gl ) case DC_GL_WINDOW: case DC_GL_CHILD_WIN: TRACE( "destroying %lx drawable %lx\n", gl->window, gl->drawable ); - pglXDestroyWindow( gdi_display, gl->drawable ); + funcs->p_glXDestroyWindow( gdi_display, gl->drawable ); destroy_client_window( gl->hwnd, gl->window ); XFreeColormap( gdi_display, gl->colormap ); break; case DC_GL_PIXMAP_WIN: TRACE( "destroying pixmap %lx drawable %lx\n", gl->pixmap, gl->drawable ); - pglXDestroyPixmap( gdi_display, gl->drawable ); + funcs->p_glXDestroyPixmap( gdi_display, gl->drawable ); XFreePixmap( gdi_display, gl->pixmap ); break; case DC_GL_PBUFFER: TRACE( "destroying pbuffer drawable %lx\n", gl->drawable ); - pglXDestroyPbuffer( gdi_display, gl->drawable ); + funcs->p_glXDestroyPbuffer( gdi_display, gl->drawable ); break; default: break; @@ -767,8 +683,8 @@ static inline void sync_context(struct x11drv_context *context) } if (refresh) { - pglXMakeContextCurrent( gdi_display, context->drawables[0]->drawable, - context->drawables[1]->drawable, context->ctx ); + funcs->p_glXMakeContextCurrent( gdi_display, context->drawables[0]->drawable, + context->drawables[1]->drawable, context->ctx ); release_gl_drawable( old[0] ); release_gl_drawable( old[1] ); } @@ -834,12 +750,13 @@ static GLXContext create_glxcontext(Display *display, struct x11drv_context *con { GLXContext ctx;
- if(context->gl3_context) - ctx = pglXCreateContextAttribsARB(gdi_display, context->fmt->fbconfig, shareList, GL_TRUE, attribs); - else if(context->fmt->visual) - ctx = pglXCreateContext(gdi_display, context->fmt->visual, shareList, GL_TRUE); + if (context->gl3_context) + ctx = pglXCreateContextAttribsARB( gdi_display, context->fmt->fbconfig, shareList, GL_TRUE, attribs ); + else if (context->fmt->visual) + ctx = funcs->p_glXCreateContext( gdi_display, context->fmt->visual, shareList, GL_TRUE ); else /* Create a GLX Context for a pbuffer */ - ctx = pglXCreateNewContext(gdi_display, context->fmt->fbconfig, context->fmt->render_type, shareList, TRUE); + ctx = funcs->p_glXCreateNewContext( gdi_display, context->fmt->fbconfig, + context->fmt->render_type, shareList, TRUE );
return ctx; } @@ -876,8 +793,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct glx_pixel (visual->class == PseudoColor || visual->class == GrayScale || visual->class == DirectColor) ? AllocAll : AllocNone ); gl->window = create_client_window( hwnd, visual, gl->colormap ); - if (gl->window) - gl->drawable = pglXCreateWindow( gdi_display, gl->format->fbconfig, gl->window, NULL ); + if (gl->window) gl->drawable = funcs->p_glXCreateWindow( gdi_display, gl->format->fbconfig, gl->window, NULL ); TRACE( "%p created client %lx drawable %lx\n", hwnd, gl->window, gl->drawable ); } #ifdef SONAME_LIBXCOMPOSITE @@ -892,7 +808,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct glx_pixel { struct x11drv_win_data *data;
- gl->drawable = pglXCreateWindow( gdi_display, gl->format->fbconfig, gl->window, NULL ); + gl->drawable = funcs->p_glXCreateWindow( gdi_display, gl->format->fbconfig, gl->window, NULL ); pXCompositeRedirectWindow( gdi_display, gl->window, CompositeRedirectManual );
if ((data = get_win_data( hwnd ))) @@ -921,7 +837,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct glx_pixel gl->pixmap = XCreatePixmap( gdi_display, root_window, width, height, visual->depth ); if (gl->pixmap) { - gl->drawable = pglXCreatePixmap( gdi_display, gl->format->fbconfig, gl->pixmap, NULL ); + gl->drawable = funcs->p_glXCreatePixmap( gdi_display, gl->format->fbconfig, gl->pixmap, NULL ); if (!gl->drawable) XFreePixmap( gdi_display, gl->pixmap );
gl->hdc_dst = NtGdiOpenDCW( &device_str, NULL, NULL, 0, TRUE, NULL, NULL, NULL ); @@ -1114,8 +1030,8 @@ static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_for }
/* If we can't get basic information, there is no point continuing */ - if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &drawable_type )) return 0; - if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &render_type )) return 0; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &drawable_type )) return 0; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &render_type )) return 0;
memset( pf, 0, sizeof(*pf) ); pf->pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); @@ -1146,13 +1062,13 @@ static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_for
if (!(pf->pfd.dwFlags & PFD_GENERIC_FORMAT)) pf->pfd.dwFlags |= PFD_SUPPORT_COMPOSITION;
- pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value ); if (value) { pf->pfd.dwFlags |= PFD_DOUBLEBUFFER; pf->pfd.dwFlags &= ~PFD_SUPPORT_GDI; } - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STEREO, &value ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STEREO, &value ); if (value) pf->pfd.dwFlags |= PFD_STEREO;
/* Pixel type */ @@ -1160,16 +1076,16 @@ static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_for else pf->pfd.iPixelType = PFD_TYPE_COLORINDEX;
/* Color bits */ - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &value ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &value ); pf->pfd.cColorBits = value;
/* Red, green, blue and alpha bits / shifts */ if (pf->pfd.iPixelType == PFD_TYPE_RGBA) { - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RED_SIZE, &rb ); - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_GREEN_SIZE, &gb ); - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb ); - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_RED_SIZE, &rb ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_GREEN_SIZE, &gb ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab );
pf->pfd.cBlueBits = bb; pf->pfd.cBlueShift = 0; @@ -1194,10 +1110,10 @@ static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_for }
/* Accum RGBA bits */ - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_RED_SIZE, &rb ); - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_GREEN_SIZE, &gb ); - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_BLUE_SIZE, &bb ); - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_ALPHA_SIZE, &ab ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_RED_SIZE, &rb ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_GREEN_SIZE, &gb ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_BLUE_SIZE, &bb ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_ACCUM_ALPHA_SIZE, &ab );
pf->pfd.cAccumBits = rb + gb + bb + ab; pf->pfd.cAccumRedBits = rb; @@ -1206,23 +1122,24 @@ static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_for pf->pfd.cAccumAlphaBits = ab;
/* Aux bits */ - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_AUX_BUFFERS, &value ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_AUX_BUFFERS, &value ); pf->pfd.cAuxBuffers = value;
/* Depth bits */ - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value ); pf->pfd.cDepthBits = value;
/* stencil bits */ - pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value ); + funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value ); pf->pfd.cStencilBits = value;
pf->pfd.iLayerType = PFD_MAIN_PLANE;
if (!has_swap_method) pf->swap_method = WGL_SWAP_EXCHANGE_ARB; - else if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SWAP_METHOD_OML, &value )) + else if (!funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SWAP_METHOD_OML, &value )) { - switch (value) { + switch (value) + { case GLX_SWAP_EXCHANGE_OML: pf->swap_method = WGL_SWAP_EXCHANGE_ARB; break; case GLX_SWAP_COPY_OML: pf->swap_method = WGL_SWAP_COPY_ARB; break; case GLX_SWAP_UNDEFINED_OML: pf->swap_method = WGL_SWAP_UNDEFINED_ARB; break; @@ -1231,7 +1148,7 @@ static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_for } else pf->swap_method = -1;
- if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_TYPE, &value) ) pf->transparent = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_TYPE, &value )) pf->transparent = -1; else pf->transparent = value != GLX_NONE;
if (render_type & GLX_RGBA_BIT) pf->pixel_type = WGL_TYPE_RGBA_ARB; @@ -1242,51 +1159,51 @@ static BOOL x11drv_describe_pixel_format( int iPixelFormat, struct wgl_pixel_for else { ERR( "unexpected RenderType(%x)\n", render_type ); pf->pixel_type = -1; }
pf->draw_to_pbuffer = (drawable_type & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE; - if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_PIXELS, &value )) value = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_PIXELS, &value )) value = -1; pf->max_pbuffer_pixels = value; - if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_WIDTH, &value )) value = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_WIDTH, &value )) value = -1; pf->max_pbuffer_width = value; - if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_HEIGHT, &value )) value = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_MAX_PBUFFER_HEIGHT, &value )) value = -1; pf->max_pbuffer_height = value;
- if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_RED_VALUE, &value )) + if (!funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_RED_VALUE, &value )) { pf->transparent_red_value_valid = GL_TRUE; pf->transparent_red_value = value; } - if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &value )) + if (!funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &value )) { pf->transparent_green_value_valid = GL_TRUE; pf->transparent_green_value = value; } - if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &value )) + if (!funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &value )) { pf->transparent_blue_value_valid = GL_TRUE; pf->transparent_blue_value = value; } - if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &value )) + if (!funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &value )) { pf->transparent_alpha_value_valid = GL_TRUE; pf->transparent_alpha_value = value; } - if (!pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &value )) + if (!funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &value )) { pf->transparent_index_value_valid = GL_TRUE; pf->transparent_index_value = value; }
- if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SAMPLE_BUFFERS_ARB, &value )) value = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SAMPLE_BUFFERS_ARB, &value )) value = -1; pf->sample_buffers = value; - if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SAMPLES_ARB, &value )) value = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_SAMPLES_ARB, &value )) value = -1; pf->samples = value;
- if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &value )) value = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &value )) value = -1; pf->framebuffer_srgb_capable = value;
pf->bind_to_texture_rgb = pf->bind_to_texture_rgba = render_type != GLX_COLOR_INDEX_BIT && (drawable_type & GLX_PBUFFER_BIT); pf->bind_to_texture_rectangle_rgb = pf->bind_to_texture_rectangle_rgba = GL_FALSE;
- if (pglXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_FLOAT_COMPONENTS_NV, &value )) value = -1; + if (funcs->p_glXGetFBConfigAttrib( gdi_display, fmt->fbconfig, GLX_FLOAT_COMPONENTS_NV, &value )) value = -1; pf->float_components = value;
if (TRACE_ON(wgl)) dump_PIXELFORMATDESCRIPTOR( &pf->pfd ); @@ -1307,7 +1224,7 @@ static BOOL x11drv_context_destroy(void *private) list_remove( &ctx->entry ); pthread_mutex_unlock( &context_mutex );
- if (ctx->ctx) pglXDestroyContext( gdi_display, ctx->ctx ); + if (ctx->ctx) funcs->p_glXDestroyContext( gdi_display, ctx->ctx ); release_gl_drawable( ctx->drawables[0] ); release_gl_drawable( ctx->drawables[1] ); release_gl_drawable( ctx->new_drawables[0] ); @@ -1320,7 +1237,7 @@ static void *x11drv_get_proc_address( const char *name ) { void *ptr; if ((ptr = dlsym( funcs->opengl_handle, name ))) return ptr; - return pglXGetProcAddressARB( (const GLubyte *)name ); + return funcs->p_glXGetProcAddress( (const GLubyte *)name ); }
static void set_context_drawables( struct x11drv_context *ctx, struct gl_drawable *draw, @@ -1349,7 +1266,7 @@ static BOOL x11drv_context_make_current( HDC draw_hdc, HDC read_hdc, void *priva
if (!private) { - pglXMakeCurrent( gdi_display, None, NULL ); + funcs->p_glXMakeCurrent( gdi_display, None, NULL ); NtCurrentTeb()->glReserved2 = NULL; return TRUE; } @@ -1359,8 +1276,8 @@ static BOOL x11drv_context_make_current( HDC draw_hdc, HDC read_hdc, void *priva read_gl = get_gl_drawable( NtUserWindowFromDC( read_hdc ), read_hdc );
pthread_mutex_lock( &context_mutex ); - if (!pglXMakeContextCurrent) ret = pglXMakeCurrent( gdi_display, draw_gl->drawable, ctx->ctx ); - else ret = pglXMakeContextCurrent( gdi_display, draw_gl->drawable, read_gl ? read_gl->drawable : 0, ctx->ctx ); + if (!funcs->p_glXMakeContextCurrent) ret = funcs->p_glXMakeCurrent( gdi_display, draw_gl->drawable, ctx->ctx ); + else ret = funcs->p_glXMakeContextCurrent( gdi_display, draw_gl->drawable, read_gl ? read_gl->drawable : 0, ctx->ctx ); if (ret) { ctx->hdc = draw_hdc; @@ -1554,15 +1471,15 @@ static BOOL x11drv_pbuffer_create( HDC hdc, int format, BOOL largest, GLenum tex surface->format = fmt; surface->ref = 1;
- surface->drawable = pglXCreatePbuffer( gdi_display, fmt->fbconfig, glx_attribs ); + surface->drawable = funcs->p_glXCreatePbuffer( gdi_display, fmt->fbconfig, glx_attribs ); TRACE( "new Pbuffer drawable as %p (%lx)\n", surface, surface->drawable ); if (!surface->drawable) { free( surface ); return FALSE; } - pglXQueryDrawable( gdi_display, surface->drawable, GLX_WIDTH, (unsigned int *)width ); - pglXQueryDrawable( gdi_display, surface->drawable, GLX_HEIGHT, (unsigned int *)height ); + funcs->p_glXQueryDrawable( gdi_display, surface->drawable, GLX_WIDTH, (unsigned int *)width ); + funcs->p_glXQueryDrawable( gdi_display, surface->drawable, GLX_HEIGHT, (unsigned int *)height ); SetRect( &rect, 0, 0, *width, *height ); set_dc_drawable( hdc, surface->drawable, &rect, IncludeInferiors );
@@ -1742,7 +1659,7 @@ static BOOL x11drv_swap_buffers( void *private, HWND hwnd, HDC hdc, int interval target_sbc = pglXSwapBuffersMscOML( gdi_display, gl->drawable, 0, 0, 0 ); break; } - pglXSwapBuffers(gdi_display, gl->drawable); + funcs->p_glXSwapBuffers( gdi_display, gl->drawable ); break; case DC_GL_WINDOW: case DC_GL_CHILD_WIN: @@ -1756,7 +1673,7 @@ static BOOL x11drv_swap_buffers( void *private, HWND hwnd, HDC hdc, int interval target_sbc = pglXSwapBuffersMscOML( gdi_display, gl->drawable, 0, 0, 0 ); break; } - pglXSwapBuffers(gdi_display, gl->drawable); + funcs->p_glXSwapBuffers( gdi_display, gl->drawable ); break; }
@@ -1786,27 +1703,3 @@ static const struct opengl_driver_funcs x11drv_driver_funcs = .p_pbuffer_updated = x11drv_pbuffer_updated, .p_pbuffer_bind = x11drv_pbuffer_bind, }; - -#else /* no OpenGL includes */ - -/********************************************************************** - * X11DRV_OpenglInit - */ -UINT X11DRV_OpenGLInit( UINT version, const struct opengl_funcs *opengl_funcs, const struct opengl_driver_funcs **driver_funcs ) -{ - return STATUS_NOT_IMPLEMENTED; -} - -void sync_gl_drawable( HWND hwnd, BOOL known_child ) -{ -} - -void set_gl_drawable_parent( HWND hwnd, HWND parent ) -{ -} - -void destroy_gl_drawable( HWND hwnd ) -{ -} - -#endif /* defined(SONAME_LIBGL) */