How can I get the vector from camera to object?

I’d like to implement a simple shader that will color my triangles based on the angle between the gaze axisi of the camera and surface normal. I know how to do the normals and get angle between two vectors, but how can I knwo the ‘gaze axis’ of camera vector? Also how can I querry the current position of opengl camera?

Thank you,
Luke

void gluUnProject(x,y,z,modelview,
projection,viewport,px,py,pz);

You can usually use the inverse of your modelview matrix to get the gaze axis and the camera position.

mvi = inverse modelview matrix
camera pos = {mvi[12], mvi[13], mvi[14]}
gaze axis = {mvi[8], mvi[9], mvi[10]}