diff options
author | Kenneth Russel <[email protected]> | 2004-04-26 02:22:20 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2004-04-26 02:22:20 +0000 |
commit | d0f8de4a9412c6049445adea21592065e212d1c9 (patch) | |
tree | 8ecb9b926eaac4ad72c05480b72b6eb64948e9f9 /src/net/java/games/jogl/impl | |
parent | 0268b8b446fcff93971c1d0dd3b188b3cb5436d9 (diff) |
Fixed Issue 76: Multisampling (FSAA) does not work on ATI
Applied patch from Yuri Vl. Gushchin to fetch extensions while dummy
context is current.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@123 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl')
-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); } } |