diff options
-rwxr-xr-x | src/demos/hdr/HDR.java | 13 | ||||
-rw-r--r-- | src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java | 10 | ||||
-rwxr-xr-x | src/demos/jrefract/JRefract.java | 1 | ||||
-rw-r--r-- | src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java | 12 | ||||
-rw-r--r-- | src/demos/proceduralTexturePhysics/Water.java | 2 | ||||
-rw-r--r-- | src/demos/testContextSharing/TestContextSharing.java | 2 | ||||
-rw-r--r-- | src/demos/vertexProgRefract/VertexProgRefract.java | 1 | ||||
-rw-r--r-- | src/demos/vertexProgWarp/VertexProgWarp.java | 1 | ||||
-rw-r--r-- | src/gleem/ExaminerViewer.java | 35 | ||||
-rw-r--r-- | src/gleem/ManipManager.java | 38 | ||||
-rw-r--r-- | src/gleem/WindowUpdateListener.java | 4 |
11 files changed, 72 insertions, 47 deletions
diff --git a/src/demos/hdr/HDR.java b/src/demos/hdr/HDR.java index db79bd6..3bf1b49 100755 --- a/src/demos/hdr/HDR.java +++ b/src/demos/hdr/HDR.java @@ -282,6 +282,7 @@ public class HDR { manager.registerWindow(drawable); viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); + viewer.setAutoRedrawMode(false); viewer.setNoAltKeyMode(true); viewer.attach(drawable, new BSphereProvider() { public BSphere getBoundingSphere() { @@ -324,6 +325,12 @@ public class HDR { pbuffer.display(); + // FIXME: because of changes in lazy pbuffer instantiation + // behavior the pbuffer might not have been run just now + if (pipeline == null) { + return; + } + // blur pass if (b['g']) { // shrink image @@ -502,7 +509,7 @@ public class HDR { class PbufferListener implements GLEventListener { public void init(GLAutoDrawable drawable) { - // printThreadName("init for PbufferListener"); + printThreadName("init for PbufferListener"); // drawable.setGL(new DebugGL(drawable.getGL())); @@ -693,7 +700,7 @@ public class HDR { class BlurPbufferListener implements GLEventListener { public void init(GLAutoDrawable drawable) { - // printThreadName("init for BlurPbufferListener"); + printThreadName("init for BlurPbufferListener"); // drawable.setGL(new DebugGL(drawable.getGL())); @@ -726,7 +733,7 @@ public class HDR { class Blur2PbufferListener implements GLEventListener { public void init(GLAutoDrawable drawable) { - // printThreadName("init for Blur2PbufferListener"); + printThreadName("init for Blur2PbufferListener"); // drawable.setGL(new DebugGL(drawable.getGL())); diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java index 74f4355..cd70062 100644 --- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java +++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java @@ -303,6 +303,8 @@ public class HWShadowmapsSimple { } if (!fullyInitialized) { + // Repaint again later once everything is set up + canvas.repaint(); return; } @@ -564,7 +566,7 @@ public class HWShadowmapsSimple { gl.glMatrixMode(GL.GL_MODELVIEW); } - private void render_scene(GL gl, Mat4f view, GLDrawable drawable, CameraParameters params) { + private void render_scene(GL gl, Mat4f view, GLAutoDrawable drawable, CameraParameters params) { gl.glColor3f(1,1,1); gl.glPushMatrix(); Mat4f inverseView = new Mat4f(view); @@ -585,7 +587,7 @@ public class HWShadowmapsSimple { gl.glPopMatrix(); } - private void render_manipulators(GL gl, Mat4f view, GLDrawable drawable, CameraParameters params) { + private void render_manipulators(GL gl, Mat4f view, GLAutoDrawable drawable, CameraParameters params) { gl.glColor3f(1,1,1); gl.glPushMatrix(); Mat4f inverseView = new Mat4f(view); @@ -600,7 +602,7 @@ public class HWShadowmapsSimple { gl.glPopMatrix(); } - private void render_scene_from_camera_view(GL gl, GLU glu, GLDrawable drawable, CameraParameters params) { + private void render_scene_from_camera_view(GL gl, GLU glu, GLAutoDrawable drawable, CameraParameters params) { // place light gl.glPushMatrix(); gl.glLoadIdentity(); @@ -647,7 +649,7 @@ public class HWShadowmapsSimple { render_light_frustum(gl); } - private void render_scene_from_camera_view_shadowed(GL gl, GLU glu, GLDrawable drawable, CameraParameters params) { + private void render_scene_from_camera_view_shadowed(GL gl, GLU glu, GLAutoDrawable drawable, CameraParameters params) { // place light gl.glPushMatrix(); gl.glLoadIdentity(); diff --git a/src/demos/jrefract/JRefract.java b/src/demos/jrefract/JRefract.java index 7947a90..09b5095 100755 --- a/src/demos/jrefract/JRefract.java +++ b/src/demos/jrefract/JRefract.java @@ -442,6 +442,7 @@ public class JRefract { viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); viewer.setNoAltKeyMode(true); + viewer.setAutoRedrawMode(false); viewer.attach(drawable, new BSphereProvider() { public BSphere getBoundingSphere() { return new BSphere(new Vec3f(0, 0, 0), 1.0f); diff --git a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java index 7f8d67b..9713b6b 100644 --- a/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java +++ b/src/demos/proceduralTexturePhysics/ProceduralTexturePhysics.java @@ -83,11 +83,6 @@ public class ProceduralTexturePhysics { canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities()); canvas.addGLEventListener(new Listener()); 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); animator = new Animator(canvas); @@ -126,6 +121,12 @@ public class ProceduralTexturePhysics { private float frequencyIncrement = 0.1f; public void init(GLAutoDrawable drawable) { + water.initialize("demos/data/images/nvfixed.tga", + "demos/data/images/nvspin.tga", + "demos/data/images/droplet.tga", + "demos/data/cubemaps/CloudyHills_{0}.tga", + drawable); + GL gl = drawable.getGL(); gl.setSwapInterval(1); @@ -150,6 +151,7 @@ public class ProceduralTexturePhysics { manager.registerWindow(drawable); viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); + viewer.setAutoRedrawMode(false); viewer.attach(drawable, new BSphereProvider() { public BSphere getBoundingSphere() { return new BSphere(new Vec3f(0, 0, 0), 1.2f); diff --git a/src/demos/proceduralTexturePhysics/Water.java b/src/demos/proceduralTexturePhysics/Water.java index 295da6c..46d199a 100644 --- a/src/demos/proceduralTexturePhysics/Water.java +++ b/src/demos/proceduralTexturePhysics/Water.java @@ -186,7 +186,7 @@ public class Water { String spinFilename, String dropletFilename, String cubeMapFilenamePattern, - GLDrawable parentWindow) { + GLAutoDrawable parentWindow) { loadInitialTexture(initialMapFilename); tmpSpinFilename = spinFilename; tmpDropletFilename = dropletFilename; diff --git a/src/demos/testContextSharing/TestContextSharing.java b/src/demos/testContextSharing/TestContextSharing.java index 93801a6..9d23f12 100644 --- a/src/demos/testContextSharing/TestContextSharing.java +++ b/src/demos/testContextSharing/TestContextSharing.java @@ -62,7 +62,7 @@ public class TestContextSharing { frame1.setLayout(new BorderLayout()); frame1.add(canvas1, BorderLayout.CENTER); - GLCanvas canvas2 = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities(), null, canvas1, null); + GLCanvas canvas2 = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities(), null, canvas1.getContext(), null); canvas2.addGLEventListener(new Listener()); canvas2.setSize(256, 256); Frame frame2 = new Frame("Canvas 2"); diff --git a/src/demos/vertexProgRefract/VertexProgRefract.java b/src/demos/vertexProgRefract/VertexProgRefract.java index 1e3a5e1..7bc223f 100644 --- a/src/demos/vertexProgRefract/VertexProgRefract.java +++ b/src/demos/vertexProgRefract/VertexProgRefract.java @@ -315,6 +315,7 @@ public class VertexProgRefract { viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); viewer.setNoAltKeyMode(true); + viewer.setAutoRedrawMode(false); viewer.attach(drawable, new BSphereProvider() { public BSphere getBoundingSphere() { return new BSphere(new Vec3f(0, 0, 0), 1.0f); diff --git a/src/demos/vertexProgWarp/VertexProgWarp.java b/src/demos/vertexProgWarp/VertexProgWarp.java index a95f149..4fbb345 100644 --- a/src/demos/vertexProgWarp/VertexProgWarp.java +++ b/src/demos/vertexProgWarp/VertexProgWarp.java @@ -192,6 +192,7 @@ public class VertexProgWarp { viewer = new ExaminerViewer(MouseButtonHelper.numMouseButtons()); viewer.setNoAltKeyMode(true); + viewer.setAutoRedrawMode(false); viewer.attach(drawable, new BSphereProvider() { public BSphere getBoundingSphere() { return new BSphere(new Vec3f(0, 0, 0), 1.0f); diff --git a/src/gleem/ExaminerViewer.java b/src/gleem/ExaminerViewer.java index e60d4f7..f621ae7 100644 --- a/src/gleem/ExaminerViewer.java +++ b/src/gleem/ExaminerViewer.java @@ -78,6 +78,7 @@ public class ExaminerViewer { private boolean iOwnInteraction; private boolean noAltKeyMode; + private boolean autoRedrawMode; /** Simple state machine for computing distance dragged */ private boolean button1Down; @@ -300,6 +301,20 @@ public class ExaminerViewer { return noAltKeyMode; } + /** Enables or disables the automatic redrawing of the + GLAutoDrawable to which this ExaminerViewer is attached. If the + GLAutoDrawable is already being animated, disabling auto redraw + mode may provide better performance. Defaults to on. */ + public void setAutoRedrawMode(boolean onOrOff) { + autoRedrawMode = onOrOff; + } + + /** Returns whether this ExaminerViewer automatically redraws the + GLAutoDrawable to which it is attached upon updates. */ + public boolean getAutoRedrawMode() { + return autoRedrawMode; + } + /** Rotates this ExaminerViewer about the focal point by the specified incremental rotation; performs postmultiplication, i.e. the incremental rotation is applied after the current @@ -410,12 +425,10 @@ public class ExaminerViewer { } - // Force redraw - // FIXME: this can cause bad behavior (slowdowns, jittery - // rendering) if window is being automatically rendered; should - // have flag to disable auto redraw by the examiner viewer, - // since that API isn't present in the GLDrawable any more - window.display(); + if (autoRedrawMode) { + // Force redraw + window.display(); + } } } @@ -472,12 +485,10 @@ public class ExaminerViewer { iOwnInteraction = false; } - // Force redraw - // FIXME: this can cause bad behavior (slowdowns, jittery - // rendering) if window is being automatically rendered; should - // have flag to disable auto redraw by the examiner viewer, - // since that API isn't present in the GLDrawable any more - window.display(); + if (autoRedrawMode) { + // Force redraw + window.display(); + } } } diff --git a/src/gleem/ManipManager.java b/src/gleem/ManipManager.java index 439d4fa..e29edfe 100644 --- a/src/gleem/ManipManager.java +++ b/src/gleem/ManipManager.java @@ -55,7 +55,7 @@ public class ManipManager { private static ManipManager soleInstance; // Maps GLDrawables to WindowInfos private Map windowToInfoMap = new HashMap(); - // Maps Manips to Set<GLDrawable> + // Maps Manips to Set<GLAutoDrawable> private Map manipToWindowMap = new HashMap(); // MouseAdapter for this @@ -78,7 +78,7 @@ public class ManipManager { } }; private WindowUpdateListener defaultWindowListener = new WindowUpdateListener() { - public void update(GLDrawable window) { + public void update(GLAutoDrawable window) { window.display(); } }; @@ -108,14 +108,14 @@ public class ManipManager { /** Make the ManipManager aware of the existence of a given window. This causes mouse and mouse motion listeners to be installed on this window; see setupMouseListeners, below. */ - public synchronized void registerWindow(GLDrawable window) { + public synchronized void registerWindow(GLAutoDrawable window) { windowToInfoMap.put(window, new WindowInfo()); setupMouseListeners(window); } /** Remove all references to a given window, including removing all manipulators from it. */ - public synchronized void unregisterWindow(GLDrawable window) { + public synchronized void unregisterWindow(GLAutoDrawable window) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); for (Iterator iter = info.manips.iterator(); iter.hasNext(); ) { removeManipFromWindow((Manip) iter.next(), window); @@ -126,7 +126,7 @@ public class ManipManager { /** Make a given manipulator visible and active in a given window. The window must be registered. */ - public synchronized void showManipInWindow(Manip manip, GLDrawable window) { + public synchronized void showManipInWindow(Manip manip, GLAutoDrawable window) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); if (info == null) { throw new RuntimeException("Window not registered"); @@ -142,7 +142,7 @@ public class ManipManager { /** Remove a given manipulator from a given window. The window must be registered. */ - public synchronized void removeManipFromWindow(Manip manip, GLDrawable window) { + public synchronized void removeManipFromWindow(Manip manip, GLAutoDrawable window) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); if (info == null) { throw new RuntimeException("Window not registered"); @@ -157,7 +157,7 @@ public class ManipManager { /** This must be called for a registered window every time the camera parameters of the window change. */ - public synchronized void updateCameraParameters(GLDrawable window, CameraParameters params) { + public synchronized void updateCameraParameters(GLAutoDrawable window, CameraParameters params) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); if (info == null) { throw new RuntimeException("Window not registered"); @@ -180,7 +180,7 @@ public class ManipManager { repainting of windows in which manipulators have moved. The default implementation, which can be restored by passing a null listener argument to this method, calls repaint() on the - GLDrawable if it is not a GLRunnable instance (i.e., a + GLAutoDrawable if it is not a GLRunnable instance (i.e., a GLAnimCanvas or GLAnimJPanel, which redraw themselves automatically). */ public synchronized void setWindowUpdateListener(WindowUpdateListener listener) { @@ -195,7 +195,7 @@ public class ManipManager { drawing occurs immediately; this routine must be called when an OpenGL context is valid, i.e., from within the display() method of a GLEventListener. */ - public synchronized void render(GLDrawable window, GL gl) { + public synchronized void render(GLAutoDrawable window, GL gl) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); if (info == null) { throw new RuntimeException("Window not registered"); @@ -212,7 +212,7 @@ public class ManipManager { listeners for the canvas (see the ExaminerViewer class), the setupMouseListeners and removeMouseListeners routines, as well as the appropriate delegate routines, are made public here. */ - public synchronized void setupMouseListeners(GLDrawable window) { + public synchronized void setupMouseListeners(GLAutoDrawable window) { window.addMouseMotionListener(mouseMotionListener); window.addMouseListener(mouseListener); } @@ -220,7 +220,7 @@ public class ManipManager { /** Removes the automatically-installed mouse listeners for the given window. This allows application code to determine the policy for intercepting mouse events. */ - public synchronized void removeMouseListeners(GLDrawable window) { + public synchronized void removeMouseListeners(GLAutoDrawable window) { window.removeMouseMotionListener(mouseMotionListener); window.removeMouseListener(mouseListener); } @@ -230,7 +230,7 @@ public class ManipManager { are exposed so application-level code can intercept events when certain modifier keys are depressed. */ public synchronized void mouseMoved(MouseEvent e) { - passiveMotionMethod((GLDrawable) e.getComponent(), e.getX(), e.getY()); + passiveMotionMethod((GLAutoDrawable) e.getComponent(), e.getX(), e.getY()); } /** The ManipManager watches for the following events: mouseMoved, @@ -238,7 +238,7 @@ public class ManipManager { are exposed so application-level code can intercept events when certain modifier keys are depressed. */ public synchronized void mouseDragged(MouseEvent e) { - motionMethod((GLDrawable) e.getComponent(), e.getX(), e.getY()); + motionMethod((GLAutoDrawable) e.getComponent(), e.getX(), e.getY()); } /** The ManipManager watches for the following events: mouseMoved, @@ -246,7 +246,7 @@ public class ManipManager { are exposed so application-level code can intercept events when certain modifier keys are depressed. */ public synchronized void mousePressed(MouseEvent e) { - mouseMethod((GLDrawable) e.getComponent(), e.getModifiers(), + mouseMethod((GLAutoDrawable) e.getComponent(), e.getModifiers(), true, e.getX(), e.getY()); } @@ -255,7 +255,7 @@ public class ManipManager { are exposed so application-level code can intercept events when certain modifier keys are depressed. */ public synchronized void mouseReleased(MouseEvent e) { - mouseMethod((GLDrawable) e.getComponent(), e.getModifiers(), + mouseMethod((GLAutoDrawable) e.getComponent(), e.getModifiers(), false, e.getX(), e.getY()); } @@ -268,7 +268,7 @@ public class ManipManager { setWindowUpdateListener(null); } - private void motionMethod(GLDrawable window, int x, int y) { + private void motionMethod(GLAutoDrawable window, int x, int y) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); if (info.dragging) { // Compute ray in 3D @@ -280,7 +280,7 @@ public class ManipManager { } } - private void passiveMotionMethod(GLDrawable window, int x, int y) { + private void passiveMotionMethod(GLAutoDrawable window, int x, int y) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); // Compute ray in 3D Vec3f rayStart = new Vec3f(); @@ -320,7 +320,7 @@ public class ManipManager { } } - private void mouseMethod(GLDrawable window, int modifiers, + private void mouseMethod(GLAutoDrawable window, int modifiers, boolean isPress, int x, int y) { if ((modifiers & InputEvent.BUTTON1_MASK) != 0) { WindowInfo info = (WindowInfo) windowToInfoMap.get(window); @@ -396,7 +396,7 @@ public class ManipManager { Set windows = (Set) manipToWindowMap.get(manip); assert windows != null; for (Iterator iter = windows.iterator(); iter.hasNext(); ) { - windowListener.update((GLDrawable) iter.next()); + windowListener.update((GLAutoDrawable) iter.next()); } } } diff --git a/src/gleem/WindowUpdateListener.java b/src/gleem/WindowUpdateListener.java index b91ee05..c87107a 100644 --- a/src/gleem/WindowUpdateListener.java +++ b/src/gleem/WindowUpdateListener.java @@ -44,8 +44,8 @@ import net.java.games.jogl.*; /** A WindowUpdateListener is used by the ManipManager to transmit repaint() notifications to windows containing Manips. When a Manip is moved, the ManipManager sends update notifications to all - GLDrawables in which that Manip is shown. */ + GLAutoDrawables in which that Manip is shown. */ public interface WindowUpdateListener { - public void update(GLDrawable window); + public void update(GLAutoDrawable window); } |