diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index c5a807eac..e3b5b39a6 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -104,7 +104,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 = 0x10; +const uint32 CDriverGL::ReleaseVersion = 0x11; // Number of register to allocate for the EXTVertexShader extension const uint CDriverGL::_EVSNumConstant = 97; @@ -196,7 +196,6 @@ CDriverGL::CDriverGL() #ifdef NL_OS_WINDOWS _PBuffer = NULL; - _hWnd = NULL; _hRC = NULL; _hDC = NULL; _NeedToRestaureGammaRamp = false; @@ -207,19 +206,25 @@ CDriverGL::CDriverGL() NL3D::MAC::ctor(); #elif defined (NL_OS_UNIX) - cursor = None; - win = 0; - dpy = 0; + + _cursor = None; + _dpy = 0; + _visual_info = NULL; # ifdef XF86VIDMODE // zero the old screen mode memset(&_OldScreenMode, 0, sizeof(_OldScreenMode)); - # endif //XF86VIDMODE + #endif // NL_OS_UNIX + _win = EmptyWindow; + _DestroyWindow = false; + _OffScreen = false; _FullScreen = false; + _Resizable = false; + _AntiAliasing = -1; _CurrentMaterial=NULL; _Initialized = false; @@ -341,72 +346,6 @@ CDriverGL::~CDriverGL() #endif } -// *************************************************************************** -bool CDriverGL::stretchRect(ITexture * /* srcText */, NLMISC::CRect &/* srcRect */, ITexture * /* destText */, NLMISC::CRect &/* destRect */) -{ - H_AUTO_OGL(CDriverGL_stretchRect) - - return false; -} - -// *************************************************************************** -bool CDriverGL::supportBloomEffect() const -{ - return (isVertexProgramSupported() && supportFrameBufferObject() && supportPackedDepthStencil() && supportTextureRectangle()); -} - -// *************************************************************************** -bool CDriverGL::supportNonPowerOfTwoTextures() const -{ - return _Extensions.ARBTextureNonPowerOfTwo; -} - -// *************************************************************************** -bool CDriverGL::isTextureRectangle(ITexture * tex) const -{ - return (supportTextureRectangle() && tex->isBloomTexture() && tex->mipMapOff() - && (!isPowerOf2(tex->getWidth()) || !isPowerOf2(tex->getHeight()))); -} - -// *************************************************************************** -bool CDriverGL::activeFrameBufferObject(ITexture * tex) -{ - if(supportFrameBufferObject()/* && supportPackedDepthStencil()*/) - { - if(tex) - { - CTextureDrvInfosGL* gltext = (CTextureDrvInfosGL*)(ITextureDrvInfos*)(tex->TextureDrvShare->DrvTexture); - return gltext->activeFrameBufferObject(tex); - } - else - { - nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - return true; - } - } - - return false; -} - -// -------------------------------------------------- -void CDriverGL::disableHardwareVertexProgram() -{ - H_AUTO_OGL(CDriverGL_disableHardwareVertexProgram) - _Extensions.DisableHardwareVertexProgram= true; -} - -void CDriverGL::disableHardwareVertexArrayAGP() -{ - H_AUTO_OGL(CDriverGL_disableHardwareVertexArrayAGP) - _Extensions.DisableHardwareVertexArrayAGP= true; -} - -void CDriverGL::disableHardwareTextureShader() -{ - H_AUTO_OGL(CDriverGL_disableHardwareTextureShader) - _Extensions.DisableHardwareTextureShader= true; -} - // -------------------------------------------------- bool CDriverGL::setupDisplay() { @@ -682,6 +621,74 @@ bool CDriverGL::setupDisplay() return true; } +// *************************************************************************** +bool CDriverGL::stretchRect(ITexture * /* srcText */, NLMISC::CRect &/* srcRect */, ITexture * /* destText */, NLMISC::CRect &/* destRect */) +{ + H_AUTO_OGL(CDriverGL_stretchRect) + + return false; +} + +// *************************************************************************** +bool CDriverGL::supportBloomEffect() const +{ + return (isVertexProgramSupported() && supportFrameBufferObject() && supportPackedDepthStencil() && supportTextureRectangle()); +} + +// *************************************************************************** +bool CDriverGL::supportNonPowerOfTwoTextures() const +{ + return _Extensions.ARBTextureNonPowerOfTwo; +} + +// *************************************************************************** +bool CDriverGL::isTextureRectangle(ITexture * tex) const +{ + return (supportTextureRectangle() && tex->isBloomTexture() && tex->mipMapOff() + && (!isPowerOf2(tex->getWidth()) || !isPowerOf2(tex->getHeight()))); +} + +// *************************************************************************** +bool CDriverGL::activeFrameBufferObject(ITexture * tex) +{ + if(supportFrameBufferObject()/* && supportPackedDepthStencil()*/) + { + if(tex) + { + CTextureDrvInfosGL* gltext = (CTextureDrvInfosGL*)(ITextureDrvInfos*)(tex->TextureDrvShare->DrvTexture); + return gltext->activeFrameBufferObject(tex); + } + else + { + nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + return true; + } + } + + return false; +} + +// -------------------------------------------------- +void CDriverGL::disableHardwareVertexProgram() +{ + H_AUTO_OGL(CDriverGL_disableHardwareVertexProgram) + _Extensions.DisableHardwareVertexProgram= true; +} + +// *************************************************************************** +void CDriverGL::disableHardwareVertexArrayAGP() +{ + H_AUTO_OGL(CDriverGL_disableHardwareVertexArrayAGP) + _Extensions.DisableHardwareVertexArrayAGP= true; +} + +// *************************************************************************** +void CDriverGL::disableHardwareTextureShader() +{ + H_AUTO_OGL(CDriverGL_disableHardwareTextureShader) + _Extensions.DisableHardwareTextureShader= true; +} + // -------------------------------------------------- void CDriverGL::resetTextureShaders() { @@ -863,7 +870,7 @@ bool CDriverGL::swapBuffers() NL3D::MAC::swapBuffers(); #elif defined (NL_OS_UNIX) - glXSwapBuffers(dpy, win); + glXSwapBuffers(_dpy, _win); #endif // NL_OS_WINDOWS @@ -949,87 +956,9 @@ bool CDriverGL::release() _AGPVertexArrayRange= NULL; _VRAMVertexArrayRange= NULL; -#ifdef NL_OS_WINDOWS - // Then delete. - // wglMakeCurrent(NULL,NULL); + destroyWindow(); - // Off-screen rendering ? - if (_OffScreen) - { - if (_PBuffer) - { - wglDeleteContext( _hRC ); - nwglReleasePbufferDCARB( _PBuffer, _hDC ); - nwglDestroyPbufferARB( _PBuffer ); - } - } - else - { - if (_hRC) - wglDeleteContext(_hRC); - - if (_hWnd&&_hDC) - { - ReleaseDC(_hWnd,_hDC); - if (_DestroyWindow) - DestroyWindow (_hWnd); - } - - if(_FullScreen) - { - switchBackToOldMode(); - _FullScreen= false; - } - } - - _hRC=NULL; - _hDC=NULL; - _hWnd=NULL; - _PBuffer = NULL; - - // Restaure monitor color parameters - if (_NeedToRestaureGammaRamp) - { - HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL); - if (dc) - { - if (!SetDeviceGammaRamp (dc, _GammaRampBackuped)) - nlwarning ("(CDriverGL::release): SetDeviceGammaRamp failed"); - - // Release the DC - ReleaseDC (NULL, dc); - } - else - { - nlwarning ("(CDriverGL::release): can't create DC"); - } - } - -#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) - - NL3D::MAC::release(); - -#elif defined (NL_OS_UNIX) - if(_FullScreen) - { - switchBackToOldMode(); - - // Ungrab the keyboard (probably not necessary); - XUnmapWindow(dpy, win); - XSync(dpy, True); - XUngrabKeyboard(dpy, CurrentTime); - } - - if (ctx) - { - glXDestroyContext(dpy, ctx); - ctx = NULL; - } - - XCloseDisplay(dpy); - dpy = NULL; - -#endif // NL_OS_UNIX + unInit(); // released _Initialized= false; @@ -1042,7 +971,7 @@ void CDriverGL::setupViewport (const class CViewport& viewport) { H_AUTO_OGL(CDriverGL_setupViewport ) #ifdef NL_OS_WINDOWS - if (_hWnd == NULL) return; + if (_win == EmptyWindow) return; // Setup gl viewport int clientWidth = _WindowWidth; @@ -1056,7 +985,7 @@ void CDriverGL::setupViewport (const class CViewport& viewport) #elif defined (NL_OS_UNIX) XWindowAttributes win_attributes; - if (!XGetWindowAttributes(dpy, win, &win_attributes)) + if (!XGetWindowAttributes(_dpy, _win, &win_attributes)) throw EBadDisplay("Can't get window attributes."); // Setup gl viewport @@ -1114,7 +1043,7 @@ void CDriverGL::setupScissor (const class CScissor& scissor) { H_AUTO_OGL(CDriverGL_setupScissor ) #ifdef NL_OS_WINDOWS - if (_hWnd == NULL) return; + if (_win == EmptyWindow) return; // Setup gl viewport int clientWidth = _WindowWidth; @@ -1130,7 +1059,7 @@ void CDriverGL::setupScissor (const class CScissor& scissor) #elif defined (NL_OS_UNIX) XWindowAttributes win_attributes; - if (!XGetWindowAttributes(dpy, win, &win_attributes)) + if (!XGetWindowAttributes(_dpy, _win, &win_attributes)) throw EBadDisplay("Can't get window attributes."); // Setup gl viewport @@ -2729,7 +2658,7 @@ void CDriverGL::stencilFunc(TStencilFunc stencilFunc, int ref, uint mask) { H_AUTO_OGL(CDriverGL_CDriverGL) - GLenum glstencilFunc; + GLenum glstencilFunc = 0; switch(stencilFunc) { @@ -2752,7 +2681,7 @@ void CDriverGL::stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass) { H_AUTO_OGL(CDriverGL_CDriverGL) - GLenum glFail, glZFail, glZPass; + GLenum glFail = 0, glZFail = 0, glZPass = 0; switch(fail) { diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 605acd3a0..e8001014c 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -305,13 +305,11 @@ public: virtual nlWindow getDisplay() { -#ifdef NL_OS_WINDOWS - return _hWnd; -#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) +#if defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) return NULL; -#elif defined(NL_OS_UNIX) - return win; -#endif // NL_OS_WINDOWS +#else + return _win; +#endif } virtual uint32 getAvailableVertexAGPMemory (); @@ -655,26 +653,29 @@ private: private: // Version of the driver. Not the interface version!! Increment when implementation of the driver change. - static const uint32 ReleaseVersion; + static const uint32 ReleaseVersion; bool _FullScreen; bool _OffScreen; + bool _Resizable; uint _Interval; + sint8 _AntiAliasing; sint32 _WindowWidth, _WindowHeight, _WindowX, _WindowY; + nlWindow _win; + bool _DestroyWindow; + #ifdef NL_OS_WINDOWS friend static bool GlWndProc(CDriverGL *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - HWND _hWnd; HDC _hDC; PIXELFORMATDESCRIPTOR _pfd; HGLRC _hRC; static uint _Registered; DEVMODE _OldScreenMode; NLMISC::CEventEmitterMulti _EventEmitter; // this can contains a win emitter and eventually a direct input emitter - bool _DestroyWindow; // Off-screen rendering in Dib section HPBUFFERARB _PBuffer; @@ -684,16 +685,16 @@ private: #elif defined (NL_OS_UNIX) - Display *dpy; - GLXContext ctx; - Window win; - Cursor cursor; + Display* _dpy; + GLXContext _ctx; + Cursor _cursor; NLMISC::CUnixEventEmitter _EventEmitter; + XVisualInfo* _visual_info; #ifdef XF86VIDMODE - int _OldDotClock; // old dotclock - XF86VidModeModeLine _OldScreenMode; // old modeline - int _OldX, _OldY; //Viewport settings + int _OldDotClock; // old dotclock + XF86VidModeModeLine _OldScreenMode; // old modeline + int _OldX, _OldY; //Viewport settings #endif //XF86VIDMODE #endif // NL_OS_UNIX @@ -841,8 +842,15 @@ private: bool _CurrentGlNormalize; private: - void switchBackToOldMode(); bool setupDisplay(); + bool unInit(); + + bool createWindow(const GfxMode& mode); + bool destroyWindow(); + // Methods to manage screen resolutions + bool restoreScreenMode(); + bool saveScreenMode(); + bool setScreenMode(const GfxMode &mode); // Get the proj matrix setupped in GL void refreshProjMatrixFromGL(); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index 346218a99..f329b067f 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -416,9 +416,9 @@ PFNWGLFREEMEMORYNVPROC nwglFreeMemoryNV; // Pbuffer extension PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB; -PFNWGLGETPUFFERDCARBPROC nwglGetPbufferDCARB; -PFNWGLRELEASEPUFFERDCARBPROC nwglReleasePbufferDCARB; -PFNWGLDESTROYPUFFERARBPROC nwglDestroyPbufferARB; +PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB; +PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB; +PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB; PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB; // Get Pixel format extension @@ -431,10 +431,9 @@ PFNWGLSWAPINTERVALEXTPROC nwglSwapIntervalEXT; PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT; // WGL_ARB_extensions_string -PFNWGFGETEXTENSIONSSTRINGARB nwglGetExtensionsStringARB; +PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB; #endif - // *************************************************************************** // *************************************************************************** // *************************************************************************** @@ -857,9 +856,9 @@ static bool setupWGLARBPBuffer(const char *glext) #ifdef NL_OS_WINDOWS CHECK_ADDRESS(PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB); - CHECK_ADDRESS(PFNWGLGETPUFFERDCARBPROC, wglGetPbufferDCARB); - CHECK_ADDRESS(PFNWGLRELEASEPUFFERDCARBPROC, wglReleasePbufferDCARB); - CHECK_ADDRESS(PFNWGLDESTROYPUFFERARBPROC, wglDestroyPbufferARB); + CHECK_ADDRESS(PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB); + CHECK_ADDRESS(PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB); + CHECK_ADDRESS(PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB); CHECK_ADDRESS(PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB); #endif @@ -1249,6 +1248,7 @@ void registerGlExtensions(CGlExtensions &ext) // Disable feature ??? if(!ext.DisableHardwareVertexArrayAGP) ext.NVVertexArrayRange= setupNVVertexArrayRange(glext); + if(ext.NVVertexArrayRange) { GLint nverts; @@ -1256,7 +1256,6 @@ void registerGlExtensions(CGlExtensions &ext) ext.NVVertexArrayRangeMaxVertex= nverts; } - // Compression S3TC OK iff ARBTextureCompression. ext.EXTTextureCompressionS3TC= (ext.ARBTextureCompression && setupEXTTextureCompressionS3TC(glext)); @@ -1269,7 +1268,6 @@ void registerGlExtensions(CGlExtensions &ext) // Check NVTextureEnvCombine4. ext.NVTextureEnvCombine4= setupNVTextureEnvCombine4(glext); - // Check for cube mapping ext.ARBTextureCubeMap = setupARBTextureCubeMap(glext); @@ -1305,8 +1303,6 @@ void registerGlExtensions(CGlExtensions &ext) ext.ARBFragmentProgram = false; } - - // For now, the only way to know if emulation, is to test some extension which exist only on GeForce3. // if GL_NV_texture_shader is not here, then we are not on GeForce3. ext.NVVertexProgramEmulated= ext.NVVertexProgram && (strstr(glext, "GL_NV_texture_shader")==NULL); @@ -1319,6 +1315,7 @@ void registerGlExtensions(CGlExtensions &ext) // Check NVVertexArrayRange2 ext.NVVertexArrayRange2= setupNVVertexArrayRange2(glext); + // if supported if(ext.NVVertexArrayRange2) // VBHard swap without flush of the VAR. @@ -1411,7 +1408,7 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC) { H_AUTO_OGL(registerWGlExtensions); // Get proc address - CHECK_ADDRESS(PFNWGFGETEXTENSIONSSTRINGARB, wglGetExtensionsStringARB); + CHECK_ADDRESS(PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB); // Get extension string const char *glext = nwglGetExtensionsStringARB (hDC); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h index 7bb33bf29..f8ba04107 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -158,7 +158,15 @@ public: ARBFragmentProgram = false; ARBVertexBufferObject = false; ARBVertexProgram = false; + NVTextureRectangle = false; + EXTTextureRectangle = false; + ARBTextureRectangle = false; ARBTextureNonPowerOfTwo = false; + NVOcclusionQuery = false; + FrameBufferObject = false; + PackedDepthStencil = false; + NVVertexArrayRange2 = false; + NVStateVARWithoutFlush = 0; /// \name Disable Hardware feature. False by default. setuped by IDriver DisableHardwareVertexProgram= false; @@ -167,6 +175,7 @@ public: // misc IsATI9500OrAbove = false; + IsGeforceFXOrAbove = false; }; std::string toString() @@ -643,9 +652,9 @@ extern NEL_PFNGLGETOCCLUSIONQUERYUIVNVPROC nglGetOcclusionQueryuivNV; // Pbuffer extension //================== extern PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB; -extern PFNWGLGETPUFFERDCARBPROC nwglGetPbufferDCARB; -extern PFNWGLRELEASEPUFFERDCARBPROC nwglReleasePbufferDCARB; -extern PFNWGLDESTROYPUFFERARBPROC nwglDestroyPbufferARB; +extern PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB; +extern PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB; +extern PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB; extern PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB; @@ -663,7 +672,7 @@ extern PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT; // WGL_ARB_extensions_string -extern PFNWGFGETEXTENSIONSSTRINGARB nwglGetExtensionsStringARB; +extern PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB; #endif diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h index 837482553..310205c2b 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h @@ -55,9 +55,9 @@ DECLARE_HANDLE (HPBUFFERARB); typedef void *(APIENTRY * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); typedef void *(APIENTRY * PFNWGLFREEMEMORYNVPROC) (void *pointer); typedef HPBUFFERARB (APIENTRY * PFNWGLCREATEPBUFFERARBPROC) (HDC hdc, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (APIENTRY * PFNWGLGETPUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (APIENTRY * PFNWGLRELEASEPUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC); -typedef BOOL (APIENTRY * PFNWGLDESTROYPUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef HDC (APIENTRY * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (APIENTRY * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC); +typedef BOOL (APIENTRY * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (APIENTRY * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); typedef BOOL (APIENTRY * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC, int, int, UINT, const int *, int *); @@ -67,7 +67,7 @@ typedef BOOL (APIENTRY * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC, const int *, con typedef BOOL (APIENTRY * PFNWGLSWAPINTERVALEXTPROC) (int); typedef int (APIENTRY * PFNWGLGETSWAPINTERVALEXTPROC) (void); -typedef const char* (APIENTRY * PFNWGFGETEXTENSIONSSTRINGARB) (HDC); +typedef const char* (APIENTRY * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC); #endif diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp index 0acd2c57d..77809fbe3 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_texture.cpp @@ -53,15 +53,19 @@ CTextureDrvInfosGL::CTextureDrvInfosGL(IDriver *drv, ItTexDrvInfoPtrMap it, CDri // The id is auto created here. glGenTextures(1,&ID); - Compressed= false; - MipMap= false; - TextureMemory= 0; + Compressed = false; + MipMap = false; + TextureMemory = 0; // Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid. _Driver= drvGl; TextureMode = isRectangleTexture?GL_TEXTURE_RECTANGLE_NV:GL_TEXTURE_2D; + FBOId = 0; + DepthFBOId = 0; + StencilFBOId = 0; + InitFBO = false; AttachDepthStencil = true; UsePackedDepthStencil = drvGl->supportPackedDepthStencil(); @@ -157,33 +161,41 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex) InitFBO = true; break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - nlwarning("Unsupported framebuffer format\n"); + nlwarning("Unsupported framebuffer format"); break; -#if GL_GLEXT_VERSION > 24 +#ifdef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - nlwarning("Framebuffer incomplete attachment\n"); + nlwarning("Framebuffer incomplete attachment"); break; #endif case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: - nlwarning("Framebuffer incomplete, missing attachment\n"); + nlwarning("Framebuffer incomplete, missing attachment"); break; -#if GL_GLEXT_VERSION < 39 +#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: - nlwarning("Framebuffer incomplete, duplicate attachment\n"); + nlwarning("Framebuffer incomplete, duplicate attachment"); break; #endif case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: - nlwarning("Framebuffer incomplete, attached images must have same dimensions\n"); + nlwarning("Framebuffer incomplete, attached images must have same dimensions"); break; case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: - nlwarning("Framebuffer incomplete, attached images must have same format\n"); + nlwarning("Framebuffer incomplete, attached images must have same format"); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: - nlwarning("Framebuffer incomplete, missing draw buffer\n"); + nlwarning("Framebuffer incomplete, missing draw buffer"); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: - nlwarning("Framebuffer incomplete, missing read buffer\n"); + nlwarning("Framebuffer incomplete, missing read buffer"); break; + case GL_FRAMEBUFFER_BINDING_EXT: + nlwarning("Framebuffer BINDING_EXT"); + break; +#ifdef GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + nlwarning("Framebuffer incomplete multisample"); + break; +#endif default: nlwarning("Framebuffer incomplete\n"); //nlassert(0); @@ -237,7 +249,6 @@ static inline CTextureDrvInfosGL* getTextureGl(ITexture& tex) return gltex; } - // *************************************************************************** // Translation of TexFmt mode. GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed) @@ -268,7 +279,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed) } } - // Get gl tex format, try S3TC compressed ones. if(_Extensions.EXTTextureCompressionS3TC) { @@ -284,7 +294,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed) } } - // Get standard gl tex format. compressed= false; switch(texfmt) @@ -313,7 +322,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed) } } - // *************************************************************************** static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt) { @@ -392,7 +400,6 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const return w*h* 4; } - // *************************************************************************** // Translation of Wrap mode. static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtensions &extensions) @@ -409,7 +416,6 @@ static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtens } } - // *************************************************************************** static inline GLenum translateMagFilterToGl(CTextureDrvInfosGL *glText) { @@ -472,7 +478,6 @@ static inline GLenum translateMinFilterToGl(CTextureDrvInfosGL *glText) #endif // NEL_FORCE_NEAREST } - // *************************************************************************** static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt) { @@ -489,7 +494,6 @@ static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt) return false; } - // *************************************************************************** static inline bool isDXTCFormat(GLint glfmt) { @@ -506,7 +510,6 @@ static inline bool isDXTCFormat(GLint glfmt) return false; } - // *************************************************************************** bool CDriverGL::setupTexture (ITexture& tex) { @@ -515,8 +518,6 @@ bool CDriverGL::setupTexture (ITexture& tex) return setupTextureEx (tex, true, nTmp); } - - // *************************************************************************** #ifndef NL_DEBUG inline @@ -624,15 +625,12 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, return true; // Do not do anything } - // 1. If modified, may (re)load texture part or all of the texture. //================================================================= - bool mustLoadAll= false; bool mustLoadPart= false; - // To avoid any delete/new ptr problem, disable all texturing. /* If an old texture is deleted, _CurrentTexture[*] and _CurrentTextureInfoGL[*] are invalid. But this is grave only if a new texture is created, with the same pointer (bad luck). @@ -643,7 +641,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, activateTexture(stage, NULL); } - // A. Share mgt. //============== if(tex.supportSharing()) @@ -786,7 +783,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, glTexImage2D (NLCubeFaceToGLCubeFace[nText], i, glfmt, w, h, 0, glSrcFmt, glSrcType, ptr); bAllUploaded = true; NEL_MEASURE_UPLOAD_TIME_END - } else { @@ -915,7 +911,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, } //printf("%d,%d,%d\n", tex.getMipMapCount(), tex.getWidth(0), tex.getHeight(0)); - // profiling. add new TextureMemory usage. _AllocatedTextureMemory+= gltext->TextureMemory; } @@ -983,8 +978,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, else glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL); - - // Next mipmap!! // floor . x0= x0/2; @@ -999,12 +992,9 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - - } } - // Release, if wanted. if(tex.getReleasable()) tex.release(); @@ -1019,13 +1009,11 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded, _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled); } - // The texture is correctly setuped. tex.clearTouched(); return true; } - // *************************************************************************** bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) { @@ -1067,14 +1055,11 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - - bool dummy; GLint glfmt = getGlTextureFormat (tex, dummy); GLint glSrcFmt = getGlSrcTextureFormat (tex, glfmt); GLenum glSrcType= getGlSrcTextureComponentType(glSrcFmt); - // If DXTC format if (_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt)) { @@ -1116,7 +1101,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) return false; } - nlassert (((x0&3) == 0) && ((y0&3) == 0)); if ((w>=4) && (h>=4)) { @@ -1132,8 +1116,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) nglCompressedTexImage2DARB (GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, glfmt, w, h, 0, imageSize, ptr); } - - } else { @@ -1150,8 +1132,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); glPixelStorei (GL_UNPACK_SKIP_ROWS, 0); glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0); - - } // Disable texture 0 @@ -1195,7 +1175,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex) _TextureUsed.insert (gltext); } - if(tex->isTextureCube()) { // setup texture mode, after activeTextureARB() @@ -1215,7 +1194,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex) // setup this texture glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); - // Change parameters of texture, if necessary. //============================================ if(gltext->MagFilter!= tex->getMagFilter()) @@ -1228,8 +1206,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex) gltext->MinFilter= tex->getMinFilter(); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); } - - } } } @@ -1320,7 +1296,6 @@ static void forceActivateTexEnvModeEnvCombine4(const CMaterial::CTexEnv &env) H_AUTO_OGL(forceActivateTexEnvModeEnvCombine4) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV); - //== RGB == switch(env.Env.OpRGB) { @@ -1683,7 +1658,6 @@ void CDriverGL::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv & //===== if (env.Env.OpAlpha == CMaterial::Mad) { - if (_Extensions.ATITextureEnvCombine3) { glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATI); @@ -1737,12 +1711,8 @@ void CDriverGL::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv & { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } - - - } - // *************************************************************************** void CDriverGL::activateTexEnvColor(uint stage, NLMISC::CRGBA col) { @@ -1753,7 +1723,6 @@ void CDriverGL::activateTexEnvColor(uint stage, NLMISC::CRGBA col) } } - // *************************************************************************** void CDriverGL::activateTexEnvMode(uint stage, const CMaterial::CTexEnv &env) { @@ -1825,7 +1794,13 @@ void CDriverGL::swapTextureHandle(ITexture &tex0, ITexture &tex1) swap(t0->WrapT, t1->WrapT); swap(t0->MagFilter, t1->MagFilter); swap(t0->MinFilter, t1->MinFilter); - + swap(t0->TextureMode, t1->TextureMode); + swap(t0->FBOId, t1->FBOId); + swap(t0->DepthFBOId, t1->DepthFBOId); + swap(t0->StencilFBOId, t1->StencilFBOId); + swap(t0->InitFBO, t1->InitFBO); + swap(t0->AttachDepthStencil, t1->AttachDepthStencil); + swap(t0->UsePackedDepthStencil, t1->UsePackedDepthStencil); } @@ -1879,6 +1854,7 @@ bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width getWindowSize(w, h); getViewport(_OldViewport); + CViewport newVP; newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h)); setupViewport(newVP); @@ -1972,7 +1948,7 @@ bool CDriverGL::getRenderTargetSize (uint32 &width, uint32 &height) #elif defined (NL_OS_UNIX) XWindowAttributes win_attributes; - if (!XGetWindowAttributes(dpy, win, &win_attributes)) + if (!XGetWindowAttributes(_dpy, _win, &win_attributes)) throw EBadDisplay("Can't get window attributes."); // Setup gl viewport 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 ff78f43a1..a863a898b 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -54,7 +54,7 @@ static bool GlWndProc(CDriverGL *driver, HWND hWnd, UINT message, WPARAM wParam, if (driver != NULL) { RECT rect; - GetClientRect (driver->_hWnd, &rect); + GetClientRect (driver->_win, &rect); // Setup gl viewport driver->_WindowWidth = rect.right-rect.left; @@ -153,7 +153,7 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) wc.cbWndExtra = 0; wc.hInstance = GetModuleHandle(NULL); wc.hIcon = (HICON)windowIcon; - wc.hCursor = LoadCursorW(NULL,(LPCWSTR)IDC_ARROW); + wc.hCursor = LoadCursorA(NULL, IDC_ARROW); wc.hbrBackground = WHITE_BRUSH; wc.lpszClassName = L"NLClass"; wc.lpszMenuName = NULL; @@ -186,8 +186,9 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) #elif defined (NL_OS_UNIX) - dpy = XOpenDisplay(NULL); - if (dpy == NULL) + _dpy = XOpenDisplay(NULL); + + if (_dpy == NULL) { nlerror ("XOpenDisplay failed on '%s'", getenv("DISPLAY")); } @@ -200,65 +201,100 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc) return true; } +// *************************************************************************** +bool CDriverGL::unInit() +{ + H_AUTO_OGL(CDriverGL_unInit) + + if (_FullScreen) + { + restoreScreenMode(); + showCursor(true); + + _FullScreen = false; + } + +#ifdef NL_OS_WINDOWS + + // Off-screen rendering ? + if (_PBuffer) + { + nwglReleasePbufferDCARB(_PBuffer, _hDC); + nwglDestroyPbufferARB(_PBuffer); + _PBuffer = NULL; + } + + if (!UnregisterClassW(L"NLClass", GetModuleHandle(NULL))) + nlwarning("Can't unregister NLClass"); + + // Restaure monitor color parameters + if (_NeedToRestaureGammaRamp) + { + HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL); + if (dc) + { + if (!SetDeviceGammaRamp (dc, _GammaRampBackuped)) + nlwarning ("(CDriverGL::release): SetDeviceGammaRamp failed"); + + // Release the DC + ReleaseDC (NULL, dc); + } + else + { + nlwarning ("(CDriverGL::release): can't create DC"); + } + } + +#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + + NL3D::MAC::release(); + +#elif defined (NL_OS_UNIX) + + XCloseDisplay(_dpy); + _dpy = NULL; + +#endif // NL_OS_UNIX + + return true; +} + // -------------------------------------------------- bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay) { H_AUTO_OGL(CDriverGL_setDisplay) - uint width = mode.Width; - uint height = mode.Height; + _win = EmptyWindow; + _WindowWidth = _WindowHeight = _WindowX = _WindowY = 0; + _FullScreen = false; + _Resizable = resizeable; + _OffScreen = mode.OffScreen; + _DestroyWindow = false; #ifdef NL_OS_WINDOWS + // Init pointers + _PBuffer = NULL; + _hRC = NULL; + _hDC = NULL; + // Driver caps. //============= // Retrieve the WGL extensions before init the driver. int pf; - _OffScreen = mode.OffScreen; - - // Init pointers - _PBuffer = NULL; - _hWnd = NULL; - _WindowWidth = _WindowHeight = _WindowX = _WindowY = 0; - _hRC = NULL; - _hDC = NULL; - // Offscreen mode ? if (_OffScreen) { - // Get a hdc - - ULONG WndFlags=WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS; - WndFlags&=~WS_VISIBLE; - RECT WndRect; - WndRect.left=0; - WndRect.top=0; - WndRect.right=width; - WndRect.bottom=height; - AdjustWindowRect(&WndRect,WndFlags,FALSE); - HWND tmpHWND = CreateWindowW(L"NLClass", - L"", - WndFlags, - CW_USEDEFAULT,CW_USEDEFAULT, - WndRect.right,WndRect.bottom, - NULL, - NULL, - GetModuleHandleW(NULL), - NULL); - if (!tmpHWND) - { - nlwarning ("CDriverGL::setDisplay: CreateWindowW failed"); +#if 0 + if (!createWindow(mode)) return false; - } // resize the window RECT rc; SetRect (&rc, 0, 0, width, height); - _WindowWidth = width; - _WindowHeight = height; - AdjustWindowRectEx (&rc, GetWindowStyle (_hWnd), GetMenu (_hWnd) != NULL, GetWindowExStyle (_hWnd)); - SetWindowPos (_hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); + AdjustWindowRectEx (&rc, GetWindowStyle (_win), GetMenu (_win) != NULL, GetWindowExStyle (_win)); + SetWindowPos (_win, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); // Get the HDC tempHDC = GetDC(tmpHWND); @@ -306,7 +342,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re nlwarning ("CDriverGL::setDisplay: wglCreateContext failed: 0x%x", error); DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -320,7 +356,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re wglDeleteContext (tempGLRC); DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -337,7 +373,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re nlwarning ("CDriverGL::setDisplay: wglGetCurrentDC failed: 0x%x", error); DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -409,7 +445,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -423,7 +459,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re wglDeleteContext (tempGLRC); DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -436,7 +472,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re wglDeleteContext (tempGLRC); DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -458,7 +494,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -476,7 +512,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re wglDeleteContext (tempGLRC); DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; @@ -508,111 +544,26 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re nwglDestroyPbufferARB( _PBuffer ); DestroyWindow (tmpHWND); _PBuffer = NULL; - _hWnd = NULL; + _win = EmptyWindow; _hRC = NULL; _hDC = NULL; return false; } +#endif } else { - _FullScreen= false; - if (wnd) + if (wnd == EmptyWindow) { - _hWnd=wnd; - _DestroyWindow=false; + if (!createWindow(mode)) + return false; } else { - ULONG WndFlags; - RECT WndRect; - - // Must destroy this window - _DestroyWindow=true; - - if(mode.Windowed) - if(resizeable) - WndFlags=WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS; - else - WndFlags=WS_SYSMENU+WS_DLGFRAME+WS_CLIPCHILDREN+WS_CLIPSIBLINGS; - else - { - WndFlags=WS_POPUP; - - _FullScreen= true; - DEVMODE devMode; - _OldScreenMode.dmSize= sizeof(DEVMODE); - _OldScreenMode.dmDriverExtra= 0; - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &_OldScreenMode); - _OldScreenMode.dmFields= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY ; - - devMode.dmSize= sizeof(DEVMODE); - devMode.dmDriverExtra= 0; - devMode.dmFields= DM_PELSWIDTH | DM_PELSHEIGHT; - devMode.dmPelsWidth= width; - devMode.dmPelsHeight= height; - - if(mode.Depth > 0) - { - devMode.dmBitsPerPel= mode.Depth; - devMode.dmFields |= DM_BITSPERPEL; - } - - if(mode.Frequency > 0) - { - devMode.dmDisplayFrequency= mode.Frequency; - devMode.dmFields |= DM_DISPLAYFREQUENCY; - } - - if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - return false; - } - WndRect.left=0; - WndRect.top=0; - WndRect.right=width; - WndRect.bottom=height; - AdjustWindowRect(&WndRect,WndFlags,FALSE); - _hWnd = CreateWindowW( L"NLClass", - L"", - WndFlags, - CW_USEDEFAULT,CW_USEDEFAULT, - WndRect.right,WndRect.bottom, - NULL, - NULL, - GetModuleHandleW(NULL), - NULL); - if (_hWnd == NULL) - { - DWORD res = GetLastError(); - nlwarning("CreateWindow failed: %u", res); - return false; - } - - SetWindowLongPtr (_hWnd, GWLP_USERDATA, (LONG_PTR)this); - - // resize the window - RECT rc; - SetRect (&rc, 0, 0, width, height); - AdjustWindowRectEx (&rc, GetWindowStyle (_hWnd), GetMenu (_hWnd) != NULL, GetWindowExStyle (_hWnd)); - UINT flags = SWP_NOZORDER | SWP_NOACTIVATE; - if (mode.Windowed) - flags |= SWP_NOMOVE; - SetWindowPos (_hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, flags); - - if (show || _FullScreen) - showWindow(true); + _win = wnd; } - // Init Window Width and Height - RECT clientRect; - GetClientRect (_hWnd, &clientRect); - _WindowWidth = clientRect.right-clientRect.left; - _WindowHeight = clientRect.bottom-clientRect.top; - GetWindowRect (_hWnd, &clientRect); - _WindowX = clientRect.left; - _WindowY = clientRect.top; - - _hDC=GetDC(_hWnd); + _hDC=GetDC(_win); wglMakeCurrent(_hDC,NULL); _Depth=uint8(GetDeviceCaps(_hDC,BITSPIXEL)); @@ -656,13 +607,16 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re { _EventEmitter.removeEmitter(_EventEmitter.getEmitter(_EventEmitter.getNumEmitters() - 1)); } + NLMISC::CWinEventEmitter *we = new NLMISC::CWinEventEmitter; + // setup the event emitter, and try to retrieve a direct input interface _EventEmitter.addEmitter(we, true /*must delete*/); // the main emitter + /// try to get direct input try { - NLMISC::CDIEventEmitter *diee = NLMISC::CDIEventEmitter::create(GetModuleHandle(NULL), _hWnd, we); + NLMISC::CDIEventEmitter *diee = NLMISC::CDIEventEmitter::create(GetModuleHandle(NULL), _win, we); if (diee) { _EventEmitter.addEmitter(diee, true); @@ -706,96 +660,63 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re }; // first try 24bpp and if that fails 16bpp - XVisualInfo *visual_info = glXChooseVisual (dpy, DefaultScreen(dpy), sAttribList24bpp); + XVisualInfo *visual_info = glXChooseVisual (_dpy, DefaultScreen(_dpy), sAttribList24bpp); if (visual_info == NULL) - visual_info = glXChooseVisual(dpy, DefaultScreen(dpy), sAttribList16bpp); + visual_info = glXChooseVisual(_dpy, DefaultScreen(_dpy), sAttribList16bpp); if(visual_info == NULL) { nlerror("glXChooseVisual() failed"); } - else - { - nldebug("3D: glXChooseVisual OK"); - } - ctx = glXCreateContext (dpy, visual_info, None, GL_TRUE); - if(ctx == NULL) + _ctx = glXCreateContext (_dpy, visual_info, None, GL_TRUE); + if (_ctx == NULL) { nlerror("glXCreateContext() failed"); } - else + + _visual_info = visual_info; + + if (wnd == EmptyWindow) { - nldebug("3D: glXCreateContext() OK"); - } - - XSetWindowAttributes attr; - attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy)); - attr.override_redirect = False; - - int attr_flags = CWOverrideRedirect | CWBackPixel; - - if(wnd == EmptyWindow) - { - 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"); - } + if (!createWindow(mode)) + return false; } else { - win = wnd; - XChangeWindowAttributes(dpy, win, attr_flags, &attr); + _win = wnd; + + XSetWindowAttributes attr; + attr.background_pixel = BlackPixel(_dpy, DefaultScreen(_dpy)); + attr.override_redirect = False; + + int attr_flags = CWOverrideRedirect | CWBackPixel; + + XChangeWindowAttributes(_dpy, _win, attr_flags, &attr); } - const char *title="NeL window"; + glXMakeCurrent (_dpy, _win, _ctx); + XMapRaised (_dpy, _win); - XSizeHints size_hints; - size_hints.x = 0; - size_hints.y = 0; - size_hints.width = width; - size_hints.height = height; - size_hints.flags = PSize | PMinSize | PMaxSize; - size_hints.min_width = width; - size_hints.min_height = height; - size_hints.max_width = width; - size_hints.max_height = height; + XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask); -#ifdef X_HAVE_UTF8_STRING - Xutf8SetWMProperties (dpy, win, (char*)title, (char*)title, NULL, 0, &size_hints, NULL, NULL); -#else - XTextProperty text_property; - XStringListToTextProperty((char**)&title, 1, &text_property); - XSetWMProperties (dpy, win, &text_property, &text_property, 0, 0, &size_hints, 0, 0); -#endif +// XMapWindow(_dpy, _win); - glXMakeCurrent (dpy, win, ctx); - XMapRaised (dpy, win); - - XSelectInput (dpy, win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask); - - XMapWindow(dpy, win); - - _EventEmitter.init (dpy, win); + _EventEmitter.init (_dpy, _win); // XEvent event; // XIfEvent(dpy, &event, WaitForNotify, (char *)this); - setMode(mode); - #endif // NL_OS_UNIX - return setupDisplay(); + setMode(mode); + + if (!setupDisplay()) + return false; + + if (show || _FullScreen) + showWindow(true); + + return true; } #ifdef NL_OS_WINDOWS @@ -814,11 +735,47 @@ static void modifyStyle (HWND hWnd, int nStyleOffset, LONG_PTR dwRemove, LONG_PT #endif // -------------------------------------------------- -void CDriverGL::switchBackToOldMode() +bool CDriverGL::saveScreenMode() { -#ifdef NL_OS_WINDOWS - ChangeDisplaySettings(&_OldScreenMode, 0); -#elif defined(XF86VIDMODE) + H_AUTO_OGL(CDriverGL_saveScreenMode) + + bool res = true; + +#if defined(NL_OS_WINDOWS) + + // don't need to save it because Windows will use default desktop resolution + +#elif defined(NL_OS_UNIX) + +#if defined(XF86VIDMODE) + + // Store old mode in order to restore it when leaving fullscreen + memset(&_OldScreenMode, 0, sizeof(XF86VidModeModeLine)); + XF86VidModeGetModeLine(_dpy, DefaultScreen(_dpy), &_OldDotClock, &_OldScreenMode); + res = XF86VidModeGetViewPort(_dpy, DefaultScreen(_dpy), &_OldX, &_OldY); + +#endif // XF86VIDMODE + +#endif // NL_OS_WINDOWS + + return res; +} + +// -------------------------------------------------- +bool CDriverGL::restoreScreenMode() +{ + H_AUTO_OGL(CDriverGL_restoreScreenMode) + + bool res = false; + +#if defined(NL_OS_WINDOWS) + + res = (ChangeDisplaySettings(NULL, 0) == DISP_CHANGE_SUCCESSFUL); + +#elif defined(NL_OS_UNIX) + +#if defined(XF86VIDMODE) + XF86VidModeModeInfo info; nlinfo("3D: Switching back to original mode"); @@ -837,72 +794,272 @@ void CDriverGL::switchBackToOldMode() info.c_private = _OldScreenMode.c_private; nlinfo("3D: Switching back mode to %dx%d", info.hdisplay, info.vdisplay); - XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &info); + XF86VidModeSwitchToMode(_dpy, DefaultScreen(_dpy), &info); nlinfo("3D: Switching back viewport to %d,%d",_OldX, _OldY); - XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), _OldX, _OldY); + res = XF86VidModeSetViewPort(_dpy, DefaultScreen(_dpy), _OldX, _OldY); + #endif // XF86VIDMODE + +#endif // NL_OS_WINDOWS + + return res; } +// -------------------------------------------------- +bool CDriverGL::setScreenMode(const GfxMode &mode) +{ + H_AUTO_OGL(CDriverGL_setScreenMode) + + if (mode.Windowed) + { + // if fullscreen, switch back to desktop screen mode + if (_FullScreen) + restoreScreenMode(); + + return true; + } + + // save previous screen mode only if switching from windowed to fullscreen + if (!_FullScreen) + saveScreenMode(); + + // if switching exactly to the same screen mode, doesn't change it + GfxMode previousMode; + if (getCurrentScreenMode(previousMode) + && mode.Width == previousMode.Width + && mode.Height == previousMode.Height + && mode.Depth == previousMode.Depth + && mode.Frequency == previousMode.Frequency) + return true; + +#if defined(NL_OS_WINDOWS) + + DEVMODE devMode; + memset(&devMode, 0, sizeof(DEVMODE)); + devMode.dmSize = sizeof(DEVMODE); + devMode.dmDriverExtra = 0; + devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; + devMode.dmPelsWidth = mode.Width; + devMode.dmPelsHeight = mode.Height; + + if(mode.Depth > 0) + { + devMode.dmBitsPerPel = mode.Depth; + devMode.dmFields |= DM_BITSPERPEL; + } + + if(mode.Frequency > 0) + { + devMode.dmDisplayFrequency = mode.Frequency; + devMode.dmFields |= DM_DISPLAYFREQUENCY; + } + + if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) + { + nlwarning("Fullscreen mode switch failed"); + return false; + } + +#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + + // TODO + +#elif defined(NL_OS_UNIX) + +#if defined(XF86VIDMODE) + + bool found = false; + + // Find the requested mode and use it + XF86VidModeModeInfo **modes; + int nmodes; + if (XF86VidModeGetAllModeLines(_dpy, DefaultScreen(_dpy), &nmodes, &modes)) + { + for (int i = 0; i < nmodes; i++) + { + nldebug("3D: Available mode - %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); + if (modes[i]->hdisplay == mode.Width && modes[i]->vdisplay == mode.Height) + { + if (XF86VidModeSwitchToMode(_dpy, DefaultScreen(_dpy), modes[i])) + { + nlinfo("3D: Switching to mode %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); + XF86VidModeSetViewPort(_dpy, DefaultScreen(_dpy), 0, 0); + found = true; + } + break; + } + } + XFree(modes); + } + + if (!found) + return false; + +#endif // XF86VIDMODE + +#endif // NL_OS_WINDOWS + + return true; +} + +// *************************************************************************** +bool CDriverGL::createWindow(const GfxMode &mode) +{ + H_AUTO_OGL(CDriverGL_createWindow) + + nlWindow window = EmptyWindow; + +#ifdef NL_OS_WINDOWS + + // create the OpenGL window + window = CreateWindowW(L"NLClass", L"NeL Window", WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, + CW_USEDEFAULT, CW_USEDEFAULT, mode.Width, mode.Height, HWND_DESKTOP, NULL, GetModuleHandle(NULL), NULL); + + if (window == EmptyWindow) + { + DWORD res = GetLastError(); + nlwarning("CreateWindow failed: %u", res); + return false; + } + + // associate OpenGL driver to window + SetWindowLongPtr(window, GWLP_USERDATA, (LONG_PTR)this); + +#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + + // TODO + +#elif defined (NL_OS_UNIX) + + if (_visual_info == NULL) + return false; + + XSetWindowAttributes attr; + attr.background_pixel = BlackPixel(_dpy, DefaultScreen(_dpy)); + +#ifdef XF86VIDMODE + // If we're going to attempt fullscreen, we need to set redirect to True, + // This basically places the window with no borders in the top left + // corner of the screen. + if (mode.Windowed) + { + attr.override_redirect = False; + } + else + { + attr.override_redirect = True; + } +#else + attr.override_redirect = False; +#endif + + int attr_flags = CWOverrideRedirect | CWBackPixel; + + nlWindow root = RootWindow(_dpy, DefaultScreen(_dpy)); + + attr.colormap = XCreateColormap(_dpy, root, _visual_info->visual, AllocNone); + attr_flags |= CWColormap; + + window = XCreateWindow (_dpy, root, 0, 0, mode.Width, mode.Height, 0, _visual_info->depth, InputOutput, _visual_info->visual, attr_flags, &attr); + + if (window == EmptyWindow) + { + nlerror("3D: XCreateWindow() failed"); + return false; + } + +#endif // NL_OS_UNIX + + _win = window; + + _WindowWidth = mode.Width; + _WindowHeight = mode.Height; + + // Must destroy this window + _DestroyWindow = true; + + setWindowTitle(ucstring("NeL window")); + + return true; +} + +// *************************************************************************** +bool CDriverGL::destroyWindow() +{ + H_AUTO_OGL(CDriverGL_destroyWindow) + +#ifdef NL_OS_WINDOWS + + // Then delete. + // wglMakeCurrent(NULL,NULL); + + if (_hDC) + wglMakeCurrent(_hDC, NULL); + + if (_hRC) + { + wglDeleteContext(_hRC); + _hRC = NULL; + } + + if (_win && _hDC) + { + ReleaseDC(_win, _hDC); + _hDC = NULL; + + if (_DestroyWindow) + DestroyWindow(_win); + } + +#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + + // TODO + +#elif defined (NL_OS_UNIX) + + if (_ctx) + { + glXDestroyContext(_dpy, _ctx); + _ctx = NULL; + } + + if (_win && _DestroyWindow) + XDestroyWindow(_dpy, _win); + + // Ungrab the keyboard (probably not necessary); +// XUnmapWindow(_dpy, _win); + XSync(_dpy, True); + XUngrabKeyboard(_dpy, CurrentTime); + +#endif + + _win = EmptyWindow; + + return true; +} // -------------------------------------------------- bool CDriverGL::setMode(const GfxMode& mode) { H_AUTO_OGL(CDriverGL_setMode) + + if (!setScreenMode(mode)) + return false; + + _WindowWidth = mode.Width; + _WindowHeight = mode.Height; + #ifdef NL_OS_WINDOWS + if (mode.Windowed) { if (_FullScreen) - { - switchBackToOldMode(); - modifyStyle(_hWnd, GWL_STYLE, WS_POPUP, WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS); - } - _WindowWidth = mode.Width; - _WindowHeight = mode.Height; - + modifyStyle(_win, GWL_STYLE, WS_POPUP, WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS); } else { - // get old mode. - DEVMODE oldDevMode; - if (!_FullScreen) - { - oldDevMode.dmSize= sizeof(DEVMODE); - oldDevMode.dmDriverExtra= 0; - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &oldDevMode); - oldDevMode.dmFields= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY ; - } - - // setup new mode - DEVMODE newDevMode; - newDevMode.dmSize= sizeof(DEVMODE); - newDevMode.dmDriverExtra= 0; - newDevMode.dmFields= DM_PELSWIDTH | DM_PELSHEIGHT; - newDevMode.dmPelsWidth= mode.Width; - newDevMode.dmPelsHeight= mode.Height; - - if(mode.Depth > 0) - { - newDevMode.dmBitsPerPel= mode.Depth; - newDevMode.dmFields |= DM_BITSPERPEL; - } - - if(mode.Frequency > 0) - { - newDevMode.dmDisplayFrequency= mode.Frequency; - newDevMode.dmFields |= DM_DISPLAYFREQUENCY; - } - - // try to really change the display mode - if (ChangeDisplaySettings(&newDevMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - return false; - // mode ok => copy changes - _WindowWidth = mode.Width; - _WindowHeight = mode.Height; - _Depth= mode.Depth; - // bkup user mode - if (!_FullScreen) - _OldScreenMode= oldDevMode; + _Depth = mode.Depth; // if old mode was not fullscreen if (!_FullScreen) @@ -910,7 +1067,7 @@ bool CDriverGL::setMode(const GfxMode& mode) // Under the XP theme desktop, this function call the winproc WM_SIZE and change _WindowWidth and _WindowHeight sint32 windowWidth = _WindowWidth; sint32 windowHeight = _WindowHeight; - modifyStyle(_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS, WS_POPUP); + modifyStyle(_win, GWL_STYLE, WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, WS_POPUP); _WindowWidth = windowWidth; _WindowHeight = windowHeight; } @@ -919,63 +1076,29 @@ bool CDriverGL::setMode(const GfxMode& mode) // Resize the window RECT rc; SetRect (&rc, 0, 0, _WindowWidth, _WindowHeight); - AdjustWindowRectEx (&rc, GetWindowStyle (_hWnd), false, GetWindowExStyle (_hWnd)); + AdjustWindowRectEx (&rc, GetWindowStyle (_win), GetMenu (_win) != NULL, GetWindowExStyle (_win)); UINT flags = SWP_NOZORDER | SWP_NOACTIVATE; if (mode.Windowed) flags |= SWP_NOMOVE; - SetWindowPos (_hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, flags); + SetWindowPos (_win, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, flags); - showWindow(true); +// showWindow(true); // Init Window Width and Height RECT clientRect; - GetClientRect (_hWnd, &clientRect); + GetClientRect (_win, &clientRect); _WindowWidth = clientRect.right-clientRect.left; _WindowHeight = clientRect.bottom-clientRect.top; - GetWindowRect (_hWnd, &clientRect); + GetWindowRect (_win, &clientRect); _WindowX = clientRect.left; _WindowY = clientRect.top; - _FullScreen = !mode.Windowed; #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + NL3D::MAC::setMode(mode); + #elif defined(NL_OS_UNIX) -#ifdef XF86VIDMODE - if (!mode.Windowed) - { - // Store old mdoe in order to restore it when leaving fullscreen - if (mode.Windowed == _FullScreen) - { - memset(&_OldScreenMode, 0, sizeof(_OldScreenMode)); - XF86VidModeGetModeLine(dpy, DefaultScreen(dpy), &_OldDotClock, &_OldScreenMode); - XF86VidModeGetViewPort(dpy, DefaultScreen(dpy), &_OldX, &_OldY); - } - - // Find the requested mode and use it - XF86VidModeModeInfo **modes; - int nmodes; - if (XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &nmodes, &modes)) - { - for (int i = 0; i < nmodes; i++) - { - nldebug("3D: Available mode - %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); - if(modes[i]->hdisplay == mode.Width && modes[i]->vdisplay == mode.Height) - { - if(XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), modes[i])) - { - nlinfo("3D: Switching to mode %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); - XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), 0, 0); - } - break; - } - } - } - } - else if (mode.Windowed == _FullScreen) - switchBackToOldMode(); -#endif // XF86VIDMODE - // Update WM hints (update size and disallow resizing) XSizeHints size_hints; size_hints.x = 0; @@ -996,7 +1119,7 @@ bool CDriverGL::setMode(const GfxMode& mode) } #endif - XSetWMNormalHints(dpy, win, &size_hints); + XSetWMNormalHints(_dpy, _win, &size_hints); // x11 fullscreen is not working on mac os x #if !defined(NL_OS_MAC) @@ -1006,27 +1129,28 @@ bool CDriverGL::setMode(const GfxMode& mode) XEvent xev; memset(&xev, 0, sizeof(xev)); xev.type = ClientMessage; - xev.xclient.window = win; - xev.xclient.message_type = XInternAtom(dpy, "_NET_WM_STATE", false); + xev.xclient.window = _win; + xev.xclient.message_type = XInternAtom(_dpy, "_NET_WM_STATE", false); xev.xclient.format = 32; xev.xclient.data.l[0] = !mode.Windowed; - xev.xclient.data.l[1] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", false); + xev.xclient.data.l[1] = XInternAtom(_dpy, "_NET_WM_STATE_FULLSCREEN", false); xev.xclient.data.l[2] = 0; - XSendEvent(dpy, DefaultRootWindow(dpy), false, SubstructureNotifyMask, &xev); + XSendEvent(_dpy, DefaultRootWindow(_dpy), false, SubstructureNotifyMask, &xev); } #endif + // Resize and update the window + XResizeWindow(_dpy, _win, mode.Width, mode.Height); +// XMapWindow(_dpy, _win); + +#endif // NL_OS_UNIX + #if !defined(NL_OS_MAC) _FullScreen = !mode.Windowed; #else _FullScreen = false; #endif - // Resize and update the window - XResizeWindow(dpy, win, mode.Width, mode.Height); - XMapWindow(dpy, win); - -#endif // NL_OS_UNIX return true; } @@ -1065,7 +1189,7 @@ bool CDriverGL::getModes(std::vector &modes) # ifdef XF86VIDMODE int nmodes; XF86VidModeModeInfo **ms; - Bool ok = XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &nmodes, &ms); + Bool ok = XF86VidModeGetAllModeLines(_dpy, DefaultScreen(_dpy), &nmodes, &ms); if(ok) { nldebug("3D: %d available modes:", nmodes); @@ -1096,18 +1220,21 @@ bool CDriverGL::getModes(std::vector &modes) bool CDriverGL::getCurrentScreenMode(GfxMode &mode) { H_AUTO_OGL(CDriverGL_getCurrentScreenMode) + #ifdef NL_OS_WINDOWS + DEVMODE devmode; - devmode.dmSize= sizeof(DEVMODE); - devmode.dmDriverExtra= 0; + devmode.dmSize = sizeof(DEVMODE); + devmode.dmDriverExtra = 0; EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode); - mode.Windowed= !_FullScreen; - mode.OffScreen= false; - mode.Depth= (uint8)devmode.dmBitsPerPel; - mode.Frequency= devmode.dmDisplayFrequency, - mode.Width= (uint16)devmode.dmPelsWidth; - mode.Height= (uint16)devmode.dmPelsHeight; + mode.Windowed = !_FullScreen; + mode.OffScreen = false; + mode.Depth = (uint8)devmode.dmBitsPerPel; + mode.Frequency = devmode.dmDisplayFrequency, + mode.Width = (uint16)devmode.dmPelsWidth; + mode.Height = (uint16)devmode.dmPelsHeight; + mode.AntiAlias = _AntiAliasing; #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Temporary Mac Implementation" @@ -1131,7 +1258,7 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode) sint pixelClock; XF86VidModeModeLine xmode; - if (!XF86VidModeGetModeLine(dpy, DefaultScreen(dpy), &pixelClock, &xmode)) + if (!XF86VidModeGetModeLine(_dpy, DefaultScreen(_dpy), &pixelClock, &xmode)) { nlwarning("XF86VidModeGetModeLine returns 0, cannot get current video mode"); return false; @@ -1145,7 +1272,7 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode) #endif mode.OffScreen = false; - mode.Depth = (uint) DefaultDepth(dpy, DefaultScreen(dpy)); + mode.Depth = (uint) DefaultDepth(_dpy, DefaultScreen(_dpy)); mode.Frequency = 1000 * pixelClock / (xmode.htotal * xmode.vtotal) ; mode.Width = xmode.hdisplay; mode.Height = xmode.vdisplay; @@ -1161,16 +1288,23 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode) void CDriverGL::setWindowTitle(const ucstring &title) { #ifdef NL_OS_WINDOWS - SetWindowTextW(_hWnd,(WCHAR*)title.c_str()); + + SetWindowTextW(_win, (WCHAR*)title.c_str()); #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + NL3D::MAC::setWindowTitle(title); #elif defined (NL_OS_UNIX) + +#ifdef X_HAVE_UTF8_STRING + Xutf8SetWMProperties (_dpy, _win, (char*)title.toUtf8().c_str(), (char*)title.toUtf8().c_str(), NULL, 0, NULL, NULL, NULL); +#else XTextProperty text_property; - char *t = (char*)title.toUtf8().c_str(); - XStringListToTextProperty(&t, 1, &text_property); - XSetWMName(dpy, win, &text_property); + XStringListToTextProperty((char**)&title.toUtf8().c_str(), 1, &text_property); + XSetWMProperties (_dpy, _win, &text_property, &text_property, 0, 0, NULL, 0, 0); +#endif + #endif // NL_OS_WINDOWS } @@ -1179,14 +1313,18 @@ void CDriverGL::setWindowPos(uint32 x, uint32 y) { _WindowX = (sint32)x; _WindowY = (sint32)y; + #ifdef NL_OS_WINDOWS - SetWindowPos(_hWnd, NULL, _WindowX, _WindowY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); + + SetWindowPos(_win, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + NL3D::MAC::setWindowPos(x, y); #elif defined (NL_OS_UNIX) - XMoveWindow(dpy, win, _WindowX, _WindowY); + + XMoveWindow(_dpy, _win, x, y); #endif // NL_OS_WINDOWS } @@ -1195,16 +1333,23 @@ void CDriverGL::setWindowPos(uint32 x, uint32 y) void CDriverGL::showWindow(bool show) { #ifdef NL_OS_WINDOWS - ShowWindow (_hWnd, show ? SW_SHOW:SW_HIDE); + ShowWindow (_win, show ? SW_SHOW:SW_HIDE); #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Missing Mac Implementation" nlwarning("OpenGL Driver: Missing Mac Implementation"); #elif defined (NL_OS_UNIX) + if (show) - XMapWindow(dpy, win); + { + XMapWindow(_dpy, _win); +// XMapRaised(_dpy, _win); + } else - XUnmapWindow(dpy, win); + { + XUnmapWindow(_dpy, _win); + } + #endif // NL_OS_WINDOWS } @@ -1224,25 +1369,26 @@ bool CDriverGL::activate() { H_AUTO_OGL(CDriverGL_activate) #ifdef NL_OS_WINDOWS - HGLRC hglrc=wglGetCurrentContext(); + HGLRC hglrc = wglGetCurrentContext(); + + if (hglrc != _hRC) + wglMakeCurrent(_hDC, _hRC); - if (hglrc!=_hRC) - { - wglMakeCurrent(_hDC,_hRC); - } #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) + # warning "OpenGL Driver: Temporary Mac Implementation" nlwarning("OpenGL Driver: Temporary Mac Implementation"); // already done in setDisplay, not needed here - unclean! FIXME #elif defined (NL_OS_UNIX) - GLXContext nctx=glXGetCurrentContext(); - if (nctx != NULL && nctx!=ctx) - { - glXMakeCurrent(dpy, win,ctx); - } + + GLXContext nctx = glXGetCurrentContext(); + + if (nctx != NULL && nctx != _ctx) + glXMakeCurrent(_dpy, _win, _ctx); + #endif // NL_OS_WINDOWS return true; } @@ -1294,7 +1440,9 @@ IDriver::TMessageBoxId CDriverGL::systemMessageBox (const char* message, const c void CDriverGL::showCursor(bool b) { H_AUTO_OGL(CDriverGL_showCursor) + #ifdef NL_OS_WINDOWS + if (b) { while (ShowCursor(b) < 0) @@ -1305,6 +1453,7 @@ void CDriverGL::showCursor(bool b) while (ShowCursor(b) >= 0) ; } + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) NL3D::MAC::showCursor(b); @@ -1313,63 +1462,70 @@ void CDriverGL::showCursor(bool b) if (b) { - if (cursor != None) + if (_cursor != None) { - XFreeCursor(dpy, cursor); - cursor = None; + XFreeCursor(_dpy, _cursor); + _cursor = None; } - XUndefineCursor(dpy, win); + XUndefineCursor(_dpy, _win); } else { - if (cursor == None) + if (_cursor == None) { char bm_no_data[] = { 0,0,0,0, 0,0,0,0 }; - Pixmap pixmap_no_data = XCreateBitmapFromData (dpy, win, bm_no_data, 8, 8); + Pixmap pixmap_no_data = XCreateBitmapFromData (_dpy, _win, bm_no_data, 8, 8); XColor black; memset(&black, 0, sizeof (XColor)); black.flags = DoRed | DoGreen | DoBlue; - cursor = XCreatePixmapCursor (dpy, pixmap_no_data, pixmap_no_data, &black, &black, 0, 0); - XFreePixmap(dpy, pixmap_no_data); + _cursor = XCreatePixmapCursor (_dpy, pixmap_no_data, pixmap_no_data, &black, &black, 0, 0); + XFreePixmap(_dpy, pixmap_no_data); } - XDefineCursor(dpy, win, cursor); + XDefineCursor(_dpy, _win, _cursor); } + #endif // NL_OS_UNIX } - // -------------------------------------------------- void CDriverGL::setMousePos(float x, float y) { H_AUTO_OGL(CDriverGL_setMousePos) + #ifdef NL_OS_WINDOWS - if (_hWnd) + + if (_win) { // NeL window coordinate to MSWindows coordinates POINT pt; - pt.x = (int)((float)(_WindowWidth)*x); - pt.y = (int)((float)(_WindowHeight)*(1.0f-y)); - ClientToScreen (_hWnd, &pt); + pt.x = (sint)((float)(_WindowWidth)*x); + pt.y = (sint)((float)(_WindowHeight)*(1.0f-y)); + ClientToScreen (_win, &pt); SetCursorPos(pt.x, pt.y); } + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) NL3D::MAC::setMousePos(x, y); #elif defined (NL_OS_UNIX) + XWindowAttributes xwa; - XGetWindowAttributes (dpy, win, &xwa); + XGetWindowAttributes (_dpy, _win, &xwa); int x1 = (int)(x * (float) xwa.width); int y1 = (int)((1.0f - y) * (float) xwa.height); - XWarpPointer (dpy, None, win, None, None, None, None, x1, y1); + XWarpPointer (_dpy, None, _win, None, None, None, None, x1, y1); + #endif // NL_OS_UNIX } void CDriverGL::getWindowSize(uint32 &width, uint32 &height) { H_AUTO_OGL(CDriverGL_getWindowSize) + #ifdef NL_OS_WINDOWS - // Off-srceen rendering ? + + // Off-screen rendering ? if (_OffScreen) { if (_PBuffer) @@ -1380,29 +1536,34 @@ void CDriverGL::getWindowSize(uint32 &width, uint32 &height) } else { - if (_hWnd) + if (_win) { width = (uint32)(_WindowWidth); height = (uint32)(_WindowHeight); } } + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) NL3D::MAC::getWindowSize(width, height); #elif defined (NL_OS_UNIX) + XWindowAttributes xwa; - XGetWindowAttributes (dpy, win, &xwa); + XGetWindowAttributes (_dpy, _win, &xwa); width = (uint32) xwa.width; height = (uint32) xwa.height; + #endif // NL_OS_UNIX } void CDriverGL::getWindowPos(uint32 &x, uint32 &y) { H_AUTO_OGL(CDriverGL_getWindowPos) + #ifdef NL_OS_WINDOWS - // Off-srceen rendering ? + + // Off-screen rendering ? if (_OffScreen) { if (_PBuffer) @@ -1412,18 +1573,41 @@ void CDriverGL::getWindowPos(uint32 &x, uint32 &y) } else { - if (_hWnd) + if (_win) { - x = (uint32)(_WindowX); - y = (uint32)(_WindowY); + x = (uint32)_WindowX; + y = (uint32)_WindowY; } } + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) NL3D::MAC::getWindowPos(x, y); #elif defined (NL_OS_UNIX) - x = y = 0; + + int screen = DefaultScreen(_dpy); + +#if 0 + // Display size is a member of display structure + int display_width = DisplayWidth(_dpy, screen); + int display_height = DisplayHeight(_dpy, screen); +#endif + + int xtmp = 0, ytmp = 0; + unsigned int width = 0, height = 0; + unsigned int border_width = 0; + unsigned int depth = 0; + + // Get geometry information about root window + if (!XGetGeometry(_dpy, RootWindow(_dpy, screen), (Window*)&_win, &xtmp, &ytmp, &width, &height, &border_width, &depth)) + { + nlwarning("can't get root window geometry"); + } + + x = xtmp; + y = ytmp; + #endif // NL_OS_UNIX } @@ -1431,8 +1615,13 @@ void CDriverGL::getWindowPos(uint32 &x, uint32 &y) bool CDriverGL::isActive() { H_AUTO_OGL(CDriverGL_isActive) + + bool res = true; + #ifdef NL_OS_WINDOWS - return (IsWindow(_hWnd) != 0); + + res = (IsWindow(_win) != FALSE); + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Missing Mac Implementation" // nlwarning("OpenGL Driver: Missing Mac Implementation"); @@ -1440,7 +1629,8 @@ bool CDriverGL::isActive() #elif defined (NL_OS_UNIX) #endif // NL_OS_UNIX - return true; + + return res; } void CDriverGL::setCapture (bool b) @@ -1452,14 +1642,14 @@ void CDriverGL::setCapture (bool b) if (b) { RECT client; - GetClientRect (_hWnd, &client); + GetClientRect (_win, &client); POINT pt1,pt2; pt1.x = client.left; pt1.y = client.top; - ClientToScreen (_hWnd, &pt1); + ClientToScreen (_win, &pt1); pt2.x = client.right; pt2.y = client.bottom; - ClientToScreen (_hWnd, &pt2); + ClientToScreen (_win, &pt2); client.bottom = pt2.y; client.top = pt1.y; client.left = pt1.x; @@ -1488,11 +1678,11 @@ void CDriverGL::setCapture (bool b) if(b) // capture the cursor. { - XGrabPointer(dpy, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime); + XGrabPointer(_dpy, _win, True, 0, GrabModeAsync, GrabModeAsync, _win, None, CurrentTime); } else // release the cursor. { - XUngrabPointer(dpy, CurrentTime); + XUngrabPointer(_dpy, CurrentTime); } #endif // NL_OS_UNIX @@ -1503,26 +1693,32 @@ NLMISC::IMouseDevice* CDriverGL::enableLowLevelMouse(bool enable, bool exclusive { H_AUTO_OGL(CDriverGL_enableLowLevelMouse) + NLMISC::IMouseDevice *res = NULL; + #ifdef NL_OS_WINDOWS - if (_EventEmitter.getNumEmitters() < 2) return NULL; - NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); - if (enable) + + NLMISC::CDIEventEmitter *diee = NULL; + + if (_EventEmitter.getNumEmitters() > 1) + diee = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); + + if (enable) + { + try { - try - { - NLMISC::IMouseDevice *md = diee->getMouseDevice(exclusive); - return md; - } - catch (EDirectInput &) - { - return NULL; - } + if (diee) + res = diee->getMouseDevice(exclusive); } - else + catch (EDirectInput &) { + } + } + else + { + if (diee) diee->releaseMouse(); - return NULL; - } + } + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Missing Mac Implementation" nlwarning("OpenGL Driver: Missing Mac Implementation"); @@ -1530,33 +1726,41 @@ NLMISC::IMouseDevice* CDriverGL::enableLowLevelMouse(bool enable, bool exclusive #elif defined (NL_OS_UNIX) #endif - return NULL; + + return res; } // *************************************************************************** NLMISC::IKeyboardDevice* CDriverGL::enableLowLevelKeyboard(bool enable) { H_AUTO_OGL(CDriverGL_enableLowLevelKeyboard) + + NLMISC::IKeyboardDevice *res = NULL; + #ifdef NL_OS_WINDOWS - if (_EventEmitter.getNumEmitters() < 2) return NULL; - NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); - if (enable) + + NLMISC::CDIEventEmitter *diee = NULL; + + if (_EventEmitter.getNumEmitters() > 1) + diee = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); + + if (enable) + { + try { - try - { - NLMISC::IKeyboardDevice *md = diee->getKeyboardDevice(); - return md; - } - catch (EDirectInput &) - { - return NULL; - } + if (diee) + res = diee->getKeyboardDevice(); } - else + catch (EDirectInput &) { + } + } + else + { + if (diee) diee->releaseKeyboard(); - return NULL; - } + } + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Missing Mac Implementation" nlwarning("OpenGL Driver: Missing Mac Implementation"); @@ -1564,17 +1768,22 @@ NLMISC::IKeyboardDevice* CDriverGL::enableLowLevelKeyboard(bool enable) #elif defined (NL_OS_UNIX) #endif - return NULL; + + return res; } // *************************************************************************** NLMISC::IInputDeviceManager* CDriverGL::getLowLevelInputDeviceManager() { H_AUTO_OGL(CDriverGL_getLowLevelInputDeviceManager) + + NLMISC::IInputDeviceManager *res = NULL; + #ifdef NL_OS_WINDOWS - if (_EventEmitter.getNumEmitters() < 2) return NULL; - NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); - return diee; + + if (_EventEmitter.getNumEmitters() > 1) + res = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Missing Mac Implementation" nlwarning("OpenGL Driver: Missing Mac Implementation"); @@ -1582,7 +1791,8 @@ NLMISC::IInputDeviceManager* CDriverGL::getLowLevelInputDeviceManager() #elif defined (NL_OS_UNIX) #endif - return NULL; + + return res; } // *************************************************************************** @@ -1590,37 +1800,49 @@ uint CDriverGL::getDoubleClickDelay(bool hardwareMouse) { H_AUTO_OGL(CDriverGL_getDoubleClickDelay) + uint res = 250; + #ifdef NL_OS_WINDOWS - NLMISC::IMouseDevice *md = NULL; - if (_EventEmitter.getNumEmitters() >= 2) + + NLMISC::IMouseDevice *md = NULL; + + if (_EventEmitter.getNumEmitters() >= 2) + { + NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); + if (diee->isMouseCreated()) { - NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast(_EventEmitter.getEmitter(1)); - if (diee->isMouseCreated()) + try { - try - { - md = diee->getMouseDevice(hardwareMouse); - } - catch (EDirectInput &) - { - // could not get device .. - } + md = diee->getMouseDevice(hardwareMouse); + } + catch (EDirectInput &) + { + // could not get device .. } } - if (md) - { - return md->getDoubleClickDelay(); - } + } + + if (md) + { + res = md->getDoubleClickDelay(); + } + else + { // try to read the good value from windows - return ::GetDoubleClickTime(); + res = ::GetDoubleClickTime(); + } + #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Missing Mac Implementation" nlwarning("OpenGL Driver: Missing Mac Implementation"); #elif defined (NL_OS_UNIX) - // TODO for Linux FIXME: FAKE FIX - return 250; + + // TODO for Linux + #endif + + return res; } // *************************************************************************** @@ -1671,21 +1893,20 @@ bool CDriverGL::setMonitorColorProperties (const CMonitorColorProperties &proper else { nlwarning ("(CDriverGL::setMonitorColorProperties): can't create DC"); - return false; } #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) # warning "OpenGL Driver: Missing Mac Implementation" nlwarning("OpenGL Driver: Missing Mac Implementation"); - return false; #elif defined (NL_OS_UNIX) // TODO for Linux: implement CDriverGL::setMonitorColorProperties nlwarning ("CDriverGL::setMonitorColorProperties not implemented"); - return false; #endif + + return false; } } // NL3D diff --git a/code/nel/src/3d/nelu.cpp b/code/nel/src/3d/nelu.cpp index 721d6f1cb..535e80b70 100644 --- a/code/nel/src/3d/nelu.cpp +++ b/code/nel/src/3d/nelu.cpp @@ -61,15 +61,11 @@ bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow syst CNELU::Driver= CDRU::createD3DDriver(); } else +#endif // NL_OS_WINDOWS { CNELU::Driver= CDRU::createGlDriver(); } -#else // NL_OS_WINDOWS - CNELU::Driver= CDRU::createGlDriver(); - //CNELU::Driver= CDRU::createD3DDriver(); - -#endif // NL_OS_WINDOWS if (!CNELU::Driver->init()) { nlwarning ("CNELU::initDriver: init() failed"); diff --git a/code/nel/src/misc/file.cpp b/code/nel/src/misc/file.cpp index df36c17be..98ede1eb1 100644 --- a/code/nel/src/misc/file.cpp +++ b/code/nel/src/misc/file.cpp @@ -48,7 +48,6 @@ uint32 CIFile::_ReadingFromFile = 0; uint32 CIFile::_FileOpened = 0; uint32 CIFile::_FileRead = 0; CSynchronized > CIFile::_OpenedFiles(""); - // = CSynchronized >(""); // ====================================================================================================== CIFile::CIFile() : IStream(true) diff --git a/code/nel/tools/3d/shapes_exporter/main.cpp b/code/nel/tools/3d/shapes_exporter/main.cpp index 4e3a81888..6532d26d4 100644 --- a/code/nel/tools/3d/shapes_exporter/main.cpp +++ b/code/nel/tools/3d/shapes_exporter/main.cpp @@ -16,6 +16,7 @@ #include #include +#include #include "shapes_exporter.h" using namespace NLMISC; @@ -40,6 +41,44 @@ void split(const std::string &str, std::vector &tokens, const std:: } } +static CHashKeyMD5 getNewMD5(const std::string &filename) +{ + CMD5Context md5ctx; + CHashKeyMD5 Message_Digest; + Message_Digest.clear(); + + CIFile ifile; + if (!ifile.open(filename)) + { + nlwarning ("MD5: Can't open the file '%s'", filename.c_str()); + return Message_Digest; + } + + md5ctx.init(); + + uint8 buffer[1024]; + int bufferSize = 1024; + sint fs = ifile.getFileSize(); + sint n, read = 0; + do + { + //bs = (int)fread (buffer, 1, bufferSize, fp); + n = std::min (bufferSize, fs-read); + //nlinfo ("read %d bytes", n); + ifile.serialBuffer((uint8 *)buffer, n); + + md5ctx.update(buffer, n); + + read += n; + } + while (!ifile.eof()); + + ifile.close (); + + md5ctx.final(Message_Digest); + + return Message_Digest; +} #if defined(NL_OS_WINDOWS) && !defined(_CONSOLE) sint WINAPI WinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR cmdline, int /* nCmdShow */) @@ -68,7 +107,6 @@ sint main(int argc, char **argv) exporter.parseConfigFile("shapes_exporter.cfg"); exporter.init(); - exporter.setupLight(); if (argc > 1) { @@ -84,8 +122,26 @@ sint main(int argc, char **argv) std::vector filenames; // search all .max files + CPath::getPathContent(exporter.settings.input_path, true, false, true, filenames); // CPath::getFileList("max", filenames); // search .max files corresponding to a filter + // fix bad textures + CPath::remapFile("ma_hof_armor_00_tibia_c1.tga", "ma_hof_armor00_tibia_c1.png"); + CPath::remapFile("ma_hof_armor_00_foot_c1.tga", "ma_hof_armor00_foot_c1.png"); + CPath::remapFile("ma_hof_armor_01_botte_c1.tga", "ma_hof_armor01_botte_c1.png"); + CPath::remapFile("ma_hof_armor_01_pied_c1.tga", "ma_hof_armor01_pied_c1.png"); + + CPath::remapFile("ma_hom_armor_01_botte_c1.tga", "ma_hom_armor01_botte_c1.png"); + CPath::remapFile("ma_hom_armor_01_pied_c1.tga", "ma_hom_armor01_pied_c1.png"); + + CPath::remapFile("hair_spec.tga", "spec_hair.png"); + + CPath::remapFile("zo_hof_armor_00_mollet_c1.tga", "zo_hof_armor00_mollet_c1.png"); + CPath::remapFile("zo_hof_armor_00_pied_c1.tga", "zo_hof_armor00_pied_c1.png"); + + CPath::remapFile("zo_hom_armor_00_mollet_c1.tga", "zo_hom_armor00_mollet_c1.png"); + CPath::remapFile("zo_hom_armor_00_pied_c1.tga", "zo_hom_armor00_pied_c1.png"); + // CPath::getFileListByName("ps", "braziera", filenames); // CPath::getFileListByName("ps", "fireworka", filenames); // CPath::getFileListByName("ps", "fireworkf", filenames); @@ -100,38 +156,106 @@ sint main(int argc, char **argv) CPath::getFileList("ps", shapes); for(size_t i = 0; i < filenames.size(); ++i) { + if (filenames[i].find(".max") == std::string::npos) + continue; + + std::string baseFilename = toLower(CFile::getFilenameWithoutExtension(filenames[i])); + // compute the md5 of .max file - std::string md5 = getMD5(filenames[i]).toString(); + std::string md5 = getNewMD5(filenames[i]).toString(); nlinfo("processing %s with md5 = %s", filenames[i].c_str(), md5.c_str()); // the final directory with images std::string output_path = exporter.settings.output_path + md5.substr(0, 2) + "/" + md5; + // file is an animation + std::string animation = ""; // CPath::lookup(baseFilename + ".anim", false, false, false); + // file is a skeleton + std::string skeleton = ""; // CPath::lookup(baseFilename + ".skel", false, false, false); + // file is a shape + std::string shape = CPath::lookup(baseFilename + ".shape", false, false, false); + + // copy .shape file + if (!shape.empty() && false) + { + CIFile in; + COFile out; + + // create output directory if it doesn't already exists + if (!CFile::isExists(output_path) && !CFile::createDirectoryTree(output_path)) + { + nlwarning("can't create %s", output_path.c_str()); + continue; + } + + if (in.open(shape) && out.open(output_path + "/" + baseFilename + ".shape")) + { + uint32 size = in.getFileSize(); + + uint8 *buffer = new uint8[size]; + + in.serialBuffer(buffer, size); + out.serialBuffer(buffer, size); + + delete [] buffer; + } + } + + // try with several shapes binded on a skeleton std::vector filtered_shapes; - if(CFile::getExtension(filenames[i]) == "ps") + if (!animation.empty()) { + // render animation + skeleton = ShapesExporter::findSkeleton(filenames[i]); + + // TODO: take from cfg +// filtered_shapes.push_back(); + continue; + // no filter if it's a PS filtered_shapes.push_back(filenames[i]); } + else if (!shape.empty()) + { +// skeleton = ShapesExporter::findSkeleton(shape); + // render shape + } + else if (!skeleton.empty()) + { + // don't render anything + continue; + } else { + continue; +/* // create a temporary list with shapes which could correspond to .max file for(size_t j = 0; j < shapes.size(); ++j) { // only add files with the same beginning - if (shapes[j].find(CFile::getFilenameWithoutExtension(filenames[i])) == 0) + if (shapes[j].find(baseFilename) == 0) { filtered_shapes.push_back(shapes[j]); } } - } +*/ + // if there is no corresponding file, we can't render it + if (filtered_shapes.empty()) + { + nlwarning("didn't find type of %s", filenames[i].c_str()); + continue; + } - // if there is no corresponding file, we can't render it - if (filtered_shapes.empty()) - { - nlinfo("no shape found"); - continue; + // if we found only one shape, we don't need a skeleton + if (filtered_shapes.size() == 1) + { + shape = filtered_shapes[0]; + } + else + { + skeleton = ShapesExporter::findSkeleton(filenames[i]); + } } // create output directory if it doesn't already exists @@ -141,32 +265,29 @@ sint main(int argc, char **argv) continue; } - // if we found only one shape, we don't need a skeleton - if (filtered_shapes.size() == 1) + bool res = false; + + if (!skeleton.empty()) { - if (!exporter.exportShape(filtered_shapes[0], output_path)) + res = exporter.exportSkeleton(skeleton, filtered_shapes, output_path); + } + else + { + res = exporter.exportShape(shape, output_path); + } + + if (res) + { + if (!exporter.createThumbnail(filenames[i], output_path)) { - // an error occured, try to delete directory - nlwarning("can't export shape"); - CFile::deleteDirectory(output_path); - continue; + nlwarning("can't create thumbnail"); } } else { - // TODO: search for the right skeleton - if (!exporter.exportSkeleton("fy_hof_skel.skel", filtered_shapes, output_path)) - { - // an error occured, try to delete directory - nlwarning("can't export shape"); - CFile::deleteDirectory(output_path); - continue; - } - } - - if (!exporter.createThumbnail(filenames[i], output_path)) - { - nlwarning("can't create thumbnail"); + // an error occured, try to delete directory + nlwarning("can't export shape"); + CFile::deleteDirectory(output_path); } } } diff --git a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cfg b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cfg index b5d69fa02..6db4b9a5a 100644 --- a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cfg +++ b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cfg @@ -1,7 +1,8 @@ +input_path = ""; search_pathes = { }; recursive_search_pathes = { }; output_path = "storage"; -extensions_remapping = { "dds", "tga" }; +extensions_remapping = { "png", "tga", "dds", "tga" }; preview_width = 80; preview_height = 80; @@ -17,7 +18,7 @@ output_antialiasing = 2; // 0 or 1 = none, 2 = 2x, etc... output_quality = 90; output_background = { 0, 0, 0 }; -light_ambiant = { 255, 255, 255 }; +light_ambiant = { 0, 0, 0 }; light_diffuse = { 255, 255, 255 }; light_specular = { 255, 255, 255 }; -light_direction = { 0.25, 0.5, 0.25 }; +light_direction = { 0.25, 0.25, 0.25 }; diff --git a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp index 7caf6ec40..288f581ed 100644 --- a/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp +++ b/code/nel/tools/3d/shapes_exporter/shapes_exporter.cpp @@ -106,6 +106,15 @@ bool ShapesExporter::parseConfigFile(const string &filename) return false; } + // input path + try + { + settings.input_path = CPath::standardizePath(cf.getVar("input_path").asString()); + } + catch (EUnknownVar &) + { + } + // output path try { @@ -332,7 +341,7 @@ bool ShapesExporter::parseConfigFile(const string &filename) return true; } -bool ShapesExporter::setupLight() +bool ShapesExporter::setupLight(const CVector &position, const CVector &direction) { // create the light ULight *Light = ULight::createLight(); @@ -342,7 +351,8 @@ bool ShapesExporter::setupLight() Light->setMode(ULight::DirectionalLight); // set position of the light - Light->setupDirectional(settings.light_ambiant, settings.light_diffuse, settings.light_specular, settings.light_direction); +// Light->setupDirectional(settings.light_ambiant, settings.light_diffuse, settings.light_specular, settings.light_direction); + Light->setupPointLight(settings.light_ambiant, settings.light_diffuse, settings.light_specular, position, direction + settings.light_direction); // set and enable the light Driver->setLight(0, *Light); @@ -351,21 +361,117 @@ bool ShapesExporter::setupLight() return true; } -void ShapesExporter::setCamera(CAABBox &bbox, UInstance &entity, bool high_z) +void ShapesExporter::setCamera(CAABBox &bbox, UTransform &entity, bool high_z) { + CVector pos(0.f, 0.f, 0.f); + CQuat quat(0.f, 0.f, 0.f, 0.f); + NL3D::UInstance inst; + inst.cast(entity); + if (!inst.empty()) + { + inst.getDefaultPos(pos); + inst.getDefaultRotQuat(quat); +/* + if (quat.getAxis().isNull()) + { + quat.set(0, 0, 0, 0); + inst.setRotQuat(quat); + } +*/ +// quat.set(1.f, 1.f, 0.f, 0.f); + +// inst.setRotQuat(quat); +// inst.getRotQuat(quat); + + // check for presence of all textures from each sets + bool allGood = true; + + for(uint s = 0; s < 5; ++s) + { + inst.selectTextureSet(s); + + uint numMat = inst.getNumMaterials(); + + // by default, all textures are present + allGood = true; + + for(uint i = 0; i < numMat; ++i) + { + UInstanceMaterial mat = inst.getMaterial(i); + + for(sint j = 0; j <= mat.getLastTextureStage(); ++j) + { + // if a texture is missing + if (mat.isTextureFile(j) && mat.getTextureFileName(j) == "CTextureMultiFile:Dummy") + allGood = false; + } + } + + // if all textures have been found for this set, skip other sets + if (allGood) + break; + } + } + + // fix scale (some shapes have a different value) + entity.setScale(1.f, 1.f, 1.f); + UCamera Camera = Scene->getCam(); - CVector center = bbox.getCenter(); CVector max_radius = bbox.getHalfSize(); + CVector center = bbox.getCenter(); entity.setPivot(center); + center += pos; float fov = float(20.0*Pi/180.0); Camera.setPerspective (fov, 1.0f, 0.1f, 1000.0f); float radius = max(max(max_radius.x, max_radius.y), max_radius.z); + if (radius == 0.f) radius = 1.f; float left, right, bottom, top, znear, zfar; Camera.getFrustum(left, right, bottom, top, znear, zfar); float dist = radius / (tan(fov/2)); - Camera.lookAt(CVector(center.x+dist+max_radius.x, center.y, center.z+(high_z?max_radius.z/1.0f:0.0f)), center); + CVector eye(center); +/* if (axis == CVector::I) + eye.y -= dist+radius; + else if (axis == CVector::J) + eye.x += dist+radius; +*/ +// quat.normalize(); + + CVector ax(quat.getAxis()); + +// float angle = quat.getAngle(); +/* + if (ax.isNull()) + { + if (int(angle*100.f) == int(NLMISC::Pi * 200.f)) + { + ax = CVector::J; + } + } + else +*/ + if (ax.isNull() || ax == CVector::I) + { + ax = CVector::I; + } + else if (ax == -CVector::K) + { + ax = -CVector::J; + } +/* else if (ax.x < -0.9f && ax.y == 0.f && ax.z == 0.f) + { + ax = -CVector::J ; + } +*/ +// ax.normalize(); + + eye -= ax * (dist+radius); + if (high_z) + eye.z += max_radius.z/1.0f; + Camera.lookAt(eye, center); + + setupLight(eye, center - eye); } bool ShapesExporter::exportShape(const string &filename, const string &output_path) @@ -397,15 +503,15 @@ bool ShapesExporter::exportShape(const string &filename, const string &output_pa Scene->animate(1.0); Scene->render(); - UParticleSystemInstance *psi = static_cast(&Entity); - if(psi) - { - psi->getSystemBBox(bbox); - setCamera(bbox, Entity); - } - if(CFile::getExtension(filename) == "ps") { + UParticleSystemInstance *psi = static_cast(&Entity); + if(psi) + { + psi->getSystemBBox(bbox); + setCamera(bbox, Entity); + } + // first pass to detect bbox & duration CAABBox bbox2; double duration = 0.0; @@ -418,7 +524,7 @@ bool ShapesExporter::exportShape(const string &filename, const string &output_pa } else { - renderShape(Entity, CVector::I, output_path); + renderShape(Entity, output_path); } // delete entity @@ -470,22 +576,9 @@ bool ShapesExporter::exportSkeleton(const string &skeleton, const vector // get AABox of Entity CAABBox bbox; Skeleton.computeCurrentBBox(bbox, NULL); + setCamera(bbox, Skeleton); - CVector center = bbox.getCenter(); - CVector max_radius = bbox.getMax(); - - Skeleton.setPivot(center); - - float radius = max_radius.x; - - if (max_radius.y > radius) radius = max_radius.y; - if (max_radius.z > radius) radius = max_radius.z; - - // camera will look at entities -// Camera.lookAt(CVector(center.x, center.y - bbox.getRadius() * 1.5f, center.z * 2.f), CVector(center.x, center.y, center.z * 2.f)); - Camera.lookAt(CVector(center.x + bbox.getRadius() * 2.0f, center.y, center.z), CVector(center.x, center.y, center.z)); - - renderShape(Skeleton, CVector::J, output_path); + renderShape(Skeleton, output_path); // delete entities for(size_t i = 0; i < Entities.size(); ++i) @@ -500,6 +593,95 @@ bool ShapesExporter::exportSkeleton(const string &skeleton, const vector return true; } +/* +bool ShapesExporter::exportAnimation(const std::string &animation, const std::string &skeleton, const std::vector &parts, const std::string &output_path) +{ + UPlayListManager *PlayListManager = Scene->createPlayListManager(); + UAnimationSet *AnimSet = Driver->createAnimationSet(); + +// uint anim_id = AnimSet->addAnimation("anim.anim", "anim_name", false); +// uint weight_id = AnimSet->addSkeletonWeight("file.wgt", "skel_name"): + +// UAnimation *anim = AnimSet->getAnimation(anim_id); +// anim->getEndTime(); + +// UPlayList *playlist = playlist_manager->createPlayList(AnimSet); +// playlist->registerTransform(Skeleton); + +// playlist->setAnimation(0, anim_id); +// playlist->setTimeOrigin(newSlot, time); +// playlist->setWeightSmoothness(newSlot, 1.0f); + + // get scene camera + UCamera Camera = Scene->getCam(); + if (Camera.empty()) + { + nlwarning("can't get camera from scene"); + return false; + } + + // add a skeleton to the scene + USkeleton Skeleton = Scene->createSkeleton(skeleton); + + // if we can't create entity, skip it + if (Skeleton.empty()) + { + nlwarning("can't create skeleton from %s", skeleton.c_str()); + return false; + } + + std::vector Entities(parts.size()); + + for(size_t i = 0; i < parts.size(); ++i) + { + Entities[i] = Scene->createInstance(parts[i]); + + // if we can't create entity, skip it + if (Entities[i].empty()) + { + nlwarning("can't create instance from %s", parts[i].c_str()); + return false; + } + + if (!Skeleton.bindSkin(Entities[i])) + { + nlwarning("can't bind %s to skeleton", parts[i].c_str()); + return false; + } + } + + // get AABox of Entity + CAABBox bbox; + Skeleton.computeCurrentBBox(bbox, NULL); + + setCamera(); + + // camera will look at skeleton + Camera.lookAt(CVector(center.x + dist - radius, center.y, center.z), center); + + renderAllImages(Skeleton, CVector::J, output_path); + + // delete entities + for(size_t i = 0; i < Entities.size(); ++i) + { + Skeleton.detachSkeletonSon(Entities[i]); + Scene->deleteInstance(Entities[i]); + } + + // delete skeleton + Scene->deleteSkeleton(Skeleton); + + Scene->deletePlayListManager(PlayListManager); + Driver->deleteAnimationSet(AnimSet); + +// m_playlist->emptyPlayList(); +// m_playlist->resetAllChannels(); +// m_playlistman->deletePlayList(m_playlist); + + return true; +} +*/ + bool ShapesExporter::saveOneImage(const string &filename) { CBitmap btm; @@ -543,21 +725,49 @@ bool ShapesExporter::saveOneImage(const string &filename) nlwarning("can't create %s", filename.c_str()); return false; } + return true; } -bool ShapesExporter::renderShape(UTransform &entity, const CVector &axis, const string &output_path) +bool ShapesExporter::renderShape(UTransform &entity, const string &output_path) { + CQuat quat(0.f, 0.f, 0.f, 0.f); + + CVector axis1 = CVector::J, axis2 = CVector::K; + int orientation1 = -1, orientation2 = 1; + + NL3D::UInstance inst; + inst.cast(entity); + if (!inst.empty()) + { +// inst.getDefaultRotQuat(quat); + inst.getRotQuat(quat); +/* if (!quat.getAxis().isNull()) + { + CVector a = quat.getAxis(); + if (a.z != 0 && a.x == 0.f) + { + axis1 = CVector::J; + orientation1 = -1; + } + if (a.y != 0.f) + { + axis2 = CVector::J; + } + } +*/ + } + // main loop for (uint step_z = 0; step_z < settings.output_steps_z; ++step_z) { - CQuat z(axis, (float)step_z * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_z)); + CQuat z(axis1, orientation1 * (float)step_z * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_z)); for (uint step_x = 0; step_x < settings.output_steps_x; ++step_x) { - CQuat x(CVector::K, (float)step_x * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_x)); + CQuat x(axis2, orientation2 * (float)step_x * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_x)); - entity.setRotQuat(z * x); + entity.setRotQuat(quat * z * x); string filename = CPath::standardizePath(output_path) + toString("%03d_%03d.%s", step_z, step_x, settings.output_format.c_str()); @@ -729,3 +939,65 @@ bool ShapesExporter::createThumbnail(const string &filename, const string &path) return true; } + +std::string ShapesExporter::findSkeleton(const std::string &shape) +{ + std::string baseFilename = CFile::getFilenameWithoutExtension(shape); + + // work in 60% of cases + std::string skeleton = CPath::lookup(baseFilename + ".skel", false, false, false); + + if (!skeleton.empty()) + return skeleton; + + // remove last part + size_t pos = baseFilename.rfind("_"); + + if (pos != std::string::npos) + { + skeleton = CPath::lookup(baseFilename.substr(0, pos) + ".skel", false, false, false); + + if (!skeleton.empty()) + return skeleton; + + pos = baseFilename.find("_"); + + std::vector filenames; + + CPath::getFileListByName("skel", baseFilename.substr(pos), filenames); + + if (filenames.size() == 1) + { + skeleton = filenames[0]; + return skeleton; + } + + } + + int gender = 0; + + if (baseFilename.find("_hom_") != std::string::npos) + { + gender = 1; + } + else if (baseFilename.find("_hof_") != std::string::npos) + { + gender = 2; + } + + // bipeds + if (gender > 0) + { + // karavan + if (baseFilename.find("ca_") == 0) + return gender == 1 ? "ca_hom_armor01.skel":"ca_hof_armor01.skel"; + + return gender == 1 ? "fy_hom_skel.skel":"fy_hof_skel.skel"; + } + + nlwarning("can't find skeleton for %s", shape.c_str()); + // goo mobs +// CPath::getFileListByName("max", "_hof_", filenames); + + return ""; +} diff --git a/code/nel/tools/3d/shapes_exporter/shapes_exporter.h b/code/nel/tools/3d/shapes_exporter/shapes_exporter.h index d8a989c71..233682e55 100644 --- a/code/nel/tools/3d/shapes_exporter/shapes_exporter.h +++ b/code/nel/tools/3d/shapes_exporter/shapes_exporter.h @@ -26,6 +26,7 @@ struct Settings { Settings(); + std::string input_path; std::string output_path; std::string preview_format; @@ -56,18 +57,19 @@ public: bool init(); bool parseConfigFile(const std::string &filename); - bool setupLight(); + bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction); bool exportShape(const std::string &filename, const std::string &output_path); bool exportSkeleton(const std::string &skeleton, const std::vector &parts, const std::string &output_path); - - void setCamera(NLMISC::CAABBox &bbox, NL3D::UInstance &entity, bool high_z=false); + void setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z=false); bool saveOneImage(const std::string &output_path); - bool renderShape(NL3D::UTransform &entity, const NLMISC::CVector &axis, const std::string &output_path); + bool renderShape(NL3D::UTransform &entity, const std::string &output_path); bool renderPS(NL3D::UInstance &entity, const std::string &output_path, double &duration, NLMISC::CAABBox &bbox); bool createThumbnail(const std::string &filename, const std::string &path); + static std::string findSkeleton(const std::string &shape); + Settings settings; NL3D::UDriver* Driver; NL3D::UScene* Scene; diff --git a/code/nel/tools/all.sln b/code/nel/tools/all.sln index bbb9e335d..d5f8411ef 100644 --- a/code/nel/tools/all.sln +++ b/code/nel/tools/all.sln @@ -395,6 +395,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml_packer", "misc\xml_pack {44B21233-EFCC-4825-B5E5-3A3BD6CC5516} = {44B21233-EFCC-4825-B5E5-3A3BD6CC5516} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_exporter", "3d\shapes_exporter\shapes_exporter.vcproj", "{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}" + ProjectSection(ProjectDependencies) = postProject + {2B48BE83-108B-4E8E-8A55-6627CF09AC5A} = {2B48BE83-108B-4E8E-8A55-6627CF09AC5A} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -931,6 +936,14 @@ Global {222663AE-5BAD-49B3-837F-26A518A3373A}.Release|Win32.Build.0 = Release|Win32 {222663AE-5BAD-49B3-837F-26A518A3373A}.Release|x64.ActiveCfg = Release|x64 {222663AE-5BAD-49B3-837F-26A518A3373A}.Release|x64.Build.0 = Release|x64 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|Win32.Build.0 = Debug|Win32 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|x64.ActiveCfg = Debug|x64 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|x64.Build.0 = Debug|x64 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|Win32.ActiveCfg = Release|Win32 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|Win32.Build.0 = Release|Win32 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|x64.ActiveCfg = Release|x64 + {F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/code/ryzom/client/src/character_cl.cpp b/code/ryzom/client/src/character_cl.cpp index c9e4c87da..48b277e9c 100644 --- a/code/ryzom/client/src/character_cl.cpp +++ b/code/ryzom/client/src/character_cl.cpp @@ -1396,7 +1396,7 @@ void CCharacterCL::updateVisualPropertyBehaviour(const NLMISC::TGameCycle &gameC // New Behaviour Received. CBehaviour beh(prop); if(verboseVP(this)) - nlinfo("(%05d,%03d) CH::updateVPBeha:%d: '%s(%d)' received.", sint32(T1%100000), NetMngr.getCurrentServerTick(), _Slot, behaviourToString(beh.Behaviour).c_str(), beh.Behaviour); + nlinfo("(%05d,%03d) CH::updateVPBeha:%d: '%s(%d)' received.", sint32(T1%100000), NetMngr.getCurrentServerTick(), _Slot, behaviourToString((EBehaviour)beh.Behaviour).c_str(), beh.Behaviour); // Add in right stage. _Stages.addStage(gameCycle, PROPERTY_BEHAVIOUR, prop); @@ -2219,7 +2219,11 @@ void CCharacterCL::endAnimTransition() // If the animation is a rotation, set the character direction he should have at the end of the animation. if(_CurrentState->Rotation) { - if(isUser()) nldebug(" rotation : set dir as end anim dir"); + if(isUser()) + { + nldebug(" rotation : set dir as end anim dir"); + } + dir(dirEndAnim()); } // Fit the current direction to the target when attacking. @@ -4173,6 +4177,8 @@ void CCharacterCL::performCurrentAttackEnd(const CBehaviourContext &bc, bool dir } } break; + default: + break; } // if object has a list of cast rays, then we assume it is a static object (like guard towers) @@ -4671,7 +4677,7 @@ void CCharacterCL::applyBehaviour(const CBehaviourContext &bc) // virtual // INFO : display some debug informations. if((VerboseAnimUser && _Slot==0) || (VerboseAnimSelection && _Slot == UserEntity->selection())) - nlinfo("CH:applyBeh:%d: '%d(%s)'", _Slot, behaviour.Behaviour, behaviourToString(behaviour.Behaviour).c_str()); + nlinfo("CH:applyBeh:%d: '%d(%s)'", _Slot, behaviour.Behaviour, behaviourToString((EBehaviour)behaviour.Behaviour).c_str()); // ***** Apply the behaviour according to type @@ -4730,6 +4736,8 @@ void CCharacterCL::applyBehaviour(const CBehaviourContext &bc) // virtual case MBEHAV::CAST_MIX_LINK: endCast(behaviour, previousBehaviour); break; + default: + break; } // DeltaHP applyBehaviourFlyingHPs(bc, behaviour, targetHitDates); @@ -6668,7 +6676,9 @@ ADD_METHOD(void CCharacterCL::updatePos(const TTime ¤tTimeInMs, CEntityCL // Else : There is no move. } else + { CHECK(posInStage==false && dist2Dest()<=0.0); + } // If there is no position in the next stage and the stage should be done already. if(!_Stages._StageSet.empty() && !posInStage && !stageReach && !allToFirstPos && ((_LastFrameTime+loopTimeStep) >= stageTime)) @@ -6682,7 +6692,7 @@ ADD_METHOD(void CCharacterCL::updatePos(const TTime ¤tTimeInMs, CEntityCL if(loopTimeStep < 0.0) loopTimeStep = 0.0; // - // \todo GUIGUI : ajuster le timeOffset comme on arrete la boucle avant l'heure + // \todo GUIGUI : adjust timeOffset, because we stopped the loop before // // Stage complete. stageReach = true; diff --git a/code/ryzom/client/src/client_sheets/plant_sheet.cpp b/code/ryzom/client/src/client_sheets/plant_sheet.cpp index f4b9d9ddc..331fac0d2 100644 --- a/code/ryzom/client/src/client_sheets/plant_sheet.cpp +++ b/code/ryzom/client/src/client_sheets/plant_sheet.cpp @@ -139,7 +139,10 @@ void CSeasonFXSheet::build(const NLGEORGES::UFormElm &item, NLMISC::CSheetId par NLMISC::clamp(MinDuration, 0.f, CycleDuration /*- startHourMaxInterval*/); NLMISC::clamp(MaxDuration, 0.f, CycleDuration /*- startHourMaxInterval*/); - if (!ok) nldebug("Key not found."); + if (!ok) + { + nldebug("Key not found."); + } } //======================================================= @@ -210,10 +213,11 @@ void CPlantSheet::build(const NLGEORGES::UFormElm &item) { if(!(item.getValueByName(_ShapeName, "3D.Shape") && item.getValueByName(_MaxDist, "3D.MaxDist") && - item.getValueByName(_CoarseMeshDist, "3D.CoarseMeshDist") - ) - ) - nldebug("Key not found."); + item.getValueByName(_CoarseMeshDist, "3D.CoarseMeshDist"))) + { + nldebug("Key not found."); + } + // serial fxs by season SeasonFX[EGSPD::CSeason::Spring].build(item, Id, "3D.SpringFX."); SeasonFX[EGSPD::CSeason::Summer].build(item, Id, "3D.SummerFX."); diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index c69d91733..353ab705c 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -890,7 +890,7 @@ NLMISC_COMMAND(db, "Modify Database"," ") static bool talkInChan(uint32 nb,std::vectorargs) { uint32 maxChans = CChatGroup::MaxDynChanPerPlayer; - if (nb<0||nb>=maxChans) + if (nb>=maxChans) { return false; } diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index 4d0483a38..a81198a8f 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -377,6 +377,7 @@ void CLoginStateMachine::run() { mustReboot = CPatchManager::getInstance()->mustLaunchBatFile(); } + if (mustReboot) { // skip eula and show reboot screen diff --git a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp index 984e05700..1e1f123db 100644 --- a/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp +++ b/code/ryzom/client/src/interface_v3/bot_chat_manager.cpp @@ -239,7 +239,8 @@ void CBotChatManager::debugLocalReceiveMissionInfo() { viewTextID->setTextId(infos.Prerequisits[i].Description); } - /*if (!help->ScrollTextGroup.empty()) +#if 0 + if (!help->ScrollTextGroup.empty()) { CInterfaceGroup *viewTextGroup = help->HelpWindow->getGroup(help->ScrollTextGroup); if (viewTextGroup) @@ -248,8 +249,8 @@ void CBotChatManager::debugLocalReceiveMissionInfo() CInterfaceGroup *viewTextGroup = help->HelpWindow->getGroup(help->ScrollTextIdGroup); if (viewTextGroup) viewTextGroup->setActive(true); - */ -/* } +#endif + } _MissionHelpWindowsWaiting.erase(index); } diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index a842de29b..6be8d315b 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -69,9 +69,9 @@ extern CClientChatManager ChatMngr; CChatWindowDesc::CChatWindowDesc() : InsertPosition(-1), ParentBlink(false), - Listener(NULL), Savable(false), - Localize(false) + Localize(false), + Listener(NULL) { } @@ -80,7 +80,7 @@ CChatWindowDesc::CChatWindowDesc() : InsertPosition(-1), ///////////////// //================================================================================= -CChatWindow::CChatWindow() : _Listener(NULL), _Chat(NULL), _ParentBlink(false), _EB(NULL) +CChatWindow::CChatWindow() : _Listener(NULL), _Chat(NULL), _EB(NULL), _ParentBlink(false) { } diff --git a/code/ryzom/client/src/interface_v3/chat_window.h b/code/ryzom/client/src/interface_v3/chat_window.h index dd5bfaac1..77cce3487 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.h +++ b/code/ryzom/client/src/interface_v3/chat_window.h @@ -49,7 +49,7 @@ struct CChatWindowDesc ucstring Title; // unique title for the window std::string FatherContainer; // name of the father container. If empty, the chat box must be added manually in the hierarchy std::string ChatTemplate; // Template for the chat interface, or "" to use the default one - TTemplateParams ChatTemplateParams; // optional tempalte parameters + TTemplateParams ChatTemplateParams; // optional template parameters sint InsertPosition; // [optional] -1 if the chat box should be inserted at the end of the container list, or the index otherwise bool ParentBlink; // [optional] when true, make the parent group blink bool Savable; // should the position of the chat box be saved between session ? Default is false diff --git a/code/ryzom/client/src/interface_v3/ctrl_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_button.cpp index 887d32b17..17d89e900 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_button.cpp @@ -192,6 +192,8 @@ void CCtrlButton::draw () } } break; + default: + break; } color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8); diff --git a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp index 358532c0e..d2191a4eb 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_text_button.cpp @@ -342,6 +342,8 @@ void CCtrlTextButton::draw () } } break; + default: + break; } // *** Draw diff --git a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp index 559bd44d4..40e62346f 100644 --- a/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp +++ b/code/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp @@ -126,7 +126,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) // get item size. CViewRenderer &rVR = pIM->getViewRenderer(); - sint32 dispSlotBmpId; + sint32 dispSlotBmpId = 0; switch(_CtrlInfo._Type) { case CCtrlSheetInfo::SheetType_Auto: @@ -144,6 +144,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup) case CCtrlSheetInfo::SheetType_Macro: dispSlotBmpId = rVR.getTextureIdFromName ("w_slot_brick.tga"); break; case CCtrlSheetInfo::SheetType_GuildFlag: dispSlotBmpId = rVR.getTextureIdFromName ("w_slot_blason.tga"); break; case CCtrlSheetInfo::SheetType_ElevatorDestination: dispSlotBmpId = rVR.getTextureIdFromName ("w_slot_blason.tga"); break; + default: break; } rVR.getTextureSizeFromId (dispSlotBmpId, _WSlot, _HSlot); diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 006ea1785..9caea5382 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -2475,13 +2475,12 @@ void CGroupHTML::setTitle (const ucstring &title) CInterfaceElement *parent = getParent(); if (parent) { - if (parent = parent->getParent()) + parent = parent->getParent(); + + CGroupContainer *container = dynamic_cast(parent); + if (container) { - CGroupContainer *container = dynamic_cast(parent); - if (container) - { - container->setUCTitle (title); - } + container->setUCTitle (title); } } } diff --git a/code/ryzom/client/src/interface_v3/group_table.cpp b/code/ryzom/client/src/interface_v3/group_table.cpp index 2f4b018c1..48ec926a4 100644 --- a/code/ryzom/client/src/interface_v3/group_table.cpp +++ b/code/ryzom/client/src/interface_v3/group_table.cpp @@ -615,6 +615,8 @@ void CGroupTable::updateCoords() alignmentX = _Columns[column].Width - cell->WidthMax; widthReduceX = alignmentX; break; + default: + break; } } @@ -665,6 +667,8 @@ void CGroupTable::updateCoords() case CGroupCell::Bottom: alignmentY = _Rows[row].Height - (sint32)cell->Group->getH(); break; + default: + break; } } diff --git a/code/ryzom/client/src/interface_v3/interface_link.cpp b/code/ryzom/client/src/interface_v3/interface_link.cpp index f102855b3..e8f583bea 100644 --- a/code/ryzom/client/src/interface_v3/interface_link.cpp +++ b/code/ryzom/client/src/interface_v3/interface_link.cpp @@ -123,6 +123,8 @@ static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem return false; } break; + default: + break; } return true; diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 4fdc00375..16c85edf2 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2907,7 +2907,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event) // window handling. if not handled by a control if (!handled) { - if ((pNewCurrentWnd != NULL) && _ModalStack.empty() || (!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd)) + if (((pNewCurrentWnd != NULL) && _ModalStack.empty()) || ((!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd))) { CEventDescriptorMouse ev2 = eventDesc; sint32 x= eventDesc.getX(), y = eventDesc.getY(); diff --git a/code/ryzom/client/src/npc_icon.h b/code/ryzom/client/src/npc_icon.h index 697fc1873..07a5ec4eb 100644 --- a/code/ryzom/client/src/npc_icon.h +++ b/code/ryzom/client/src/npc_icon.h @@ -61,7 +61,7 @@ class CNPCMissionGiverDesc public: /// Constructor - CNPCMissionGiverDesc() : _MissionGiverState(NPC_ICON::AwaitingFirstData), _IsDescTransient(true), _HasChanged(false) + CNPCMissionGiverDesc() : _MissionGiverState(NPC_ICON::AwaitingFirstData), _LastUpdateTimestamp(0), _IsDescTransient(true), _HasChanged(false) {} // Current assignment operator: bitwise copy diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index d860cd951..fc8ec2b51 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -66,7 +66,7 @@ #include "../../far_tp.h" #include "../../net_manager.h" -#include "zlib.h" +#include diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 1f8f84a3f..7dd8519bd 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -220,10 +220,16 @@ void releaseMainLoopReselect() // Remove all entities. if (Driver) + { nldebug("RCSR1: %u textures", Driver->getTotalAsyncTextureSizeAsked()); + } + EntitiesMngr.release(); + if (Driver) + { nldebug("RCSR2: %u textures", Driver->getTotalAsyncTextureSizeAsked()); + } // Reset Fx manager (must be done after EntitiesMngr.release()) Important because may still point to 3D elements FXMngr.reset(); @@ -266,11 +272,17 @@ void releaseMainLoopReselect() // Release the Entities Animation Manager (Yoyo: fuckingly important because keep a pointer // on a _PlayListManager that is created from Scene) if (Driver) + { nldebug("RCSR3: %u textures", Driver->getTotalAsyncTextureSizeAsked()); + } + CEntityAnimationManager::delInstance(); EAM= NULL; + if (Driver) + { nldebug("RCSR4: %u textures", Driver->getTotalAsyncTextureSizeAsked()); + } // Not necessary I think because owns only static data (string + function ptrs) // --releaseContextualCursor(); diff --git a/code/ryzom/client/src/seven_zip/7zAlloc.cpp b/code/ryzom/client/src/seven_zip/7zAlloc.cpp index 3e8e6387a..d5da81b12 100644 --- a/code/ryzom/client/src/seven_zip/7zAlloc.cpp +++ b/code/ryzom/client/src/seven_zip/7zAlloc.cpp @@ -1,6 +1,5 @@ /* 7zAlloc.c */ -#include "nel/misc/types_nl.h" #include #include "7zAlloc.h" diff --git a/code/ryzom/client/src/seven_zip/7zBuffer.cpp b/code/ryzom/client/src/seven_zip/7zBuffer.cpp index 1d47d4055..8bc8e0670 100644 --- a/code/ryzom/client/src/seven_zip/7zBuffer.cpp +++ b/code/ryzom/client/src/seven_zip/7zBuffer.cpp @@ -1,7 +1,5 @@ /* 7zBuffer.c */ -#include "nel/misc/types_nl.h" - #include "7zBuffer.h" #include "7zAlloc.h" diff --git a/code/ryzom/client/src/seven_zip/7zCrc.cpp b/code/ryzom/client/src/seven_zip/7zCrc.cpp index 37861d035..6dc7dd325 100644 --- a/code/ryzom/client/src/seven_zip/7zCrc.cpp +++ b/code/ryzom/client/src/seven_zip/7zCrc.cpp @@ -1,6 +1,5 @@ /* 7zCrc.c */ -#include "nel/misc/types_nl.h" #include "7zCrc.h" #define kCrcPoly 0xEDB88320 diff --git a/code/ryzom/client/src/seven_zip/7zMain.cpp b/code/ryzom/client/src/seven_zip/7zMain.cpp index 00ff961a9..ee2ac82b7 100644 --- a/code/ryzom/client/src/seven_zip/7zMain.cpp +++ b/code/ryzom/client/src/seven_zip/7zMain.cpp @@ -14,7 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/misc/types_nl.h" #include #include #include diff --git a/code/ryzom/client/src/seven_zip/7zTypes.h b/code/ryzom/client/src/seven_zip/7zTypes.h index 104b8e042..0e01e8748 100644 --- a/code/ryzom/client/src/seven_zip/7zTypes.h +++ b/code/ryzom/client/src/seven_zip/7zTypes.h @@ -3,8 +3,6 @@ #ifndef __COMMON_TYPES_H #define __COMMON_TYPES_H -#include "nel/misc/types_nl.h" - #ifndef _7ZIP_BYTE_DEFINED #define _7ZIP_BYTE_DEFINED typedef unsigned char Byte; diff --git a/code/ryzom/client/src/seven_zip/CMakeLists.txt b/code/ryzom/client/src/seven_zip/CMakeLists.txt index f116006d6..451ae56de 100644 --- a/code/ryzom/client/src/seven_zip/CMakeLists.txt +++ b/code/ryzom/client/src/seven_zip/CMakeLists.txt @@ -19,11 +19,11 @@ TARGET_LINK_LIBRARIES(ryzom_sevenzip ${PLATFORM_LINKFLAGS}) SET_TARGET_PROPERTIES(ryzom_sevenzip PROPERTIES VERSION ${NL_VERSION}) IF(WIN32) - SET_TARGET_PROPERTIES(seven_zip + SET_TARGET_PROPERTIES(ryzom_sevenzip PROJECT_LABEL "Library: Seven Zip" DEBUG_POSTFIX "_d" RELEASE_POSTFIX "_r" - LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrt" + LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrt") ENDIF(WIN32) ADD_DEFINITIONS(-D_SZ_ONE_DIRECTORY) diff --git a/code/ryzom/client/src/seven_zip/LzmaRamDecode.cpp b/code/ryzom/client/src/seven_zip/LzmaRamDecode.cpp index 251a8ba67..0f0f84248 100644 --- a/code/ryzom/client/src/seven_zip/LzmaRamDecode.cpp +++ b/code/ryzom/client/src/seven_zip/LzmaRamDecode.cpp @@ -1,6 +1,5 @@ /* LzmaRamDecode.c */ -#include "nel/misc/types_nl.h" #include "LzmaRamDecode.h" #ifdef _SZ_ONE_DIRECTORY #include "LzmaDecode.h" diff --git a/code/ryzom/client/src/seven_zip/LzmaTypes.h b/code/ryzom/client/src/seven_zip/LzmaTypes.h index 19844cdc5..4a1f7db49 100644 --- a/code/ryzom/client/src/seven_zip/LzmaTypes.h +++ b/code/ryzom/client/src/seven_zip/LzmaTypes.h @@ -10,8 +10,6 @@ This file is part of LZMA SDK 4.40 (2006-05-01) #ifndef __LZMATYPES_H #define __LZMATYPES_H -#include "nel/misc/types_nl.h" - #ifndef _7ZIP_BYTE_DEFINED #define _7ZIP_BYTE_DEFINED typedef unsigned char Byte; diff --git a/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp b/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp index 1315bddf8..0fc3df40f 100644 --- a/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp +++ b/code/ryzom/common/src/game_share/_backup_service_interface_non_module.cpp @@ -85,7 +85,7 @@ private: void CGenericRequestIdRegister::pushRequestId(uint32 requestId,const std::string& fileName) { // check for out of order entries in the request list - BOMB_IF(!_RequestIds.empty() && uint32(requestId-_RequestIds.back().RequestId)<0,"Ignoring out of order request id in generic callback registration for file "+CSString(fileName).quote(),return); + BOMB_IF(!_RequestIds.empty() && ((sint32)requestId-(sint32)_RequestIds.back().RequestId)<0,"Ignoring out of order request id in generic callback registration for file "+CSString(fileName).quote(),return); // setup a new record for this request id / file name pair SRequestId theNewRequestId; diff --git a/code/ryzom/common/src/game_share/_backup_service_interface_singleton.cpp b/code/ryzom/common/src/game_share/_backup_service_interface_singleton.cpp index 524ef5df2..efff0524d 100644 --- a/code/ryzom/common/src/game_share/_backup_service_interface_singleton.cpp +++ b/code/ryzom/common/src/game_share/_backup_service_interface_singleton.cpp @@ -174,7 +174,7 @@ uint32 CBackupInterfaceSingleton::pushGenericAckCallback(NLMISC::CSmartPtr= sizeof(pactNatureStrings)/sizeof(string) ) + if ((uint)pactNature >= sizeof(pactNatureStrings)/sizeof(string) ) { nlwarning("= sizeof(pactTypeStrings)/sizeof(string) ) + if ((uint)pactType >= sizeof(pactTypeStrings)/sizeof(string) ) { nlwarning(" clauses; bool clauseOpen=false; - uint32 clauseEnd; + uint32 clauseEnd = 0; for (uint32 i=len;i--;) { switch(buff[i]) diff --git a/code/ryzom/tools/sheets_packer/sheets_packer.cfg b/code/ryzom/tools/sheets_packer/sheets_packer.cfg index b04c42a42..9f2647ec5 100644 --- a/code/ryzom/tools/sheets_packer/sheets_packer.cfg +++ b/code/ryzom/tools/sheets_packer/sheets_packer.cfg @@ -1,18 +1,7 @@ -////////////////////////// -////////////////////////// -/// CLIENT CONFIG FILE /// -////////////////////////// -////////////////////////// -FullScreen = 0; -Width = 800; -Height = 600; -PositionX = 0; -PositionY = 0; -Frequency = 60; -Depth = 32; -Sleep = -1; -Contrast = 0.0; // -1.0 ~ 1.0 -Luminosity = 0.0; // -1.0 ~ 1.0 -Gamma = 0.0; // -1.0 ~ 1.0 +///////////////////////////////// +///////////////////////////////// +/// SHEETS PACKER CONFIG FILE /// +///////////////////////////////// +///////////////////////////////// DataPath = { "../../common/data_leveldesign", "../../common/data_common", "../../client/data" }; LigoPrimitiveClass = "world_editor_classes.xml"; diff --git a/code/ryzom/tools/sheets_packer/sheets_packer.cpp b/code/ryzom/tools/sheets_packer/sheets_packer.cpp index da2b48001..e7f6388b3 100644 --- a/code/ryzom/tools/sheets_packer/sheets_packer.cpp +++ b/code/ryzom/tools/sheets_packer/sheets_packer.cpp @@ -65,50 +65,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdline, int main(int argc, char **argv) #endif { - -/* -#if defined(NL_OS_WINDOWS) - - // extract the 2 first param (argv[1] and argv[2]) it must be cookie and addr - - string cmd = cmdline; - std::string::size_type pos1 = cmd.find_first_not_of (' '); - std::string::size_type pos2; - if (pos1 != string::npos) - { - pos2 = cmd.find (' ', pos1); - if(pos2 != string::npos) - { - cookie = cmd.substr (pos1, pos2-pos1); - - pos1 = cmd.find_first_not_of (' ', pos2); - if (pos1 != string::npos) - { - pos2 = cmd.find (' ', pos1); - if(pos2 == string::npos) - { - fsaddr = cmd.substr (pos1); - } - else if (pos1 != pos2) - { - fsaddr = cmd.substr (pos1, pos2-pos1); - } - } - } - } - -#else - - if (argc>=3) - { - cookie = argv[1]; - fsaddr = argv[2]; - } - nlinfo ("From command line (argc=%d): cookie '%s' addr '%s'", argc, cookie.c_str (), fsaddr.c_str()); -#endif -*/ - - ///////////////////////////////// // Initialize the application. // try diff --git a/code/ryzom/tools/sheets_packer/sheets_packer_cfg.cpp b/code/ryzom/tools/sheets_packer/sheets_packer_cfg.cpp index f1e553778..92d87592f 100644 --- a/code/ryzom/tools/sheets_packer/sheets_packer_cfg.cpp +++ b/code/ryzom/tools/sheets_packer/sheets_packer_cfg.cpp @@ -22,21 +22,12 @@ ///////////// #include "stdpch.h" -#if defined(NL_OS_WINDOWS) -#include -#endif // Misc. #include "nel/misc/config_file.h" #include "nel/misc/bit_mem_stream.h" // Client. #include "sheets_packer_cfg.h" -#include "debug_client.h" -// 3D Interface. -//#include "nel/3d/u_driver.h" -//#include "nel/3d/u_scene.h" -// Game Share. -#include "game_share/time_weather_season/time_and_season.h" /////////// // MACRO // @@ -138,7 +129,6 @@ // USING // /////////// using namespace NLMISC; -//using namespace NL3D; //////////// @@ -148,13 +138,6 @@ CClientConfig AppCfg; const std::string ConfigFileName = "sheets_packer.cfg"; -//////////// -// EXTERN // -//////////// -//extern NL3D::UScene *Scene; -//extern NL3D::UDriver *Driver; -extern CRyzomTime RT; - ///////////// // METHODS // ///////////// @@ -165,17 +148,6 @@ extern CRyzomTime RT; CClientConfig::CClientConfig() { SaveConfig = false; - PositionX = 0; - PositionY = 0; - Frequency = 60; - Windowed = false; // Default is windowed mode. - Width = 800; // Default Width for the window. - Height = 600; // Default Height for the window. - Depth = 32; // Default Bit per Pixel. - Contrast = 0.f; // Default Monitor Contrast. - Luminosity = 0.f; // Default Monitor Luminosity. - Gamma = 0.f; // Default Monitor Gamma. - PreDataPath.push_back("../../client/data/gamedev/language/"); // Default Path for the language data DataPath.push_back("../../client/data/"); // Default Path for the Data. DataPath.push_back("../../common/data_leveldesign/"); // Default Path for the Level Design Directory. DataPath.push_back("../../common/data_common/"); // Default Path for the Level Design Directory. @@ -197,69 +169,8 @@ void setValues() CConfigFile::CVar *varPtr = 0; - - /////////////////// - // WINDOW CONFIG // - // Mode. - - // SaveConfig - varPtr = AppCfg.ConfigFile.getVarPtr ("SaveConfig"); - if (varPtr) - AppCfg.SaveConfig = varPtr->asInt() ? true : false; - else - nlwarning ("Default value used for 'SaveConfig' !!!"); - - // Window Positon - varPtr = AppCfg.ConfigFile.getVarPtr ("PositionX"); - if (varPtr) - AppCfg.PositionX = varPtr->asInt(); - else - nlwarning ("Default value used for 'PositionX' !!!"); - varPtr = AppCfg.ConfigFile.getVarPtr ("PositionY"); - if (varPtr) - AppCfg.PositionY = varPtr->asInt(); - else - nlwarning ("Default value used for 'PositionY' !!!"); - - // Window frequency - varPtr = AppCfg.ConfigFile.getVarPtr ("Frequency"); - if (varPtr) - AppCfg.Frequency = varPtr->asInt(); - else - nlwarning ("Default value used for 'Frequency' !!!"); - - try - { - CConfigFile::CVar &cvFullScreen = AppCfg.ConfigFile.getVar("FullScreen"); - AppCfg.Windowed = cvFullScreen.asInt() ? false : true; - } - catch(EUnknownVar &) {nlwarning("Default value used for 'Fullscreen' !!!");} - // Width - READ_INT(Width) - // Height - READ_INT(Height) - // Depth : Bit Per Pixel - READ_INT(Depth) - // Contrast - READ_FLOAT(Contrast) - // Luminosity - READ_FLOAT(Luminosity) - // Gamma - READ_FLOAT(Gamma) - - ////////// // MISC // - // Pre Data Path. - try - { - CConfigFile::CVar &cvPreDataPath = AppCfg.ConfigFile.getVar("PreDataPath"); - AppCfg.PreDataPath.clear (); - for (uint i = 0; i < cvPreDataPath.size(); i++) - AppCfg.PreDataPath.push_back(cvPreDataPath.asString(i)); - } - catch(EUnknownVar &) {nlwarning("Default value used for 'PreDataPath' !!!");} - // Data Path. try { @@ -314,35 +225,7 @@ void setValues() // LanguageCode READ_STRING(LanguageCode) - READ_BOOL(FPExceptions) - - - - ////////// - // INIT // - // FPU -#ifdef NL_OS_WINDOWS - if(AppCfg.FPExceptions) - _control87(_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM); - else - _control87(_EM_INVALID|_EM_DENORMAL|_EM_ZERODIVIDE|_EM_OVERFLOW|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM); -#endif // NL_OS_WINDOWS - -/* if(Driver) - { - // Set the monitor color properties - CMonitorColorProperties monitorColor; - for(uint i=0; i<3; i++) - { - monitorColor.Contrast[i] = AppCfg.Contrast; - monitorColor.Luminosity[i] = AppCfg.Luminosity; - monitorColor.Gamma[i] = AppCfg.Gamma; - } - if(!Driver->setMonitorColorProperties(monitorColor)) - nlwarning("reloadCFG: setMonitorColorProperties fails"); - } -*/ }// load // @@ -355,41 +238,6 @@ void CClientConfig::serial(class NLMISC::IStream &f) throw(NLMISC::EStream) // Start the opening of a new node named ClientCFG. f.xmlPush("ClientCFG"); - f.xmlPushBegin("Windowed"); - f.xmlPushEnd(); - f.serial(Windowed); - f.xmlPop(); - - f.xmlPushBegin("Width"); - f.xmlPushEnd(); - f.serial(Width); - f.xmlPop(); - - f.xmlPushBegin("Height"); - f.xmlPushEnd(); - f.serial(Height); - f.xmlPop(); - - f.xmlPushBegin("Depth"); - f.xmlPushEnd(); - f.serial(Depth); - f.xmlPop(); - - f.xmlPushBegin("Contrast"); - f.xmlPushEnd(); - f.serial(Contrast); - f.xmlPop(); - - f.xmlPushBegin("Luminosity"); - f.xmlPushEnd(); - f.serial(Luminosity); - f.xmlPop(); - - f.xmlPushBegin("Gamma"); - f.xmlPushEnd(); - f.serial(Gamma); - f.xmlPop(); - // Close the serial for hte Client CFG. f.xmlPop(); }// serial // @@ -412,52 +260,13 @@ void CClientConfig::init(const std::string &configFileName) //----------------------------------------------- -// init : +// release : //----------------------------------------------- void CClientConfig::release () { // Do we have to save the cfg file ? if (AppCfg.SaveConfig) { - // Are we in window mode ? - if (AppCfg.Windowed) - { -/* // Driver still alive ? - if (Driver && Driver->isActive ()) - { -#ifdef NL_OS_WINDOWS - HWND hWnd = (HWND)Driver->getDisplay (); - - // Get the window position - RECT window; - RECT client; - GetWindowRect (hWnd, &window); - GetClientRect (hWnd, &client); - - // Save values - try - { - CConfigFile::CVar *varPtr = AppCfg.ConfigFile.getVarPtr ("PositionX"); - if (varPtr) - varPtr->setAsInt (window.left); - varPtr = AppCfg.ConfigFile.getVarPtr ("PositionY"); - if (varPtr) - varPtr->setAsInt (window.top); - varPtr = AppCfg.ConfigFile.getVarPtr ("Width"); - if (varPtr) - varPtr->setAsInt (client.right - client.left); - varPtr = AppCfg.ConfigFile.getVarPtr ("Height"); - if (varPtr) - varPtr->setAsInt (client.bottom - client.top); - } - catch (Exception &e) - { - nlwarning ("Error while set config file variables : %s", e.what ()); - } -#endif // NL_OS_WINDOWS - } -*/ } - // Save it AppCfg.ConfigFile.save (); } diff --git a/code/ryzom/tools/sheets_packer/sheets_packer_cfg.h b/code/ryzom/tools/sheets_packer/sheets_packer_cfg.h index 308e7b1a2..169693af4 100644 --- a/code/ryzom/tools/sheets_packer/sheets_packer_cfg.h +++ b/code/ryzom/tools/sheets_packer/sheets_packer_cfg.h @@ -43,29 +43,7 @@ struct CClientConfig /// Save the cfg file when exit the client ? bool SaveConfig; - /// Window position in windowed mode - sint PositionX; - sint PositionY; - - /// Window frequency - uint Frequency; - /// Application start in a window or in fullscreen. - bool Windowed; - /// Width for the Application. - uint16 Width; - /// Height for the Application. - uint16 Height; - /// Bit Per Pixel (only used in Fullscreen mode). - uint16 Depth; - /// Monitor Constrast [-1 ~ 1], default 0 - float Contrast; - /// Monitor Luminosity [-1 ~ 1], default 0 - float Luminosity; - /// Monitor Gamma [-1 ~ 1], default 0 - float Gamma; - /// Pre Data Path. - std::vector PreDataPath; /// Data Path. std::vector DataPath; /// True if we want the packed sheet to be updated if needed diff --git a/code/ryzom/tools/sheets_packer/sheets_packer_init.cpp b/code/ryzom/tools/sheets_packer/sheets_packer_init.cpp index c43ae9475..906e86e7d 100644 --- a/code/ryzom/tools/sheets_packer/sheets_packer_init.cpp +++ b/code/ryzom/tools/sheets_packer/sheets_packer_init.cpp @@ -81,26 +81,6 @@ bool init() nlinfo("Loading config file..."); AppCfg.init(ConfigFileName); - -/* - // Create the driver (most important part of the client). - nlinfo("Creating 3d driver..."); - Driver = UDriver::createDriver (); - if(Driver == 0) - { - nlerror("sheets_packer_init: Cannot create a Driver."); - return false; - } - - UDriver::CMode mode; - mode.Windowed = AppCfg.Windowed; - mode.Depth = AppCfg.Depth; - mode.Width = AppCfg.Width; - mode.Height = AppCfg.Height; - - // Set the mode of the window. - Driver->setDisplay(mode); -*/ // Define the root path that contains all data needed for the application. nlinfo("Adding search paths..."); for(uint i = 0; i < AppCfg.DataPath.size(); i++) diff --git a/code/ryzom/tools/sheets_packer/sheets_packer_release.cpp b/code/ryzom/tools/sheets_packer/sheets_packer_release.cpp index 4adffa25a..1f08c1cc4 100644 --- a/code/ryzom/tools/sheets_packer/sheets_packer_release.cpp +++ b/code/ryzom/tools/sheets_packer/sheets_packer_release.cpp @@ -21,27 +21,17 @@ // INCLUDE // ///////////// #include "stdpch.h" -// Misc. -#include "nel/misc/debug.h" -// 3D Interface. -//#include "nel/3d/u_driver.h" -// Client #include "sheets_packer_release.h" +#include "nel/misc/debug.h" + /////////// // USING // /////////// -//using namespace NL3D; using namespace NLMISC; -//////////// -// EXTERN // -//////////// -//extern UDriver *Driver; - - /////////////// // FUNCTIONS // /////////////// @@ -51,20 +41,9 @@ using namespace NLMISC; //--------------------------------------------------- void release() { - // Delete the driver. -/* if(Driver) - { - // Release Scene, textcontexts, materials, ... - Driver->release(); - - // Delete the driver. - delete Driver; - Driver = 0; - } -*/ - DebugLog->removeDisplayer ("CLIENT.LOG"); - InfoLog->removeDisplayer ("CLIENT.LOG"); - WarningLog->removeDisplayer ("CLIENT.LOG"); - ErrorLog->removeDisplayer ("CLIENT.LOG"); - AssertLog->removeDisplayer ("CLIENT.LOG"); + DebugLog->removeDisplayer ("SHEETS_PACKER.LOG"); + InfoLog->removeDisplayer ("SHEETS_PACKER.LOG"); + WarningLog->removeDisplayer ("SHEETS_PACKER.LOG"); + ErrorLog->removeDisplayer ("SHEETS_PACKER.LOG"); + AssertLog->removeDisplayer ("SHEETS_PACKER.LOG"); }// release //