From 6a78fc23a51299e45a791f0f8b670334985d37de Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 12 Jun 2010 23:01:46 +0200 Subject: [PATCH] Fixed: #981 Create createWindow and destroyWindow private methods in OpenGL driver --- code/nel/src/3d/driver/opengl/driver_opengl.cpp | 5 ++++- code/nel/src/3d/driver/opengl/driver_opengl.h | 3 ++- .../src/3d/driver/opengl/driver_opengl_window.cpp | 13 +++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index 915950053..e3b5b39a6 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -206,17 +206,20 @@ CDriverGL::CDriverGL() NL3D::MAC::ctor(); #elif defined (NL_OS_UNIX) + _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; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index 39eb70dfc..e8001014c 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -664,6 +664,7 @@ private: sint32 _WindowWidth, _WindowHeight, _WindowX, _WindowY; nlWindow _win; + bool _DestroyWindow; #ifdef NL_OS_WINDOWS @@ -675,7 +676,6 @@ private: 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; @@ -689,6 +689,7 @@ private: GLXContext _ctx; Cursor _cursor; NLMISC::CUnixEventEmitter _EventEmitter; + XVisualInfo* _visual_info; #ifdef XF86VIDMODE int _OldDotClock; // old dotclock 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 ca5978e59..a863a898b 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -674,7 +674,9 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re nlerror("glXCreateContext() failed"); } - if (wnd != EmptyWindow) + _visual_info = visual_info; + + if (wnd == EmptyWindow) { if (!createWindow(mode)) return false; @@ -929,6 +931,9 @@ bool CDriverGL::createWindow(const GfxMode &mode) #elif defined (NL_OS_UNIX) + if (_visual_info == NULL) + return false; + XSetWindowAttributes attr; attr.background_pixel = BlackPixel(_dpy, DefaultScreen(_dpy)); @@ -952,10 +957,10 @@ bool CDriverGL::createWindow(const GfxMode &mode) nlWindow root = RootWindow(_dpy, DefaultScreen(_dpy)); - attr.colormap = XCreateColormap(_dpy, root, visual_info->visual, AllocNone); + 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); + window = XCreateWindow (_dpy, root, 0, 0, mode.Width, mode.Height, 0, _visual_info->depth, InputOutput, _visual_info->visual, attr_flags, &attr); if (window == EmptyWindow) { @@ -1595,7 +1600,7 @@ void CDriverGL::getWindowPos(uint32 &x, uint32 &y) unsigned int depth = 0; // Get geometry information about root window - if (!XGetGeometry(_dpy, RootWindow(_dpy, screen), &_win, &xtmp, &ytmp, &width, &height, &border_width, &depth)) + if (!XGetGeometry(_dpy, RootWindow(_dpy, screen), (Window*)&_win, &xtmp, &ytmp, &width, &height, &border_width, &depth)) { nlwarning("can't get root window geometry"); }