I’ve created 2 spheres and I want to be able to control both of them separately with the keyboard at the same time. Right now I’m only able to control only one of them at a time. How can I go about doing this? What I’m doing is incrementing and decrementing the x and z coordinates through the keyboard.
e.g.
glPushMatrix();
glTranslatef(p1x, 0 , p1z);
drawSphere(1, 1, 1, 1);
glPopMatrix();
glPushMatrix();
glTranslatef(p2x, 0 , p2z);
drawSphere(1, 1, 1, 1);
glPopMatrix();
and then I have functions that update the p1x, p1z, p2x, p2z when the key is pressed
Anyone have an elegant solution for this?