Alexandre Julliard : opengl32: Redirect standard OpenGL functions through the TEB function table.
Alexandre Julliard
julliard at winehq.org
Wed Jul 18 12:44:40 CDT 2012
Module: wine
Branch: master
Commit: df91c7bc833780169695221b564ee71b76ffe112
URL: http://source.winehq.org/git/wine.git/?a=commit;h=df91c7bc833780169695221b564ee71b76ffe112
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Jul 16 23:56:55 2012 +0200
opengl32: Redirect standard OpenGL functions through the TEB function table.
---
dlls/opengl32/make_opengl | 3 --
dlls/opengl32/opengl_norm.c | 27 ++++++++++++++++++++++
dlls/opengl32/wgl.c | 53 +------------------------------------------
dlls/winex11.drv/opengl.c | 42 +++++++++++++++------------------
4 files changed, 47 insertions(+), 78 deletions(-)
diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl
index 9773a4a..af309ec 100755
--- a/dlls/opengl32/make_opengl
+++ b/dlls/opengl32/make_opengl
@@ -235,9 +235,6 @@ sub GenerateThunk($$$)
return "" if $func_ref->[0] eq "glDebugEntry";
return "" if $func_ref->[0] eq "glGetString";
- return "" if $func_ref->[0] eq "glGetIntegerv";
- return "" if $func_ref->[0] eq "glFinish";
- return "" if $func_ref->[0] eq "glFlush";
# If for opengl_norm.c, generate a nice heading otherwise Patrik won't be happy :-)
# Patrik says: Well I would be even happier if a (OPENGL32.@) was added as well. Done. :-)
diff --git a/dlls/opengl32/opengl_norm.c b/dlls/opengl32/opengl_norm.c
index 66efce7..6d9cf65 100644
--- a/dlls/opengl32/opengl_norm.c
+++ b/dlls/opengl32/opengl_norm.c
@@ -812,6 +812,24 @@ void WINAPI wine_glFeedbackBuffer( GLsizei size, GLenum type, GLfloat* buffer )
}
/***********************************************************************
+ * glFinish (OPENGL32.@)
+ */
+void WINAPI wine_glFinish( void ) {
+ const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
+ TRACE("()\n");
+ funcs->gl.p_glFinish( );
+}
+
+/***********************************************************************
+ * glFlush (OPENGL32.@)
+ */
+void WINAPI wine_glFlush( void ) {
+ const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
+ TRACE("()\n");
+ funcs->gl.p_glFlush( );
+}
+
+/***********************************************************************
* glFogf (OPENGL32.@)
*/
void WINAPI wine_glFogf( GLenum pname, GLfloat param ) {
@@ -929,6 +947,15 @@ void WINAPI wine_glGetFloatv( GLenum pname, GLfloat* params ) {
}
/***********************************************************************
+ * glGetIntegerv (OPENGL32.@)
+ */
+void WINAPI wine_glGetIntegerv( GLenum pname, GLint* params ) {
+ const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
+ TRACE("(%d, %p)\n", pname, params );
+ funcs->gl.p_glGetIntegerv( pname, params );
+}
+
+/***********************************************************************
* glGetLightfv (OPENGL32.@)
*/
void WINAPI wine_glGetLightfv( GLenum light, GLenum pname, GLfloat* params ) {
diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 8acc173..7a1b1d2 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -47,14 +47,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
WINE_DECLARE_DEBUG_CHANNEL(opengl);
-static struct
-{
- /* internal WGL functions */
- void (WINAPI *p_wglFinish)(void);
- void (WINAPI *p_wglFlush)(void);
- void (WINAPI *p_wglGetIntegerv)(GLenum pname, GLint* params);
-} wine_wgl;
-
#ifdef SONAME_LIBGLU
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
MAKE_FUNCPTR(gluNewTess)
@@ -1205,24 +1197,6 @@ GLint WINAPI wine_glDebugEntry( GLint unknown1, GLint unknown2 )
return 0;
}
-/***********************************************************************
- * glFinish (OPENGL32.@)
- */
-void WINAPI wine_glFinish( void )
-{
- TRACE("()\n");
- wine_wgl.p_wglFinish();
-}
-
-/***********************************************************************
- * glFlush (OPENGL32.@)
- */
-void WINAPI wine_glFlush( void )
-{
- TRACE("()\n");
- wine_wgl.p_wglFlush();
-}
-
/* build the extension string by filtering out the disabled extensions */
static char *build_gl_extensions( const char *extensions )
{
@@ -1294,14 +1268,6 @@ const GLubyte * WINAPI wine_glGetString( GLenum name )
}
/***********************************************************************
- * glGetIntegerv (OPENGL32.@)
- */
-void WINAPI wine_glGetIntegerv( GLenum pname, GLint* params )
-{
- wine_wgl.p_wglGetIntegerv(pname, params);
-}
-
-/***********************************************************************
* wglSwapBuffers (OPENGL32.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc )
@@ -1309,23 +1275,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH wglSwapBuffers( HDC hdc )
return GdiSwapBuffers(hdc);
}
-/* This is for brain-dead applications that use OpenGL functions before even
- creating a rendering context.... */
-static BOOL process_attach(void)
-{
- HDC hdc = GetDC( 0 );
- const struct wgl_funcs *funcs = get_dc_funcs( hdc );
-
- ReleaseDC( 0, hdc );
-
- /* internal WGL functions */
- wine_wgl.p_wglFinish = (void *)funcs->p_wglGetProcAddress("wglFinish");
- wine_wgl.p_wglFlush = (void *)funcs->p_wglGetProcAddress("wglFlush");
- wine_wgl.p_wglGetIntegerv = (void *)funcs->p_wglGetProcAddress("wglGetIntegerv");
- return TRUE;
-}
-
-
/**********************************************************************/
static void process_detach(void)
@@ -1344,7 +1293,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
opengl32_handle = hinst;
DisableThreadLibraryCalls(hinst);
NtCurrentTeb()->glTable = &null_opengl_funcs;
- return process_attach();
+ break;
case DLL_THREAD_ATTACH:
NtCurrentTeb()->glTable = &null_opengl_funcs;
break;
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index aae4f4b..b36a29c 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -328,6 +328,10 @@ static void (*pglXFreeMemoryNV)(GLvoid *pointer);
static void (*pglXCopySubBufferMESA)(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
/* Standard OpenGL */
+static void (*pglFinish)(void);
+static void (*pglFlush)(void);
+static void (*pglGetIntegerv)(GLenum,GLint*);
+
MAKE_FUNCPTR(glBindTexture)
MAKE_FUNCPTR(glBitmap)
MAKE_FUNCPTR(glCopyTexSubImage1D)
@@ -336,16 +340,17 @@ MAKE_FUNCPTR(glCopyTexSubImage2D)
MAKE_FUNCPTR(glDrawBuffer)
MAKE_FUNCPTR(glEndList)
MAKE_FUNCPTR(glGetError)
-MAKE_FUNCPTR(glGetIntegerv)
MAKE_FUNCPTR(glGetString)
MAKE_FUNCPTR(glNewList)
MAKE_FUNCPTR(glPixelStorei)
MAKE_FUNCPTR(glReadPixels)
MAKE_FUNCPTR(glTexImage2D)
-MAKE_FUNCPTR(glFinish)
-MAKE_FUNCPTR(glFlush)
#undef MAKE_FUNCPTR
+static void wglFinish(void);
+static void wglFlush(void);
+static void wglGetIntegerv(GLenum pname, GLint* params);
+
static int GLXErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
{
/* In the future we might want to find the exact X or GLX error to report back to the app */
@@ -513,6 +518,14 @@ static BOOL has_opengl(void)
}
}
+ /* redirect some standard OpenGL functions */
+#define REDIRECT(func) \
+ do { p##func = opengl_funcs.gl.p_##func; opengl_funcs.gl.p_##func = w##func; } while(0)
+ REDIRECT( glFinish );
+ REDIRECT( glFlush );
+ REDIRECT( glGetIntegerv );
+#undef REDIRECT
+
pglXGetProcAddressARB = wine_dlsym(opengl_handle, "glXGetProcAddressARB", NULL, 0);
if (pglXGetProcAddressARB == NULL) {
ERR("Could not find glXGetProcAddressARB in libGL, disabling OpenGL.\n");
@@ -563,14 +576,11 @@ static BOOL has_opengl(void)
LOAD_FUNCPTR(glDrawBuffer);
LOAD_FUNCPTR(glEndList);
LOAD_FUNCPTR(glGetError);
- LOAD_FUNCPTR(glGetIntegerv);
LOAD_FUNCPTR(glGetString);
LOAD_FUNCPTR(glNewList);
LOAD_FUNCPTR(glPixelStorei);
LOAD_FUNCPTR(glReadPixels);
LOAD_FUNCPTR(glTexImage2D);
- LOAD_FUNCPTR(glFinish);
- LOAD_FUNCPTR(glFlush);
#undef LOAD_FUNCPTR
/* It doesn't matter if these fail. They'll only be used if the driver reports
@@ -1791,7 +1801,7 @@ static HDC glxdrv_wglGetCurrentDC( struct wgl_context *ctx )
}
/* WGL helper function which handles differences in glGetIntegerv from WGL and GLX */
-static void WINAPI X11DRV_wglGetIntegerv(GLenum pname, GLint* params)
+static void wglGetIntegerv(GLenum pname, GLint* params)
{
wine_tsx11_lock();
switch(pname)
@@ -1872,7 +1882,7 @@ static void flush_gl_drawable( struct glx_physdev *physdev )
}
-static void WINAPI X11DRV_wglFinish(void)
+static void wglFinish(void)
{
struct wgl_context *ctx = NtCurrentTeb()->glContext;
enum x11drv_escape_codes code = X11DRV_FLUSH_GL_DRAWABLE;
@@ -1888,7 +1898,7 @@ static void WINAPI X11DRV_wglFinish(void)
}
}
-static void WINAPI X11DRV_wglFlush(void)
+static void wglFlush(void)
{
struct wgl_context *ctx = NtCurrentTeb()->glContext;
enum x11drv_escape_codes code = X11DRV_FLUSH_GL_DRAWABLE;
@@ -3052,17 +3062,6 @@ static BOOL register_extension(const WineGLExtension * ext)
return TRUE;
}
-static const WineGLExtension WGL_internal_functions =
-{
- "",
- {
- { "wglFinish", X11DRV_wglFinish },
- { "wglFlush", X11DRV_wglFlush },
- { "wglGetIntegerv", X11DRV_wglGetIntegerv },
- }
-};
-
-
static const WineGLExtension WGL_ARB_create_context_extension =
{
"WGL_ARB_create_context",
@@ -3166,9 +3165,6 @@ static void X11DRV_WineGL_LoadExtensions(void)
{
WineGLInfo.wglExtensions[0] = 0;
- /* Load Wine internal functions */
- register_extension(&WGL_internal_functions);
-
/* ARB Extensions */
if(glxRequireExtension("GLX_ARB_create_context"))
More information about the wine-cvs
mailing list