lid6j86's picture

Perspective

I keep seeing all these examples with gluPerspective, and I'm reading about gluPerspective, and that it is for 3d rendering (whereas ortho is for 2d rendering), but I can't seem to find the method anywhere. I've looked in a dozen places, including under GL., i've tried to find Glu, etc... and I can't find it. did OpenTK change how that works, or how to call it?

i saw something about setting up a frustrum or something... is that what it has switched to?

I'm ok on a 2d setting now for setting up the window but i'm having a heck of a time getting started on the 3d perspective.

one last question, does OpenTK default as a left handed or right handed coordinate system? (i prefer for it to be left handed)

Thanks.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Showle1943's picture
lid6j86 wrote:

I keep seeing all these examples with gluPerspective, and I'm reading about gluPerspective, and that it is for 3d rendering (whereas ortho is for 2d rendering), but I can't seem to find the method anywhere. I've looked in a dozen places, including under GL., i've tried to find Glu, etc... and I can't find it. did OpenTK change how that works, or how to call it?

i saw something about setting up a frustrum or something... is that what it has switched to?

I'm ok on a 2d setting now for setting up the window but i'm having a heck of a time getting started on the 3d perspective.

one last question, does OpenTK default as a left handed or right handed coordinate system? (i prefer for it to be left handed)

Thanks.

I'm trying to find the same answer - have scoured dozens of sites but nothing. If you find an answer please let me know.

jrwatts's picture

GLU is old and deprecated, but you can still access it, if you wish, with OpenTK.Compatibility.

Edit: Ignore the following sentence; I was half-asleep when typing it and completely wrong (see later comment for correct answer)!
I believe the preferred replacement for gluPerspective() is Matrix4.LookAt()...search for that on the forums and you'll find plenty of examples of how to use it.

Also, OpenGL is right-handed by default, but can easily be transformed for left-handed coordinates with GL.Scale(1.0, 1.0, -1.0) (you may need to swap your vertex winding, as well).

lid6j86's picture

I have vertex winding to counterclockwise.

i thought matrix4.lookat was for something different, i'll take a look

lid6j86's picture

Is there any way the admins can add to the documentation list on the site about Matrix4? seems like it's quite important as the basis for 3d perspective mode, etc...

jrwatts's picture

Gah, this is what happens when you try to answer questions while half-asleep! Sorry, Matrix4.LookAt() is, of course, the replacement for gluLookAt(), not gluPerspective()! Off the top of my head, I'm not sure what to use in place of gluPerspective() (although I vaguely recall this topic coming up before).

Edit: Did a search of the forums for gluPerspective, and found an alternate implementation in this thread: http://www.opentk.com/node/2050 (see the Glu.cs file attached to the second-to-last comment).

lid6j86's picture

think i finally found it:

http://stackoverflow.com/questions/2417697/gluperspective-was-removed-in..., just needs translated.

anyone have any idea why gluperspective was depreciated from OpenGL? It seems like it was fairly easy to use and impliment, but they got rid of it in favor of forcing you to do it manually... was it causing too many errors of some sort?

jrwatts's picture

http://stackoverflow.com/questions/1218449/opengl-whats-the-deal-with-de... (from the same site as your link) does a fairly good job of explaining why various functions (in particular, the whole fixed function pipeline) have been deprecated (in a nutshell, it's too hard to make sure new features work with the old stuff).

http://stackoverflow.com/questions/2079038/new-to-opengl-and-deprecation points to some tutorials that don't use the deprecated functions.

Really, I see no problem with just sticking with OpenGL 2.0 functionality and ignoring all the deprecation, if you're writing a simple program that doesn't need the latest features (it seems unlikely to me that hardware manufacturers will drop support for OpenGL 2.0 any time soon). (And I'm sure there are plenty of people on this forum who disagree with me!)

lid6j86's picture

So 1 more question for now until a later time when I bug you all again:

I'm looking at this Matrix4 stuff, but there are a lot of things that look very similar.

For instance, what is the difference between Matrix4.CreatePerspectiveFieldofView and Matrix4.Perspective?

They both look like they have the same parameters, and they both have the same description

anyways, it might make sense to make a small dedicated tutorial to matrix4 and its possibilities/ some examples.