blob: 9145d15c27c2f97d212718a9292a4141e5ff676d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
import com.jogamp.opengl.util.gl2.GLUT;
import javax.media.opengl.GL2;
import javax.media.opengl.glu.GLU;
import java.awt.Color;
import robotrace.Vector;
/**
* Base class that provides basic bindings to the ugly JOGL interface. This
* works around the limitations imposed by JOGL.
*/
abstract class BetterBase {
/**
* OpenGL context.
*/
protected static GL2 gl;
/**
* OpenGL Utility instance.
*/
protected static GLU glu;
/**
* OpenGL Utility Toolkit instance.
*/
protected static GLUT glut;
public static void setGL(GL2 gl) {
BetterBase.gl = gl;
}
public static void setGLU(GLU glu) {
BetterBase.glu = glu;
}
public static void setGLUT(GLUT glut) {
BetterBase.glut = glut;
}
/**
* Utility method to set color.
*
* @param color An AWT color.
*/
static void setColor(Color color) {
// contains four RGBA color components (floats in range 0 to 1)
float[] rgba = color.getRGBComponents(null);
gl.glColor3fv(rgba, 0);
}
/**
* Pass a vector as a vertex to OpenGL.
*/
static public void glVertex(Vector vector) {
gl.glVertex3d(vector.x(),
vector.y(),
vector.z());
}
/**
* Use given vector as normal.
*/
static public void glNormal(Vector vector) {
gl.glNormal3d(vector.x(),
vector.y(),
vector.z());
}
}
|