From 17dffaac7d5a8fc595775d456bb85e343d5aa195 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 10 Oct 2017 10:06:10 +0200 Subject: [PATCH] opengl32: Get WGL function definitions from the XML files. Signed-off-by: Alexandre Julliard --- dlls/gdi32/dibdrv/opengl.c | 4 +- dlls/opengl32/make_opengl | 147 +++++++++++++++++++--------------- dlls/opengl32/opengl32.spec | 5 +- dlls/opengl32/opengl_norm.c | 18 ++--- dlls/opengl32/winegl.xml | 14 ++++ dlls/wineandroid.drv/opengl.c | 4 +- dlls/winemac.drv/opengl.c | 4 +- dlls/winex11.drv/opengl.c | 4 +- include/wine/wgl_driver.h | 10 +-- 9 files changed, 122 insertions(+), 88 deletions(-) diff --git a/dlls/gdi32/dibdrv/opengl.c b/dlls/gdi32/dibdrv/opengl.c index 77d63201cf7..20cfc023980 100644 --- a/dlls/gdi32/dibdrv/opengl.c +++ b/dlls/gdi32/dibdrv/opengl.c @@ -214,10 +214,10 @@ static struct wgl_context *dibdrv_wglCreateContext( HDC hdc ) /*********************************************************************** * dibdrv_wglDeleteContext */ -static void dibdrv_wglDeleteContext( struct wgl_context *context ) +static BOOL dibdrv_wglDeleteContext( struct wgl_context *context ) { pOSMesaDestroyContext( context->context ); - HeapFree( GetProcessHeap(), 0, context ); + return HeapFree( GetProcessHeap(), 0, context ); } /*********************************************************************** diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index a3148d871a2..502b9aea290 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -180,7 +180,19 @@ my %arg_conv = "GLintptrARB" => [ "long", "INT_PTR" ], "GLsizeiptrARB" => [ "long", "INT_PTR" ], "GLhalfNV" => [ "long", "unsigned short" ], - "GLvdpauSurfaceNV" => [ "long", "INT_PTR" ]); + "GLvdpauSurfaceNV" => [ "long", "INT_PTR" ], + "HDC" => [ "long" ], + "HGLRC" => [ "long" ], + "HENHMETAFILE" => [ "long" ], + "LPGLYPHMETRICSFLOAT" => [ "ptr" ], + "LPCSTR" => [ "str" ], + "int" => [ "long" ], + "INT" => [ "long" ], + "BOOL" => [ "long" ], + "DWORD" => [ "long" ], + "FLOAT" => [ "float" ], + "UINT" => [ "long" ], + ); # # Used to convert some types @@ -358,9 +370,29 @@ sub generate_null_func($$) return $ret; } +sub generate_spec_entry($$) +{ + my ($name, $func) = @_; + my $args=" "; + foreach my $arg (@{$func->[1]}) + { + my $type = $arg->[0]; + if ($type =~ /\*/) { + $args .= "ptr "; + } elsif (defined($arg_conv{$type})) { + $args .= "$@$arg_conv{$type}[0] "; + } else { + die "No conversion for func $name type $type\n"; + } + } + $args = substr($args,1,-1); + return "@ stdcall $_($args)"; +} + sub get_func_proto($$$) { my ($format, $name, $func) = @_; + die "unknown func $name" unless defined $func->[0]; my $ret = sprintf "%-10s", ConvertType($func->[0]); $ret .= " " . sprintf($format,$name) . "("; for (my $i = 0; $i < @{$func->[1]}; $i++) @@ -445,29 +477,33 @@ if ($version eq "1.0") { # my %norm_functions; my %ext_functions; +my %wgl_functions; -my %wgl_functions = - ( - "wglCopyContext" => [ "BOOL", [ [ "struct wgl_context *", "src" ], - [ "struct wgl_context *", "dst" ], - [ "UINT", "mask" ] ] ], - "wglCreateContext" => [ "struct wgl_context *", [ [ "HDC", "hdc" ] ] ], - "wglDeleteContext" => [ "void", [ [ "struct wgl_context *", "context" ] ] ], - "wglDescribePixelFormat" => [ "INT", [ [ "HDC", "hdc" ], - [ "INT", "format" ], - [ "UINT", "size" ], - [ "PIXELFORMATDESCRIPTOR *", "descr" ] ] ], - "wglGetPixelFormat" => [ "INT", [ [ "HDC", "hdc" ] ] ], - "wglGetProcAddress" => [ "PROC", [ [ "LPCSTR", "name" ] ] ], - "wglMakeCurrent" => [ "BOOL", [ [ "HDC", "hdc" ], - [ "struct wgl_context *", "context" ] ] ], - "wglSetPixelFormat" => [ "BOOL", [ [ "HDC", "hdc" ], - [ "INT", "format" ], - [ "const PIXELFORMATDESCRIPTOR *", "descr" ] ] ], - "wglShareLists" => [ "BOOL", [ [ "struct wgl_context *", "org" ], - [ "struct wgl_context *", "dst" ] ] ], - "wglSwapBuffers" => [ "BOOL", [ [ "HDC", "hdc" ] ] ], - ); +my %supported_wgl_functions = + ( + "wglCopyContext" => 1, + "wglCreateContext" => 1, + "wglDeleteContext" => 1, + "wglDescribePixelFormat" => 1, + "wglGetPixelFormat" => 1, + "wglGetProcAddress" => 1, + "wglMakeCurrent" => 1, + "wglSetPixelFormat" => 1, + "wglShareLists" => 1, + "wglSwapBuffers" => 1, + ); + +my %remapped_wgl_functions = + ( + "ChoosePixelFormat" => "wglChoosePixelFormat", + "DescribePixelFormat" => "wglDescribePixelFormat", + "GetPixelFormat" => "wglGetPixelFormat", + "GetEnhMetaFilePixelFormat" => 0, + "SetPixelFormat" => "wglSetPixelFormat", + "SwapBuffers" => "wglSwapBuffers", + "wglUseFontBitmaps" => 0, + "wglUseFontOutlines" => 0, + ); my %supported_wgl_extensions = ( @@ -578,6 +614,19 @@ sub parse_file($$) } } } + elsif ($v->{api} eq "wgl") + { + for my $req (@{$v->{require}}) { + for (keys %{$req->{command}}) { + if (defined $remapped_wgl_functions{$_}) { + $wgl_functions{$remapped_wgl_functions{$_}} = $functions{$_} if $remapped_wgl_functions{$_}; + } + else { + $wgl_functions{$_} = $functions{$_}; + } + } + } + } } # generate extension functions @@ -643,6 +692,7 @@ print HEADER "struct opengl_funcs\n{\n"; print HEADER " struct\n {\n"; foreach (sort keys %wgl_functions) { + next unless defined $supported_wgl_functions{$_}; printf HEADER " %s;\n", get_func_proto("(WINE_GLAPI *p_%s)", $_, $wgl_functions{$_}); } print HEADER " } wgl;\n\n"; @@ -690,6 +740,7 @@ print HEADER "#endif\n\n"; foreach (sort keys %arg_conv) { + next unless $arg_conv{$_}[1]; printf HEADER "typedef %-22s %s;\n", $arg_conv{$_}[1], $_; } print HEADER "\n"; @@ -716,46 +767,11 @@ close HEADER; open(SPEC, ">$spec_file") or die "cannot create $spec_file"; foreach (sort keys %norm_functions) { - my $args=" "; - for (my $i = 0; $i < @{$norm_functions{$_}->[1]}; $i++) { - my $type = $norm_functions{$_}->[1]->[$i]->[0]; - if ($type =~ /\*/) { - $args .= "ptr "; - } elsif (defined($arg_conv{$type})) { - $args .= "$@$arg_conv{$type}[0] "; - } else { - die "No conversion for GL type $type...\n"; - } - } - $args = substr($args,1,-1); - print SPEC "@ stdcall $_($args)\n"; + printf SPEC "%s\n", generate_spec_entry( $_, $norm_functions{$_} ); +} +foreach (sort keys %wgl_functions) { + printf SPEC "%s\n", generate_spec_entry( $_, $wgl_functions{$_} ); } - -print SPEC "@ stdcall wglChoosePixelFormat(long ptr) -@ stdcall wglCopyContext(long long long) -@ stdcall wglCreateContext(long) -@ stdcall wglCreateLayerContext(long long) -@ stdcall wglDeleteContext(long) -@ stdcall wglDescribeLayerPlane(long long long long ptr) -@ stdcall wglDescribePixelFormat(long long long ptr) -@ stdcall wglGetCurrentContext() -@ stdcall wglGetCurrentDC() -@ stub wglGetDefaultProcAddress -@ stdcall wglGetLayerPaletteEntries(long long long long ptr) -@ stdcall wglGetPixelFormat(long) -@ stdcall wglGetProcAddress(str) -@ stdcall wglMakeCurrent(long long) -@ stdcall wglRealizeLayerPalette(long long long) -@ stdcall wglSetLayerPaletteEntries(long long long long ptr) -@ stdcall wglSetPixelFormat(long long ptr) -@ stdcall wglShareLists(long long) -@ stdcall wglSwapBuffers(long) -@ stdcall wglSwapLayerBuffers(long long) -@ stdcall wglUseFontBitmapsA(long long long long) -@ stdcall wglUseFontBitmapsW(long long long long) -@ stdcall wglUseFontOutlinesA(long long long long long long long ptr) -@ stdcall wglUseFontOutlinesW(long long long long long long long ptr) -"; close(SPEC); @@ -783,6 +799,7 @@ foreach (sort keys %norm_functions) { } foreach (sort keys %wgl_functions) { + next unless defined $supported_wgl_functions{$_}; print NORM generate_null_func($_, $wgl_functions{$_}); } foreach (sort keys %norm_functions) { @@ -793,7 +810,11 @@ foreach (sort keys %ext_functions) { } print NORM "\nstruct opengl_funcs null_opengl_funcs =\n{\n {\n"; -foreach (sort keys %wgl_functions) { print NORM " null_$_,\n"; } +foreach (sort keys %wgl_functions) +{ + next unless defined $supported_wgl_functions{$_}; + print NORM " null_$_,\n"; +} print NORM " },\n {\n"; foreach (sort keys %norm_functions) { print NORM " null_$_,\n" unless $_ eq "glDebugEntry"; } print NORM " },\n {\n"; diff --git a/dlls/opengl32/opengl32.spec b/dlls/opengl32/opengl32.spec index f620ac4f8fd..4d4288cd48e 100644 --- a/dlls/opengl32/opengl32.spec +++ b/dlls/opengl32/opengl32.spec @@ -344,7 +344,6 @@ @ stdcall wglDescribePixelFormat(long long long ptr) @ stdcall wglGetCurrentContext() @ stdcall wglGetCurrentDC() -@ stub wglGetDefaultProcAddress @ stdcall wglGetLayerPaletteEntries(long long long long ptr) @ stdcall wglGetPixelFormat(long) @ stdcall wglGetProcAddress(str) @@ -357,5 +356,5 @@ @ stdcall wglSwapLayerBuffers(long long) @ stdcall wglUseFontBitmapsA(long long long long) @ stdcall wglUseFontBitmapsW(long long long long) -@ stdcall wglUseFontOutlinesA(long long long long long long long ptr) -@ stdcall wglUseFontOutlinesW(long long long long long long long ptr) +@ stdcall wglUseFontOutlinesA(long long long long float float long ptr) +@ stdcall wglUseFontOutlinesW(long long long long float float long ptr) diff --git a/dlls/opengl32/opengl_norm.c b/dlls/opengl32/opengl_norm.c index d974cb4de07..1640b1708fc 100644 --- a/dlls/opengl32/opengl_norm.c +++ b/dlls/opengl32/opengl_norm.c @@ -2014,15 +2014,15 @@ void WINAPI glViewport( GLint x, GLint y, GLsizei width, GLsizei height ) { TRACE("(%d, %d, %d, %d)\n", x, y, width, height ); funcs->gl.p_glViewport( x, y, width, height ); } -static BOOL null_wglCopyContext( struct wgl_context * src, struct wgl_context * dst, UINT mask ) { return 0; } -static struct wgl_context * null_wglCreateContext( HDC hdc ) { return 0; } -static void null_wglDeleteContext( struct wgl_context * context ) { } -static INT null_wglDescribePixelFormat( HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr ) { return 0; } -static INT null_wglGetPixelFormat( HDC hdc ) { return 0; } -static PROC null_wglGetProcAddress( LPCSTR name ) { return 0; } -static BOOL null_wglMakeCurrent( HDC hdc, struct wgl_context * context ) { return 0; } -static BOOL null_wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR * descr ) { return 0; } -static BOOL null_wglShareLists( struct wgl_context * org, struct wgl_context * dst ) { return 0; } +static BOOL null_wglCopyContext( struct wgl_context * hglrcSrc, struct wgl_context * hglrcDst, UINT mask ) { return 0; } +static struct wgl_context * null_wglCreateContext( HDC hDc ) { return 0; } +static BOOL null_wglDeleteContext( struct wgl_context * oldContext ) { return 0; } +static int null_wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR* ppfd ) { return 0; } +static int null_wglGetPixelFormat( HDC hdc ) { return 0; } +static PROC null_wglGetProcAddress( LPCSTR lpszProc ) { return 0; } +static BOOL null_wglMakeCurrent( HDC hDc, struct wgl_context * newContext ) { return 0; } +static BOOL null_wglSetPixelFormat( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR* ppfd ) { return 0; } +static BOOL null_wglShareLists( struct wgl_context * hrcSrvShare, struct wgl_context * hrcSrvSource ) { return 0; } static BOOL null_wglSwapBuffers( HDC hdc ) { return 0; } static void null_glAccum( GLenum op, GLfloat value ) { } static void null_glAlphaFunc( GLenum func, GLfloat ref ) { } diff --git a/dlls/opengl32/winegl.xml b/dlls/opengl32/winegl.xml index 683e910a1a3..2461d35825a 100644 --- a/dlls/opengl32/winegl.xml +++ b/dlls/opengl32/winegl.xml @@ -275,6 +275,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + + int wglDescribePixelFormat + HDC hdc + int ipfd + UINT cjpfd + + PIXELFORMATDESCRIPTOR *ppfd + BOOL wglSetPixelFormatWINE HDC hdc @@ -310,6 +318,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index ec26000cbb2..d6cd93b38c2 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -439,13 +439,13 @@ static struct wgl_context *android_wglCreateContext( HDC hdc ) /*********************************************************************** * android_wglDeleteContext */ -static void android_wglDeleteContext( struct wgl_context *ctx ) +static BOOL android_wglDeleteContext( struct wgl_context *ctx ) { EnterCriticalSection( &drawable_section ); list_remove( &ctx->entry ); LeaveCriticalSection( &drawable_section ); p_eglDestroyContext( display, ctx->context ); - HeapFree( GetProcessHeap(), 0, ctx ); + return HeapFree( GetProcessHeap(), 0, ctx ); } /*********************************************************************** diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 6e1f151e019..a7a67deea02 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -4434,7 +4434,7 @@ static struct wgl_context *macdrv_wglCreateContext(HDC hdc) /*********************************************************************** * macdrv_wglDeleteContext */ -static void macdrv_wglDeleteContext(struct wgl_context *context) +static BOOL macdrv_wglDeleteContext(struct wgl_context *context) { TRACE("deleting context %p/%p/%p\n", context, context->context, context->cglcontext); @@ -4443,7 +4443,7 @@ static void macdrv_wglDeleteContext(struct wgl_context *context) LeaveCriticalSection(&context_section); macdrv_dispose_opengl_context(context->context); - HeapFree(GetProcessHeap(), 0, context); + return HeapFree(GetProcessHeap(), 0, context); } /*********************************************************************** diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 5eb70a86928..f9faa4b3aac 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1841,7 +1841,7 @@ static struct wgl_context *glxdrv_wglCreateContext( HDC hdc ) /*********************************************************************** * glxdrv_wglDeleteContext */ -static void glxdrv_wglDeleteContext(struct wgl_context *ctx) +static BOOL glxdrv_wglDeleteContext(struct wgl_context *ctx) { struct wgl_pbuffer *pb; @@ -1860,7 +1860,7 @@ static void glxdrv_wglDeleteContext(struct wgl_context *ctx) if (ctx->ctx) pglXDestroyContext( gdi_display, ctx->ctx ); if (ctx->vis) XFree( ctx->vis ); - HeapFree( GetProcessHeap(), 0, ctx ); + return HeapFree( GetProcessHeap(), 0, ctx ); } /*********************************************************************** diff --git a/include/wine/wgl_driver.h b/include/wine/wgl_driver.h index 16997e46795..753d13425b2 100644 --- a/include/wine/wgl_driver.h +++ b/include/wine/wgl_driver.h @@ -7,7 +7,7 @@ #define WINE_GLAPI #endif -#define WINE_WGL_DRIVER_VERSION 16 +#define WINE_WGL_DRIVER_VERSION 17 struct wgl_context; struct wgl_pbuffer; @@ -18,12 +18,12 @@ struct opengl_funcs { BOOL (WINE_GLAPI *p_wglCopyContext)(struct wgl_context *,struct wgl_context *,UINT); struct wgl_context * (WINE_GLAPI *p_wglCreateContext)(HDC); - void (WINE_GLAPI *p_wglDeleteContext)(struct wgl_context *); - INT (WINE_GLAPI *p_wglDescribePixelFormat)(HDC,INT,UINT,PIXELFORMATDESCRIPTOR *); - INT (WINE_GLAPI *p_wglGetPixelFormat)(HDC); + BOOL (WINE_GLAPI *p_wglDeleteContext)(struct wgl_context *); + int (WINE_GLAPI *p_wglDescribePixelFormat)(HDC,int,UINT,PIXELFORMATDESCRIPTOR*); + int (WINE_GLAPI *p_wglGetPixelFormat)(HDC); PROC (WINE_GLAPI *p_wglGetProcAddress)(LPCSTR); BOOL (WINE_GLAPI *p_wglMakeCurrent)(HDC,struct wgl_context *); - BOOL (WINE_GLAPI *p_wglSetPixelFormat)(HDC,INT,const PIXELFORMATDESCRIPTOR *); + BOOL (WINE_GLAPI *p_wglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*); BOOL (WINE_GLAPI *p_wglShareLists)(struct wgl_context *,struct wgl_context *); BOOL (WINE_GLAPI *p_wglSwapBuffers)(HDC); } wgl;