|
|
#1 |
|
Very Simple Explanation of glOrthof() in OpenGL ES
I saw some previous posts and explantations on the internet of glOrthof, but I just don't get it. I am watching the Stanford OpenGL ES lesson on Youtube and the following code came up:
Code:
glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0, backingWidth, 0, backingHeight, -1, 1); http://www.stanford.edu/class/cs193p/cgi-bin/drupal/node/79 (The file where this code appears is ESRenderer1.m) Thanks! |
|
|
|
0
|
|
|
#2 |
|
The arguments you pass to glOrtho define the boundaries of the projection. For 2D drawing, glOrtho defines the visible area of the screen in OpenGL units. In the code you listed, calling glOrtho sets the lower left corner of the screen to (0, 0) and the upper right corner of the screen to (backingWidth, backingHeight). Anything drawn in the range of (0, 0) to (backingWidth, backingHeight) will be visible on the screen. Assuming that backingWidth and backingHeight are the width and height of the screen in pixels, the code you listed sets a projection where one OpenGL unit equals one screen pixel.
Why does the example draw the picture with a size of one pixel? I haven't looked at the code, but my guess is the code draws from 0 to 1 in OpenGL units. Since you set up the projection so one OpenGL unit equals one pixel, the drawn picture is one pixel in size. If you modify the call to glOrtho by substituting 1 for backingWidth and backingHeight, the picture should fill the screen. Last edited by szymczyk; Dec 29, 2012 at 12:41 PM. |
|
|
|
0
|
|
|
#3 |
|
Great explanation! That makes a lot of sense. Thank You!
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 04:05 PM.






Linear Mode
