Put Camera at Moving's Object's Position

I need help. I’m trying to track a moving object’s position. I am using “glGetFloatv(GL_CURRENT_RASTER_POSITION, posParams);” to track the object’s position.
Then I have “gluLookAt(0,0,0,posParams[0],posParams[1],posParams[2],0,1,0);” in my display function. I want the camera to be positioned where the object is.
But my world is not displaying correctly.
What am I doing wrong? Maybe I’m not using glGetFloatv correctly?

thanks,
dellatorre

What is your ‘object’, how do You draw it?
Do You use any glRasterPos calls, or render some bitmap text?
If not, you probably didn’s set raster position at all.

No, I’m thinking now that GL_CURRENT_RASTER_POSITION is not the correct parameter that I should be using.
My moving object is just a square drawn with GL_POINTS.
Do you know which function I should be using to track it to get the coordinates of its position to use in gluLookAt?

thanks

Surely you have your “objects’s” position in your code somewhere? If your object is a square drawn with GL_POINTS then your object’s position could be the center of that square, or the position of it’s “head” or “eyes”.

What you also need in order to use gluLookAt is the “Up” vector for your view. This would normally be the “Up” of your object. You also need a place to look at. That would typically be along your “object’s” view vector.

Your post is very unclear as to what you want to achieve / are doing. But taking a stab at it, assuming your square is sitting on the floor and sliding around and you want to see it’s view as it moves in an environment then your Up vector would be as you have it in the last three elements of gluLookAt. Your eye position should be your objects position and go in the first three elements of gluLookAt, and the second three elements of gluLookAt should be a point directly in-front of your object in it’s direction of travel. A crude way to get the last one is to add a few frames worth of velocity onto your objects position.

I know its initial position, but I want the camera to follow it. I want a first person view (like the moving square is a car). So I need to continually track the square’s position as it moves (which happens by pressing the arrow keys)

Track it from a static position or follow it like a chase camera?

The principal is the same except if you have a fixed position to “watch” from that will simply go into the first coordinate in gluLookAt.

If it’s a chase camera then you need to track the earlier positions of your car and choose one a reasonable distance back along that list for your camera’s position (put it in the first coordinate in gluLookAt). A simpler method is to move backwards along your car’s view vector so you are behind it and your camera will appear to be stuck on a stick on the back of your car.

The second coordinate in gluLookAt should always be your car’s position, and the last one should be a vector perpendicular to the surface your car is on.

I know its initial position, but I want the camera to follow it.

Do you not know what its position is later? You are, after all, telling OpenGL where to draw it later, so you must on some level know where you’re drawing it.