diff options
author | Kenneth Russel <[email protected]> | 2004-10-05 22:01:25 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2004-10-05 22:01:25 +0000 |
commit | 81741bee34a8f6f8d17b8dde26bac42d94a5737d (patch) | |
tree | 5bc3b4bff0a648352c0cb622b66ae04ce76bcb54 | |
parent | 26b232df74edf1fe32961422b923baa81ab63605 (diff) |
Fixed Issue 34: glutWireCube / glutSolidCube generate wrong cubes
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@156 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r-- | src/net/java/games/jogl/util/GLUT.java | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/net/java/games/jogl/util/GLUT.java b/src/net/java/games/jogl/util/GLUT.java index de010e5be..36b54d6b1 100644 --- a/src/net/java/games/jogl/util/GLUT.java +++ b/src/net/java/games/jogl/util/GLUT.java @@ -413,6 +413,7 @@ public class GLUT { } } + private static float[][] boxVertices; private static final float[][] boxNormals = { {-1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, @@ -429,19 +430,18 @@ public class GLUT { {5, 6, 2, 1}, {7, 4, 0, 3} }; - private float[][] boxVertices; private void drawBox(GL gl, float size, int type) { if (boxVertices == null) { float[][] v = new float[8][]; for (int i = 0; i < 8; i++) { v[i] = new float[3]; } - v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2; - v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2; - v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2; - v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2; - v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2; - v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2; + v[0][0] = v[1][0] = v[2][0] = v[3][0] = -0.5f; + v[4][0] = v[5][0] = v[6][0] = v[7][0] = 0.5f; + v[0][1] = v[1][1] = v[4][1] = v[5][1] = -0.5f; + v[2][1] = v[3][1] = v[6][1] = v[7][1] = 0.5f; + v[0][2] = v[3][2] = v[4][2] = v[7][2] = -0.5f; + v[1][2] = v[2][2] = v[5][2] = v[6][2] = 0.5f; boxVertices = v; } float[][] v = boxVertices; @@ -450,10 +450,14 @@ public class GLUT { for (int i = 5; i >= 0; i--) { gl.glBegin(type); gl.glNormal3fv(n[i]); - gl.glVertex3fv(v[faces[i][0]]); - gl.glVertex3fv(v[faces[i][1]]); - gl.glVertex3fv(v[faces[i][2]]); - gl.glVertex3fv(v[faces[i][3]]); + float[] vt = v[faces[i][0]]; + gl.glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size); + vt = v[faces[i][1]]; + gl.glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size); + vt = v[faces[i][2]]; + gl.glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size); + vt = v[faces[i][3]]; + gl.glVertex3f(vt[0] * size, vt[1] * size, vt[2] * size); gl.glEnd(); } } |