opengl32: Get type definitions from the XML files.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl
index 480ad68..dc30df5 100755
--- a/dlls/opengl32/make_opengl
+++ b/dlls/opengl32/make_opengl
@@ -83,140 +83,80 @@
 my %norm_categories = ();
 
 #
-# This hash table gives the conversion between OpenGL types and what
-# is used by the TRACE printfs
+# This hash table gives the conversion between OpenGL types and
+# the .spec type and debug format
 #
-my %debug_conv =
-    ("GLbitfield" => "%d",
-     "GLboolean" => "%d",
-     "GLbyte" => "%d",
-     "GLclampd" => "%f",
-     "GLclampf" => "%f",
-     "GLclampx" => "%d",
-     "GLdouble" => "%f",
-     "GLenum" => "%d",
-     "GLfloat" => "%f",
-     "GLfixed" => "%d",
-     "GLint" => "%d",
-     "GLshort" => "%d",
-     "GLsizei" => "%d",
-     "GLstring" => "%s",
-     "GLsync" => "%p",
-     "GLubyte" => "%d",
-     "GLuint" => "%d",
-     "GLushort" => "%d",
-     "GLhalfNV" => "%d",
-     "GLintptrARB" => "%ld",
-     "GLsizeiptrARB" => "%ld",
-     "GLintptr" => "%ld",
-     "GLsizeiptr" => "%ld",
-     "GLhandleARB" => "%d",
-     "GLcharARB" => "%c",
-     "GLuint64" => "%s,wine_dbgstr_longlong(%s)",
-     "GLint64" => "%s,wine_dbgstr_longlong(%s)",
-     "GLuint64EXT" => "%s,wine_dbgstr_longlong(%s)",
-     "GLint64EXT" => "%s,wine_dbgstr_longlong(%s)",
-     "GLvoid" => "(void)",
-     "_GLfuncptr" => "%p",
-     "GLDEBUGPROC" => "%p",
-     "GLDEBUGPROCARB" => "%p",
-     "GLDEBUGPROCAMD" => "%p",
-     "GLDEBUGPROCKHR" => "%p",
-     "GLeglClientBufferEXT" => "%p",
-     "GLvdpauSurfaceNV" => "%ld",
-     "GLVULKANPROCNV" => "%p",
-     "int" => "%d",
-     "unsigned int" => "%u",
-     "UINT" => "%u",
-     "DWORD" => "%u",
-     "BOOL" => "%u",
-     "INT64" => "%s,wine_dbgstr_longlong(%s)",
-     "UINT64" => "%s,wine_dbgstr_longlong(%s)",
-     "LPVOID" => "%p",
-     "HANDLE" => "%p",
-     "HDC" => "%p",
-     "HGLRC" => "%p",
-     "HPBUFFERARB" => "%p",
-     "HPBUFFEREXT" => "%p",
+my %arg_types =
+    (
+     "GLbitfield" =>           [ "long",   "%d" ],
+     "GLboolean" =>            [ "long",   "%d" ],
+     "GLbyte" =>               [ "long",   "%d" ],
+     "GLchar" =>               [ "long",   "%c" ],
+     "GLcharARB" =>            [ "long",   "%c" ],
+     "GLclampd" =>             [ "double", "%f" ],
+     "GLclampf" =>             [ "float",  "%f" ],
+     "GLclampx" =>             [ "long",   "%d" ],
+     "GLdouble" =>             [ "double", "%f" ],
+     "GLeglClientBufferEXT" => [ "ptr",    "%p" ],
+     "GLenum" =>               [ "long",   "%d" ],
+     "GLfixed" =>              [ "long",   "%d" ],
+     "GLfloat" =>              [ "float",  "%f" ],
+     "GLhalfNV" =>             [ "long",   "%d" ],
+     "GLhandleARB" =>          [ "long",   "%d" ],
+     "GLint" =>                [ "long",   "%d" ],
+     "GLint64" =>              [ "int64",  "wine_dbgstr_longlong(%s)" ],
+     "GLint64EXT" =>           [ "int64",  "wine_dbgstr_longlong(%s)" ],
+     "GLintptr" =>             [ "long",   "%ld" ],
+     "GLintptrARB" =>          [ "long",   "%ld" ],
+     "GLshort" =>              [ "long",   "%d" ],
+     "GLsizei" =>              [ "long",   "%d" ],
+     "GLsizeiptr" =>           [ "long",   "%ld" ],
+     "GLsizeiptrARB" =>        [ "long",   "%ld" ],
+     "GLstring" =>             [ "str",    "wine_dbgstr_a(%s)" ],
+     "GLsync" =>               [ "ptr",    "%p" ],
+     "GLubyte" =>              [ "long",   "%d" ],
+     "GLuint" =>               [ "long",   "%d" ],
+     "GLuint64" =>             [ "int64",  "wine_dbgstr_longlong(%s)" ],
+     "GLuint64EXT" =>          [ "int64",  "wine_dbgstr_longlong(%s)" ],
+     "GLushort" =>             [ "long",   "%d" ],
+     "GLvdpauSurfaceNV" =>     [ "long",   "%ld" ],
+     "GLDEBUGPROC" =>          [ "ptr",    "%p" ],
+     "GLDEBUGPROCARB" =>       [ "ptr",    "%p" ],
+     "GLDEBUGPROCAMD" =>       [ "ptr",    "%p" ],
+     "GLDEBUGPROCKHR" =>       [ "ptr",    "%p" ],
+     "GLVULKANPROCNV" =>       [ "ptr",    "%p" ],
+     "HDC" =>                  [ "long",   "%p" ],
+     "HGLRC" =>                [ "long",   "%p" ],
+     "HPBUFFERARB" =>          [ "long",   "%p" ],
+     "HENHMETAFILE" =>         [ "long",   "%p" ],
+     "LPGLYPHMETRICSFLOAT" =>  [ "ptr",    "%p" ],
+     "LPCSTR" =>               [ "str",    "wine_dbgstr_a(%s)" ],
+     "UINT" =>                 [ "long",   "%u" ],
+     "DWORD" =>                [ "long",   "%u" ],
+     "BOOL" =>                 [ "long",   "%u" ],
+     "FLOAT" =>                [ "float",  "%f" ],
     );
 
-#
-# This hash table gives the conversion between OpenGL types and what
-# is used in the .spec and header files.
-#
-my %arg_conv =
-    ("GLbitfield" =>       [ "long", "unsigned int" ],
-     "GLboolean" =>        [ "long", "unsigned char" ],
-     "GLbyte" =>           [ "long", "signed char" ],
-     "GLchar" =>           [ "long", "char" ],
-     "GLclampd" =>         [ "double", "double" ],
-     "GLclampf" =>         [ "float", "float" ],
-     "GLclampx" =>         [ "long", "int" ],
-     "GLdouble" =>         [ "double", "double" ],
-     "GLenum" =>           [ "long", "unsigned int" ],
-     "GLfloat" =>          [ "float", "float" ],
-     "GLfixed" =>          [ "long", "int" ],
-     "GLint" =>            [ "long", "int" ],
-     "GLint64" =>          [ "int64", "INT64" ],
-     "GLint64EXT" =>       [ "int64", "INT64" ],
-     "GLintptr" =>         [ "long", "INT_PTR" ],
-     "GLshort" =>          [ "long", "short" ],
-     "GLsizei" =>          [ "long", "int" ],
-     "GLsizeiptr" =>       [ "long", "INT_PTR" ],
-     "GLstring" =>         [ "str", "const unsigned char *" ],
-     "GLsync" =>           [ "ptr", "struct __GLsync *" ],
-     "GLubyte" =>          [ "long", "unsigned char" ],
-     "GLuint" =>           [ "long", "unsigned int" ],
-     "GLuint64" =>         [ "int64", "UINT64" ],
-     "GLuint64EXT" =>      [ "int64", "UINT64" ],
-     "GLushort" =>         [ "long", "unsigned short" ],
-     "GLvoid" =>           [ "void", "void" ],
-     "GLcharARB" =>        [ "long", "char" ],
-     "GLhandleARB" =>      [ "long", "unsigned int" ],
-     "GLintptrARB" =>      [ "long", "INT_PTR" ],
-     "GLsizeiptrARB" =>    [ "long", "INT_PTR" ],
-     "GLhalfNV" =>         [ "long", "unsigned short" ],
-     "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" ],
+my %remap_types =
+    (
+     "HGLRC" => "struct wgl_context *",
+     "HPBUFFERARB" => "struct wgl_pbuffer *",
     );
-
 #
 # Used to convert some types
 #
 sub ConvertType($)
 {
-    my ($type) = @_;
+    my $arg = shift;
+    my $ret = $arg->textContent();
+    my @type = $arg->findnodes("./ptype");
 
-    my %hash = (
-              "struct _cl_context" => "void",
-              "struct _cl_event" => "void",
-              "HGLRC" => "struct wgl_context *",
-              "GLDEBUGPROC" => "void *",
-              "GLDEBUGPROCARB" => "void *",
-              "GLDEBUGPROCAMD" => "void *",
-              "GLDEBUGPROCKHR" => "void *",
-              "GLeglClientBufferEXT" => "void *",
-              "GLVULKANPROCNV" => "void *",
-              "HPBUFFERARB" => "struct wgl_pbuffer *",
-              "HPBUFFEREXT" => "struct wgl_pbuffer *",
-        );
-
-    foreach my $org (reverse sort keys %hash) {
-        if ($type =~ /^(.*)$org(.*)$/) {
-            return "$1$hash{$org}$2";
-        }
+    if (@type)
+    {
+        my $type = $type[0]->textContent();
+        $ret =~ s/$type/$remap_types{$type}/ if defined $remap_types{$type};
     }
-    return $type;
+    return $ret;
 }
 
 #
@@ -241,22 +181,17 @@
         my $param = $arg->textContent();
         $call_arg .= " " . $pname . ",";
         if ($param =~ /\*/ || $param =~ /\[/) {
-            $trace_arg .= "%p";
+            $trace_arg .= ", %p";
             $trace_call_arg .= ", " . $pname;
-        } elsif (defined $debug_conv{$ptype}) {
-            if ($debug_conv{$ptype} =~ /(.*),(.*)/) {
-                $trace_arg .= $1;
-                $trace_call_arg .= ", " . sprintf $2, $pname;
-            } else {
-                $trace_arg .= $debug_conv{$ptype};
-                $trace_call_arg .= ", " . $pname;
-            }
+        } elsif (defined $arg_types{$ptype}) {
+            my $format = ${$arg_types{$ptype}}[1];
+            $trace_arg .= ", " . ($format =~ /^%/ ? $format : "%s");
+            $trace_call_arg .= ", " . sprintf $format =~ /^%/ ? "%s" : $format, $pname;
         }
         else { printf "Unknown type %s in %s\n", $param, $name; }
-        $trace_arg .= ", ";
     }
     $call_arg =~ s/,$/ /;
-    $trace_arg =~ s/, $//;
+    $trace_arg =~ s/^, //;
     return "$ret DECLSPEC_HIDDEN;\n" if $name eq "glGetStringi";
     $ret .= "\n{\n  const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;\n";
     $ret .= "  TRACE( \"($trace_arg)\\n\"$trace_call_arg );\n" if $gen_traces;
@@ -264,8 +199,6 @@
     $ret .= "return " unless is_void_func( $func_ref );
     $ret .= "funcs->$prefix.p_$name($call_arg);\n";
     $ret .= "}\n";
-
-    # Return this string....
     return $ret;
 }
 
@@ -300,8 +233,8 @@
         my $param = $arg->textContent();
         if ($param =~ /[[*]/) {
             $args .= "ptr ";
-        } elsif (defined($arg_conv{$ptype})) {
-            $args .= "$@$arg_conv{$ptype}[0] ";
+        } elsif (defined($arg_types{$ptype})) {
+            $args .= "$@$arg_types{$ptype}[0] ";
         } else {
             die "No conversion for func $name type $param\n";
         }
@@ -335,12 +268,12 @@
 {
     my ($format, $name, $func) = @_;
     die "unknown func $name" unless defined $func->[0];
-    my $proto = ConvertType( $func->[0]->textContent() );
+    my $proto = ConvertType( $func->[0] );
     $proto =~ s/ $//;
     my $args = "";
     foreach my $arg (@{$func->[1]})
     {
-        $args .= " " . ConvertType( $arg->textContent() ) . ",";
+        $args .= " " . ConvertType( $arg ) . ",";
     }
     $args =~ s/,$/ /;
     $args ||= "void";
@@ -396,6 +329,7 @@
 my %norm_functions;
 my %ext_functions;
 my %wgl_functions;
+my (%gl_types, @gl_types);  # also use an array to preserve declaration order
 
 my %supported_wgl_functions =
     (
@@ -480,6 +414,17 @@
         }
     }
 
+    # save all types
+    foreach my $type ($xml->findnodes("/registry/types/type"))
+    {
+        next if $type->{api};
+        my $name = @{$type->findnodes("./name")}[0];
+        next unless $name;
+        $name = $name->textContent;
+        push @gl_types, $name unless $gl_types{$name};
+        $gl_types{$name} = $type;
+    }
+
     # generate norm functions
     foreach my $feature ($xml->findnodes("/registry/feature"))
     {
@@ -636,10 +581,9 @@
 print HEADER "#undef near\n";
 print HEADER "#undef far\n\n";
 
-foreach (sort keys %arg_conv)
+foreach (@gl_types)
 {
-    next unless $arg_conv{$_}[1];
-    printf HEADER "typedef %-22s %s;\n", $arg_conv{$_}[1], $_;
+    printf HEADER $gl_types{$_}->textContent() . "\n";
 }
 print HEADER "\n";
 
diff --git a/dlls/opengl32/opengl_ext.c b/dlls/opengl32/opengl_ext.c
index 7b22e68..91aa33d 100644
--- a/dlls/opengl32/opengl_ext.c
+++ b/dlls/opengl32/opengl_ext.c
@@ -940,7 +940,7 @@
   funcs->ext.p_glBufferStorage( target, size, data, flags );
 }
 
-static void WINAPI glBufferStorageExternalEXT( GLenum target, GLintptr offset, GLsizeiptr size, void * clientBuffer, GLbitfield flags )
+static void WINAPI glBufferStorageExternalEXT( GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags )
 {
   const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
   TRACE( "(%d, %ld, %ld, %p, %d)\n", target, offset, size, clientBuffer, flags );
@@ -2270,7 +2270,7 @@
   funcs->ext.p_glCreateStatesNV( n, states );
 }
 
-static GLsync WINAPI glCreateSyncFromCLeventARB( void *context, void *event, GLbitfield flags )
+static GLsync WINAPI glCreateSyncFromCLeventARB( struct _cl_context *context, struct _cl_event *event, GLbitfield flags )
 {
   const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
   TRACE( "(%p, %p, %d)\n", context, event, flags );
@@ -2319,21 +2319,21 @@
   funcs->ext.p_glCurrentPaletteMatrixARB( index );
 }
 
-static void WINAPI glDebugMessageCallback( void * callback, const void *userParam )
+static void WINAPI glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam )
 {
   const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
   TRACE( "(%p, %p)\n", callback, userParam );
   funcs->ext.p_glDebugMessageCallback( callback, userParam );
 }
 
-static void WINAPI glDebugMessageCallbackAMD( void * callback, void *userParam )
+static void WINAPI glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam )
 {
   const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
   TRACE( "(%p, %p)\n", callback, userParam );
   funcs->ext.p_glDebugMessageCallbackAMD( callback, userParam );
 }
 
-static void WINAPI glDebugMessageCallbackARB( void * callback, const void *userParam )
+static void WINAPI glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam )
 {
   const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
   TRACE( "(%p, %p)\n", callback, userParam );
@@ -6836,7 +6836,7 @@
   funcs->ext.p_glGetVideouivNV( video_slot, pname, params );
 }
 
-static void * WINAPI glGetVkProcAddrNV( const GLchar *name )
+static GLVULKANPROCNV WINAPI glGetVkProcAddrNV( const GLchar *name )
 {
   const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
   TRACE( "(%p)\n", name );
@@ -9804,7 +9804,7 @@
   funcs->ext.p_glNamedBufferStorageEXT( buffer, size, data, flags );
 }
 
-static void WINAPI glNamedBufferStorageExternalEXT( GLuint buffer, GLintptr offset, GLsizeiptr size, void * clientBuffer, GLbitfield flags )
+static void WINAPI glNamedBufferStorageExternalEXT( GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags )
 {
   const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
   TRACE( "(%d, %ld, %ld, %p, %d)\n", buffer, offset, size, clientBuffer, flags );
diff --git a/dlls/opengl32/opengl_norm.c b/dlls/opengl32/opengl_norm.c
index ca0a3ac..bebea25 100644
--- a/dlls/opengl32/opengl_norm.c
+++ b/dlls/opengl32/opengl_norm.c
@@ -2826,7 +2826,7 @@
 static void null_glBufferParameteriAPPLE( GLenum target, GLenum pname, GLint param ) { }
 static GLuint null_glBufferRegionEnabled(void) { return 0; }
 static void null_glBufferStorage( GLenum target, GLsizeiptr size, const void *data, GLbitfield flags ) { }
-static void null_glBufferStorageExternalEXT( GLenum target, GLintptr offset, GLsizeiptr size, void * clientBuffer, GLbitfield flags ) { }
+static void null_glBufferStorageExternalEXT( GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags ) { }
 static void null_glBufferStorageMemEXT( GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset ) { }
 static void null_glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const void *data ) { }
 static void null_glBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data ) { }
@@ -3016,16 +3016,16 @@
 static GLuint null_glCreateShaderProgramEXT( GLenum type, const GLchar *string ) { return 0; }
 static GLuint null_glCreateShaderProgramv( GLenum type, GLsizei count, const GLchar *const*strings ) { return 0; }
 static void null_glCreateStatesNV( GLsizei n, GLuint *states ) { }
-static GLsync null_glCreateSyncFromCLeventARB( void *context, void *event, GLbitfield flags ) { return 0; }
+static GLsync null_glCreateSyncFromCLeventARB( struct _cl_context *context, struct _cl_event *event, GLbitfield flags ) { return 0; }
 static void null_glCreateTextures( GLenum target, GLsizei n, GLuint *textures ) { }
 static void null_glCreateTransformFeedbacks( GLsizei n, GLuint *ids ) { }
 static void null_glCreateVertexArrays( GLsizei n, GLuint *arrays ) { }
 static void null_glCullParameterdvEXT( GLenum pname, GLdouble *params ) { }
 static void null_glCullParameterfvEXT( GLenum pname, GLfloat *params ) { }
 static void null_glCurrentPaletteMatrixARB( GLint index ) { }
-static void null_glDebugMessageCallback( void * callback, const void *userParam ) { }
-static void null_glDebugMessageCallbackAMD( void * callback, void *userParam ) { }
-static void null_glDebugMessageCallbackARB( void * callback, const void *userParam ) { }
+static void null_glDebugMessageCallback( GLDEBUGPROC callback, const void *userParam ) { }
+static void null_glDebugMessageCallbackAMD( GLDEBUGPROCAMD callback, void *userParam ) { }
+static void null_glDebugMessageCallbackARB( GLDEBUGPROCARB callback, const void *userParam ) { }
 static void null_glDebugMessageControl( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled ) { }
 static void null_glDebugMessageControlARB( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled ) { }
 static void null_glDebugMessageEnableAMD( GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled ) { }
@@ -3669,7 +3669,7 @@
 static void null_glGetVideoivNV( GLuint video_slot, GLenum pname, GLint *params ) { }
 static void null_glGetVideoui64vNV( GLuint video_slot, GLenum pname, GLuint64EXT *params ) { }
 static void null_glGetVideouivNV( GLuint video_slot, GLenum pname, GLuint *params ) { }
-static void * null_glGetVkProcAddrNV( const GLchar *name ) { return 0; }
+static GLVULKANPROCNV null_glGetVkProcAddrNV( const GLchar *name ) { return 0; }
 static void null_glGetnColorTable( GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table ) { }
 static void null_glGetnColorTableARB( GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table ) { }
 static void null_glGetnCompressedTexImage( GLenum target, GLint lod, GLsizei bufSize, void *pixels ) { }
@@ -4093,7 +4093,7 @@
 static void null_glNamedBufferPageCommitmentEXT( GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit ) { }
 static void null_glNamedBufferStorage( GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags ) { }
 static void null_glNamedBufferStorageEXT( GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags ) { }
-static void null_glNamedBufferStorageExternalEXT( GLuint buffer, GLintptr offset, GLsizeiptr size, void * clientBuffer, GLbitfield flags ) { }
+static void null_glNamedBufferStorageExternalEXT( GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags ) { }
 static void null_glNamedBufferStorageMemEXT( GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset ) { }
 static void null_glNamedBufferSubData( GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data ) { }
 static void null_glNamedBufferSubDataEXT( GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data ) { }
diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c
index dc15147..4b91842 100644
--- a/dlls/opengl32/tests/opengl.c
+++ b/dlls/opengl32/tests/opengl.c
@@ -24,7 +24,6 @@
 #include "wine/wgl.h"
 
 #define MAX_FORMATS 256
-DECLARE_HANDLE(HPBUFFERARB);
 
 /* WGL_ARB_create_context */
 static HGLRC (WINAPI *pwglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext, const int *attribList);
diff --git a/dlls/opengl32/winegl.xml b/dlls/opengl32/winegl.xml
index 2461d35..7918c3f 100644
--- a/dlls/opengl32/winegl.xml
+++ b/dlls/opengl32/winegl.xml
@@ -22,6 +22,24 @@
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
     </comment>
 
+    <types>
+        <!-- Override some types for Win32 API -->
+        <type>typedef INT_PTR <name>GLintptr</name>;</type>
+        <type>typedef INT_PTR <name>GLsizeiptr</name>;</type>
+        <type>typedef INT64 <name>GLint64</name>;</type>
+        <type>typedef UINT64 <name>GLuint64</name>;</type>
+        <type>typedef INT_PTR <name>GLintptrARB</name>;</type>
+        <type>typedef INT_PTR <name>GLsizeiptrARB</name>;</type>
+        <type>typedef INT64 <name>GLint64EXT</name>;</type>
+        <type>typedef UINT64 <name>GLuint64EXT</name>;</type>
+        <type>typedef unsigned int <name>GLhandleARB</name>;</type>
+        <type>typedef void *<name>GLDEBUGPROC</name>;</type>
+        <type>typedef void *<name>GLDEBUGPROCAMD</name>;</type>
+        <type>typedef void *<name>GLDEBUGPROCARB</name>;</type>
+        <type>typedef void *<name>GLDEBUGPROCKHR</name>;</type>
+        <type>typedef void *<name>GLVULKANPROCNV</name>;</type>
+    </types>
+
     <commands namespace="GL">
         <command>
             <proto>GLint <name>glDebugEntry</name></proto>
diff --git a/include/wine/wgl.h b/include/wine/wgl.h
index 1978183..4c146c2 100644
--- a/include/wine/wgl.h
+++ b/include/wine/wgl.h
@@ -10,38 +10,64 @@
 #undef near
 #undef far
 
-typedef unsigned int           GLbitfield;
-typedef unsigned char          GLboolean;
-typedef signed char            GLbyte;
-typedef char                   GLchar;
-typedef char                   GLcharARB;
-typedef double                 GLclampd;
-typedef float                  GLclampf;
-typedef int                    GLclampx;
-typedef double                 GLdouble;
-typedef unsigned int           GLenum;
-typedef int                    GLfixed;
-typedef float                  GLfloat;
-typedef unsigned short         GLhalfNV;
-typedef unsigned int           GLhandleARB;
-typedef int                    GLint;
-typedef INT64                  GLint64;
-typedef INT64                  GLint64EXT;
-typedef INT_PTR                GLintptr;
-typedef INT_PTR                GLintptrARB;
-typedef short                  GLshort;
-typedef int                    GLsizei;
-typedef INT_PTR                GLsizeiptr;
-typedef INT_PTR                GLsizeiptrARB;
-typedef const unsigned char *  GLstring;
-typedef struct __GLsync *      GLsync;
-typedef unsigned char          GLubyte;
-typedef unsigned int           GLuint;
-typedef UINT64                 GLuint64;
-typedef UINT64                 GLuint64EXT;
-typedef unsigned short         GLushort;
-typedef INT_PTR                GLvdpauSurfaceNV;
-typedef void                   GLvoid;
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef void GLvoid;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef int GLint;
+typedef int GLclampx;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned int GLuint;
+typedef int GLsizei;
+typedef float GLfloat;
+typedef float GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void *GLeglClientBufferEXT;
+typedef void *GLeglImageOES;
+typedef char GLchar;
+typedef char GLcharARB;
+typedef unsigned short GLhalfARB;
+typedef unsigned short GLhalf;
+typedef GLint GLfixed;
+typedef INT_PTR GLintptr;
+typedef INT_PTR GLsizeiptr;
+typedef INT64 GLint64;
+typedef UINT64 GLuint64;
+typedef INT_PTR GLintptrARB;
+typedef INT_PTR GLsizeiptrARB;
+typedef INT64 GLint64EXT;
+typedef UINT64 GLuint64EXT;
+typedef struct __GLsync *GLsync;
+struct _cl_context;
+struct _cl_event;
+typedef void *GLDEBUGPROC;
+typedef void *GLDEBUGPROCARB;
+typedef void *GLDEBUGPROCKHR;
+typedef void *GLDEBUGPROCAMD;
+typedef unsigned short GLhalfNV;
+typedef GLintptr GLvdpauSurfaceNV;
+typedef void *GLVULKANPROCNV;
+struct _GPU_DEVICE {
+    DWORD  cb;
+    CHAR   DeviceName[32];
+    CHAR   DeviceString[128];
+    DWORD  Flags;
+    RECT   rcVirtualScreen;
+};
+DECLARE_HANDLE(HPBUFFERARB);
+DECLARE_HANDLE(HPBUFFEREXT);
+DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
+DECLARE_HANDLE(HPVIDEODEV);
+DECLARE_HANDLE(HPGPUNV);
+DECLARE_HANDLE(HGPUNV);
+DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
+typedef struct _GPU_DEVICE GPU_DEVICE;
+typedef struct _GPU_DEVICE *PGPU_DEVICE;
+typedef unsigned int GLhandleARB;
 
 #define GL_1PASS_EXT                                                             0x80A1
 #define GL_1PASS_SGIS                                                            0x80A1
