summaryrefslogtreecommitdiffstats
path: root/src/demos/gears
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-09-09 23:22:37 +0000
committerKenneth Russel <[email protected]>2007-09-09 23:22:37 +0000
commit487efe1bea563865643c20206be7fc78854b8139 (patch)
tree307ccab21c9c03f05a77fbb8e9afe36d7bb4ca03 /src/demos/gears
parent648e947b1d4dd9b64fdd9872453482af1b849480 (diff)
Added comments based on some from Jason Moore
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@220 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/gears')
-rw-r--r--src/demos/gears/Gears.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/demos/gears/Gears.java b/src/demos/gears/Gears.java
index efd7d09..4ae780e 100644
--- a/src/demos/gears/Gears.java
+++ b/src/demos/gears/Gears.java
@@ -112,9 +112,14 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene
}
public void display(GLAutoDrawable drawable) {
+ // Turn the gears' teeth
angle += 2.0f;
+ // Get the GL corresponding to the drawable we are animating
GL gl = drawable.getGL();
+
+ // Special handling for the case where the GLJPanel is translucent
+ // and wants to be composited with other Java 2D content
if ((drawable instanceof GLJPanel) &&
!((GLJPanel) drawable).isOpaque() &&
((GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) {
@@ -123,29 +128,36 @@ public class Gears implements GLEventListener, MouseListener, MouseMotionListene
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
+ // Rotate the entire assembly of gears based on how the user
+ // dragged the mouse around
gl.glPushMatrix();
gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+ // Place the first gear and call its display list
gl.glPushMatrix();
gl.glTranslatef(-3.0f, -2.0f, 0.0f);
gl.glRotatef(angle, 0.0f, 0.0f, 1.0f);
gl.glCallList(gear1);
gl.glPopMatrix();
+ // Place the second gear and call its display list
gl.glPushMatrix();
gl.glTranslatef(3.1f, -2.0f, 0.0f);
gl.glRotatef(-2.0f * angle - 9.0f, 0.0f, 0.0f, 1.0f);
gl.glCallList(gear2);
gl.glPopMatrix();
+ // Place the third gear and call its display list
gl.glPushMatrix();
gl.glTranslatef(-3.1f, 4.2f, 0.0f);
gl.glRotatef(-2.0f * angle - 25.0f, 0.0f, 0.0f, 1.0f);
gl.glCallList(gear3);
gl.glPopMatrix();
+ // Remember that every push needs a pop; this one is paired with
+ // rotating the entire gear assembly
gl.glPopMatrix();
}