Commit 2c40e299 authored by Alexandre Julliard's avatar Alexandre Julliard

Import wine_tsx11_lock/unlock directly from x11drv in opengl32 and

ddraw, so that they don't need to link with libwine_tsx11. Removed header wine_gl.h.
parent 7dafa617
......@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = ddraw.dll
IMPORTS = user32 gdi32 kernel32
EXTRALIBS = $(LIBUUID) $(LIBTSX11) $(X_LIBS) $(XLIB)
EXTRALIBS = $(LIBUUID) $(X_LIBS) $(XLIB)
LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o
......
......@@ -43,6 +43,9 @@ static const ddraw_driver* DDRAW_drivers[MAX_DDRAW_DRIVERS];
static int DDRAW_num_drivers; /* = 0 */
static int DDRAW_default_driver;
void (*wine_tsx11_lock_ptr)(void) = NULL;
void (*wine_tsx11_unlock_ptr)(void) = NULL;
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/**********************************************************************/
......@@ -503,6 +506,16 @@ BOOL WINAPI DDRAW_DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
DDRAW_HAL_Init(hInstDLL, fdwReason, lpv);
DDRAW_User_Init(hInstDLL, fdwReason, lpv);
if (fdwReason == DLL_PROCESS_ATTACH)
{
HMODULE mod = GetModuleHandleA( "x11drv.dll" );
if (mod)
{
wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
}
}
if (DDRAW_num_drivers > 0)
DDRAW_default_driver = DDRAW_ChooseDefaultDriver();
......
......@@ -24,7 +24,36 @@
#include "d3d_private.h"
#include "wine_gl.h"
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
#include <GL/gl.h>
#include <GL/glx.h>
#ifdef HAVE_GL_GLEXT_H
# include <GL/glext.h>
#endif
#undef XMD_H
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
/* X11 locking */
extern void (*wine_tsx11_lock_ptr)(void);
extern void (*wine_tsx11_unlock_ptr)(void);
/* As GLX relies on X, this is needed */
#define ENTER_GL() wine_tsx11_lock_ptr()
#define LEAVE_GL() wine_tsx11_unlock_ptr()
/*****************************************************************************
* IDirect3DLight MESA private structure
......
......@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = opengl32.dll
IMPORTS = user32 gdi32 kernel32
EXTRALIBS = $(LIBTSX11) $(X_LIBS) $(XLIB)
EXTRALIBS = $(X_LIBS) $(XLIB)
LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o
......
......@@ -544,7 +544,7 @@ print NORM "
/* Auto-generated file... Do not edit ! */
#include \"config.h\"
#include \"wine_gl.h\"
#include \"opengl_ext.h\"
#include \"wine/debug.h\"
typedef const GLubyte * GLstring;
......@@ -567,13 +567,11 @@ print EXT "
/* Auto-generated file... Do not edit ! */
#include \"config.h\"
#include \"wine_gl.h\"
#include \"opengl_ext.h\"
#include \"wine/debug.h\"
typedef const GLubyte * GLstring;
#include \"opengl_ext.h\"
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
";
......
......@@ -2,13 +2,11 @@
/* Auto-generated file... Do not edit ! */
#include "config.h"
#include "wine_gl.h"
#include "opengl_ext.h"
#include "wine/debug.h"
typedef const GLubyte * GLstring;
#include "opengl_ext.h"
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
void (*func_glActiveTexture)( GLenum ) = (void *) 0xdeadbeef;
......
......@@ -19,6 +19,37 @@
#ifndef __DLLS_OPENGL32_OPENGL_EXT_H
#define __DLLS_OPENGL32_OPENGL_EXT_H
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
#include <GL/gl.h>
#include <GL/glx.h>
#ifdef HAVE_GL_GLEXT_H
# include <GL/glext.h>
#endif
#undef XMD_H
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
/* X11 locking */
extern void (*wine_tsx11_lock_ptr)(void);
extern void (*wine_tsx11_unlock_ptr)(void);
/* As GLX relies on X, this is needed */
#define ENTER_GL() wine_tsx11_lock_ptr()
#define LEAVE_GL() wine_tsx11_unlock_ptr()
typedef struct {
char *name; /* name of the extension */
char *glx_name; /* name used on Unix's libGL */
......
......@@ -2,7 +2,7 @@
/* Auto-generated file... Do not edit ! */
#include "config.h"
#include "wine_gl.h"
#include "opengl_ext.h"
#include "wine/debug.h"
typedef const GLubyte * GLstring;
......
......@@ -26,7 +26,6 @@
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
#include "wine_gl.h"
#include "x11drv.h"
#include "wgl.h"
......@@ -35,6 +34,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
void (*wine_tsx11_lock_ptr)(void) = NULL;
void (*wine_tsx11_unlock_ptr)(void) = NULL;
static GLXContext default_cx = NULL;
static Display *default_display; /* display to use for default context */
......@@ -586,13 +588,17 @@ static BOOL process_attach(void)
HDC hdc;
XVisualInfo *vis = NULL;
Window root = (Window)GetPropA( GetDesktopWindow(), "__wine_x11_whole_window" );
HMODULE mod = GetModuleHandleA( "x11drv.dll" );
if (!root)
if (!root || !mod)
{
ERR("X11DRV not loaded. Cannot create default context.\n");
return FALSE;
}
wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
hdc = GetDC(0);
default_display = get_display( hdc );
ReleaseDC( 0, hdc );
......
......@@ -99,3 +99,7 @@ init X11DRV_Init
@ cdecl GetClipboardFormatName(long str long) X11DRV_GetClipboardFormatName
@ cdecl IsSelectionOwner() X11DRV_IsSelectionOwner
@ cdecl ResetSelectionOwner(ptr long) X11DRV_ResetSelectionOwner
# X11 locks
@ cdecl -norelay wine_tsx11_lock() X11DRV_tsx11_lock
@ cdecl -norelay wine_tsx11_unlock() X11DRV_tsx11_unlock
......@@ -41,7 +41,6 @@
#include "gdi.h"
#include "user.h"
#include "win.h"
#include "wine_gl.h"
#include "x11drv.h"
#include "xvidmode.h"
#include "dga2.h"
......@@ -137,17 +136,17 @@ static int error_handler( Display *display, XErrorEvent *error_evt )
}
/***********************************************************************
* lock_tsx11
* X11DRV_tsx11_lock (X11DRV.@)
*/
static void lock_tsx11(void)
void X11DRV_tsx11_lock(void)
{
EnterCriticalSection( &X11DRV_CritSection );
}
/***********************************************************************
* unlock_tsx11
* X11DRV_tsx11_unlock (X11DRV.@)
*/
static void unlock_tsx11(void)
void X11DRV_tsx11_unlock(void)
{
LeaveCriticalSection( &X11DRV_CritSection );
}
......@@ -262,36 +261,6 @@ static void setup_options(void)
/***********************************************************************
* setup_opengl_visual
*
* Setup the default visual used for OpenGL and Direct3D, and the desktop
* window (if it exists). If OpenGL isn't available, the visual is simply
* set to the default visual for the display
*/
#ifdef HAVE_OPENGL
static void setup_opengl_visual( Display *display )
{
int err_base, evt_base;
/* In order to support OpenGL or D3D, we require a double-buffered
* visual */
wine_tsx11_lock();
if (glXQueryExtension(display, &err_base, &evt_base) == True) {
int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
desktop_vi = glXChooseVisual(display, DefaultScreen(display), dblBuf);
}
wine_tsx11_unlock();
if (desktop_vi != NULL) {
visual = desktop_vi->visual;
screen = ScreenOfDisplay(display, desktop_vi->screen);
screen_depth = desktop_vi->depth;
}
}
#endif /* HAVE_OPENGL */
/***********************************************************************
* X11DRV process initialisation routine
*/
static void process_attach(void)
......@@ -304,8 +273,8 @@ static void process_attach(void)
/* setup TSX11 locking */
old_tsx11_lock = wine_tsx11_lock;
old_tsx11_unlock = wine_tsx11_unlock;
wine_tsx11_lock = lock_tsx11;
wine_tsx11_unlock = unlock_tsx11;
wine_tsx11_lock = X11DRV_tsx11_lock;
wine_tsx11_unlock = X11DRV_tsx11_unlock;
/* Open display */
......@@ -338,9 +307,12 @@ static void process_attach(void)
else screen_depth = DefaultDepthOfScreen( screen );
/* If OpenGL is available, change the default visual, etc as necessary */
#ifdef HAVE_OPENGL
setup_opengl_visual( display );
#endif /* HAVE_OPENGL */
if ((desktop_vi = X11DRV_setup_opengl_visual( display )))
{
visual = desktop_vi->visual;
screen = ScreenOfDisplay(display, desktop_vi->screen);
screen_depth = desktop_vi->depth;
}
/* tell the libX11 that we will do input method handling ourselves
* that keep libX11 from doing anything whith dead keys, allowing Wine
......
......@@ -25,15 +25,36 @@
#include <stdlib.h>
#include <string.h>
#include "wine/debug.h"
#include "gdi.h"
#include "x11drv.h"
#include "wine_gl.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(opengl);
#ifdef HAVE_OPENGL
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
#include <GL/gl.h>
#include <GL/glx.h>
#ifdef HAVE_GL_GLEXT_H
# include <GL/glext.h>
#endif
#undef XMD_H
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
static void dump_PIXELFORMATDESCRIPTOR(PIXELFORMATDESCRIPTOR *ppfd) {
DPRINTF(" - size / version : %d / %d\n", ppfd->nSize, ppfd->nVersion);
DPRINTF(" - dwFlags : ");
......@@ -123,7 +144,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
/* ADD2(GLX_AUX_BUFFERS, ppfd->cAuxBuffers); */
att_list[att_pos] = None;
ENTER_GL(); {
wine_tsx11_lock(); {
/*
This command cannot be used as we need to use the default visual...
Let's hope it at least contains some OpenGL functionnalities
......@@ -138,7 +159,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
TRACE("Found visual : %p - returns %d\n", vis, physDev->used_visuals + 1);
}
LEAVE_GL();
wine_tsx11_unlock();
if (vis == NULL) {
ERR("No visual found !\n");
......@@ -199,9 +220,9 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
/* Create a 'standard' X Visual */
ENTER_GL();
wine_tsx11_lock();
vis = glXChooseVisual(gdi_display, DefaultScreen(gdi_display), dblBuf);
LEAVE_GL();
wine_tsx11_unlock();
WARN("Uninitialized Visual. Creating standard (%p) !\n", vis);
......@@ -222,7 +243,7 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
/* These flags are always the same... */
ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_ACCELERATED;
/* Now the flags extraced from the Visual */
ENTER_GL();
wine_tsx11_lock();
glXGetConfig(gdi_display, vis, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER;
glXGetConfig(gdi_display, vis, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO;
......@@ -272,7 +293,7 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
glXGetConfig( gdi_display, vis, GLX_STENCIL_SIZE, &value );
ppfd->cStencilBits = value;
LEAVE_GL();
wine_tsx11_unlock();
/* Aux : to do ... */
......@@ -316,13 +337,37 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) {
TRACE("(%p)\n", physDev);
ENTER_GL();
wine_tsx11_lock();
glXSwapBuffers(gdi_display, physDev->drawable);
LEAVE_GL();
wine_tsx11_unlock();
return TRUE;
}
/***********************************************************************
* X11DRV_setup_opengl_visual
*
* Setup the default visual used for OpenGL and Direct3D, and the desktop
* window (if it exists). If OpenGL isn't available, the visual is simply
* set to the default visual for the display
*/
XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
{
int err_base, evt_base;
XVisualInfo *visual = NULL;
/* In order to support OpenGL or D3D, we require a double-buffered
* visual */
wine_tsx11_lock();
if (glXQueryExtension(display, &err_base, &evt_base) == True)
{
int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
visual = glXChooseVisual(display, DefaultScreen(display), dblBuf);
}
wine_tsx11_unlock();
return visual;
}
#else /* defined(HAVE_OPENGL) */
int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
......@@ -361,4 +406,9 @@ BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) {
return FALSE;
}
XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
{
return NULL;
}
#endif /* defined(HAVE_OPENGL) */
/* Wrapper for OpenGL includes...
* Copyright 1998 - Lionel Ulmer
*
* This wrapper is needed because Mesa uses also the CALLBACK / WINAPI
* constants.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_WINE_GL_H
#define __WINE_WINE_GL_H
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#if defined(HAVE_OPENGL)
#include "ts_xlib.h"
/* As GLX relies on X, this is needed */
#define ENTER_GL() wine_tsx11_lock()
#define LEAVE_GL() wine_tsx11_unlock()
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
#define XMD_H /* This is to prevent the Xmd.h inclusion bug to happen :-/ */
#include <GL/gl.h>
#include <GL/glx.h>
#ifdef HAVE_GL_GLEXT_H
# include <GL/glext.h>
#endif
#undef XMD_H
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
#endif /* HAVE_OPENGL */
#endif /* __WINE_WINE_GL_H */
......@@ -436,5 +436,6 @@ extern void X11DRV_sync_window_style( Display *display, WND *win );
extern int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder );
extern int X11DRV_sync_client_window_position( Display *display, WND *win );
extern void X11DRV_set_wm_hints( Display *display, WND *win );
extern XVisualInfo *X11DRV_setup_opengl_visual( Display *display );
#endif /* __WINE_X11DRV_H */
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