Reputation: 78914
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.
Upvotes: 7
Views: 6056
Reputation: 14788
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.
Upvotes: -1
Reputation: 1954
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.
Upvotes: 0
Reputation: 27583
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);
Upvotes: 4