From e53e8311425efd34c9e67dd2404886892ea03910 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 13 Apr 2011 15:16:17 +0000 Subject: [PATCH] fix crash on glx implementations that don't support FBConfig --- .../glxdisplay/glxGraphicsStateGuardian.cxx | 26 ++++++++----------- panda/src/glxdisplay/glxGraphicsWindow.cxx | 7 +++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 081625d4b8..8a86113d40 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -266,24 +266,20 @@ choose_pixel_format(const FrameBufferProperties &properties, if (!_supports_fbconfig) { // We have a good OpenGL context, but it doesn't support the // FBConfig interface, so we'll stop there. - if (glxdisplay_cat.is_debug()) { - glxdisplay_cat.debug() - <<" No FBConfig supported; using XVisual only.\n"; + glxdisplay_cat.debug() + <<" No FBConfig supported; using XVisual only.\n" + << _fbprops << "\n"; - glxdisplay_cat.debug() - << _fbprops << "\n"; + _context = _temp_context; + _temp_context = (GLXContext)NULL; - _context = _temp_context; - _temp_context = (GLXContext)NULL; + // By convention, every indirect XVisual that can render to a + // window can also render to a GLXPixmap. Direct visuals we're + // not as sure about. + _context_has_pixmap = !glXIsDirect(_display, _context); - // By convention, every indirect XVisual that can render to a - // window can also render to a GLXPixmap. Direct visuals we're - // not as sure about. - _context_has_pixmap = !glXIsDirect(_display, _context); - - // Pbuffers aren't supported at all with the XVisual interface. - _context_has_pbuffer = false; - } + // Pbuffers aren't supported at all with the XVisual interface. + _context_has_pbuffer = false; return; } diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 79c7e48e8d..3614cdef2f 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -179,6 +179,13 @@ open_window() { } } + if (glxgsg->_context == NULL) { + // We're supposed to have a context at this point. + glxdisplay_cat.error() + << "No GLX context: cannot open window.\n"; + return false; + } + _visual_info = glxgsg->_visual; if (_visual_info == NULL) { // No X visual for this fbconfig; how can we open the window?