views:

1821

answers:

4

Is there a way to make OpenGL transform a general vector I give it with the current modelview matrix and get the result back?

The obvious way is to query the modelview matrix and do the multiplication myself but I am almost sure there should be a way to make OpenGL do this for me.

+2  A: 

You are right, you have to get the modelview matrix and transform the vector yourself.

For a confirm, see this link at paragraph 9.120.

Marco M.
+1  A: 

It is best to do the calculation outside of OpenGL. The Matrix and Quaternions FAQ is a good resource for learning how to perform the calculations if you do not know already. You fetch the 4x4 model-view matrix as follows

float modelview[16];
glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
Judge Maygarden
A: 

It's probably best to do the transformations on the CPU side. The only other way I can think of is to use EXT_transform_feedback plus a vertex shader that does only the modelview transformations.

Maurice Gilden
A: 

The reason why opengl probably won't just do this for you is because the calculation isn't part of the rendering pipeline. and opengl (for the most part) only performs calculations during the display loop. So it doesn't make sense to provide these kind of synchronous interfaces.

luke