diff --git a/dlls/gdi/Makefile.in b/dlls/gdi/Makefile.in index 3075f954d6b..5abe06ca70e 100644 --- a/dlls/gdi/Makefile.in +++ b/dlls/gdi/Makefile.in @@ -44,6 +44,7 @@ C_SRCS = \ mfdrv/mapping.c \ mfdrv/objects.c \ mfdrv/text.c \ + opengl.c \ painting.c \ palette.c \ path.c \ diff --git a/dlls/gdi/driver.c b/dlls/gdi/driver.c index 76657a7d5c2..b0e3f24ddd2 100644 --- a/dlls/gdi/driver.c +++ b/dlls/gdi/driver.c @@ -194,6 +194,10 @@ static struct graphics_driver *create_driver( HMODULE module ) GET_FUNC(StrokePath); GET_FUNC(SwapBuffers); GET_FUNC(WidenPath); + + /* OpenGL32 */ + GET_FUNC(wglCreateContext); + GET_FUNC(wglMakeCurrent); #undef GET_FUNC } else memset( &driver->funcs, 0, sizeof(driver->funcs) ); diff --git a/dlls/gdi/gdi32.spec b/dlls/gdi/gdi32.spec index 723ffd38e9d..73dd0c32a6c 100644 --- a/dlls/gdi/gdi32.spec +++ b/dlls/gdi/gdi32.spec @@ -495,6 +495,12 @@ @ extern pfnSelectPalette @ stub pstackConnect +################################################################ +# Wine extensions: OpenGL support +# +@ stdcall wglCreateContext(long) +@ stdcall wglMakeCurrent(long long) + ################################################################ # Wine extensions: Win16 functions that are needed by other dlls # diff --git a/dlls/gdi/gdi_private.h b/dlls/gdi/gdi_private.h index 42f996ae9dd..e63308c4a50 100644 --- a/dlls/gdi/gdi_private.h +++ b/dlls/gdi/gdi_private.h @@ -182,6 +182,10 @@ typedef struct tagDC_FUNCS BOOL (*pStrokePath)(PHYSDEV); BOOL (*pSwapBuffers)(PHYSDEV); BOOL (*pWidenPath)(PHYSDEV); + + /* OpenGL32 */ + HGLRC (*pwglCreateContext)(PHYSDEV); + BOOL (*pwglMakeCurrent)(PHYSDEV, HGLRC); } DC_FUNCTIONS; /* It should not be necessary to access the contents of the GdiPath diff --git a/dlls/gdi/opengl.c b/dlls/gdi/opengl.c new file mode 100644 index 00000000000..b6012501953 --- /dev/null +++ b/dlls/gdi/opengl.c @@ -0,0 +1,76 @@ +/* + * OpenGL function forwarding to the display driver + * + * Copyright (c) 1999 Lionel Ulmer + * Copyright (c) 2005 Raphael Junqueira + * Copyright (c) 2006 Roderick Colenbrander + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "wine/port.h" + +#include +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winerror.h" +#include "gdi.h" +#include "gdi_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wgl); + +/*********************************************************************** + * wglCreateContext (OPENGL32.@) + */ +HGLRC WINAPI wglCreateContext(HDC hdc) +{ + HGLRC ret = 0; + DC * dc = DC_GetDCPtr( hdc ); + + TRACE("(%p)\n",hdc); + + if (!dc) return 0; + + if (!dc->funcs->pwglCreateContext) FIXME(" :stub\n"); + else ret = dc->funcs->pwglCreateContext(dc->physDev); + + GDI_ReleaseObj( hdc ); + return ret; +} + +/*********************************************************************** + * wglMakeCurrent (OPENGL32.@) + */ +BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc) +{ + BOOL ret = FALSE; + DC * dc = DC_GetDCPtr( hdc ); + + TRACE("hdc: (%p), hglrc: (%p)\n", hdc, hglrc); + + if (!dc) return FALSE; + + if (!dc->funcs->pwglMakeCurrent) FIXME(" :stub\n"); + else ret = dc->funcs->pwglMakeCurrent(dc->physDev,hglrc); + + GDI_ReleaseObj( hdc); + return ret; +} diff --git a/dlls/opengl32/opengl32.spec b/dlls/opengl32/opengl32.spec index 460045a109a..dbd93b28d5e 100644 --- a/dlls/opengl32/opengl32.spec +++ b/dlls/opengl32/opengl32.spec @@ -376,7 +376,7 @@ @ stdcall glViewport( long long long long ) wine_glViewport @ stdcall wglChoosePixelFormat(long ptr) gdi32.ChoosePixelFormat @ stdcall wglCopyContext(long long long) -@ stdcall wglCreateContext(long) +@ stdcall wglCreateContext(long) gdi32.wglCreateContext @ stdcall wglCreateLayerContext(long long) @ stdcall wglDeleteContext(long) @ stdcall wglDescribeLayerPlane(long long long long ptr) @@ -387,7 +387,7 @@ @ stdcall wglGetLayerPaletteEntries(long long long long ptr) @ stdcall wglGetPixelFormat(long) gdi32.GetPixelFormat @ stdcall wglGetProcAddress(str) -@ stdcall wglMakeCurrent(long long) +@ stdcall wglMakeCurrent(long long) gdi32.wglMakeCurrent @ stdcall wglRealizeLayerPalette(long long long) @ stdcall wglSetLayerPaletteEntries(long long long long ptr) @ stdcall wglSetPixelFormat(long long ptr) gdi32.SetPixelFormat diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index bb66430fe17..f593b0188e0 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -47,12 +47,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(wgl); WINE_DECLARE_DEBUG_CHANNEL(opengl); typedef struct wine_wgl_s { - HGLRC WINAPI (*p_wglCreateContext)(HDC hdc); BOOL WINAPI (*p_wglDeleteContext)(HGLRC hglrc); HGLRC WINAPI (*p_wglGetCurrentContext)(void); HDC WINAPI (*p_wglGetCurrentDC)(void); PROC WINAPI (*p_wglGetProcAddress)(LPCSTR lpszProc); - BOOL WINAPI (*p_wglMakeCurrent)(HDC hdc, HGLRC hglrc); BOOL WINAPI (*p_wglShareLists)(HGLRC hglrc1, HGLRC hglrc2); BOOL WINAPI (*p_wglUseFontBitmapsA)(HDC hdc, DWORD first, DWORD count, DWORD listBase); BOOL WINAPI (*p_wglUseFontBitmapsW)(HDC hdc, DWORD first, DWORD count, DWORD listBase); @@ -128,15 +126,6 @@ inline static Display *get_display( HDC hdc ) return display; } -/*********************************************************************** - * wglCreateContext (OPENGL32.@) - */ -HGLRC WINAPI wglCreateContext(HDC hdc) -{ - TRACE("(%p)\n", hdc); - return wine_wgl.p_wglCreateContext(hdc); -} - /*********************************************************************** * wglCreateLayerContext (OPENGL32.@) */ @@ -287,14 +276,6 @@ PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) { } } -/*********************************************************************** - * wglMakeCurrent (OPENGL32.@) - */ -BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc) { - TRACE("hdc: (%p), hglrc: (%p)\n", hdc, hglrc); - return wine_wgl.p_wglMakeCurrent(hdc, hglrc); -} - /*********************************************************************** * wglRealizeLayerPalette (OPENGL32.@) */ @@ -694,12 +675,10 @@ static BOOL process_attach(void) wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); /* Load WGL function pointers from winex11.drv */ - wine_wgl.p_wglCreateContext = (void *)GetProcAddress(mod, "wglCreateContext"); wine_wgl.p_wglDeleteContext = (void *)GetProcAddress(mod, "wglDeleteContext"); wine_wgl.p_wglGetCurrentContext = (void *)GetProcAddress(mod, "wglGetCurrentContext"); wine_wgl.p_wglGetCurrentDC = (void *)GetProcAddress(mod, "wglGetCurrentDC"); wine_wgl.p_wglGetProcAddress = (void *)GetProcAddress(mod, "wglGetProcAddress"); - wine_wgl.p_wglMakeCurrent = (void *)GetProcAddress(mod, "wglMakeCurrent"); wine_wgl.p_wglShareLists = (void *)GetProcAddress(mod, "wglShareLists"); wine_wgl.p_wglUseFontBitmapsA = (void*)GetProcAddress(mod, "wglUseFontBitmapsA"); wine_wgl.p_wglUseFontBitmapsW = (void*)GetProcAddress(mod, "wglUseFontBitmapsW"); diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index ad2c938e691..6a77a2743c3 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1194,7 +1194,7 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev, } /* OpenGL32 wglCreateContext */ -HGLRC WINAPI X11DRV_wglCreateContext(HDC hdc) +HGLRC X11DRV_wglCreateContext(X11DRV_PDEVICE *physDev) { Wine_GLContext *ret; GLXFBConfig* cfgs_fmt = NULL; @@ -1205,6 +1205,7 @@ HGLRC WINAPI X11DRV_wglCreateContext(HDC hdc) int nCfgs_fmt = 0; int value = 0; int gl_test = 0; + HDC hdc = physDev->hdc; TRACE("(%p)->(PF:%d)\n", hdc, hdcPF); @@ -1365,8 +1366,9 @@ PROC X11DRV_wglGetProcAddress(LPCSTR lpszProc) /* OpenGL32 wglMakeCurrent */ -BOOL WINAPI X11DRV_wglMakeCurrent(HDC hdc, HGLRC hglrc) { +BOOL X11DRV_wglMakeCurrent(X11DRV_PDEVICE *physDev, HGLRC hglrc) { BOOL ret; + HDC hdc = physDev->hdc; DWORD type = GetObjectType(hdc); TRACE("(%p,%p)\n", hdc, hglrc); @@ -1377,7 +1379,7 @@ BOOL WINAPI X11DRV_wglMakeCurrent(HDC hdc, HGLRC hglrc) { NtCurrentTeb()->glContext = NULL; } else { Wine_GLContext *ctx = (Wine_GLContext *) hglrc; - Drawable drawable = get_drawable( hdc ); + Drawable drawable = physDev->drawable; if (ctx->ctx == NULL) { int draw_vis_id, ctx_vis_id; VisualID visualid = (VisualID)GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" ); @@ -2373,12 +2375,14 @@ static GLboolean WINAPI X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuf pglGetIntegerv(object->texture_target, &prev_binded_tex); if (NULL == object->render_ctx) { object->render_hdc = X11DRV_wglGetPbufferDCARB(hPbuffer); - object->render_ctx = X11DRV_wglCreateContext(object->render_hdc); + /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */ + object->render_ctx = wglCreateContext(object->render_hdc); do_init = 1; } object->prev_hdc = X11DRV_wglGetCurrentDC(); object->prev_ctx = X11DRV_wglGetCurrentContext(); - X11DRV_wglMakeCurrent(object->render_hdc, object->render_ctx); + /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */ + wglMakeCurrent(object->render_hdc, object->render_ctx); /* if (do_init) { glBindTexture(object->texture_target, object->texture); @@ -2430,7 +2434,8 @@ static GLboolean WINAPI X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer, int i pglCopyTexSubImage2D(object->texture_target, object->texture_level, 0, 0, 0, 0, object->width, object->height); } - X11DRV_wglMakeCurrent(object->prev_hdc, object->prev_ctx); + /* FIXME: This is routed through gdi32.dll to winex11.drv, replace this with GLX calls */ + wglMakeCurrent(object->prev_hdc, object->prev_ctx); return GL_TRUE; } if (NULL != pglXReleaseTexImageARB) {