PDA

View Full Version : Controling an object



cyam95
12-10-2001, 06:57 AM
Say that I've 5 quad object.How do I manipulate each object, like when I press an A key the third object will change it color. Can anyone help me?

pythagoras
12-10-2001, 08:33 AM
In the example you suggest, you would respond to the keystroke by calling glColor before the third object is rendered. Something like this:

glPushAttrib(GL_CURRENT_BIT);
glColor3*(r, g, b);
RenderObject(3);
glPopAttrib();

How you make this happen in response to the keystroke depends on the system you are using (X, win32, GLUT, etc), and the way your scene rendering code is organized.

HTH G.

cyam95
12-19-2001, 01:22 AM
Can u explain a little depth. I'm using GLUT to make this program. What this program does actually like this :

I'm rendering a keyboard object that each object represent a key on the keyboard (I hope u got the idea).

When the user press a key on the keyboard say an E key the object that represent the key will change it color and when the user lift up the key the object state will return to the previous color.

Can anyone give an idea.

Gavin
12-19-2001, 02:30 AM
You mean how do you catch the key press/release?

glutKeyboardFunc();
glutKeyboardUpFunc();