summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/net/java/games/jogl/util/GLUT.java26
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();
}
}