If I remember correctly (haven’t been working with Cg for a long time), you have to hand over the modelview matrix manually to Cg as a variable. In Cg you don’t have a builtin modelview matrix variable automatically as in GLSL (like in OpenGL 3.x with forward compatibility / core profile).
So, get the matrix with:
glGet(GL_MODELVIEW_MATRIX, …);
And make sure the Cg shader program gets this matrix.
(the GLSL equivalent function would be: glUniformMatrix4fv)
And as DmitryM said: apply the matrix multiplication with the vertex manually in the shader.
Ok, well if I remember correctly (and for me too it has been a while), you can get auto-tracked matricies via glTrackMatrixNV. For instance, something like this:
and then in the shader when declaring the uniform input, nail it to a set of 4 constant registers, starting at the same base register:
..., uniform float4x4 sgglModelView : C60, ...
See NV_vertex_program for details. May only work for the NVidia profiles.
And for the ARB profiles, you’d just reference glstate.matrix.modelview (or something like that) in the shader and be done with it. Tracking is automagic.