diff options
Diffstat (limited to 'src/gleem')
-rw-r--r-- | src/gleem/ExaminerViewer.java | 59 | ||||
-rw-r--r-- | src/gleem/HandleBoxManip.java | 3 | ||||
-rw-r--r-- | src/gleem/Manip.java | 3 | ||||
-rw-r--r-- | src/gleem/ManipManager.java | 59 | ||||
-rw-r--r-- | src/gleem/ManipPart.java | 3 | ||||
-rw-r--r-- | src/gleem/ManipPartGroup.java | 3 | ||||
-rw-r--r-- | src/gleem/ManipPartLineSeg.java | 3 | ||||
-rw-r--r-- | src/gleem/ManipPartTriBased.java | 3 | ||||
-rw-r--r-- | src/gleem/TestExaminerViewer.java | 25 | ||||
-rw-r--r-- | src/gleem/TestHandleBox.java | 26 | ||||
-rw-r--r-- | src/gleem/TestMultiWin.java | 25 | ||||
-rw-r--r-- | src/gleem/TestTranslate1.java | 26 | ||||
-rw-r--r-- | src/gleem/TestTranslate2.java | 26 | ||||
-rw-r--r-- | src/gleem/Translate1Manip.java | 3 | ||||
-rw-r--r-- | src/gleem/Translate2Manip.java | 3 | ||||
-rw-r--r-- | src/gleem/WindowUpdateListener.java | 7 | ||||
-rw-r--r-- | src/gleem/linalg/Vec2f.java | 4 |
17 files changed, 161 insertions, 120 deletions
diff --git a/src/gleem/ExaminerViewer.java b/src/gleem/ExaminerViewer.java index 2cb2f05..61976b1 100644 --- a/src/gleem/ExaminerViewer.java +++ b/src/gleem/ExaminerViewer.java @@ -44,13 +44,14 @@ import java.awt.event.*; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** <P> This is an application-level class, not part of the manipulator hierarchy. It is an example of how you might integrate gleem with another application which uses the mouse. </P> - <P> For the given GLDrawable, the ExaminerViewer takes over the + <P> For the given GLAutoDrawable, the ExaminerViewer takes over the setting of the view position. It passes along mouse events it is not interested in to the ManipManager's mouse routines. </P> @@ -71,13 +72,14 @@ import net.java.games.jogl.*; button. </P> */ public class ExaminerViewer { - private GLDrawable window; + private GLAutoDrawable window; /** Simple state machine for figuring out whether we are grabbing events */ private boolean interactionUnderway; private boolean iOwnInteraction; private boolean noAltKeyMode; + private boolean autoRedrawMode = true; /** Simple state machine for computing distance dragged */ private boolean button1Down; @@ -125,12 +127,12 @@ public class ExaminerViewer { }; private GLEventListener glListener = new GLEventListener() { - public void init(GLDrawable drawable) {} - public void display(GLDrawable drawable) {} - public void reshape(GLDrawable drawable, int x, int y, int width, int height) { + public void init(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) {} + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { reshapeMethod(width, height); } - public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} }; /** The constructor takes the number of mouse buttons on this system @@ -140,17 +142,17 @@ public class ExaminerViewer { oldNumMouseButtons = numMouseButtons; } - /** <P> Attaches this ExaminerViewer to the given GLDrawable. This + /** <P> Attaches this ExaminerViewer to the given GLAutoDrawable. This causes the ManipManager's mouse routines to be removed from the window (using ManipManager.removeMouseListeners) and the - ExaminerViewer's to be installed. The GLDrawable should be + ExaminerViewer's to be installed. The GLAutoDrawable should be registered with the ManipManager before the ExaminerViewer is attached to it. </P> <P> In order for the viewer to do anything useful, you need to provide a BSphereProvider to it to allow "view all" functionality. </P> */ - public void attach(GLDrawable window, BSphereProvider provider) { + public void attach(GLAutoDrawable window, BSphereProvider provider) { this.window = window; this.provider = provider; init(); @@ -158,7 +160,7 @@ public class ExaminerViewer { } /** Detaches from the given window. This causes the ManipManager's - mouse listeners to be reinstalled on the GLDrawable and the + mouse listeners to be reinstalled on the GLAutoDrawable and the ExaminerViewer's to be removed. */ public void detach() { removeListeners(); @@ -300,6 +302,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 @@ -355,9 +371,8 @@ public class ExaminerViewer { button1Down = false; button2Down = false; - Dimension size = window.getSize(); - int xSize = size.width; - int ySize = size.height; + int xSize = window.getWidth(); + int ySize = window.getHeight(); params.setOrientation(orientation); params.setPosition(computePosition(new Vec3f())); params.setForwardDirection(Vec3f.NEG_Z_AXIS); @@ -411,9 +426,9 @@ public class ExaminerViewer { } - // Force redraw if window will not do it automatically - if (!window.getNoAutoRedrawMode()) { - window.display(); + if (autoRedrawMode) { + // Force redraw + window.repaint(); } } } @@ -471,9 +486,9 @@ public class ExaminerViewer { iOwnInteraction = false; } - // Force redraw if window will not do it automatically - if (!window.getNoAutoRedrawMode()) { - window.display(); + if (autoRedrawMode) { + // Force redraw + window.repaint(); } } } @@ -581,11 +596,11 @@ public class ExaminerViewer { gl.glMatrixMode(GL.GL_MODELVIEW); float[] data = new float[16]; params.getModelviewMatrix().getColumnMajorData(data); - gl.glLoadMatrixf(data); + gl.glLoadMatrixf(data, 0); gl.glMatrixMode(GL.GL_PROJECTION); params.getProjectionMatrix().getColumnMajorData(data); - gl.glLoadMatrixf(data); + gl.glLoadMatrixf(data, 0); } private void recalcInverseRotation(GL gl) { diff --git a/src/gleem/HandleBoxManip.java b/src/gleem/HandleBoxManip.java index bedde65..73256c0 100644 --- a/src/gleem/HandleBoxManip.java +++ b/src/gleem/HandleBoxManip.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** Patterned after Inventor's HandleBoxManip (by Paul Isaacs and David Mott) and TransformerManip (by Paul Isaacs). Center box diff --git a/src/gleem/Manip.java b/src/gleem/Manip.java index b037430..919b805 100644 --- a/src/gleem/Manip.java +++ b/src/gleem/Manip.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** The base class for all manipulators. Fundamentally a manipulator must support a ray cast operation with itself and logic to diff --git a/src/gleem/ManipManager.java b/src/gleem/ManipManager.java index 0a0d86d..b959e74 100644 --- a/src/gleem/ManipManager.java +++ b/src/gleem/ManipManager.java @@ -44,7 +44,8 @@ import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** The ManipManager handles making manipulators visible in a window. */ @@ -55,7 +56,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,10 +79,8 @@ public class ManipManager { } }; private WindowUpdateListener defaultWindowListener = new WindowUpdateListener() { - public void update(GLDrawable window) { - if (!window.getNoAutoRedrawMode()) { - window.display(); - } + public void update(GLAutoDrawable window) { + window.repaint(); } }; private WindowUpdateListener windowListener; @@ -110,25 +109,31 @@ 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) { + if (window == null) { + return; + } WindowInfo info = (WindowInfo) windowToInfoMap.get(window); - for (Iterator iter = info.manips.iterator(); iter.hasNext(); ) { - removeManipFromWindow((Manip) iter.next(), window); + if (info != null) { + Object[] manips = info.manips.toArray(); + for (int i = 0; i < manips.length; i++) { + removeManipFromWindow((Manip) manips[i], window); + } + windowToInfoMap.remove(window); + removeMouseListeners(window); } - windowToInfoMap.remove(window); - removeMouseListeners(window); } /** 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"); @@ -144,7 +149,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"); @@ -159,7 +164,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"); @@ -182,7 +187,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) { @@ -197,7 +202,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"); @@ -214,7 +219,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); } @@ -222,7 +227,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); } @@ -232,7 +237,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, @@ -240,7 +245,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, @@ -248,7 +253,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()); } @@ -257,7 +262,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()); } @@ -270,7 +275,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 @@ -282,7 +287,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(); @@ -322,7 +327,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); @@ -398,7 +403,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/ManipPart.java b/src/gleem/ManipPart.java index 50fbe61..83f21cf 100644 --- a/src/gleem/ManipPart.java +++ b/src/gleem/ManipPart.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** A ManipPart is a visible or invisible sub-part of a manipulator. ManipParts are organized into trees. */ diff --git a/src/gleem/ManipPartGroup.java b/src/gleem/ManipPartGroup.java index 859a8a3..97a31ec 100644 --- a/src/gleem/ManipPartGroup.java +++ b/src/gleem/ManipPartGroup.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** This class groups a set of ManipParts. Makes a set of ManipParts look like one. */ diff --git a/src/gleem/ManipPartLineSeg.java b/src/gleem/ManipPartLineSeg.java index 8278533..ea34b5c 100644 --- a/src/gleem/ManipPartLineSeg.java +++ b/src/gleem/ManipPartLineSeg.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** A line segment from (-1, 0, 0) to (1, 0, 0). */ diff --git a/src/gleem/ManipPartTriBased.java b/src/gleem/ManipPartTriBased.java index 97f8ae3..208c8ea 100644 --- a/src/gleem/ManipPartTriBased.java +++ b/src/gleem/ManipPartTriBased.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** Triangle-based manipulator part. This is the base class for most of the ManipParts that GLEEM uses internally. You can feel free to diff --git a/src/gleem/TestExaminerViewer.java b/src/gleem/TestExaminerViewer.java index 55d0283..7e52992 100644 --- a/src/gleem/TestExaminerViewer.java +++ b/src/gleem/TestExaminerViewer.java @@ -41,7 +41,9 @@ package gleem; import java.awt.*; import java.awt.event.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; +import com.sun.opengl.utils.*; import gleem.linalg.*; /** Tests the Examiner Viewer. */ @@ -72,22 +74,20 @@ public class TestExaminerViewer { } static class Listener implements GLEventListener { - private GL gl; - private GLU glu; + private GLU glu = new GLU(); private CameraParameters params = new CameraParameters(); private ExaminerViewer viewer; - public void init(GLDrawable drawable) { - gl = drawable.getGL(); - glu = drawable.getGLU(); + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClearColor(0, 0, 0, 0); float[] lightPosition = new float[] {1, 1, 1, 0}; float[] ambient = new float[] { 0.0f, 0.0f, 0.0f, 1.0f }; float[] diffuse = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); @@ -122,7 +122,8 @@ public class TestExaminerViewer { viewer.viewAll(gl); } - public void display(GLDrawable drawable) { + public void display(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); viewer.update(gl); ManipManager.getManipManager().updateCameraParameters(drawable, viewer.getCameraParameters()); @@ -130,8 +131,8 @@ public class TestExaminerViewer { } // Unused routines - public void reshape(GLDrawable drawable, int x, int y, int w, int h) {} - public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} } public static void main(String[] args) { diff --git a/src/gleem/TestHandleBox.java b/src/gleem/TestHandleBox.java index adf8e32..e06d004 100644 --- a/src/gleem/TestHandleBox.java +++ b/src/gleem/TestHandleBox.java @@ -41,7 +41,9 @@ package gleem; import java.awt.*; import java.awt.event.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; +import com.sun.opengl.utils.*; import gleem.linalg.*; /** Tests the HandleBox Manip. */ @@ -51,21 +53,19 @@ public class TestHandleBox { private static final int Y_SIZE = 400; static class Listener implements GLEventListener { - private GL gl; - private GLU glu; + private GLU glu = new GLU(); private CameraParameters params = new CameraParameters(); - public void init(GLDrawable drawable) { - gl = drawable.getGL(); - glu = drawable.getGLU(); + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClearColor(0, 0, 0, 0); float[] lightPosition = new float[] {1, 1, 1, 0}; float[] ambient = new float[] { 0.0f, 0.0f, 0.0f, 1.0f }; float[] diffuse = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); @@ -95,13 +95,15 @@ public class TestHandleBox { manager.showManipInWindow(manip, drawable); } - public void display(GLDrawable drawable) { + public void display(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); ManipManager.getManipManager().updateCameraParameters(drawable, params); ManipManager.getManipManager().render(drawable, gl); } - public void reshape(GLDrawable drawable, int x, int y, int w, int h) { + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { + GL gl = drawable.getGL(); float aspect, theta; aspect = (float) w / (float) h; if (w >= h) @@ -120,7 +122,7 @@ public class TestHandleBox { } // Unused routines - public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} } public static void main(String[] args) { diff --git a/src/gleem/TestMultiWin.java b/src/gleem/TestMultiWin.java index ce2c257..1a1fcf1 100644 --- a/src/gleem/TestMultiWin.java +++ b/src/gleem/TestMultiWin.java @@ -41,7 +41,9 @@ package gleem; import java.awt.*; import java.awt.event.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; +import com.sun.opengl.utils.*; import gleem.linalg.*; /** Tests viewing manipulators in multiple winodws. */ @@ -74,22 +76,20 @@ public class TestMultiWin { } static class Listener implements GLEventListener { - private GL gl; - private GLU glu; + private GLU glu = new GLU(); private CameraParameters params = new CameraParameters(); private ExaminerViewer viewer; - public void init(GLDrawable drawable) { - gl = drawable.getGL(); - glu = drawable.getGLU(); + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClearColor(0, 0, 0, 0); float[] lightPosition = new float[] {1, 1, 1, 0}; float[] ambient = new float[] { 0.0f, 0.0f, 0.0f, 1.0f }; float[] diffuse = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); @@ -121,7 +121,8 @@ public class TestMultiWin { viewer.viewAll(gl); } - public void display(GLDrawable drawable) { + public void display(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); viewer.update(gl); ManipManager.getManipManager().updateCameraParameters(drawable, viewer.getCameraParameters()); @@ -129,8 +130,8 @@ public class TestMultiWin { } // Unused routines - public void reshape(GLDrawable drawable, int x, int y, int w, int h) {} - public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} } private static void showFrame(String name, Point location) { diff --git a/src/gleem/TestTranslate1.java b/src/gleem/TestTranslate1.java index 131fa0c..b9eb81a 100644 --- a/src/gleem/TestTranslate1.java +++ b/src/gleem/TestTranslate1.java @@ -41,7 +41,9 @@ package gleem; import java.awt.*; import java.awt.event.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; +import com.sun.opengl.utils.*; import gleem.linalg.*; /** Tests the Translate1 Manip. */ @@ -51,21 +53,19 @@ public class TestTranslate1 { private static final int Y_SIZE = 400; static class Listener implements GLEventListener { - private GL gl; - private GLU glu; + private GLU glu = new GLU(); private CameraParameters params = new CameraParameters(); - public void init(GLDrawable drawable) { - gl = drawable.getGL(); - glu = drawable.getGLU(); + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClearColor(0, 0, 0, 0); float[] lightPosition = new float[] {1, 1, 1, 0}; float[] ambient = new float[] { 0.0f, 0.0f, 0.0f, 1.0f }; float[] diffuse = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); @@ -96,13 +96,15 @@ public class TestTranslate1 { manager.showManipInWindow(manip, drawable); } - public void display(GLDrawable drawable) { + public void display(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); ManipManager.getManipManager().updateCameraParameters(drawable, params); ManipManager.getManipManager().render(drawable, gl); } - public void reshape(GLDrawable drawable, int x, int y, int w, int h) { + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { + GL gl = drawable.getGL(); float aspect, theta; aspect = (float) w / (float) h; if (w >= h) @@ -121,7 +123,7 @@ public class TestTranslate1 { } // Unused routines - public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} } public static void main(String[] args) { diff --git a/src/gleem/TestTranslate2.java b/src/gleem/TestTranslate2.java index 1789575..96f5684 100644 --- a/src/gleem/TestTranslate2.java +++ b/src/gleem/TestTranslate2.java @@ -41,7 +41,9 @@ package gleem; import java.awt.*; import java.awt.event.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import javax.media.opengl.glu.*; +import com.sun.opengl.utils.*; import gleem.linalg.*; /** Tests the Translate2 Manip. */ @@ -51,21 +53,19 @@ public class TestTranslate2 { private static final int Y_SIZE = 400; static class Listener implements GLEventListener { - private GL gl; - private GLU glu; + private GLU glu = new GLU(); private CameraParameters params = new CameraParameters(); - public void init(GLDrawable drawable) { - gl = drawable.getGL(); - glu = drawable.getGLU(); + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClearColor(0, 0, 0, 0); float[] lightPosition = new float[] {1, 1, 1, 0}; float[] ambient = new float[] { 0.0f, 0.0f, 0.0f, 1.0f }; float[] diffuse = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }; - gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse); - gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, ambient, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, diffuse, 0); + gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition, 0); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); @@ -96,13 +96,15 @@ public class TestTranslate2 { manager.showManipInWindow(manip, drawable); } - public void display(GLDrawable drawable) { + public void display(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); ManipManager.getManipManager().updateCameraParameters(drawable, params); ManipManager.getManipManager().render(drawable, gl); } - public void reshape(GLDrawable drawable, int x, int y, int w, int h) { + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { + GL gl = drawable.getGL(); float aspect, theta; aspect = (float) w / (float) h; if (w >= h) @@ -121,7 +123,7 @@ public class TestTranslate2 { } // Unused routines - public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} } public static void main(String[] args) { diff --git a/src/gleem/Translate1Manip.java b/src/gleem/Translate1Manip.java index 541173f..49c4087 100644 --- a/src/gleem/Translate1Manip.java +++ b/src/gleem/Translate1Manip.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** A Translate1Manip is a Manip which translates in only one dimension and whose default representation is a two-way arrow. */ diff --git a/src/gleem/Translate2Manip.java b/src/gleem/Translate2Manip.java index a76df48..101b1e4 100644 --- a/src/gleem/Translate2Manip.java +++ b/src/gleem/Translate2Manip.java @@ -42,7 +42,8 @@ package gleem; import java.util.*; import gleem.linalg.*; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** A Translate2Manip is a Manip which translates in two dimensions and whose default representation is two arrows. */ diff --git a/src/gleem/WindowUpdateListener.java b/src/gleem/WindowUpdateListener.java index b91ee05..793f051 100644 --- a/src/gleem/WindowUpdateListener.java +++ b/src/gleem/WindowUpdateListener.java @@ -39,13 +39,14 @@ package gleem; -import net.java.games.jogl.*; +import javax.media.opengl.*; +import com.sun.opengl.utils.*; /** 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); } diff --git a/src/gleem/linalg/Vec2f.java b/src/gleem/linalg/Vec2f.java index 2e02701..4c02b61 100644 --- a/src/gleem/linalg/Vec2f.java +++ b/src/gleem/linalg/Vec2f.java @@ -59,6 +59,10 @@ public class Vec2f { return new Vec2f(this); } + public void set(Vec2f arg) { + set(arg.x, arg.y); + } + public void set(float x, float y) { this.x = x; this.y = y; |