How to read back transformed coordinates

Started by
3 comments, last by V-man 15 years, 11 months ago
Is it possible in the OpenGL API to transform (rotate) a point and then save the result? I don't just want to apply rotations for rendering with glRotatef. I want to rotate a point and then save the result. Or do I just need to build my own rotation functions for this?
Advertisement
On SM4 hardware, that should be possible with "transform feedback", but I would think twice (actually... thrice) before using it.

Rotating some points (if that's all you need) is really a lot easier by using standard rotation functions (possibly paired with translation). It's something that works out of the box and pretty much "for free". Or, compose your own matrix and feed that to the GL.
Doing your own rotation math will work too, and it will probably be a lot easier than transform feedback, too (and won't require newest generation hardware).
Why would you want to do that? Are you intending to use OpenGL to compute stuff you need in your game logic? If that's the case, it probably is better to write your own routines.
Quote:Original post by SnotBob
Why would you want to do that? Are you intending to use OpenGL to compute stuff you need in your game logic? If that's the case, it probably is better to write your own routines.


Yes, that's what I wanted to do. I just wrote my own routines based on these replies. Thanks.
Yes, you need a math library

Here, they mention a lot of libs. There is one called MathGL++

http://www.gamedev.net/community/forums/topic.asp?topic_id=291432
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement