Commit edb0044e authored by Alexandre Julliard's avatar Alexandre Julliard

opengl32: Generate a function table with null OpenGL entry points and store it in the TEB.

parent bddea5b5
......@@ -319,6 +319,35 @@ sub GenerateThunk($$$$$)
return $ret;
}
sub generate_null_func($)
{
my ($func_ref) = @_;
my $ret;
return "" if $func_ref->[0] eq "glDebugEntry";
$ret = "static " . ConvertType($func_ref->[1]) . " null_$func_ref->[0]( ";
for (my $i = 0; $i < @{$func_ref->[2]}; $i++) {
my $type = $func_ref->[2]->[$i]->[0];
my $name = ConvertVarName($func_ref->[2]->[$i]->[1]);
$ret .= ConvertType($type) . " $name";
$ret .= "," if ($i+1 < @{$func_ref->[2]});
$ret .= " ";
}
$ret .= 'void ' if (!@{$func_ref->[2]});
$ret .= ") {";
if ($func_ref->[0] eq "glGetError")
{
$ret .= " return GL_INVALID_OPERATION;";
}
elsif ($func_ref->[1] ne "void")
{
$ret .= " return 0;";
}
$ret .= " }\n";
return $ret;
}
sub get_func_proto($)
{
my $func = shift;
......@@ -769,7 +798,10 @@ print NORM "
/* Auto-generated file... Do not edit ! */
#include \"config.h\"
#include <stdarg.h>
#include \"opengl_ext.h\"
#include \"winternl.h\"
#include \"wine/wgl_driver.h\"
#include \"wine/debug.h\"
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
......@@ -779,6 +811,17 @@ foreach (sort keys %norm_functions) {
print NORM "\n$string" if $string;
}
print NORM "\n";
foreach (sort keys %norm_functions) {
print NORM generate_null_func($norm_functions{$_});
}
print NORM "\n#define USE_GL_FUNC(name) null_##name,\n";
print NORM "struct opengl_funcs null_opengl_funcs = { { ALL_WGL_FUNCS } };\n";
print NORM "#undef USE_GL_FUNC\n";
close(NORM);
#
......
......@@ -40,6 +40,7 @@
#include <GL/glu.h>
#endif
#include "wine/gdi_driver.h"
#include "wine/wgl_driver.h"
#include "wine/library.h"
#include "wine/debug.h"
......@@ -70,6 +71,8 @@ MAKE_FUNCPTR(gluTessVertex)
static HMODULE opengl32_handle;
static void* libglu_handle = NULL;
extern struct opengl_funcs null_opengl_funcs;
const GLubyte * WINAPI wine_glGetString( GLenum name );
/* internal GDI functions */
......@@ -253,6 +256,7 @@ BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
if (!prev->funcs->p_wglMakeCurrent( 0, NULL )) return FALSE;
prev->tid = 0;
NtCurrentTeb()->glCurrentRC = 0;
NtCurrentTeb()->glTable = &null_opengl_funcs;
}
else if (!hdc)
{
......@@ -318,6 +322,7 @@ static BOOL WINAPI wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, HGLRC h
if (!prev->funcs->p_wglMakeCurrent( 0, NULL )) return FALSE;
prev->tid = 0;
NtCurrentTeb()->glCurrentRC = 0;
NtCurrentTeb()->glTable = &null_opengl_funcs;
}
return ret;
}
......@@ -1338,7 +1343,11 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
case DLL_PROCESS_ATTACH:
opengl32_handle = hinst;
DisableThreadLibraryCalls(hinst);
NtCurrentTeb()->glTable = &null_opengl_funcs;
return process_attach();
case DLL_THREAD_ATTACH:
NtCurrentTeb()->glTable = &null_opengl_funcs;
break;
case DLL_PROCESS_DETACH:
process_detach();
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment