View Full Version : glGetFloatfv(GL_INVERSE_MODELVIEW_MATRIX) ?

bunny

02-27-2004, 07:34 AM

Is there a way to get access to the inverse modelview matrix via something like glGetFloatfv? I believe that the GL maintains a copy of this, so is it possible to get access to it?

The alternative is obviously to calculate it myself, but I'm doing this hundreds of times per frame, so I want to avoid that if possible.

glGet* might be pretty slow, too, because it might stall your GPU whereas stuff you do on your CPU is done in parallel. Granted, a 4x4 matrix inversion is not exactly free, either.

Alot of times, the best thing to do is to keep track of both matrix and inverse yourself. If most of your transforms are standard transforms (scale, rotate, translate) than it is relatively easy to compute the inverses and compose them.

-Won

bunny

02-27-2004, 07:53 AM

I'm fairly sure it keeps a copy of the modelview in local memory. glGetFloatfv doesn't seem particularly slow to get the modelview matrix anyway.

I'm aware that I could keep my own copy of the modelview matrix and its inverse, but this seems like overkill for the problem I'm trying to solve.

DarkWIng

02-27-2004, 08:12 AM

If your matrices are made only form translation, rotation and uniform scaling, then you can get inverse very cheap. Just transponse 3x3 submatrix(rotation/scaling part) and negate last row(translation part)

bunny

02-27-2004, 08:43 AM

Darkwing: good point, although your method is not strictly accurate; I can do it by transposing the rotation submatrix and then rotating the translation part by it.

I guess I don't use non-uniform scaling very much, so it'll probably work fine.

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.