03-18-2003, 03:27 PM
Hi I'm very new to open gl and am a bit stuck at the moment.
I've got a basic polygon which i'v gotten to rotate. But I've come to a stop with keyboard input.
Thing is I want my polygon to rotate right when I press the right key and left when I press the left key.
I've implemented the basic keyboard input commands and have put my keyboard methods and a switch statement after my display method (not in it).
my program compiles just fine but nothing happens!!!
I was just wondering if
a) I'v put my key input code in the wrong place
b) I'm using the wrong commands to get my polygons to rotate the other way (i.e gl.glRotated(Rotate, 0,0,-1); )
//MY CODE
public void keyPressed(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
public void keyReleased(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_RIGHT:
gl.glRotated(Rotate, 0,0,1);
break;
case KeyEvent.VK_LEFT:
gl.glRotated(Rotate, 0,0,-1);
break;
}
}
I'm programing in java btw
Any help would be very much appreciated Thanks http://www.opengl.org/discussion_boards/ubb/smile.gif
I've got a basic polygon which i'v gotten to rotate. But I've come to a stop with keyboard input.
Thing is I want my polygon to rotate right when I press the right key and left when I press the left key.
I've implemented the basic keyboard input commands and have put my keyboard methods and a switch statement after my display method (not in it).
my program compiles just fine but nothing happens!!!
I was just wondering if
a) I'v put my key input code in the wrong place
b) I'm using the wrong commands to get my polygons to rotate the other way (i.e gl.glRotated(Rotate, 0,0,-1); )
//MY CODE
public void keyPressed(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
public void keyReleased(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_RIGHT:
gl.glRotated(Rotate, 0,0,1);
break;
case KeyEvent.VK_LEFT:
gl.glRotated(Rotate, 0,0,-1);
break;
}
}
I'm programing in java btw
Any help would be very much appreciated Thanks http://www.opengl.org/discussion_boards/ubb/smile.gif