PDA

View Full Version : How to manipulate Matrixs in GL3?



pi3orama
06-15-2009, 07:40 PM
Hi,
I'm trying to port one of my previous work to GL3, and I notice that nearly a whole section of "Coordinate Transformations" has been removed in GL3's specification, including all of matrix operations. It is seems that all ModelView and Perspective transformation works have to be done by vertex shaders. However, my previous work use a lot of GL's matrix operations to implement rotate and projection.

I've searched in Google, and find that if I want to save my code structure I have to do the matrix operations myself, or at least use something like OpenGL Mathematics (http://glm.g-truc.net/) to simulate the old GL to do the mathematics works. Now I'm writing an SSE matrix library, however I still believe that to use CPU to do the computation will hurt the performance.

If I stick on hardware computation, I have to rewrite most of my code, do the transformation in shaders. In my old code, the position of an object is computed by a sequence of rotate--transfer--rotate--transfer...---scale, different objects use different sequences. In old GL, push/pop matrix can help me, what about GL3? Do I need to write specific shaders for different objects?

Can anyone tell me why the community deprecated such operations, and what replacement they prefer?

Thank you!

scratt
06-15-2009, 07:53 PM
Well, if you want those features you could try enabling a context with support for the Deprecation model.

Other than that there are a few Open Source solutions out there to provide maths libraries.

You could also write them yourself.

Here's quite an interesting thread where most of what you ask is discussed:
http://www.gamedev.net/community/forums/topic.asp?topic_id=509060

pi3orama
06-15-2009, 09:34 PM
Thanks for your answer. Now I know the matrix operations are done by software and they are slow.

_NK47
06-16-2009, 04:57 AM
"and they are slow"

they don't need to be slow. compiler optimizations and memory alignment can put those classes into SSE. same as a driver would do before sending them to further processing.