PDA

View Full Version : View changes in 3.3



Wasabi
01-27-2011, 11:18 AM
I'm used to using glFrustum, gluPerspective, glOrtho, gluOrtho2D, etc, however as I'm now trying to learn OpenGL 3.3 (my driver won't run 4.1), I'm looking at the 3.3 docs and have noticed that none of them (well, of the gl* functions) are there. glFrustum, glOrtho... all gone. If I try to use them in my code, they still compile, but the fact that they're out of the docs tells me they're only for legacy purposes. So... what are the new view-based functions for 3.3? And... how do I use them?

Alfonse Reinheart
01-27-2011, 12:00 PM
If I try to use them in my code, they still compile, but the fact that they're out of the docs tells me they're only for legacy purposes.

Just make a compatibility context and be done with it. If you don't know what that is, then you're probably already getting one and it's nothing to be concerned about.


So... what are the new view-based functions for 3.3?

There aren't any.

All these functions ever did was create matrices using well-understood parameters. OpenGL 3.3 core expects you to be able to do that yourself.

Jan
01-27-2011, 12:39 PM
Just google for gluPerspective etc. and you should find pages that show the (pseudo) code how they create the matrices.

Copy&Paste that into your own project and voila you can create those matrices yourself. Then upload them into the shaders and use them as in GL 2.1.

Jan.

Wasabi
01-27-2011, 01:29 PM
Ah, okay. The one good thing I learned in my CG class was all the matrices. Now I just need to dust off that notebook, wherever it is.

But... they go in the shader? That one blind-sided me.

ZbuffeR
01-27-2011, 01:50 PM
Send the projection matrix as uniform, multiply vertex position by matrix, and you get the projected coordinates.

Wasabi
01-28-2011, 08:51 AM
I suppose it'd be best to send the modelview matrix as well, to deal with any rotations and whatnot?

However, does this mean that I need to call glUniform*() whenever I do a view change?

Alfonse Reinheart
01-28-2011, 10:30 AM
However, does this mean that I need to call glUniform*() whenever I do a view change?

For each program that uses the appropriate matrices, yes.

Groovounet
01-28-2011, 10:44 AM
Or... you can use GLM (glm.g-truc.net) which implement already all these functions in a very OpenGL fashion.

In the documentation of the next release, the replacement functions are listed:
https://docs.google.com/document/pub?id=1R4H08fWX6MeGJ0N7LqQRLKkQ7Tn2S9yTrXOMYCEEZL I