From: solomin_s Date: Wed, 6 May 2015 14:05:39 +0000 (+0300) Subject: 0026128: Visualization, TKOpenGl - fix misprint in external GLX context initialization X-Git-Tag: V6_9_0~24 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=95db72f1f6eb05a6cf4b4b6d84dd892e3a107781;p=occt-copy.git 0026128: Visualization, TKOpenGl - fix misprint in external GLX context initialization OpenGl_Window, GLX - push warning about missing caps in window Visual. Allow initialization of alien GLX context. Correction of misprinting --- diff --git a/src/OpenGl/OpenGl_Window.cxx b/src/OpenGl/OpenGl_Window.cxx index 5fedea6e84..57c8872b3b 100644 --- a/src/OpenGl/OpenGl_Window.cxx +++ b/src/OpenGl/OpenGl_Window.cxx @@ -459,53 +459,104 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver, aVis = XGetVisualInfo (aDisp, aVisInfoMask, &aVisInfo, &aNbItems); } - if (!myOwnGContext) +#if defined(__linux) || defined(Linux) || defined(__APPLE__) + if (aVis != NULL) { - if (aVis != NULL) - { - Aspect_GraphicDeviceDefinitionError::Raise ("OpenGl_Window::CreateWindow: XGetVisualInfo failed."); - return; - } + // check Visual for OpenGl context's parameters compatibility + int isGl = 0, isDoubleBuffer = 0, isRGBA = 0, isStereo = 0; + int aDepthSize = 0, aStencilSize = 0; - aWindow = aParent; - } - else - { - #if defined(__linux) || defined(Linux) || defined(__APPLE__) - if (aVis != NULL) - { - // check Visual for OpenGl context's parameters compatibility - int isGl = 0, isDoubleBuffer = 0, isRGBA = 0, isStereo = 0; - int aDepthSize = 0, aStencilSize = 0; - - if (glXGetConfig (aDisp, aVis, GLX_USE_GL, &isGl) != 0) - isGl = 0; + if (glXGetConfig (aDisp, aVis, GLX_USE_GL, &isGl) != 0) + isGl = 0; - if (glXGetConfig (aDisp, aVis, GLX_RGBA, &isRGBA) != 0) - isRGBA = 0; + if (glXGetConfig (aDisp, aVis, GLX_RGBA, &isRGBA) != 0) + isRGBA = 0; - if (glXGetConfig (aDisp, aVis, GLX_DOUBLEBUFFER, &isDoubleBuffer) != 0) - isDoubleBuffer = 0; + if (glXGetConfig (aDisp, aVis, GLX_DOUBLEBUFFER, &isDoubleBuffer) != 0) + isDoubleBuffer = 0; - if (glXGetConfig (aDisp, aVis, GLX_STEREO, &isStereo) != 0) - isStereo = 0; + if (glXGetConfig (aDisp, aVis, GLX_STEREO, &isStereo) != 0) + isStereo = 0; - if (glXGetConfig (aDisp, aVis, GLX_DEPTH_SIZE, &aDepthSize) != 0) - aDepthSize = 0; + if (glXGetConfig (aDisp, aVis, GLX_DEPTH_SIZE, &aDepthSize) != 0) + aDepthSize = 0; - if (glXGetConfig (aDisp, aVis, GLX_STENCIL_SIZE, &aStencilSize) != 0) - aStencilSize = 0; + if (glXGetConfig (aDisp, aVis, GLX_STENCIL_SIZE, &aStencilSize) != 0) + aStencilSize = 0; - if (!isGl || !aDepthSize || !isRGBA || !aStencilSize || - (isDoubleBuffer ? 1 : 0) != 1 || - (isStereo ? 1 : 0) != (theCaps->contextStereo ? 1 : 0)) + if (!isGl) + { + XFree (aVis); + aVis = NULL; + if (myOwnGContext) + { + TCollection_ExtendedString aMsg ("OpenGl_Window::CreateWindow: window Visual does not support GL rendering!"); + myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, + GL_DEBUG_TYPE_OTHER_ARB, + 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMsg); + } + } + else + { + TCollection_ExtendedString aList; + if (aDepthSize < 1) + { + if (!aList.IsEmpty()) aList += ", "; + aList += "no depth buffer"; + } + if (aStencilSize < 1) + { + if (!aList.IsEmpty()) aList += ", "; + aList += "no stencil buffer"; + } + if (isRGBA == 0) + { + if (!aList.IsEmpty()) aList += ", "; + aList += "no RGBA color buffer"; + } + if (isDoubleBuffer == 0) + { + if (!aList.IsEmpty()) aList += ", "; + aList += "no Double Buffer"; + } + if (theCaps->contextStereo && isStereo == 0) + { + if (!aList.IsEmpty()) aList += ", "; + aList += "no Quad Buffer"; + } + if (!theCaps->contextStereo && isStereo == 1) { - XFree (aVis); - aVis = NULL; + if (!aList.IsEmpty()) aList += ", "; + aList += "extra Quad Buffer"; } + if (!aList.IsEmpty()) + { + TCollection_ExtendedString aMsg = TCollection_ExtendedString ("OpenGl_Window::CreateWindow: window Visual is incomplete: ") + aList; + if (myOwnGContext) + { + XFree (aVis); + aVis = NULL; + } + myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, + GL_DEBUG_TYPE_OTHER_ARB, + 0, GL_DEBUG_SEVERITY_MEDIUM_ARB, aMsg); + } + } + } +#endif + + if (!myOwnGContext) + { + if (aVis == NULL) + { + Aspect_GraphicDeviceDefinitionError::Raise ("OpenGl_Window::CreateWindow: XGetVisualInfo is unable to choose needed configuration in existing OpenGL context. "); + return; } - #endif + aWindow = aParent; + } + else + { if (aVis == NULL) { int anIter = 0; @@ -557,6 +608,13 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver, Aspect_GraphicDeviceDefinitionError::Raise ("OpenGl_Window::CreateWindow: glXChooseVisual failed."); return; } + else + { + TCollection_ExtendedString aMsg ("OpenGl_Window::CreateWindow: child window has been created with better Visual."); + myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, + GL_DEBUG_TYPE_OTHER_ARB, + 0, GL_DEBUG_SEVERITY_MEDIUM_ARB, aMsg); + } } if (!theShareCtx.IsNull())