Projection vs Modelview

Started by elias4444, December 08, 2004, 22:15:11

Previous topic - Next topic

elias4444

I'm a complete n00b, I know. But I can't seem to find an answer to this question:

What's the difference between using GL_PROJECTION (with glMatrixMode), and GL_MODELVIEW? What are they each for? If I enable modelview, I seem to get zoomed in to the extreme (I'm just doing a 2D game with OpenGL to speed things up).  Of course, I don't understand what the different variables are for in the gluPerspective command either (fovy? aspect?) :?:

When and how should you use the two?

Speaking of which, I can't seem to figure out the changes in all the sample code in the wiki to what works. Example, in a LOT of the code samples, they call Window.create rather than Display.create. They also often call Display.getWidth() and Display.getHeight() for the gluPerspective call. I don't seem to have any of those methods.  :?:  Have they been removed? Or are they hiding somewhere?

Please forgive the n00b for what I'm sure are evident answers to everyone else.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

trevorsm

Quote from: "elias4444"What's the difference between using GL_PROJECTION (with glMatrixMode), and GL_MODELVIEW? What are they each for? If I enable modelview, I seem to get zoomed in to the extreme (I'm just doing a 2D game with OpenGL to speed things up).  Of course, I don't understand what the different variables are for in the gluPerspective command either (fovy? aspect?) :?:

The projecton matrix is used for the viewing volume (calls to gluPerspective, glOrtho, glFrustum, etc), and the modelview matrix is for transforming the objects you draw (calls to glRotate*, glTranslate*, glScale*, etc). For most cases, you'll only want to set your viewing volume (projection matrix) when you create/resize the window, but you will modify the modelview matrix every frame (make sure to call glLoadIdentity on the modelview matrix each frame before drawing anything).

Also, if you're doing a 2D game, you'll probably want to consider using glOrtho instead of gluPerspective.

Quote from: "elias4444"Speaking of which, I can't seem to figure out the changes in all the sample code in the wiki to what works. Example, in a LOT of the code samples, they call Window.create rather than Display.create. They also often call Display.getWidth() and Display.getHeight() for the gluPerspective call. I don't seem to have any of those methods.  :?:  Have they been removed? Or are they hiding somewhere?

The code in most of the examples in the Wiki are way out of date and no longer work with the latest LWJGL releases. This one will work, but you'll have to modify it a bit if you don't have Java 1.5 (it has instructions on how to do this).

Just for reference, the Window class no longer exists, and windowing is now done through org.lwjgl.opengl.Display. The tutorial in the link above will show you how to do this.

elias4444

:idea:  :idea:  :idea:

Thanks.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

nihon-jin

Tutorials worked fine for me. I just renamed all "Window" stuff to "Display" and changed imports.

I'm not sure if its the best & correct way of doing things tho, but it works at least.