Jump to content
  • Advertisement
Sign in to follow this  
Gumgo

OpenGL Skipping OpenGL's matrices entirely

This topic is 2996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using entirely Cg shaders, which requires me to pass the modelViewProjection matrix as a parameter. Additionally, I calculate matrices manually (for other purposes), without using OpenGL's matrix functions, and in my shaders I use 3x4 matrices anyway, because I don't ever need the bottom row.

Are there any disadvantages to just completely avoiding OpenGL's matrices? That is, completely avoiding glMatrixMode(), gluPerspective(), gluLookAt(), glPushMatrix(), glPopMatrix(), glLoadMatrix(), glMultMatrix(), etc.

What about the near and far planes? The only way I know how to set those is using gluPerspective(), but since I'm computing the projection matrix manually, there's no need for that.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Are there any disadvantages to just completely avoiding OpenGL's matrices? That is, completely avoiding glMatrixMode(), gluPerspective(), gluLookAt(), glPushMatrix(), glPopMatrix(), glLoadMatrix(), glMultMatrix(), etc.
Considering that all of these functions are deprecated in the most recent version of OpenGL (or at least that's my understanding), I doubt anyone would consider it disadvantageous to forgo their use.
Quote:
What about the near and far planes? The only way I know how to set those is using gluPerspective(), but since I'm computing the projection matrix manually, there's no need for that.
If you're computing the projection matrix manually, then you are in fact (implicitly) setting the near and far plane distances.

Share this post


Link to post
Share on other sites
Quote:
I'm using entirely Cg shaders, which requires me to pass the modelViewProjection matrix as a parameter. Additionally, I calculate matrices manually (for other purposes), without using OpenGL's matrix functions, and in my shaders I use 3x4 matrices anyway, because I don't ever need the bottom row.
One other quick comment. Typically, projection matrices make use of the 4th row/column, so how are you incorporating the projection transform if you only use 3x4 matrices?

Share this post


Link to post
Share on other sites
Actually, I just implemented passing the projection matrix to the shaders and realized that I did in fact need a 4x4 matrix. However, this is the only place, everywhere else I use 3x4 (with the bottom row implicitly [0, 0, 0, 1]).

I did not realize the built in matrices were now deprecated, but that definitely answers my question! Thanks.

(My initial concern was that OpenGL needed the built in matrices do compute certain things, such as the near and far planes. In my graphics class we learned a more... "mathematical" version of projection matrices, so to speak, as opposed to what you'd actually implement, so I didn't realize the near and far plane were part of that matrix. Anyway, this makes sense now, thanks for clarifying!)

Share this post


Link to post
Share on other sites
I strongly recommend you use a good math library. Ones built with template metaprogramming are very fast. I use CML which has a lot of functionality that makes it excellent for graphics, including all the usual matrix and vector stuff you'd need in graphics programming and more, plus it's lightweight, being header only, and it's damn fast with proper compiler optimization settings; the expression expansion is great and at least with Intel compiler most stuff auto-vectorizes nicely. www.cmldev.net
If you're really hardcore and you need a lot more math stuff, say you're writing your own physics library, check out Blitz++, it's just as fast, but much larger project and not so lightweight.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!