diff --git a/include/wine/wgl_driver.h b/include/wine/wgl_driver.h
index 77b82c7..b7ac584 100644
--- a/include/wine/wgl_driver.h
+++ b/include/wine/wgl_driver.h
@@ -502,7 +502,7 @@
         void       (WINE_GLAPI *p_glBufferParameteriAPPLE)( GLenum target, GLenum pname, GLint param );
         GLuint     (WINE_GLAPI *p_glBufferRegionEnabled)(void);
         void       (WINE_GLAPI *p_glBufferStorage)( GLenum target, GLsizeiptr size, const void *data, GLbitfield flags );
-        void       (WINE_GLAPI *p_glBufferStorageExternalEXT)( GLenum target, GLintptr offset, GLsizeiptr size, void * clientBuffer, GLbitfield flags );
+        void       (WINE_GLAPI *p_glBufferStorageExternalEXT)( GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags );
         void       (WINE_GLAPI *p_glBufferStorageMemEXT)( GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset );
         void       (WINE_GLAPI *p_glBufferSubData)( GLenum target, GLintptr offset, GLsizeiptr size, const void *data );
         void       (WINE_GLAPI *p_glBufferSubDataARB)( GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data );
@@ -692,16 +692,16 @@
         GLuint     (WINE_GLAPI *p_glCreateShaderProgramEXT)( GLenum type, const GLchar *string );
         GLuint     (WINE_GLAPI *p_glCreateShaderProgramv)( GLenum type, GLsizei count, const GLchar *const*strings );
         void       (WINE_GLAPI *p_glCreateStatesNV)( GLsizei n, GLuint *states );
-        GLsync     (WINE_GLAPI *p_glCreateSyncFromCLeventARB)( void *context, void *event, GLbitfield flags );
+        GLsync     (WINE_GLAPI *p_glCreateSyncFromCLeventARB)( struct _cl_context *context, struct _cl_event *event, GLbitfield flags );
         void       (WINE_GLAPI *p_glCreateTextures)( GLenum target, GLsizei n, GLuint *textures );
         void       (WINE_GLAPI *p_glCreateTransformFeedbacks)( GLsizei n, GLuint *ids );
         void       (WINE_GLAPI *p_glCreateVertexArrays)( GLsizei n, GLuint *arrays );
         void       (WINE_GLAPI *p_glCullParameterdvEXT)( GLenum pname, GLdouble *params );
         void       (WINE_GLAPI *p_glCullParameterfvEXT)( GLenum pname, GLfloat *params );
         void       (WINE_GLAPI *p_glCurrentPaletteMatrixARB)( GLint index );
