From f4fd8bb669d684140d40ba0080921466d67a8a42 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 18 Jun 2014 01:21:05 +0200 Subject: [PATCH] Fix linking of OpenGL driver under MinGW --- code/nel/include/nel/3d/driver.h | 2 +- code/nel/include/nel/3d/driver_user.h | 2 +- code/nel/include/nel/3d/dru.h | 7 +++++-- code/nel/include/nel/3d/u_driver.h | 4 ++-- code/nel/src/3d/driver/direct3d/driver_direct3d.cpp | 2 +- code/nel/src/3d/driver/direct3d/driver_direct3d.h | 2 +- code/nel/src/3d/driver/opengl/CMakeLists.txt | 2 +- code/nel/src/3d/driver/opengl/driver_opengl.cpp | 9 +++++++-- code/nel/src/3d/driver/opengl/driver_opengl.def | 6 ++++-- code/nel/src/3d/driver/opengl/driver_opengl.h | 2 +- code/nel/src/3d/driver/opengl/driver_opengl_window.cpp | 2 +- code/nel/src/3d/driver/opengl/stdopengl.h | 4 +++- code/nel/src/3d/driver_user.cpp | 6 +++--- 13 files changed, 31 insertions(+), 19 deletions(-) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 3eb5823ca..c04fffcdf 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -182,7 +182,7 @@ public: IDriver(); virtual ~IDriver(); - virtual bool init(uint windowIcon = 0, emptyProc exitFunc = 0) = 0; + virtual bool init(uintptr_t windowIcon = 0, emptyProc exitFunc = 0) = 0; /// Deriver should calls IDriver::release() first, to destroy all driver components (textures, shaders, VBuffers). virtual bool release(); diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index 30ea98c65..ff9ba8973 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -123,7 +123,7 @@ public: /// \name Object // @{ - CDriverUser (uint windowIcon, UDriver::TDriver driver, emptyProc exitFunc = 0); + CDriverUser (uintptr_t windowIcon, UDriver::TDriver driver, emptyProc exitFunc = 0); virtual ~CDriverUser(); // @} diff --git a/code/nel/include/nel/3d/dru.h b/code/nel/include/nel/3d/dru.h index 115f86432..fda543ecd 100644 --- a/code/nel/include/nel/3d/dru.h +++ b/code/nel/include/nel/3d/dru.h @@ -24,8 +24,11 @@ #include "nel/misc/geom_ext.h" #include "nel/misc/line.h" - -#ifdef NL_OS_WINDOWS +#if defined (NL_COMP_MINGW) +# define NL3D_GL_DLL_NAME "libnel_drv_opengl_win" +# define NL3D_GLES_DLL_NAME "libnel_drv_opengles_win" +# define NL3D_D3D_DLL_NAME "libnel_drv_direct3d_win" +#elif defined (NL_OS_WINDOWS) # define NL3D_GL_DLL_NAME "nel_drv_opengl_win" # define NL3D_GLES_DLL_NAME "nel_drv_opengles_win" # define NL3D_D3D_DLL_NAME "nel_drv_direct3d_win" diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 2e74ae3fe..67e0c30fd 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -845,8 +845,8 @@ public: /** * This is the static function which build a UDriver, the root for all 3D functions. */ - static UDriver *createDriver(uint windowIcon = 0, bool direct3d = false, emptyProc exitFunc = 0); - static UDriver *createDriver(uint windowIcon, TDriver driver, emptyProc exitFunc = 0); + static UDriver *createDriver(uintptr_t windowIcon = 0, bool direct3d = false, emptyProc exitFunc = 0); + static UDriver *createDriver(uintptr_t windowIcon, TDriver driver, emptyProc exitFunc = 0); /** * Purge static memory diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 864406205..814ddbf1c 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1231,7 +1231,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l // *************************************************************************** -bool CDriverD3D::init (uint windowIcon, emptyProc exitFunc) +bool CDriverD3D::init (uintptr_t windowIcon, emptyProc exitFunc) { H_AUTO_D3D(CDriver3D_init ); diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 1055e105c..36a1c9804 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -839,7 +839,7 @@ public: // *************************************************************************** // Mode initialisation, requests - virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); + virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); virtual bool release(); virtual bool setMode(const GfxMode& mode); diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index aea202e8b..9e9e05918 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -37,7 +37,7 @@ NL_ADD_RUNTIME_FLAGS(${NLDRV_OGL_LIB}) IF(WIN32) INCLUDE_DIRECTORIES(${DXSDK_INCLUDE_DIR}) TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${DXSDK_DINPUT_LIBRARY} ${DXSDK_GUID_LIBRARY}) - ADD_DEFINITIONS(/DDRIVER_OPENGL_EXPORTS) + ADD_DEFINITIONS(-DDRIVER_OPENGL_EXPORTS) ENDIF(WIN32) IF(APPLE) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index e8cb57a22..9ec29f0ba 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -108,7 +108,10 @@ IDriver* createGlDriverInstance () #else #ifdef NL_OS_WINDOWS - +#ifdef NL_COMP_MINGW +extern "C" +{ +#endif __declspec(dllexport) IDriver* NL3D_createIDriverInstance () { return new CDriverGL; @@ -118,7 +121,9 @@ __declspec(dllexport) uint32 NL3D_interfaceVersion () { return IDriver::InterfaceVersion; } - +#ifdef NL_COMP_MINGW +} +#endif #elif defined (NL_OS_UNIX) extern "C" diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.def b/code/nel/src/3d/driver/opengl/driver_opengl.def index bfe648552..369389fa9 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.def +++ b/code/nel/src/3d/driver/opengl/driver_opengl.def @@ -1,2 +1,4 @@ -EXPORTS NL3D_createIDriverInstance -EXPORTS NL3D_interfaceVersion +LIBRARY nel_drv_opengl_win_r +EXPORTS + NL3D_createIDriverInstance + NL3D_interfaceVersion \ No newline at end of file diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 57f73b0b6..46d12eef1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -304,7 +304,7 @@ public: virtual bool isLost() const { return false; } // there's no notion of 'lost device" in OpenGL - virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); + virtual bool init (uintptr_t windowIcon = 0, emptyProc exitFunc = 0); virtual void disableHardwareVertexProgram(); virtual void disableHardwarePixelProgram(); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 07c800cdc..2fea530cf 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -296,7 +296,7 @@ bool GlWndProc(CDriverGL *driver, XEvent &e) #endif // NL_OS_UNIX // *************************************************************************** -bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) +bool CDriverGL::init (uintptr_t windowIcon, emptyProc exitFunc) { H_AUTO_OGL(CDriverGL_init) diff --git a/code/nel/src/3d/driver/opengl/stdopengl.h b/code/nel/src/3d/driver/opengl/stdopengl.h index 544829b19..9773b0048 100644 --- a/code/nel/src/3d/driver/opengl/stdopengl.h +++ b/code/nel/src/3d/driver/opengl/stdopengl.h @@ -37,7 +37,9 @@ #ifdef NL_OS_WINDOWS # define WIN32_LEAN_AND_MEAN -# define NOMINMAX +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif # include # include #endif diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index e5d814755..7ccf4cfce 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -82,13 +82,13 @@ void UDriver::setMatrixMode2D43() } // *************************************************************************** -UDriver *UDriver::createDriver(uint windowIcon, bool direct3d, emptyProc exitFunc) +UDriver *UDriver::createDriver(uintptr_t windowIcon, bool direct3d, emptyProc exitFunc) { return new CDriverUser (windowIcon, direct3d ? CDriverUser::Direct3d:CDriverUser::OpenGl, exitFunc); } // *************************************************************************** -UDriver *UDriver::createDriver(uint windowIcon, TDriver driver, emptyProc exitFunc) +UDriver *UDriver::createDriver(uintptr_t windowIcon, TDriver driver, emptyProc exitFunc) { return new CDriverUser (windowIcon, (CDriverUser::TDriver)driver, exitFunc); } @@ -114,7 +114,7 @@ bool CDriverUser::_StaticInit= false; // *************************************************************************** -CDriverUser::CDriverUser (uint windowIcon, TDriver driver, emptyProc exitFunc) +CDriverUser::CDriverUser (uintptr_t windowIcon, TDriver driver, emptyProc exitFunc) { // The enum of IDriver and UDriver MUST be the same!!! nlassert((uint)IDriver::idCount == (uint)UDriver::idCount);