From f50f40e0fb2789537ecc19f8eaff439b24294a65 Mon Sep 17 00:00:00 2001 From: Wade Walker Date: Tue, 12 Apr 2011 08:57:06 -0500 Subject: Fix problem with external context on CentOS 5.5 inside VMWare This fixes a problem that's analogous to one we've had on Windows; apparently querying OS-specific info like hardware device contexts or framebuffer configuration IDs from external GL contexts doesn't always work properly, especially on 32-bit OSes and from within virtual machines. --- .../jogamp/opengl/x11/glx/X11ExternalGLXContext.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/jogl/classes/jogamp/opengl/x11/glx') diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index c488fe5cf..39032117c 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -75,7 +75,21 @@ public class X11ExternalGLXContext extends X11GLXContext { X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0]); GLX.glXQueryContext(display, ctx, GLX.GLX_FBCONFIG_ID, val, 0); - X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); + X11GLXGraphicsConfiguration cfg = null; + // sometimes glXQueryContext on an external context gives us a framebuffer config ID + // of 0, which doesn't work in a subsequent call to glXChooseFBConfig; if this happens, + // create and use a default config (this has been observed when running on CentOS 5.5 inside + // of VMWare Server 2.0 with the Mesa 6.5.1 drivers) + if( 0 == X11GLXGraphicsConfiguration.glXFBConfigID2FBConfig(display, x11Screen.getIndex(), val[0]) ) { + GLCapabilities glcapsDefault = new GLCapabilities(GLProfile.getDefault()); + cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(glcapsDefault, glcapsDefault, null, x11Screen); + if(DEBUG) { + System.err.println("X11ExternalGLXContext invalid FBCONFIG_ID "+val[0]+", using default cfg: " + cfg); + } + } + else { + cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); + } WrappedSurface ns = new WrappedSurface(cfg); ns.setSurfaceHandle(drawable); -- cgit v1.2.3