diff options
Diffstat (limited to 'src/net/java/games/jogl')
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsGLContext.java | 12 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java | 37 |
2 files changed, 28 insertions, 21 deletions
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index 5d53b21d8..45bd7f21d 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -267,17 +267,7 @@ public abstract class WindowsGLContext extends GLContext { boolean haveWGLChoosePixelFormatARB = false; boolean haveWGLARBMultisample = false; if (dummyGL != null) { - // It seems that at this point in initialization, - // glGetString(GL.GL_EXTENSIONS) is returning null, so we - // need to use wglGetExtensionsStringARB - String availableWGLExtensions = ""; - // FIXME: would like to do this operation without throwing an - // exception if wglGetExtensionsStringARB isn't available - try { - availableWGLExtensions = dummyGL.wglGetExtensionsStringARB(hdc); - } catch (GLException e) { - // Apparently wglGetExtensionsStringARB wasn't available; ignore - } + String availableWGLExtensions = WindowsGLContextFactory.getDummyGLExtensions(device); if (availableWGLExtensions.indexOf("WGL_ARB_pixel_format") >= 0) { haveWGLChoosePixelFormatARB = true; if (availableWGLExtensions.indexOf("WGL_ARB_multisample") >= 0) { diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java index 35369e06b..03fe03929 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContextFactory.java @@ -59,12 +59,13 @@ public class WindowsGLContextFactory extends GLContextFactory { // created. The standard way of working around this chicken-and-egg // problem is to create a dummy window, show it, send it a paint // message, create an OpenGL context, fetch the needed function - // pointers, and then destroy the dummy window and context. In JOGL - // since we closely associate the contexts with components we leave - // the dummy window around as it should not have a large footprint - // impact. - private static Map/*<GraphicsDevice, GL>*/ dummyContextMap = new HashMap(); - private static Set/*<GraphicsDevice >*/ pendingContextSet = new HashSet(); + // pointers, and then destroy the dummy window and context. It turns + // out that ATI cards need the dummy context to be current while + // wglChoosePixelFormatARB is called, so we cache the extension + // strings the dummy context reports as being available. + private static Map/*<GraphicsDevice, GL>*/ dummyContextMap = new HashMap(); + private static Map/*<GraphicsDevice, String>*/ dummyExtensionsMap = new HashMap(); + private static Set/*<GraphicsDevice >*/ pendingContextSet = new HashSet(); public GraphicsConfiguration chooseGraphicsConfiguration(GLCapabilities capabilities, GLCapabilitiesChooser chooser, @@ -83,6 +84,11 @@ public class WindowsGLContextFactory extends GLContextFactory { } } + public static String getDummyGLExtensions(final GraphicsDevice device) { + String exts = (String) dummyExtensionsMap.get(device); + return (exts == null) ? "" : exts; + } + public static GL getDummyGLContext(final GraphicsDevice device) { GL gl = (GL) dummyContextMap.get(device); if (gl != null) { @@ -102,19 +108,30 @@ public class WindowsGLContextFactory extends GLContextFactory { public void init(GLDrawable drawable) { pendingContextSet.remove(device); dummyContextMap.put(device, drawable.getGL()); + String availableGLExtensions = ""; + String availableWGLExtensions = ""; + String availableEXTExtensions = ""; + try { + availableWGLExtensions = drawable.getGL().wglGetExtensionsStringARB(WGL.wglGetCurrentDC()); + } catch (GLException e) {} + try { + availableEXTExtensions = drawable.getGL().wglGetExtensionsStringEXT(); + } catch (GLException e) {} + availableGLExtensions = drawable.getGL().glGetString(GL.GL_EXTENSIONS); + dummyExtensionsMap.put(device, availableGLExtensions + " " + availableEXTExtensions + " " + availableWGLExtensions); EventQueue.invokeLater(new Runnable() { public void run() { frame.dispose(); } }); } - + public void display(GLDrawable drawable) { } - + public void reshape(GLDrawable drawable, int x, int y, int width, int height) { } - + public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) { } }); @@ -124,7 +141,7 @@ public class WindowsGLContextFactory extends GLContextFactory { frame.show(); canvas.display(); } - + return (GL) dummyContextMap.get(device); } } |