From beaca5fa8a64e8b7c5e9452fa9828eb9a217bd2e Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Tue, 15 Jul 2003 22:32:06 +0000 Subject: Fixed bug in Animator where it would hang upon stopping if exception was thrown during init(). Fixed build.xml files to get javac to produce source file and line number information. Fixed demos to pop up a dialog box if an extension they need is unsupported. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@12 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4 --- .../ProceduralTexturePhysics.java | 63 ++++++++++++---------- 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'src/demos/proceduralTexturePhysics') diff --git a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java index a27ae05..f34940c 100644 --- a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java +++ b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java @@ -35,6 +35,7 @@ package demos.proceduralTexturePhysics; import java.awt.*; import java.awt.event.*; +import javax.swing.*; import net.java.games.jogl.*; import demos.util.*; @@ -98,37 +99,43 @@ public class ProceduralTexturePhysics { } }); - water = new Water(); - water.initialize("demos/data/images/nvfixed.tga", - "demos/data/images/nvspin.tga", - "demos/data/images/droplet.tga", - "demos/data/cubemaps/CloudyHills_{0}.tga", - canvas); - - while (!quit) { - if (viewer != null) { - try { - if (drawing) { - canvas.getSize(dim); - water.addDroplet(new Water.Droplet( 2 * (mousePosX / (float) dim.width - 0.5f), - -2 * (mousePosY / (float) dim.height - 0.5f), - 0.08f)); + try { + water = new Water(); + water.initialize("demos/data/images/nvfixed.tga", + "demos/data/images/nvspin.tga", + "demos/data/images/droplet.tga", + "demos/data/cubemaps/CloudyHills_{0}.tga", + canvas); + } catch (GLException e) { + JOptionPane.showMessageDialog(null, e.toString(), "Unavailable extension", JOptionPane.ERROR_MESSAGE); + } + + try { + while (!quit) { + if (viewer != null) { + try { + if (drawing) { + canvas.getSize(dim); + water.addDroplet(new Water.Droplet( 2 * (mousePosX / (float) dim.width - 0.5f), + -2 * (mousePosY / (float) dim.height - 0.5f), + 0.08f)); + } + water.tick(); + canvas.display(); + } catch (GLException e) { + // Have seen spurious exceptions getting thrown during SwapBuffers. + // Not sure why at this time; disabling of repaint() should prevent + // AWT thread from getting involved. Continue animating anyway. + e.printStackTrace(); } - water.tick(); + } else { + // Make the pbuffer get created canvas.display(); - } catch (GLException e) { - // Have seen spurious exceptions getting thrown during SwapBuffers. - // Not sure why at this time; disabling of repaint() should prevent - // AWT thread from getting involved. Continue animating anyway. - e.printStackTrace(); } - } else { - // Make the pbuffer get created - canvas.display(); } + } finally { + System.exit(0); } - - System.exit(0); } //---------------------------------------------------------------------- @@ -263,7 +270,9 @@ public class ProceduralTexturePhysics { private void checkExtension(GL gl, String extensionName) { if (!gl.isExtensionAvailable(extensionName)) { - throw new GLException("Unable to initialize " + extensionName + " OpenGL extension"); + String message = "Unable to initialize " + extensionName + " OpenGL extension"; + JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE); + throw new GLException(message); } } -- cgit v1.2.3