The plan is to move as much GL code as possible to win32u, similarly to what's been done with vulkan. While I intend to keep the existing driver-specific GL backend (GLX, macos?), I win32u can use EGL more directly while delegating only the platform specific display and surface creation to the drivers.
At the same time, it could also make it possible to use EGL for memory DCs too, as osmesa is being removed from Mesa3D main branch (still going to be present in a separate historical branch iiuc).
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/Makefile.in | 1 + dlls/win32u/dc.c | 32 --------------------- dlls/win32u/opengl.c | 63 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 dlls/win32u/opengl.c
diff --git a/dlls/win32u/Makefile.in b/dlls/win32u/Makefile.in index c64f6bc6fb9..b849f0c202d 100644 --- a/dlls/win32u/Makefile.in +++ b/dlls/win32u/Makefile.in @@ -39,6 +39,7 @@ SOURCES = \ mapping.c \ menu.c \ message.c \ + opengl.c \ opentype.c \ painting.c \ palette.c \ diff --git a/dlls/win32u/dc.c b/dlls/win32u/dc.c index 3f6a501041a..a2f76ffec71 100644 --- a/dlls/win32u/dc.c +++ b/dlls/win32u/dc.c @@ -36,8 +36,6 @@ #include "winternl.h" #include "winerror.h" #include "ntgdi_private.h" -#include "wine/wgl.h" -#include "wine/wgl_driver.h"
#include "wine/debug.h"
@@ -1473,33 +1471,3 @@ BOOL WINAPI __wine_get_icm_profile( HDC hdc, BOOL allow_default, DWORD *size, WC release_dc_ptr(dc); return ret; } - -/*********************************************************************** - * __wine_get_wgl_driver (win32u.@) - */ -const struct opengl_funcs *__wine_get_wgl_driver( HDC hdc, UINT version ) -{ - BOOL is_display, is_memdc; - DC *dc; - - if (version != WINE_WGL_DRIVER_VERSION) - { - ERR( "version mismatch, opengl32 wants %u but dibdrv has %u\n", - version, WINE_WGL_DRIVER_VERSION ); - return NULL; - } - - if (!(dc = get_dc_obj( hdc ))) return NULL; - if (dc->attr->disabled) - { - GDI_ReleaseObj( hdc ); - return NULL; - } - is_display = dc->is_display; - is_memdc = get_gdi_object_type( hdc ) == NTGDI_OBJ_MEMDC; - GDI_ReleaseObj( hdc ); - - if (is_display) return user_driver->pwine_get_wgl_driver( version ); - if (is_memdc) return dibdrv_get_wgl_driver(); - return (void *)-1; -} diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c new file mode 100644 index 00000000000..0c4b77876d8 --- /dev/null +++ b/dlls/win32u/opengl.c @@ -0,0 +1,63 @@ +/* + * Copyright 2025 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep unix +#endif + +#include "config.h" + +#include <pthread.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "ntgdi_private.h" +#include "win32u_private.h" +#include "ntuser_private.h" + +#include "wine/wgl.h" +#include "wine/wgl_driver.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wgl); + +/*********************************************************************** + * __wine_get_wgl_driver (win32u.@) + */ +const struct opengl_funcs *__wine_get_wgl_driver( HDC hdc, UINT version ) +{ + DWORD is_disabled, is_display, is_memdc; + DC *dc; + + if (version != WINE_WGL_DRIVER_VERSION) + { + ERR( "version mismatch, opengl32 wants %u but dibdrv has %u\n", + version, WINE_WGL_DRIVER_VERSION ); + return NULL; + } + + if (!(dc = get_dc_ptr( hdc ))) return NULL; + is_memdc = get_gdi_object_type( hdc ) == NTGDI_OBJ_MEMDC; + is_display = dc->is_display; + is_disabled = dc->attr->disabled; + release_dc_ptr( dc ); + + if (is_disabled) return NULL; + if (is_display) return user_driver->pwine_get_wgl_driver( version ); + if (is_memdc) return dibdrv_get_wgl_driver(); + return (void *)-1; +}
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/dibdrv/dc.c | 229 ------------------------------------ dlls/win32u/ntgdi_private.h | 1 - dlls/win32u/opengl.c | 190 ++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 230 deletions(-)
diff --git a/dlls/win32u/dibdrv/dc.c b/dlls/win32u/dibdrv/dc.c index 60cd41142b2..e141965b697 100644 --- a/dlls/win32u/dibdrv/dc.c +++ b/dlls/win32u/dibdrv/dc.c @@ -34,8 +34,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(dib);
-static const struct osmesa_funcs *osmesa_funcs; - static const DWORD bit_fields_888[3] = {0xff0000, 0x00ff00, 0x0000ff}; static const DWORD bit_fields_555[3] = {0x7c00, 0x03e0, 0x001f};
@@ -398,233 +396,6 @@ static UINT dibdrv_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags ) return DCB_RESET; /* we don't have device-specific bounds */ }
-struct wgl_context; - -static const struct -{ - BYTE color_bits; - BYTE red_bits, red_shift; - BYTE green_bits, green_shift; - BYTE blue_bits, blue_shift; - BYTE alpha_bits, alpha_shift; - BYTE accum_bits; - BYTE depth_bits; - BYTE stencil_bits; -} pixel_formats[] = -{ - { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 32, 8 }, - { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 16, 8 }, - { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 32, 8 }, - { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 16, 8 }, - { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 32, 8 }, - { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 16, 8 }, - { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 32, 8 }, - { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 16, 8 }, - { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 }, - { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 }, - { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 32, 8 }, - { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 }, -}; - -static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr ) -{ - memset( descr, 0, sizeof(*descr) ); - descr->nSize = sizeof(*descr); - descr->nVersion = 1; - descr->dwFlags = PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_GENERIC_FORMAT; - descr->iPixelType = PFD_TYPE_RGBA; - descr->cColorBits = pixel_formats[fmt - 1].color_bits; - descr->cRedBits = pixel_formats[fmt - 1].red_bits; - descr->cRedShift = pixel_formats[fmt - 1].red_shift; - descr->cGreenBits = pixel_formats[fmt - 1].green_bits; - descr->cGreenShift = pixel_formats[fmt - 1].green_shift; - descr->cBlueBits = pixel_formats[fmt - 1].blue_bits; - descr->cBlueShift = pixel_formats[fmt - 1].blue_shift; - descr->cAlphaBits = pixel_formats[fmt - 1].alpha_bits; - descr->cAlphaShift = pixel_formats[fmt - 1].alpha_shift; - descr->cAccumBits = pixel_formats[fmt - 1].accum_bits; - descr->cAccumRedBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cAccumGreenBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cAccumBlueBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cAccumAlphaBits = pixel_formats[fmt - 1].accum_bits / 4; - descr->cDepthBits = pixel_formats[fmt - 1].depth_bits; - descr->cStencilBits = pixel_formats[fmt - 1].stencil_bits; - descr->cAuxBuffers = 0; - descr->iLayerType = PFD_MAIN_PLANE; -} - -/*********************************************************************** - * dibdrv_wglCopyContext - */ -static BOOL dibdrv_wglCopyContext( struct wgl_context *src, struct wgl_context *dst, UINT mask ) -{ - FIXME( "not supported yet\n" ); - return FALSE; -} - -/*********************************************************************** - * dibdrv_wglDeleteContext - */ -static BOOL dibdrv_wglDeleteContext( struct wgl_context *context ) -{ - if (!osmesa_funcs) return FALSE; - return osmesa_funcs->delete_context( context ); -} - -/*********************************************************************** - * dibdrv_wglGetPixelFormat - */ -static int dibdrv_wglGetPixelFormat( HDC hdc ) -{ - DC *dc = get_dc_ptr( hdc ); - int ret = 0; - - if (dc) - { - ret = dc->pixel_format; - release_dc_ptr( dc ); - } - return ret; -} - -/*********************************************************************** - * dibdrv_wglCreateContext - */ -static struct wgl_context *dibdrv_wglCreateContext( HDC hdc ) -{ - PIXELFORMATDESCRIPTOR descr; - int format = dibdrv_wglGetPixelFormat( hdc ); - - if (!format) format = 1; - if (format <= 0 || format > ARRAY_SIZE( pixel_formats )) return NULL; - describe_pixel_format( format, &descr ); - - if (!osmesa_funcs) return NULL; - return osmesa_funcs->create_context( hdc, &descr ); -} - -/*********************************************************************** - * dibdrv_wglGetProcAddress - */ -static PROC dibdrv_wglGetProcAddress( const char *proc ) -{ - if (!strncmp( proc, "wgl", 3 )) return NULL; - if (!osmesa_funcs) return NULL; - return osmesa_funcs->get_proc_address( proc ); -} - -/*********************************************************************** - * dibdrv_wglMakeCurrent - */ -static BOOL dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context ) -{ - HBITMAP bitmap; - BITMAPOBJ *bmp; - dib_info dib; - BOOL ret = FALSE; - - if (!osmesa_funcs) return FALSE; - if (!context) return osmesa_funcs->make_current( NULL, NULL, 0, 0, 0, 0 ); - - bitmap = NtGdiGetDCObject( hdc, NTGDI_OBJ_SURF ); - bmp = GDI_GetObjPtr( bitmap, NTGDI_OBJ_BITMAP ); - if (!bmp) return FALSE; - - if (init_dib_info_from_bitmapobj( &dib, bmp )) - { - char *bits; - int width = dib.rect.right - dib.rect.left; - int height = dib.rect.bottom - dib.rect.top; - - if (dib.stride < 0) - bits = (char *)dib.bits.ptr + (dib.rect.bottom - 1) * dib.stride; - else - bits = (char *)dib.bits.ptr + dib.rect.top * dib.stride; - bits += dib.rect.left * dib.bit_count / 8; - - TRACE( "context %p bits %p size %ux%u\n", context, bits, width, height ); - - ret = osmesa_funcs->make_current( context, bits, width, height, dib.bit_count, dib.stride ); - } - GDI_ReleaseObj( bitmap ); - return ret; -} - -/********************************************************************** - * dibdrv_wglSetPixelFormat - */ -static BOOL dibdrv_wglSetPixelFormat( HDC hdc, int fmt, const PIXELFORMATDESCRIPTOR *descr ) -{ - if (fmt <= 0 || fmt > ARRAY_SIZE( pixel_formats )) return FALSE; - return NtGdiSetPixelFormat( hdc, fmt ); -} - -/*********************************************************************** - * dibdrv_wglShareLists - */ -static BOOL dibdrv_wglShareLists( struct wgl_context *org, struct wgl_context *dest ) -{ - FIXME( "not supported yet\n" ); - return FALSE; -} - -/*********************************************************************** - * dibdrv_wglSwapBuffers - */ -static BOOL dibdrv_wglSwapBuffers( HDC hdc ) -{ - return TRUE; -} - -/*********************************************************************** - * dibdrv_get_pixel_formats - */ -static void dibdrv_get_pixel_formats( struct wgl_pixel_format *formats, - UINT max_formats, UINT *num_formats, - UINT *num_onscreen_formats ) -{ - UINT num_pixel_formats = ARRAY_SIZE( pixel_formats ); - UINT i; - - if (formats) - { - for (i = 0; i < min( max_formats, num_pixel_formats ); ++i) - describe_pixel_format( i + 1, &formats[i].pfd ); - } - *num_formats = *num_onscreen_formats = num_pixel_formats; -} - -static struct opengl_funcs opengl_funcs = -{ - { - dibdrv_wglCopyContext, /* p_wglCopyContext */ - dibdrv_wglCreateContext, /* p_wglCreateContext */ - dibdrv_wglDeleteContext, /* p_wglDeleteContext */ - dibdrv_wglGetPixelFormat, /* p_wglGetPixelFormat */ - dibdrv_wglGetProcAddress, /* p_wglGetProcAddress */ - dibdrv_wglMakeCurrent, /* p_wglMakeCurrent */ - dibdrv_wglSetPixelFormat, /* p_wglSetPixelFormat */ - dibdrv_wglShareLists, /* p_wglShareLists */ - dibdrv_wglSwapBuffers, /* p_wglSwapBuffers */ - dibdrv_get_pixel_formats, /* p_get_pixel_formats */ - } -}; - -/********************************************************************** - * dibdrv_get_wgl_driver - */ -struct opengl_funcs *dibdrv_get_wgl_driver(void) -{ - if (!osmesa_funcs && !(osmesa_funcs = init_opengl_lib())) - { - static int warned; - if (!warned++) ERR( "OSMesa not available, no OpenGL bitmap support\n" ); - return (void *)-1; - } - osmesa_funcs->get_gl_funcs( &opengl_funcs ); - return &opengl_funcs; -} - const struct gdi_dc_funcs dib_driver = { NULL, /* pAbortDoc */ diff --git a/dlls/win32u/ntgdi_private.h b/dlls/win32u/ntgdi_private.h index f1cbdfbe591..99ebb127d68 100644 --- a/dlls/win32u/ntgdi_private.h +++ b/dlls/win32u/ntgdi_private.h @@ -219,7 +219,6 @@ extern UINT get_dib_dc_color_table( HDC hdc, UINT startpos, UINT entries, extern UINT set_dib_dc_color_table( HDC hdc, UINT startpos, UINT entries, const RGBQUAD *colors ); extern void dibdrv_set_window_surface( DC *dc, struct window_surface *surface ); -extern struct opengl_funcs *dibdrv_get_wgl_driver(void);
/* driver.c */ extern const struct gdi_dc_funcs null_driver; diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 0c4b77876d8..1fd1a35b51e 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -33,8 +33,198 @@ #include "wine/wgl.h" #include "wine/wgl_driver.h"
+#include "dibdrv/dibdrv.h" + WINE_DEFAULT_DEBUG_CHANNEL(wgl);
+static const struct osmesa_funcs *osmesa_funcs; + +struct wgl_context; + +static const struct +{ + BYTE color_bits; + BYTE red_bits, red_shift; + BYTE green_bits, green_shift; + BYTE blue_bits, blue_shift; + BYTE alpha_bits, alpha_shift; + BYTE accum_bits; + BYTE depth_bits; + BYTE stencil_bits; +} pixel_formats[] = +{ + { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 32, 8 }, + { 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 16, 8 }, + { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 32, 8 }, + { 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 16, 8 }, + { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 32, 8 }, + { 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 16, 8 }, + { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 32, 8 }, + { 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 16, 8 }, + { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 }, + { 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 }, + { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 32, 8 }, + { 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 }, +}; + +static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr ) +{ + memset( descr, 0, sizeof(*descr) ); + descr->nSize = sizeof(*descr); + descr->nVersion = 1; + descr->dwFlags = PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_GENERIC_FORMAT; + descr->iPixelType = PFD_TYPE_RGBA; + descr->cColorBits = pixel_formats[fmt - 1].color_bits; + descr->cRedBits = pixel_formats[fmt - 1].red_bits; + descr->cRedShift = pixel_formats[fmt - 1].red_shift; + descr->cGreenBits = pixel_formats[fmt - 1].green_bits; + descr->cGreenShift = pixel_formats[fmt - 1].green_shift; + descr->cBlueBits = pixel_formats[fmt - 1].blue_bits; + descr->cBlueShift = pixel_formats[fmt - 1].blue_shift; + descr->cAlphaBits = pixel_formats[fmt - 1].alpha_bits; + descr->cAlphaShift = pixel_formats[fmt - 1].alpha_shift; + descr->cAccumBits = pixel_formats[fmt - 1].accum_bits; + descr->cAccumRedBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cAccumGreenBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cAccumBlueBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cAccumAlphaBits = pixel_formats[fmt - 1].accum_bits / 4; + descr->cDepthBits = pixel_formats[fmt - 1].depth_bits; + descr->cStencilBits = pixel_formats[fmt - 1].stencil_bits; + descr->cAuxBuffers = 0; + descr->iLayerType = PFD_MAIN_PLANE; +} + +static BOOL dibdrv_wglCopyContext( struct wgl_context *src, struct wgl_context *dst, UINT mask ) +{ + FIXME( "not supported yet\n" ); + return FALSE; +} + +static BOOL dibdrv_wglDeleteContext( struct wgl_context *context ) +{ + if (!osmesa_funcs) return FALSE; + return osmesa_funcs->delete_context( context ); +} + +static int dibdrv_wglGetPixelFormat( HDC hdc ) +{ + DC *dc = get_dc_ptr( hdc ); + int ret = 0; + + if (dc) + { + ret = dc->pixel_format; + release_dc_ptr( dc ); + } + return ret; +} + +static struct wgl_context *dibdrv_wglCreateContext( HDC hdc ) +{ + PIXELFORMATDESCRIPTOR descr; + int format = dibdrv_wglGetPixelFormat( hdc ); + + if (!format) format = 1; + if (format <= 0 || format > ARRAY_SIZE( pixel_formats )) return NULL; + describe_pixel_format( format, &descr ); + + if (!osmesa_funcs) return NULL; + return osmesa_funcs->create_context( hdc, &descr ); +} + +static PROC dibdrv_wglGetProcAddress( const char *proc ) +{ + if (!strncmp( proc, "wgl", 3 )) return NULL; + if (!osmesa_funcs) return NULL; + return osmesa_funcs->get_proc_address( proc ); +} + +static BOOL dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context ) +{ + HBITMAP bitmap; + BITMAPOBJ *bmp; + dib_info dib; + BOOL ret = FALSE; + + if (!osmesa_funcs) return FALSE; + if (!context) return osmesa_funcs->make_current( NULL, NULL, 0, 0, 0, 0 ); + + bitmap = NtGdiGetDCObject( hdc, NTGDI_OBJ_SURF ); + bmp = GDI_GetObjPtr( bitmap, NTGDI_OBJ_BITMAP ); + if (!bmp) return FALSE; + + if (init_dib_info_from_bitmapobj( &dib, bmp )) + { + char *bits; + int width = dib.rect.right - dib.rect.left; + int height = dib.rect.bottom - dib.rect.top; + + if (dib.stride < 0) bits = (char *)dib.bits.ptr + (dib.rect.bottom - 1) * dib.stride; + else bits = (char *)dib.bits.ptr + dib.rect.top * dib.stride; + bits += dib.rect.left * dib.bit_count / 8; + + TRACE( "context %p bits %p size %ux%u\n", context, bits, width, height ); + + ret = osmesa_funcs->make_current( context, bits, width, height, dib.bit_count, dib.stride ); + } + GDI_ReleaseObj( bitmap ); + return ret; +} + +static BOOL dibdrv_wglSetPixelFormat( HDC hdc, int fmt, const PIXELFORMATDESCRIPTOR *descr ) +{ + if (fmt <= 0 || fmt > ARRAY_SIZE( pixel_formats )) return FALSE; + return NtGdiSetPixelFormat( hdc, fmt ); +} + +static BOOL dibdrv_wglShareLists( struct wgl_context *org, struct wgl_context *dest ) +{ + FIXME( "not supported yet\n" ); + return FALSE; +} + +static BOOL dibdrv_wglSwapBuffers( HDC hdc ) +{ + return TRUE; +} + +static void dibdrv_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, + UINT *num_formats, UINT *num_onscreen_formats ) +{ + UINT i, num_pixel_formats = ARRAY_SIZE( pixel_formats ); + + for (i = 0; formats && i < min( max_formats, num_pixel_formats ); ++i) + describe_pixel_format( i + 1, &formats[i].pfd ); + + *num_formats = *num_onscreen_formats = num_pixel_formats; +} + +static struct opengl_funcs dibdrv_opengl_funcs = +{ + .wgl.p_wglCopyContext = dibdrv_wglCopyContext, + .wgl.p_wglCreateContext = dibdrv_wglCreateContext, + .wgl.p_wglDeleteContext = dibdrv_wglDeleteContext, + .wgl.p_wglGetPixelFormat = dibdrv_wglGetPixelFormat, + .wgl.p_wglGetProcAddress = dibdrv_wglGetProcAddress, + .wgl.p_wglMakeCurrent = dibdrv_wglMakeCurrent, + .wgl.p_wglSetPixelFormat = dibdrv_wglSetPixelFormat, + .wgl.p_wglShareLists = dibdrv_wglShareLists, + .wgl.p_wglSwapBuffers = dibdrv_wglSwapBuffers, + .wgl.p_get_pixel_formats = dibdrv_get_pixel_formats, +}; + +static struct opengl_funcs *dibdrv_get_wgl_driver(void) +{ + if (!osmesa_funcs && !(osmesa_funcs = init_opengl_lib())) + { + static int warned; + if (!warned++) ERR( "OSMesa not available, no OpenGL bitmap support\n" ); + return (void *)-1; + } + osmesa_funcs->get_gl_funcs( &dibdrv_opengl_funcs ); + return &dibdrv_opengl_funcs; +} + /*********************************************************************** * __wine_get_wgl_driver (win32u.@) */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/Makefile.in | 1 - dlls/win32u/dibdrv/dibdrv.h | 12 -- dlls/win32u/dibdrv/opengl.c | 229 ------------------------------------ dlls/win32u/opengl.c | 189 ++++++++++++++++++++++++++++- 4 files changed, 187 insertions(+), 244 deletions(-) delete mode 100644 dlls/win32u/dibdrv/opengl.c
diff --git a/dlls/win32u/Makefile.in b/dlls/win32u/Makefile.in index b849f0c202d..5c51e7d7275 100644 --- a/dlls/win32u/Makefile.in +++ b/dlls/win32u/Makefile.in @@ -25,7 +25,6 @@ SOURCES = \ dibdrv/dc.c \ dibdrv/graphics.c \ dibdrv/objects.c \ - dibdrv/opengl.c \ dibdrv/primitives.c \ driver.c \ emfdrv.c \ diff --git a/dlls/win32u/dibdrv/dibdrv.h b/dlls/win32u/dibdrv/dibdrv.h index 2fcc516e925..bf85d1dd24a 100644 --- a/dlls/win32u/dibdrv/dibdrv.h +++ b/dlls/win32u/dibdrv/dibdrv.h @@ -289,15 +289,3 @@ static inline const RGBQUAD *get_dib_color_table( const dib_info *dib ) { return dib->color_table ? dib->color_table : get_default_color_table( dib->bit_count ); } - -struct osmesa_funcs -{ - void (*get_gl_funcs)( struct opengl_funcs *funcs ); - struct wgl_context * (*create_context)( HDC hdc, const PIXELFORMATDESCRIPTOR *descr ); - BOOL (*delete_context)( struct wgl_context *context ); - PROC (*get_proc_address)( const char *proc ); - BOOL (*make_current)( struct wgl_context *context, void *bits, - int width, int height, int bpp, int stride ); -}; - -extern const struct osmesa_funcs *init_opengl_lib(void); diff --git a/dlls/win32u/dibdrv/opengl.c b/dlls/win32u/dibdrv/opengl.c deleted file mode 100644 index 5d3ee471497..00000000000 --- a/dlls/win32u/dibdrv/opengl.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * DIB driver OpenGL support - * - * Copyright 2012 Alexandre Julliard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#if 0 -#pragma makedep unix -#endif - -#include "config.h" - -#include <sys/types.h> -#include <dlfcn.h> - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "ntgdi_private.h" -#include "dibdrv.h" -#include "wine/wgl.h" -#include "wine/wgl_driver.h" - -#ifdef SONAME_LIBOSMESA - -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(dib); - -#define OSMESA_COLOR_INDEX GL_COLOR_INDEX -#define OSMESA_RGBA GL_RGBA -#define OSMESA_BGRA 0x1 -#define OSMESA_ARGB 0x2 -#define OSMESA_RGB GL_RGB -#define OSMESA_BGR 0x4 -#define OSMESA_RGB_565 0x5 -#define OSMESA_ROW_LENGTH 0x10 -#define OSMESA_Y_UP 0x11 - -typedef struct osmesa_context *OSMesaContext; - -struct wgl_context -{ - OSMesaContext context; - UINT format; -}; - -static struct opengl_funcs opengl_funcs; - -#define USE_GL_FUNC(name) #name, -static const char *opengl_func_names[] = { ALL_WGL_FUNCS }; -#undef USE_GL_FUNC - -static OSMesaContext (*pOSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, - GLint accumBits, OSMesaContext sharelist ); -static void (*pOSMesaDestroyContext)( OSMesaContext ctx ); -static void * (*pOSMesaGetProcAddress)( const char *funcName ); -static GLboolean (*pOSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type, - GLsizei width, GLsizei height ); -static void (*pOSMesaPixelStore)( GLint pname, GLint value ); - -static BOOL init_opengl(void) -{ - static BOOL init_done = FALSE; - static void *osmesa_handle; - unsigned int i; - - if (init_done) return (osmesa_handle != NULL); - init_done = TRUE; - - osmesa_handle = dlopen( SONAME_LIBOSMESA, RTLD_NOW ); - if (osmesa_handle == NULL) - { - ERR( "Failed to load OSMesa: %s\n", dlerror() ); - return FALSE; - } - -#define LOAD_FUNCPTR(f) do if (!(p##f = dlsym( osmesa_handle, #f ))) \ - { \ - ERR( "%s not found in %s (%s), disabling.\n", #f, SONAME_LIBOSMESA, dlerror() ); \ - goto failed; \ - } while(0) - - LOAD_FUNCPTR(OSMesaCreateContextExt); - LOAD_FUNCPTR(OSMesaDestroyContext); - LOAD_FUNCPTR(OSMesaGetProcAddress); - LOAD_FUNCPTR(OSMesaMakeCurrent); - LOAD_FUNCPTR(OSMesaPixelStore); -#undef LOAD_FUNCPTR - - for (i = 0; i < ARRAY_SIZE( opengl_func_names ); i++) - { - if (!(((void **)&opengl_funcs.gl)[i] = pOSMesaGetProcAddress( opengl_func_names[i] ))) - { - ERR( "%s not found in %s, disabling.\n", opengl_func_names[i], SONAME_LIBOSMESA ); - goto failed; - } - } - - return TRUE; - -failed: - dlclose( osmesa_handle ); - osmesa_handle = NULL; - return FALSE; -} - -/*********************************************************************** - * osmesa_get_gl_funcs - */ -static void osmesa_get_gl_funcs( struct opengl_funcs *funcs ) -{ - funcs->gl = opengl_funcs.gl; -} - -/*********************************************************************** - * osmesa_create_context - */ -static struct wgl_context * osmesa_create_context( HDC hdc, const PIXELFORMATDESCRIPTOR *descr ) -{ - struct wgl_context *context; - UINT gl_format; - - switch (descr->cColorBits) - { - case 32: - if (descr->cRedShift == 8) gl_format = OSMESA_ARGB; - else if (descr->cRedShift == 16) gl_format = OSMESA_BGRA; - else gl_format = OSMESA_RGBA; - break; - case 24: - gl_format = descr->cRedShift == 16 ? OSMESA_BGR : OSMESA_RGB; - break; - case 16: - gl_format = OSMESA_RGB_565; - break; - default: - return NULL; - } - if (!(context = malloc( sizeof( *context )))) return NULL; - context->format = gl_format; - if (!(context->context = pOSMesaCreateContextExt( gl_format, descr->cDepthBits, descr->cStencilBits, - descr->cAccumBits, 0 ))) - { - free( context ); - return NULL; - } - return context; -} - -/*********************************************************************** - * osmesa_delete_context - */ -static BOOL osmesa_delete_context( struct wgl_context *context ) -{ - pOSMesaDestroyContext( context->context ); - free( context ); - return TRUE; -} - -/*********************************************************************** - * osmesa_get_proc_address - */ -static PROC osmesa_get_proc_address( const char *proc ) -{ - return (PROC)pOSMesaGetProcAddress( proc ); -} - -/*********************************************************************** - * osmesa_make_current - */ -static BOOL osmesa_make_current( struct wgl_context *context, void *bits, - int width, int height, int bpp, int stride ) -{ - BOOL ret; - GLenum type; - - if (!context) - { - pOSMesaMakeCurrent( NULL, NULL, GL_UNSIGNED_BYTE, 0, 0 ); - return TRUE; - } - - type = context->format == OSMESA_RGB_565 ? GL_UNSIGNED_SHORT_5_6_5 : GL_UNSIGNED_BYTE; - ret = pOSMesaMakeCurrent( context->context, bits, type, width, height ); - if (ret) - { - pOSMesaPixelStore( OSMESA_ROW_LENGTH, abs( stride ) * 8 / bpp ); - pOSMesaPixelStore( OSMESA_Y_UP, 1 ); /* Windows seems to assume bottom-up */ - } - return ret; -} - -static const struct osmesa_funcs osmesa_funcs = -{ - osmesa_get_gl_funcs, - osmesa_create_context, - osmesa_delete_context, - osmesa_get_proc_address, - osmesa_make_current -}; - -const struct osmesa_funcs *init_opengl_lib(void) -{ - if (!init_opengl()) return NULL; - return &osmesa_funcs; -} - -#else /* SONAME_LIBOSMESA */ - -const struct osmesa_funcs *init_opengl_lib(void) -{ - return NULL; -} - -#endif /* SONAME_LIBOSMESA */ diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 1fd1a35b51e..68981c2cb7f 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1,4 +1,5 @@ /* + * Copyright 2012 Alexandre Julliard * Copyright 2025 Rémi Bernon for CodeWeavers * * This library is free software; you can redistribute it and/or @@ -23,6 +24,7 @@ #include "config.h"
#include <pthread.h> +#include <dlfcn.h>
#include "ntstatus.h" #define WIN32_NO_STATUS @@ -37,9 +39,192 @@
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
-static const struct osmesa_funcs *osmesa_funcs; +#ifdef SONAME_LIBOSMESA + +struct osmesa_funcs +{ + void (*get_gl_funcs)( struct opengl_funcs *funcs ); + struct wgl_context * (*create_context)( HDC hdc, const PIXELFORMATDESCRIPTOR *descr ); + BOOL (*delete_context)( struct wgl_context *context ); + PROC (*get_proc_address)( const char *proc ); + BOOL (*make_current)( struct wgl_context *context, void *bits, + int width, int height, int bpp, int stride ); +}; + +#define OSMESA_COLOR_INDEX GL_COLOR_INDEX +#define OSMESA_RGBA GL_RGBA +#define OSMESA_BGRA 0x1 +#define OSMESA_ARGB 0x2 +#define OSMESA_RGB GL_RGB +#define OSMESA_BGR 0x4 +#define OSMESA_RGB_565 0x5 +#define OSMESA_ROW_LENGTH 0x10 +#define OSMESA_Y_UP 0x11 + +typedef struct osmesa_context *OSMesaContext; + +struct wgl_context +{ + OSMesaContext context; + UINT format; +}; + +static struct opengl_funcs opengl_funcs; + +#define USE_GL_FUNC(name) #name, +static const char *opengl_func_names[] = { ALL_WGL_FUNCS }; +#undef USE_GL_FUNC + +static OSMesaContext (*pOSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, + GLint accumBits, OSMesaContext sharelist ); +static void (*pOSMesaDestroyContext)( OSMesaContext ctx ); +static void * (*pOSMesaGetProcAddress)( const char *funcName ); +static GLboolean (*pOSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type, + GLsizei width, GLsizei height ); +static void (*pOSMesaPixelStore)( GLint pname, GLint value ); + +static BOOL init_opengl(void) +{ + static BOOL init_done = FALSE; + static void *osmesa_handle; + unsigned int i; + + if (init_done) return (osmesa_handle != NULL); + init_done = TRUE; + + osmesa_handle = dlopen( SONAME_LIBOSMESA, RTLD_NOW ); + if (osmesa_handle == NULL) + { + ERR( "Failed to load OSMesa: %s\n", dlerror() ); + return FALSE; + } + +#define LOAD_FUNCPTR(f) do if (!(p##f = dlsym( osmesa_handle, #f ))) \ + { \ + ERR( "%s not found in %s (%s), disabling.\n", #f, SONAME_LIBOSMESA, dlerror() ); \ + goto failed; \ + } while(0) + + LOAD_FUNCPTR(OSMesaCreateContextExt); + LOAD_FUNCPTR(OSMesaDestroyContext); + LOAD_FUNCPTR(OSMesaGetProcAddress); + LOAD_FUNCPTR(OSMesaMakeCurrent); + LOAD_FUNCPTR(OSMesaPixelStore); +#undef LOAD_FUNCPTR + + for (i = 0; i < ARRAY_SIZE( opengl_func_names ); i++) + { + if (!(((void **)&opengl_funcs.gl)[i] = pOSMesaGetProcAddress( opengl_func_names[i] ))) + { + ERR( "%s not found in %s, disabling.\n", opengl_func_names[i], SONAME_LIBOSMESA ); + goto failed; + } + } + + return TRUE; + +failed: + dlclose( osmesa_handle ); + osmesa_handle = NULL; + return FALSE; +} + +static void osmesa_get_gl_funcs( struct opengl_funcs *funcs ) +{ + funcs->gl = opengl_funcs.gl; +} + +static struct wgl_context *osmesa_create_context( HDC hdc, const PIXELFORMATDESCRIPTOR *descr ) +{ + struct wgl_context *context; + UINT gl_format; + + switch (descr->cColorBits) + { + case 32: + if (descr->cRedShift == 8) gl_format = OSMESA_ARGB; + else if (descr->cRedShift == 16) gl_format = OSMESA_BGRA; + else gl_format = OSMESA_RGBA; + break; + case 24: + gl_format = descr->cRedShift == 16 ? OSMESA_BGR : OSMESA_RGB; + break; + case 16: + gl_format = OSMESA_RGB_565; + break; + default: + return NULL; + } + if (!(context = malloc( sizeof(*context) ))) return NULL; + context->format = gl_format; + if (!(context->context = pOSMesaCreateContextExt( gl_format, descr->cDepthBits, descr->cStencilBits, + descr->cAccumBits, 0 ))) + { + free( context ); + return NULL; + } + return context; +} + +static BOOL osmesa_delete_context( struct wgl_context *context ) +{ + pOSMesaDestroyContext( context->context ); + free( context ); + return TRUE; +} + +static PROC osmesa_get_proc_address( const char *proc ) +{ + return (PROC)pOSMesaGetProcAddress( proc ); +} + +static BOOL osmesa_make_current( struct wgl_context *context, void *bits, + int width, int height, int bpp, int stride ) +{ + BOOL ret; + GLenum type; + + if (!context) + { + pOSMesaMakeCurrent( NULL, NULL, GL_UNSIGNED_BYTE, 0, 0 ); + return TRUE; + }
-struct wgl_context; + type = context->format == OSMESA_RGB_565 ? GL_UNSIGNED_SHORT_5_6_5 : GL_UNSIGNED_BYTE; + ret = pOSMesaMakeCurrent( context->context, bits, type, width, height ); + if (ret) + { + pOSMesaPixelStore( OSMESA_ROW_LENGTH, abs( stride ) * 8 / bpp ); + pOSMesaPixelStore( OSMESA_Y_UP, 1 ); /* Windows seems to assume bottom-up */ + } + return ret; +} + +static const struct osmesa_funcs osmesa_funcs_table = +{ + osmesa_get_gl_funcs, + osmesa_create_context, + osmesa_delete_context, + osmesa_get_proc_address, + osmesa_make_current +}; + +static const struct osmesa_funcs *init_opengl_lib(void) +{ + if (!init_opengl()) return NULL; + return &osmesa_funcs_table; +} + +#else /* SONAME_LIBOSMESA */ + +static const struct osmesa_funcs *init_opengl_lib(void) +{ + return NULL; +} + +#endif /* SONAME_LIBOSMESA */ + +static const struct osmesa_funcs *osmesa_funcs;
static const struct {
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/opengl.c | 122 +++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 79 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 68981c2cb7f..1e9d60bbebd 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -41,16 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wgl);
#ifdef SONAME_LIBOSMESA
-struct osmesa_funcs -{ - void (*get_gl_funcs)( struct opengl_funcs *funcs ); - struct wgl_context * (*create_context)( HDC hdc, const PIXELFORMATDESCRIPTOR *descr ); - BOOL (*delete_context)( struct wgl_context *context ); - PROC (*get_proc_address)( const char *proc ); - BOOL (*make_current)( struct wgl_context *context, void *bits, - int width, int height, int bpp, int stride ); -}; - #define OSMESA_COLOR_INDEX GL_COLOR_INDEX #define OSMESA_RGBA GL_RGBA #define OSMESA_BGRA 0x1 @@ -69,7 +59,7 @@ struct wgl_context UINT format; };
-static struct opengl_funcs opengl_funcs; +static struct opengl_funcs osmesa_opengl_funcs;
#define USE_GL_FUNC(name) #name, static const char *opengl_func_names[] = { ALL_WGL_FUNCS }; @@ -114,7 +104,7 @@ static BOOL init_opengl(void)
for (i = 0; i < ARRAY_SIZE( opengl_func_names ); i++) { - if (!(((void **)&opengl_funcs.gl)[i] = pOSMesaGetProcAddress( opengl_func_names[i] ))) + if (!(((void **)&osmesa_opengl_funcs.gl)[i] = pOSMesaGetProcAddress( opengl_func_names[i] ))) { ERR( "%s not found in %s, disabling.\n", opengl_func_names[i], SONAME_LIBOSMESA ); goto failed; @@ -129,11 +119,6 @@ failed: return FALSE; }
-static void osmesa_get_gl_funcs( struct opengl_funcs *funcs ) -{ - funcs->gl = opengl_funcs.gl; -} - static struct wgl_context *osmesa_create_context( HDC hdc, const PIXELFORMATDESCRIPTOR *descr ) { struct wgl_context *context; @@ -200,32 +185,6 @@ static BOOL osmesa_make_current( struct wgl_context *context, void *bits, return ret; }
-static const struct osmesa_funcs osmesa_funcs_table = -{ - osmesa_get_gl_funcs, - osmesa_create_context, - osmesa_delete_context, - osmesa_get_proc_address, - osmesa_make_current -}; - -static const struct osmesa_funcs *init_opengl_lib(void) -{ - if (!init_opengl()) return NULL; - return &osmesa_funcs_table; -} - -#else /* SONAME_LIBOSMESA */ - -static const struct osmesa_funcs *init_opengl_lib(void) -{ - return NULL; -} - -#endif /* SONAME_LIBOSMESA */ - -static const struct osmesa_funcs *osmesa_funcs; - static const struct { BYTE color_bits; @@ -279,19 +238,18 @@ static void describe_pixel_format( int fmt, PIXELFORMATDESCRIPTOR *descr ) descr->iLayerType = PFD_MAIN_PLANE; }
-static BOOL dibdrv_wglCopyContext( struct wgl_context *src, struct wgl_context *dst, UINT mask ) +static BOOL osmesa_wglCopyContext( struct wgl_context *src, struct wgl_context *dst, UINT mask ) { FIXME( "not supported yet\n" ); return FALSE; }
-static BOOL dibdrv_wglDeleteContext( struct wgl_context *context ) +static BOOL osmesa_wglDeleteContext( struct wgl_context *context ) { - if (!osmesa_funcs) return FALSE; - return osmesa_funcs->delete_context( context ); + return osmesa_delete_context( context ); }
-static int dibdrv_wglGetPixelFormat( HDC hdc ) +static int osmesa_wglGetPixelFormat( HDC hdc ) { DC *dc = get_dc_ptr( hdc ); int ret = 0; @@ -304,35 +262,32 @@ static int dibdrv_wglGetPixelFormat( HDC hdc ) return ret; }
-static struct wgl_context *dibdrv_wglCreateContext( HDC hdc ) +static struct wgl_context *osmesa_wglCreateContext( HDC hdc ) { PIXELFORMATDESCRIPTOR descr; - int format = dibdrv_wglGetPixelFormat( hdc ); + int format = osmesa_wglGetPixelFormat( hdc );
if (!format) format = 1; if (format <= 0 || format > ARRAY_SIZE( pixel_formats )) return NULL; describe_pixel_format( format, &descr );
- if (!osmesa_funcs) return NULL; - return osmesa_funcs->create_context( hdc, &descr ); + return osmesa_create_context( hdc, &descr ); }
-static PROC dibdrv_wglGetProcAddress( const char *proc ) +static PROC osmesa_wglGetProcAddress( const char *proc ) { if (!strncmp( proc, "wgl", 3 )) return NULL; - if (!osmesa_funcs) return NULL; - return osmesa_funcs->get_proc_address( proc ); + return osmesa_get_proc_address( proc ); }
-static BOOL dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context ) +static BOOL osmesa_wglMakeCurrent( HDC hdc, struct wgl_context *context ) { HBITMAP bitmap; BITMAPOBJ *bmp; dib_info dib; BOOL ret = FALSE;
- if (!osmesa_funcs) return FALSE; - if (!context) return osmesa_funcs->make_current( NULL, NULL, 0, 0, 0, 0 ); + if (!context) return osmesa_make_current( NULL, NULL, 0, 0, 0, 0 );
bitmap = NtGdiGetDCObject( hdc, NTGDI_OBJ_SURF ); bmp = GDI_GetObjPtr( bitmap, NTGDI_OBJ_BITMAP ); @@ -350,30 +305,30 @@ static BOOL dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context )
TRACE( "context %p bits %p size %ux%u\n", context, bits, width, height );
- ret = osmesa_funcs->make_current( context, bits, width, height, dib.bit_count, dib.stride ); + ret = osmesa_make_current( context, bits, width, height, dib.bit_count, dib.stride ); } GDI_ReleaseObj( bitmap ); return ret; }
-static BOOL dibdrv_wglSetPixelFormat( HDC hdc, int fmt, const PIXELFORMATDESCRIPTOR *descr ) +static BOOL osmesa_wglSetPixelFormat( HDC hdc, int fmt, const PIXELFORMATDESCRIPTOR *descr ) { if (fmt <= 0 || fmt > ARRAY_SIZE( pixel_formats )) return FALSE; return NtGdiSetPixelFormat( hdc, fmt ); }
-static BOOL dibdrv_wglShareLists( struct wgl_context *org, struct wgl_context *dest ) +static BOOL osmesa_wglShareLists( struct wgl_context *org, struct wgl_context *dest ) { FIXME( "not supported yet\n" ); return FALSE; }
-static BOOL dibdrv_wglSwapBuffers( HDC hdc ) +static BOOL osmesa_wglSwapBuffers( HDC hdc ) { return TRUE; }
-static void dibdrv_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, +static void osmesa_get_pixel_formats( struct wgl_pixel_format *formats, UINT max_formats, UINT *num_formats, UINT *num_onscreen_formats ) { UINT i, num_pixel_formats = ARRAY_SIZE( pixel_formats ); @@ -384,32 +339,41 @@ static void dibdrv_get_pixel_formats( struct wgl_pixel_format *formats, UINT max *num_formats = *num_onscreen_formats = num_pixel_formats; }
-static struct opengl_funcs dibdrv_opengl_funcs = +static struct opengl_funcs osmesa_opengl_funcs = { - .wgl.p_wglCopyContext = dibdrv_wglCopyContext, - .wgl.p_wglCreateContext = dibdrv_wglCreateContext, - .wgl.p_wglDeleteContext = dibdrv_wglDeleteContext, - .wgl.p_wglGetPixelFormat = dibdrv_wglGetPixelFormat, - .wgl.p_wglGetProcAddress = dibdrv_wglGetProcAddress, - .wgl.p_wglMakeCurrent = dibdrv_wglMakeCurrent, - .wgl.p_wglSetPixelFormat = dibdrv_wglSetPixelFormat, - .wgl.p_wglShareLists = dibdrv_wglShareLists, - .wgl.p_wglSwapBuffers = dibdrv_wglSwapBuffers, - .wgl.p_get_pixel_formats = dibdrv_get_pixel_formats, + .wgl.p_wglCopyContext = osmesa_wglCopyContext, + .wgl.p_wglCreateContext = osmesa_wglCreateContext, + .wgl.p_wglDeleteContext = osmesa_wglDeleteContext, + .wgl.p_wglGetPixelFormat = osmesa_wglGetPixelFormat, + .wgl.p_wglGetProcAddress = osmesa_wglGetProcAddress, + .wgl.p_wglMakeCurrent = osmesa_wglMakeCurrent, + .wgl.p_wglSetPixelFormat = osmesa_wglSetPixelFormat, + .wgl.p_wglShareLists = osmesa_wglShareLists, + .wgl.p_wglSwapBuffers = osmesa_wglSwapBuffers, + .wgl.p_get_pixel_formats = osmesa_get_pixel_formats, };
-static struct opengl_funcs *dibdrv_get_wgl_driver(void) +static struct opengl_funcs *osmesa_get_wgl_driver(void) { - if (!osmesa_funcs && !(osmesa_funcs = init_opengl_lib())) + if (!init_opengl()) { static int warned; if (!warned++) ERR( "OSMesa not available, no OpenGL bitmap support\n" ); return (void *)-1; } - osmesa_funcs->get_gl_funcs( &dibdrv_opengl_funcs ); - return &dibdrv_opengl_funcs; + + return &osmesa_opengl_funcs; }
+#else /* SONAME_LIBOSMESA */ + +static struct opengl_funcs *osmesa_get_wgl_driver(void) +{ + return NULL; +} + +#endif /* SONAME_LIBOSMESA */ + /*********************************************************************** * __wine_get_wgl_driver (win32u.@) */ @@ -433,6 +397,6 @@ const struct opengl_funcs *__wine_get_wgl_driver( HDC hdc, UINT version )
if (is_disabled) return NULL; if (is_display) return user_driver->pwine_get_wgl_driver( version ); - if (is_memdc) return dibdrv_get_wgl_driver(); + if (is_memdc) return osmesa_get_wgl_driver(); return (void *)-1; }
Will the move include pbuffer handling too?