Advertisement

Why do things like matrix math, etc. yourself when you have OpenGL/Direct3D/whatever?

Started by September 03, 2002 03:52 PM
5 comments, last by Subotron 22 years, 5 months ago
Hi Maybe you all think my question is really lame, but I ask it anyway. I read a few articles about math and physics, especially matrix math. I see things like making a matrix like this: 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 Which is actually the same as, using OpenGL as example: glLoadIdentity(); So why would you want to make your own LoadIdentity function where you create this matrix? Why make all this extra code? Is it just so you know what OpenGL is actually doing for you so you get smarter and you know how to do it when you don''t use OpenGL any more, or does it have other advantages? I can''t believe it gives a speed increase does it... why is it a lot of articles talk about math like this, and why do I see ppl redefine the way * (product) is being handled? Can you get a speed increase by doing things like this? Or is it something else? Oh and please understand I''m not lazy or anything, I love math. But I just don''t see why you''d get a lot more code in your project than is actually needed... Thanks in advance for replying!
Personally, I believe is using the API as much as possible, especially since the current APIs are highly optimized. BUT...

Knowing how the math works helps you use the math better. Also, it makes debugging easier if you know the expected results. So...

I would recommend learning the math so that you can use it effectively, (and that means understanding where you can do shortcuts) but I don''t see the point of implementing your own math functions unless you have a very good reason (and you understand exactly how and why the API version is or isn''t better).
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Advertisement
??? Functions like glLoadIdentity, glMultMatrix etc only affect the current matrix stack in the video driver. What good is that to me if I am writing collision detection code... or a model loader... or a rigid body simulation etc etc

It is important to understand what matrix operations mean, say like what the inverse of a matrix means, as opposed to the low level code which actually calculates the inverse (yikes! copy and paste that stuff if you can I say)
Not everyone is writing video games. Or graphics-intensive applications, for that matter. I hear NASA released a templated matrix class along with vector and some other stuff (I think I''ve even seen the code); why not ask them why they''re not using OpenGL or Direct3D?
Well that answers my question. Especially that those functions only apply on the current matrix was a very good reason for doing it. And of course, just like NASA, I probably won''t use APIs for everything either. (I hope) And like in ''The Matrix'', knowing the path is different from walking the path so knowing what a matrix does when you use it is good to know too. Thanks all for giving me this new view
quote:
Original post by zppz
??? Functions like glLoadIdentity, glMultMatrix etc only affect the current matrix stack in the video driver. What good is that to me if I am writing collision detection code... or a model loader... or a rigid body simulation etc etc



You could use glGet... But more generally, this is one of those cases where there might be a good reason to do something else.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Advertisement
quote:
Original post by Subotron
Hi
Is it just so you know what OpenGL is actually doing for you so you get smarter
Thanks in advance for replying!


yes, better know what''s happening on your pipeline

This topic is closed to new replies.

Advertisement