I have called glScalef(), gl Rotatef() etc. Now what I want to do is both pass a vertex to opengl (which I know how to do, of course) AND (and this is the difficult bit) find out what the transformed vertex coordinates are / would be after passing them through OpenGL - ie, as they are when drawn on the screen.
Am I making sense?
Other than that, I suppose I could calculate it myself with my own matrix methods. Would it slow down the rendering speed if I did this? - ie, does gl use the video hardware for its maths?
And then, of course, there is the little problem of actually writing the functions... like I said, I know very little about matrices. They aren''t in the curriculum for maths where I live at school at all - you don''t do them until uni
The way OpenGL does the entire transformation from the vertex's local space to screen space is by:
Projection Matrix * Model View Matrix * vertex where your vertex (x, y, z) is treated as a vector: |x| |y| |z| |1|
The fourth field of the vector is known as the 'w' field. When your vertex goes through the transformation, OpenGL computes the screen coordinates by the divided x, y and z by w. But before it computes the screen coordinates it must clip the vertex to the view volume you specified by your projection matrix. The clipping boundaries for homogenous coordinates that have been transformed by a projection matrix in OpenGL is -w <= z >= w -w <= y >= w 0 <= z >= w
As you can see, trying to trace what OpenGL is going to do to your vertex is a little complicated. I'm guessing you are trying this because you want to be able to identify objects that have been projected on the screen so you can pick objects with your mouse or do something similar to that. If that is what you are trying to do you might want to look at the "Selection and Feedback" chapter of the "red book" to look at a possible alternative.
Thanks for the replies. What I''m actually doing is writing my own lighting routines, so I want to be able to find out where, if I plugged my normal through OpenGL, it would end up being. Can I get the current state of gl''s matrices somehow? Ie, make a gl call with a paramter of my own matrix structure, and then plug everything through that matrix?