diff options
author | Kenneth Russel <[email protected]> | 2005-02-24 22:18:05 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-02-24 22:18:05 +0000 |
commit | d6ed054c6e6a7ff0e071ff8480b2ccd8e6b73518 (patch) | |
tree | dd995de0d79bb1f6623ed27456637f6ae12fb61f /src/demos/jgears/JGears.java | |
parent | 509353b529f6da6f50221d84adbc0a6de8308f54 (diff) |
Changed Gears and JGears demo to recommended style (to not cache the
GL object)
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@60 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/jgears/JGears.java')
-rw-r--r-- | src/demos/jgears/JGears.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/demos/jgears/JGears.java b/src/demos/jgears/JGears.java index 64a9f2e..6adc528 100644 --- a/src/demos/jgears/JGears.java +++ b/src/demos/jgears/JGears.java @@ -51,12 +51,9 @@ public class JGears { private int prevMouseX, prevMouseY; private boolean mouseRButtonDown = false; - private GL gl; - private GLDrawable gldrawable; public void init(GLDrawable drawable) { - gl = drawable.getGL(); - this.gldrawable = drawable; + GL gl = drawable.getGL(); System.err.println("INIT GL IS: " + gl.getClass().getName()); float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; @@ -74,19 +71,19 @@ public class JGears { gear1 = gl.glGenLists(1); gl.glNewList(gear1, GL.GL_COMPILE); gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, red); - gear(1.0f, 4.0f, 1.0f, 20, 0.7f); + gear(gl, 1.0f, 4.0f, 1.0f, 20, 0.7f); gl.glEndList(); gear2 = gl.glGenLists(1); gl.glNewList(gear2, GL.GL_COMPILE); gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, green); - gear(0.5f, 2.0f, 2.0f, 10, 0.7f); + gear(gl, 0.5f, 2.0f, 2.0f, 10, 0.7f); gl.glEndList(); gear3 = gl.glGenLists(1); gl.glNewList(gear3, GL.GL_COMPILE); gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, blue); - gear(1.3f, 2.0f, 0.5f, 10, 0.7f); + gear(gl, 1.3f, 2.0f, 0.5f, 10, 0.7f); gl.glEndList(); gl.glEnable(GL.GL_NORMALIZE); @@ -96,6 +93,8 @@ public class JGears { } public void reshape(GLDrawable drawable, int x, int y, int width, int height) { + GL gl = drawable.getGL(); + float h = (float)height / (float)width; gl.glMatrixMode(GL.GL_PROJECTION); @@ -128,6 +127,7 @@ public class JGears { public void display(GLDrawable drawable) { angle += 2.0f; + GL gl = drawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glPushMatrix(); @@ -158,7 +158,8 @@ public class JGears { public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {} - private void gear(float inner_radius, + private void gear(GL gl, + float inner_radius, float outer_radius, float width, int teeth, |