View Full Version : object position

09-04-2006, 06:19 AM
I am a newbee for open gl. I have created a window with two glut primitives- a sphere and a cube. Now, how can i find the present position of the primitives and how can i reset the positions related to the present positions(20 pix in x-direction from the present position). I am using VC++ 6 and open GL.
can some one explain please?

09-04-2006, 07:18 AM
You need to manipulate the modelview matrix stack to position, rotate, and scale your GLUT spheres and cubes.


09-04-2006, 10:14 AM
yes. chapter 3 of redbook explains how to use the modelview matrix to manipulate the position and angle of an object. But I want to get the position of an object in the 3d coord. system at any given time.It is like getObjectPosition() and setObjectPosition() or position an object at a particular point(x,y,z).
How to do this?


09-05-2006, 01:09 AM
Typical approach looks like this:
-application knows where objects are
-application sets up matrices to place an object in proper position
-application renders an object

So asking OpenGL for object's position in 3D is more less like asking:
"Tell me what I have just told you".

Another case is when you want to know where object is on the screen after rendering - for this you can use feedback mode.
Or you can as OpenGL what objects are at given position on the screen - this is selection mode.