I’ve drawn a bunch of points and things on the screen but I can’t get anything to rotate according to the keys I press. Can anyone see anything wrong w/ the basic logic I have here?
Any help much appreciated.
…
public void display(GLDrawable drawable) {
GL gl = drawable.getGL();
GLU glu = drawable.getGLU();
this.gldrawable = drawable;
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glMatrixMode(GL.GL_MODELVIEW);
glu.gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, -100.0, 0.0, 1.0, 0.0);
// I've tried various combinations of values with
// the glRotate method.
gl.glRotatef(0.0f, xrot, yrot, 0.0f);
model.draw();
gl.glFlush();
}
…
// I’m not exactly sure about the way I’m calling the display
// method after each keypress.
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_RIGHT:
this.yspeed += 0.01f;
yrot += 1.0;
display(this.gldrawable);
break;
case KeyEvent.VK_LEFT:
this.yspeed -= 0.01f;
yrot -= 1.0;
display(this.gldrawable);
break;
…