diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 2655695c8..6dcb38e75 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -178,7 +178,7 @@ public: // first param is the associated window. // Must be a HWND for Windows (WIN32). - virtual bool setDisplay(void* wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay)=0; + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay)=0; // Must be called after a setDisplay that initialize the mode virtual bool setMode(const GfxMode& mode)=0; virtual bool getModes(std::vector &modes)=0; diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index 9c5fe0b38..795afa19c 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -138,7 +138,7 @@ public: /// create the window. virtual bool setDisplay(const CMode &mode, bool show, bool resizeable); - virtual bool setDisplay(void *wnd, const CMode &mode, bool show, bool resizeable); + virtual bool setDisplay(nlWindow wnd, const CMode &mode, bool show, bool resizeable); virtual bool setMode(const CMode& mode); virtual bool getModes(std::vector &modes); virtual bool getCurrentScreenMode(CMode &mode); diff --git a/code/nel/include/nel/3d/nelu.h b/code/nel/include/nel/3d/nelu.h index eb92af3d4..185cc6cc5 100644 --- a/code/nel/include/nel/3d/nelu.h +++ b/code/nel/include/nel/3d/nelu.h @@ -64,7 +64,7 @@ public: * * You can access the driver with CNELU::Driver. */ - static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, void *systemWindow=NULL, bool offscreen=false, bool direct3d=false) throw(EDru); + static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false) throw(EDru); /** Init all that we need for a Scene. * - register scene basics models, @@ -108,7 +108,7 @@ public: * - initScene(); * - initEventServer(); */ - static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, void *systemWindow=NULL, bool offscreen = false, bool direct3d = false) throw(EDru); + static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false) throw(EDru); /** Delete all: * - releaseEventServer(); diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 4c7a83c4f..46472e045 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -178,7 +178,7 @@ public: * \param show show or hide the window in window mode. */ virtual bool setDisplay(const CMode &mode, bool show = true, bool resizeable = true) =0; - virtual bool setDisplay(void *wnd, const CMode &mode, bool show = true, bool resizeable = true) =0; + virtual bool setDisplay(nlWindow wnd, const CMode &mode, bool show = true, bool resizeable = true) =0; virtual bool setMode(const CMode& mode)=0; virtual bool getModes(std::vector &modes)=0; virtual bool getCurrentScreenMode(CMode &mode)=0; diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index 4f5bacb75..304757add 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -33,6 +33,7 @@ #ifdef NL_OS_WINDOWS # include # include +# include #else # include # include @@ -41,6 +42,13 @@ #include "string_common.h" +#ifdef NL_OS_WINDOWS + typedef HWND nlWindow; + #define EmptyWindow NULL +#else + typedef int nlWindow; + #define EmptyWindow 0 +#endif /// This namespace contains all miscellaneous classes used by other modules namespace NLMISC diff --git a/code/nel/src/3d/driver.cpp b/code/nel/src/3d/driver.cpp index 2fddf13d1..21afd042b 100644 --- a/code/nel/src/3d/driver.cpp +++ b/code/nel/src/3d/driver.cpp @@ -34,7 +34,7 @@ namespace NL3D { // *************************************************************************** -const uint32 IDriver::InterfaceVersion = 0x63; // added supportNonPowerOfTwoTextures() +const uint32 IDriver::InterfaceVersion = 0x64; // Added nlWindow patch. // *************************************************************************** IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" ) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index ea4a07840..49b350d00 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1295,7 +1295,7 @@ const D3DFORMAT FinalPixelFormat[ITexture::UploadFormatCount][CDriverD3D::FinalP // *************************************************************************** -bool CDriverD3D::setDisplay(void* wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay) +bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay) { H_AUTO_D3D(CDriver3D_setDisplay); if (!_D3D) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index b9979864c..00cecd1df 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -737,7 +737,7 @@ public: // Mode initialisation, requests virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); - virtual bool setDisplay(void* wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); virtual bool release(); virtual bool setMode(const GfxMode& mode); virtual bool getModes(std::vector &modes); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 3d9c40b31..8c0d2fd7b 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -98,7 +98,7 @@ uint CDriverGL::_Registered=0; #endif // NL_OS_WINDOWS // Version of the driver. Not the interface version!! Increment when implementation of the driver change. -const uint32 CDriverGL::ReleaseVersion = 0xf; +const uint32 CDriverGL::ReleaseVersion = 0x10; // Number of register to allocate for the EXTVertexShader extension const uint CDriverGL::_EVSNumConstant = 97; @@ -551,7 +551,7 @@ void CDriverGL::disableHardwareTextureShader() // -------------------------------------------------- -bool CDriverGL::setDisplay(void *wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay) +bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay) { H_AUTO_OGL(CDriverGL_setDisplay) @@ -1091,10 +1091,7 @@ bool CDriverGL::setDisplay(void *wnd, const GfxMode &mode, bool show, bool resiz nldebug("3D: glXCreateContext() OK"); } - Colormap cmap = XCreateColormap (dpy, RootWindow(dpy, DefaultScreen(dpy)), visual_info->visual, AllocNone); - XSetWindowAttributes attr; - attr.colormap = cmap; attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy)); #ifdef XF86VIDMODE @@ -1113,17 +1110,30 @@ bool CDriverGL::setDisplay(void *wnd, const GfxMode &mode, bool show, bool resiz attr.override_redirect = False; #endif - int attr_flags = CWOverrideRedirect | CWColormap | CWBackPixel; - - win = XCreateWindow (dpy, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, width, height, 0, visual_info->depth, InputOutput, visual_info->visual, attr_flags, &attr); + int attr_flags = CWOverrideRedirect | CWBackPixel; - if(!win) + if(wnd == EmptyWindow) { - nlerror("XCreateWindow() failed"); + nlWindow root = RootWindow(dpy, DefaultScreen(dpy)); + + attr.colormap = XCreateColormap(dpy, root, visual_info->visual, AllocNone); + attr_flags |= CWColormap; + + win = XCreateWindow (dpy, root, 0, 0, width, height, 0, visual_info->depth, InputOutput, visual_info->visual, attr_flags, &attr); + + if (win == EmptyWindow) + { + nlerror("3D: XCreateWindow() failed"); + } + else + { + nldebug("3D: XCreateWindow() OK"); + } } else { - nldebug("3D: XCreateWindow() OK"); + win = wnd; + XChangeWindowAttributes(dpy, win, attr_flags, &attr); } XSizeHints size_hints; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 8d7f902dd..b87467cd4 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -283,7 +283,7 @@ public: virtual void disableHardwareVertexArrayAGP(); virtual void disableHardwareTextureShader(); - virtual bool setDisplay(void* wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); + virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay); virtual bool setMode(const GfxMode& mode); virtual bool getModes(std::vector &modes); virtual bool getCurrentScreenMode(GfxMode &mode); diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index fce33c526..bd22df612 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -224,11 +224,11 @@ bool CDriverUser::setDisplay(const CMode &mode, bool show, bool resizeable) { NL3D_HAUTO_UI_DRIVER; - return setDisplay(NULL, mode, show, resizeable); + return setDisplay(EmptyWindow, mode, show, resizeable); } // *************************************************************************** -bool CDriverUser::setDisplay(void *wnd, const CMode &mode, bool show, bool resizeable) +bool CDriverUser::setDisplay(nlWindow wnd, const CMode &mode, bool show, bool resizeable) { NL3D_HAUTO_UI_DRIVER; diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 3907f8887..721d6f1cb 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -47,7 +47,7 @@ CEventServer CNELU::EventServer; CEventListenerAsync CNELU::AsyncListener; -bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, void *systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) { // Init debug system // NLMISC::InitDebug(); @@ -174,7 +174,7 @@ void CNELU::releaseDriver() } } -bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, void *systemWindow, bool offscreen, bool direct3d) throw(EDru) +bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru) { NL3D::registerSerial3d(); if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d))