Auto-movement

I want to be able to move to a certain position with just a simple press of a key. My problem is that I don’t know how to go about doing something like this. Any help?

You can use glutKeyboardFunc to read for a key on the keyboard to be pressed.
The when the key you have selected has been press just change the varible holding the location of the object to where you want it to go.

Originally posted by negative_pi:
I want to be able to move to a certain position with just a simple press of a key. My problem is that I don’t know how to go about doing something like this. Any help?

Can you give me an example of how to use the glutKeyboardFunc? I’m kinda new to it.

Here is a example

glutKeyboardFunc(keyboard); // Tells glut to start the keyboard function
glutMainLoop(); //last call in your main() loop

void keyboard (unsigned char key, int x, int y)
{
switch (key) {
case ‘W’: // Example pressing ‘W’ changes my scale value.
wscale = wscale + 0.01f;
if (wscale > 10) wscale = 0;
glutPostRedisplay();
break;
case 27: // on pressing the “ESC” key quit program.
exit(0);
break;
default:
break;
}

}

Originally posted by negative_pi:
Can you give me an example of how to use the glutKeyboardFunc? I’m kinda new to it.

Thanks.