I’ve been looking around the forums and checking some linkes to vairous NeHe
ports and samples, but I seem to be stuck with a strange problem.
I’ve written the following bits of code (this will look very familiar to many
of you):
@Override
public void display(GLAutoDrawable drawable) {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );
gl.glLoadIdentity();
gl.glTranslatef(-1.5f, 0.0f, -6.0f);
gl.glBegin(GL.GL_TRIANGLES);
gl.glVertex3f(0.0f, 1.0f, 0.0f);
gl.glVertex3f(-1.0f, -1.0f, 0.0f);
gl.glVertex3f(1.0f, -1.0f, 0.0f);
gl.glEnd();
gl.glTranslatef(3.0f, 0.0f, 0.0f);
gl.glBegin(GL.GL_QUADS);
gl.glVertex3f(-1.0f, 1.0f, 0.0f);
gl.glVertex3f(1.0f, 1.0f, 0.0f);
gl.glVertex3f(1.0f, -1.0f, 0.0f);
gl.glVertex3f(-1.0f, -1.0f, 0.0f);
gl.glEnd();
}
@Override
public void init(GLAutoDrawable drawable) {
this.gl = drawable.getGL();
this.glDrawable = drawable;
drawable.setGL( new DebugGL(drawable.getGL() ));
System.out.println("Init GL is " + gl.getClass().getName());
}
I’m running this on Java 6 (Windows Vista), and I don’t get to see either the
triangle or the square. After some puzzling, I noticed the layout manager of
the canvas apparently resizes GL contents (thus, the 1.0f values are not in
any way ‘absolute’ values, but rather proportionate, where 1.0 is the full
width or height).
Is this normal behavior for a GLCanvas object? If so, I guess I should not be
using those for 3D scenes and objects that shouldn’t resize in any way other
than by changing camera distance. If it isn’t normal behavior, then what am I
doing wrong?
I would appreciate any hints or tips as to where I might find more appropriate
lessons for JOGL (it’s not very different from OpenGL, but just enough to make
NeHe’s tutorials tricky).