summaryrefslogtreecommitdiffstats
path: root/src/demos
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos')
-rw-r--r--src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java55
-rw-r--r--src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java63
-rw-r--r--src/demos/vertexArrayRange/VertexArrayRange.java44
-rw-r--r--src/demos/vertexProgRefract/VertexProgRefract.java12
-rw-r--r--src/demos/vertexProgWarp/VertexProgWarp.java11
5 files changed, 111 insertions, 74 deletions
diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
index 5eb5614..e917ca2 100644
--- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
+++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
@@ -40,6 +40,7 @@ import java.io.*;
import java.nio.*;
import java.util.*;
import javax.imageio.*;
+import javax.swing.*;
import net.java.games.jogl.*;
import net.java.games.jogl.util.*;
@@ -158,34 +159,36 @@ public class HWShadowmapsSimple {
}
});
- while (!quit) {
- if (viewer != null) {
- viewer.update();
-
- // Grab these values once per render to avoid multithreading
- // issues with their values being changed by manipulation from
- // the AWT thread during the render
- CameraParameters params = viewer.getCameraParameters();
-
- cameraPerspective.set(params.getProjectionMatrix());
- cameraInverseTransform.set(params.getModelviewMatrix());
- cameraTransform.set(cameraInverseTransform);
- cameraTransform.invertRigid();
- spotlightTransform.set(spotlight.getTransform());
- spotlightInverseTransform.set(spotlightTransform);
- spotlightInverseTransform.invertRigid();
- objectTransform.set(object.getTransform());
- }
+ try {
+ while (!quit) {
+ if (viewer != null) {
+ viewer.update();
+
+ // Grab these values once per render to avoid multithreading
+ // issues with their values being changed by manipulation from
+ // the AWT thread during the render
+ CameraParameters params = viewer.getCameraParameters();
+
+ cameraPerspective.set(params.getProjectionMatrix());
+ cameraInverseTransform.set(params.getModelviewMatrix());
+ cameraTransform.set(cameraInverseTransform);
+ cameraTransform.invertRigid();
+ spotlightTransform.set(spotlight.getTransform());
+ spotlightInverseTransform.set(spotlightTransform);
+ spotlightInverseTransform.invertRigid();
+ objectTransform.set(object.getTransform());
+ }
- if (displayMode == RENDER_SCENE_FROM_CAMERA_VIEW_SHADOWED || !fullyInitialized) {
- if (pbuffer != null) {
- pbuffer.display();
+ if (displayMode == RENDER_SCENE_FROM_CAMERA_VIEW_SHADOWED || !fullyInitialized) {
+ if (pbuffer != null) {
+ pbuffer.display();
+ }
}
+ canvas.display();
}
- canvas.display();
+ } finally {
+ System.exit(0);
}
-
- System.exit(0);
}
//----------------------------------------------------------------------
@@ -372,7 +375,9 @@ public class HWShadowmapsSimple {
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);
}
}
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);
}
}
diff --git a/src/demos/vertexArrayRange/VertexArrayRange.java b/src/demos/vertexArrayRange/VertexArrayRange.java
index 18bf196..825c668 100644
--- a/src/demos/vertexArrayRange/VertexArrayRange.java
+++ b/src/demos/vertexArrayRange/VertexArrayRange.java
@@ -37,6 +37,7 @@ import java.awt.*;
import java.awt.event.*;
import java.nio.*;
import java.util.*;
+import javax.swing.*;
import net.java.games.jogl.*;
@@ -257,7 +258,14 @@ public class VertexArrayRange {
private void ensurePresent(String function) {
if (!canvas.getGL().isFunctionAvailable(function)) {
- throw new RuntimeException("OpenGL routine \"" + function + "\" not available");
+ final String message = "OpenGL routine \"" + function + "\" not available";
+ new Thread(new Runnable() {
+ public void run() {
+ JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE);
+ runExit();
+ }
+ }).start();
+ throw new RuntimeException(message);
}
}
@@ -285,7 +293,7 @@ public class VertexArrayRange {
ensurePresent("glFinishFenceNV");
ensurePresent("glAllocateMemoryNV");
} catch (RuntimeException e) {
- runExit();
+ quit = true;
throw (e);
}
@@ -647,22 +655,6 @@ public class VertexArrayRange {
// Unused routines
public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
-
- private void runExit() {
- quit = true;
- // Note: calling System.exit() synchronously inside the draw,
- // reshape or init callbacks can lead to deadlocks on certain
- // platforms (in particular, X11) because the JAWT's locking
- // routines cause a global AWT lock to be grabbed. Run the
- // exit routine in another thread and cause this one to
- // terminate by throwing an exception out of it.
- new Thread(new Runnable() {
- public void run() {
- animator.stop();
- System.exit(0);
- }
- }).start();
- }
} // end class VARListener
private void allocateBigArray(GL gl, boolean tryAgain) {
@@ -726,4 +718,20 @@ public class VertexArrayRange {
}
}
}
+
+ private void runExit() {
+ quit = true;
+ // Note: calling System.exit() synchronously inside the draw,
+ // reshape or init callbacks can lead to deadlocks on certain
+ // platforms (in particular, X11) because the JAWT's locking
+ // routines cause a global AWT lock to be grabbed. Run the
+ // exit routine in another thread and cause this one to
+ // terminate by throwing an exception out of it.
+ new Thread(new Runnable() {
+ public void run() {
+ animator.stop();
+ System.exit(0);
+ }
+ }).start();
+ }
}
diff --git a/src/demos/vertexProgRefract/VertexProgRefract.java b/src/demos/vertexProgRefract/VertexProgRefract.java
index 34ed174..c14f204 100644
--- a/src/demos/vertexProgRefract/VertexProgRefract.java
+++ b/src/demos/vertexProgRefract/VertexProgRefract.java
@@ -41,6 +41,7 @@ import java.nio.*;
import java.util.*;
import javax.imageio.*;
import javax.imageio.stream.*;
+import javax.swing.*;
import net.java.games.jogl.*;
import net.java.games.jogl.util.*;
@@ -229,7 +230,7 @@ public class VertexProgRefract {
initExtension(gl, "GL_NV_register_combiners");
initExtension(gl, "GL_ARB_multitexture");
} catch (RuntimeException e) {
- runExit();
+ quit = true;
throw(e);
}
@@ -510,7 +511,14 @@ public class VertexProgRefract {
private void initExtension(GL gl, String glExtensionName) {
if (!gl.isExtensionAvailable(glExtensionName)) {
- throw new RuntimeException("OpenGL extension \"" + glExtensionName + "\" not available");
+ final String message = "OpenGL extension \"" + glExtensionName + "\" not available";
+ new Thread(new Runnable() {
+ public void run() {
+ JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE);
+ runExit();
+ }
+ }).start();
+ throw new RuntimeException(message);
}
}
diff --git a/src/demos/vertexProgWarp/VertexProgWarp.java b/src/demos/vertexProgWarp/VertexProgWarp.java
index 6a6a592..c4a88bb 100644
--- a/src/demos/vertexProgWarp/VertexProgWarp.java
+++ b/src/demos/vertexProgWarp/VertexProgWarp.java
@@ -131,7 +131,7 @@ public class VertexProgWarp {
try {
initExtension(gl, "GL_ARB_vertex_program");
} catch (RuntimeException e) {
- runExit();
+ quit = true;
throw(e);
}
@@ -268,7 +268,14 @@ public class VertexProgWarp {
//
private void initExtension(GL gl, String glExtensionName) {
if (!gl.isExtensionAvailable(glExtensionName)) {
- throw new RuntimeException("OpenGL extension \"" + glExtensionName + "\" not available");
+ final String message = "OpenGL extension \"" + glExtensionName + "\" not available";
+ new Thread(new Runnable() {
+ public void run() {
+ JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE);
+ runExit();
+ }
+ }).start();
+ throw new RuntimeException(message);
}
}