-        void       (WINE_GLAPI *p_glDebugMessageCallback)( void * callback, const void *userParam );
-        void       (WINE_GLAPI *p_glDebugMessageCallbackAMD)( void * callback, void *userParam );
-        void       (WINE_GLAPI *p_glDebugMessageCallbackARB)( void * callback, const void *userParam );
+        void       (WINE_GLAPI *p_glDebugMessageCallback)( GLDEBUGPROC callback, const void *userParam );
+        void       (WINE_GLAPI *p_glDebugMessageCallbackAMD)( GLDEBUGPROCAMD callback, void *userParam );
+        void       (WINE_GLAPI *p_glDebugMessageCallbackARB)( GLDEBUGPROCARB callback, const void *userParam );
         void       (WINE_GLAPI *p_glDebugMessageControl)( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled );
         void       (WINE_GLAPI *p_glDebugMessageControlARB)( GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled );
         void       (WINE_GLAPI *p_glDebugMessageEnableAMD)( GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled );
@@ -1345,7 +1345,7 @@
         void       (WINE_GLAPI *p_glGetVideoivNV)( GLuint video_slot, GLenum pname, GLint *params );
         void       (WINE_GLAPI *p_glGetVideoui64vNV)( GLuint video_slot, GLenum pname, GLuint64EXT *params );
         void       (WINE_GLAPI *p_glGetVideouivNV)( GLuint video_slot, GLenum pname, GLuint *params );
-        void *     (WINE_GLAPI *p_glGetVkProcAddrNV)( const GLchar *name );
+        GLVULKANPROCNV (WINE_GLAPI *p_glGetVkProcAddrNV)( const GLchar *name );
         void       (WINE_GLAPI *p_glGetnColorTable)( GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table );
         void       (WINE_GLAPI *p_glGetnColorTableARB)( GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table );
         void       (WINE_GLAPI *p_glGetnCompressedTexImage)( GLenum target, GLint lod, GLsizei bufSize, void *pixels );
@@ -1769,7 +1769,7 @@
         void       (WINE_GLAPI *p_glNamedBufferPageCommitmentEXT)( GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit );
         void       (WINE_GLAPI *p_glNamedBufferStorage)( GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags );
         void       (WINE_GLAPI *p_glNamedBufferStorageEXT)( GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags );
-        void       (WINE_GLAPI *p_glNamedBufferStorageExternalEXT)( GLuint buffer, GLintptr offset, GLsizeiptr size, void * clientBuffer, GLbitfield flags );
+        void       (WINE_GLAPI *p_glNamedBufferStorageExternalEXT)( GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags );
         void       (WINE_GLAPI *p_glNamedBufferStorageMemEXT)( GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset );
         void       (WINE_GLAPI *p_glNamedBufferSubData)( GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data );
         void       (WINE_GLAPI *p_glNamedBufferSubDataEXT)( GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data );
diff --git a/include/wine/wglext.h b/include/wine/wglext.h
index 76c42c1..6ab8dd6 100644
--- a/include/wine/wglext.h
+++ b/include/wine/wglext.h
@@ -431,34 +431,6 @@
 
 /*************************************************************/
 
-#ifndef WGL_ARB_pbuffer
-DECLARE_HANDLE(HPBUFFERARB);
-#endif
-#ifndef WGL_EXT_pbuffer
-DECLARE_HANDLE(HPBUFFEREXT);
-#endif
-#ifndef WGL_NV_present_video
-DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
-#endif
-#ifndef WGL_NV_video_output
-DECLARE_HANDLE(HPVIDEODEV);
-#endif
-#ifndef WGL_NV_gpu_affinity
-DECLARE_HANDLE(HPGPUNV);
-DECLARE_HANDLE(HGPUNV);
-
-typedef struct _GPU_DEVICE {
-    DWORD  cb;
-    CHAR   DeviceName[32];
-    CHAR   DeviceString[128];
-    DWORD  Flags;
-    RECT   rcVirtualScreen;
-} GPU_DEVICE, *PGPU_DEVICE;
-#endif
-#ifndef WGL_NV_video_capture
-DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
-#endif
-
 #ifndef WGL_ARB_buffer_region
 #define WGL_ARB_buffer_region 1
 #ifdef WGL_WGLEXT_PROTOTYPES