From: Rémi Bernon rbernon@codeweavers.com
--- dlls/opengl32/make_opengl | 29 +++++++++++ dlls/opengl32/opengl_ext.h | 2 + dlls/opengl32/thunks.c | 18 +++++++ dlls/opengl32/unix_thunks.c | 96 +++++++++++++++++++++++++++++++++++++ dlls/opengl32/unixlib.h | 79 ++++++++++++++++++++++++++++++ dlls/opengl32/wgl.c | 43 ++++++----------- 6 files changed, 238 insertions(+), 29 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 00864525171..6c40c51c3e0 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -508,6 +508,9 @@ sub needs_wrapper($$) "glGetString" => 1, "glGetStringi" => 1, "wglGetCurrentReadDCARB" => 1, + "wglGetPixelFormat" => 1, + "wglGetProcAddress" => 1, + "wglSwapBuffers" => 1, ); my ($name, $func) = @_;
@@ -799,6 +802,11 @@ print OUT "#include "wingdi.h"\n\n"; print OUT "#include "wine/wgl.h"\n"; print OUT "#include "wine/unixlib.h"\n\n";
+foreach (sort keys %wgl_functions) +{ + next if defined $manual_win_functions{$_}; + print OUT generate_func_params($_, $wgl_functions{$_}); +} foreach (sort keys %norm_functions) { next if defined $manual_win_functions{$_}; @@ -812,6 +820,11 @@ foreach (sort keys %ext_functions)
print OUT "enum unix_funcs\n"; print OUT "{\n"; +foreach (sort keys %wgl_functions) +{ + next if defined $manual_win_functions{$_}; + printf OUT " unix_%s,\n", $_; +} foreach (sort keys %norm_functions) { next if defined $manual_win_functions{$_}; @@ -851,6 +864,12 @@ print OUT "#include "opengl_ext.h"\n\n"; print OUT "#include "wine/debug.h"\n\n"; print OUT "WINE_DEFAULT_DEBUG_CHANNEL(opengl);\n";
+foreach (sort keys %wgl_functions) +{ + next if defined $manual_win_functions{$_}; + next if needs_wrapper( $_, $wgl_functions{$_} ); + print OUT "\n" . generate_win_thunk($_, $wgl_functions{$_}); +} foreach (sort keys %norm_functions) { next if defined $manual_win_functions{$_}; @@ -905,6 +924,11 @@ print OUT "#include "wingdi.h"\n\n"; print OUT "#include "unixlib.h"\n\n"; print OUT "#include "opengl_ext.h"\n\n";
+foreach (sort keys %wgl_functions) +{ + next if defined $manual_win_functions{$_}; + print OUT generate_unix_thunk($_, $wgl_functions{$_}, "wgl"); +} foreach (sort keys %norm_functions) { next if defined $manual_win_functions{$_}; @@ -918,6 +942,11 @@ foreach (sort keys %ext_functions)
print OUT "const unixlib_function_t __wine_unix_call_funcs[] =\n"; print OUT "{\n"; +foreach (sort keys %wgl_functions) +{ + next if defined $manual_win_functions{$_}; + printf OUT " &wgl_%s,\n", $_; +} foreach (sort keys %norm_functions) { next if defined $manual_win_functions{$_}; diff --git a/dlls/opengl32/opengl_ext.h b/dlls/opengl32/opengl_ext.h index fc67cab1a67..7873c974cc7 100644 --- a/dlls/opengl32/opengl_ext.h +++ b/dlls/opengl32/opengl_ext.h @@ -43,4 +43,6 @@ static inline struct opengl_funcs *get_dc_funcs( HDC hdc ) return funcs; }
+extern int WINAPI wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR *ppfd ); + #endif /* __DLLS_OPENGL32_OPENGL_EXT_H */ diff --git a/dlls/opengl32/thunks.c b/dlls/opengl32/thunks.c index 0a66e2a9186..b54a2952975 100644 --- a/dlls/opengl32/thunks.c +++ b/dlls/opengl32/thunks.c @@ -17,6 +17,24 @@
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
+int WINAPI wglDescribePixelFormat( HDC hdc, int ipfd, UINT cjpfd, PIXELFORMATDESCRIPTOR *ppfd ) +{ + struct wglDescribePixelFormat_params args = { .hdc = hdc, .ipfd = ipfd, .cjpfd = cjpfd, .ppfd = ppfd, }; + NTSTATUS status; + TRACE( "hdc %p, ipfd %d, cjpfd %u, ppfd %p\n", hdc, ipfd, cjpfd, ppfd ); + if ((status = UNIX_CALL( wglDescribePixelFormat, &args ))) WARN( "wglDescribePixelFormat returned %#x\n", status ); + return args.ret; +} + +BOOL WINAPI wglSetPixelFormat( HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR *ppfd ) +{ + struct wglSetPixelFormat_params args = { .hdc = hdc, .ipfd = ipfd, .ppfd = ppfd, }; + NTSTATUS status; + TRACE( "hdc %p, ipfd %d, ppfd %p\n", hdc, ipfd, ppfd ); + if ((status = UNIX_CALL( wglSetPixelFormat, &args ))) WARN( "wglSetPixelFormat returned %#x\n", status ); + return args.ret; +} + void WINAPI glAccum( GLenum op, GLfloat value ) { struct glAccum_params args = { .op = op, .value = value, }; diff --git a/dlls/opengl32/unix_thunks.c b/dlls/opengl32/unix_thunks.c index 7988189e188..1efbd1d192a 100644 --- a/dlls/opengl32/unix_thunks.c +++ b/dlls/opengl32/unix_thunks.c @@ -13,6 +13,92 @@
#include "opengl_ext.h"
+static NTSTATUS wgl_wglCopyContext( void *args ) +{ + struct wglCopyContext_params *params = args; + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + params->ret = funcs->wgl.p_wglCopyContext( (struct wgl_context *)params->hglrcSrc, (struct wgl_context *)params->hglrcDst, params->mask ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglCreateContext( void *args ) +{ + struct wglCreateContext_params *params = args; + const struct opengl_funcs *funcs = get_dc_funcs( params->hDc ); + if (!funcs || !funcs->wgl.p_wglCreateContext) return STATUS_NOT_IMPLEMENTED; + params->ret = (HGLRC)funcs->wgl.p_wglCreateContext( params->hDc ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglDeleteContext( void *args ) +{ + struct wglDeleteContext_params *params = args; + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + params->ret = funcs->wgl.p_wglDeleteContext( (struct wgl_context *)params->oldContext ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglDescribePixelFormat( void *args ) +{ + struct wglDescribePixelFormat_params *params = args; + const struct opengl_funcs *funcs = get_dc_funcs( params->hdc ); + if (!funcs || !funcs->wgl.p_wglDescribePixelFormat) return STATUS_NOT_IMPLEMENTED; + params->ret = funcs->wgl.p_wglDescribePixelFormat( params->hdc, params->ipfd, params->cjpfd, params->ppfd ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglGetPixelFormat( void *args ) +{ + struct wglGetPixelFormat_params *params = args; + const struct opengl_funcs *funcs = get_dc_funcs( params->hdc ); + if (!funcs || !funcs->wgl.p_wglGetPixelFormat) return STATUS_NOT_IMPLEMENTED; + params->ret = funcs->wgl.p_wglGetPixelFormat( params->hdc ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglGetProcAddress( void *args ) +{ + struct wglGetProcAddress_params *params = args; + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + params->ret = funcs->wgl.p_wglGetProcAddress( params->lpszProc ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglMakeCurrent( void *args ) +{ + struct wglMakeCurrent_params *params = args; + const struct opengl_funcs *funcs = get_dc_funcs( params->hDc ); + if (!funcs || !funcs->wgl.p_wglMakeCurrent) return STATUS_NOT_IMPLEMENTED; + params->ret = funcs->wgl.p_wglMakeCurrent( params->hDc, (struct wgl_context *)params->newContext ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglSetPixelFormat( void *args ) +{ + struct wglSetPixelFormat_params *params = args; + const struct opengl_funcs *funcs = get_dc_funcs( params->hdc ); + if (!funcs || !funcs->wgl.p_wglSetPixelFormat) return STATUS_NOT_IMPLEMENTED; + params->ret = funcs->wgl.p_wglSetPixelFormat( params->hdc, params->ipfd, params->ppfd ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglShareLists( void *args ) +{ + struct wglShareLists_params *params = args; + const struct opengl_funcs *funcs = NtCurrentTeb()->glTable; + params->ret = funcs->wgl.p_wglShareLists( (struct wgl_context *)params->hrcSrvShare, (struct wgl_context *)params->hrcSrvSource ); + return STATUS_SUCCESS; +} + +static NTSTATUS wgl_wglSwapBuffers( void *args ) +{ + struct wglSwapBuffers_params *params = args; + const struct opengl_funcs *funcs = get_dc_funcs( params->hdc ); + if (!funcs || !funcs->wgl.p_wglSwapBuffers) return STATUS_NOT_IMPLEMENTED; + params->ret = funcs->wgl.p_wglSwapBuffers( params->hdc ); + return STATUS_SUCCESS; +} + static NTSTATUS gl_glAccum( void *args ) { struct glAccum_params *params = args; @@ -24216,6 +24302,16 @@ static NTSTATUS ext_wglSwapIntervalEXT( void *args )
const unixlib_function_t __wine_unix_call_funcs[] = { + &wgl_wglCopyContext, + &wgl_wglCreateContext, + &wgl_wglDeleteContext, + &wgl_wglDescribePixelFormat, + &wgl_wglGetPixelFormat, + &wgl_wglGetProcAddress, + &wgl_wglMakeCurrent, + &wgl_wglSetPixelFormat, + &wgl_wglShareLists, + &wgl_wglSwapBuffers, &gl_glAccum, &gl_glAlphaFunc, &gl_glAreTexturesResident, diff --git a/dlls/opengl32/unixlib.h b/dlls/opengl32/unixlib.h index a85e23402ea..88b744d0f10 100644 --- a/dlls/opengl32/unixlib.h +++ b/dlls/opengl32/unixlib.h @@ -16,6 +16,75 @@ #include "wine/wgl.h" #include "wine/unixlib.h"
+struct wglCopyContext_params +{ + HGLRC hglrcSrc; + HGLRC hglrcDst; + UINT mask; + BOOL ret; +}; + +struct wglCreateContext_params +{ + HDC hDc; + HGLRC ret; +}; + +struct wglDeleteContext_params +{ + HGLRC oldContext; + BOOL ret; +}; + +struct wglDescribePixelFormat_params +{ + HDC hdc; + int ipfd; + UINT cjpfd; + PIXELFORMATDESCRIPTOR *ppfd; + int ret; +}; + +struct wglGetPixelFormat_params +{ + HDC hdc; + int ret; +}; + +struct wglGetProcAddress_params +{ + LPCSTR lpszProc; + PROC ret; +}; + +struct wglMakeCurrent_params +{ + HDC hDc; + HGLRC newContext; + BOOL ret; +}; + +struct wglSetPixelFormat_params +{ + HDC hdc; + int ipfd; + const PIXELFORMATDESCRIPTOR *ppfd; + BOOL ret; +}; + +struct wglShareLists_params +{ + HGLRC hrcSrvShare; + HGLRC hrcSrvSource; + BOOL ret; +}; + +struct wglSwapBuffers_params +{ + HDC hdc; + BOOL ret; +}; + struct glAccum_params { GLenum op; @@ -22224,6 +22293,16 @@ struct wglSwapIntervalEXT_params
enum unix_funcs { + unix_wglCopyContext, + unix_wglCreateContext, + unix_wglDeleteContext, + unix_wglDescribePixelFormat, + unix_wglGetPixelFormat, + unix_wglGetProcAddress, + unix_wglMakeCurrent, + unix_wglSetPixelFormat, + unix_wglShareLists, + unix_wglSwapBuffers, unix_glAccum, unix_glAlphaFunc, unix_glAreTexturesResident, diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 2c2be3e0ace..7c8bbfa378f 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -441,16 +441,6 @@ HGLRC WINAPI wglGetCurrentContext(void) return NtCurrentTeb()->glCurrentRC; }
-/*********************************************************************** - * wglDescribePixelFormat (OPENGL32.@) - */ -INT WINAPI wglDescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr ) -{ - struct opengl_funcs *funcs = get_dc_funcs( hdc ); - if (!funcs) return 0; - return funcs->wgl.p_wglDescribePixelFormat( hdc, format, size, descr ); -} - /*********************************************************************** * wglChoosePixelFormat (OPENGL32.@) */ @@ -626,23 +616,18 @@ INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) */ INT WINAPI wglGetPixelFormat(HDC hdc) { - struct opengl_funcs *funcs = get_dc_funcs( hdc ); - if (!funcs) + struct wglGetPixelFormat_params args = { .hdc = hdc, }; + NTSTATUS status; + + TRACE( "hdc %p\n", hdc ); + + if ((status = UNIX_CALL( wglGetPixelFormat, &args ))) { + WARN( "wglGetPixelFormat returned %#x\n", status ); SetLastError( ERROR_INVALID_PIXEL_FORMAT ); - return 0; } - return funcs->wgl.p_wglGetPixelFormat( hdc ); -}
-/*********************************************************************** - * wglSetPixelFormat(OPENGL32.@) - */ -BOOL WINAPI wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR *descr ) -{ - struct opengl_funcs *funcs = get_dc_funcs( hdc ); - if (!funcs) return FALSE; - return funcs->wgl.p_wglSetPixelFormat( hdc, format, descr ); + return args.ret; }
/*********************************************************************** @@ -650,12 +635,11 @@ BOOL WINAPI wglSetPixelFormat( HDC hdc, INT format, const PIXELFORMATDESCRIPTOR */ BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc ) { - const struct opengl_funcs *funcs = get_dc_funcs( hdc ); - - if (!funcs || !funcs->wgl.p_wglSwapBuffers) return FALSE; - if (!funcs->wgl.p_wglSwapBuffers( hdc )) return FALSE; + struct wglSwapBuffers_params args = { .hdc = hdc, }; + NTSTATUS status;
- if (TRACE_ON(fps)) + if ((status = UNIX_CALL( wglSwapBuffers, &args ))) WARN( "wglSwapBuffers returned %#x\n", status ); + else if (TRACE_ON(fps)) { static long prev_time, start_time; static unsigned long frames, frames_total; @@ -673,7 +657,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc ) if (start_time == 0) start_time = time; } } - return TRUE; + + return args.ret; }
/***********************************************************************