GlViewport and Screen Size

glViewport is responsible for specifying the rectangular area on the screen onto which the viewing volume will be projected. This method takes four arguments to specify the rectangular box: the x and y coordinates of the lower-left corner, followed by the width and height. Here is an example of specifying a view as the target for this projection:

glViewport(0, // lower left "x" of the rectangle on the screen

0, // lower left "y" of the rectangle on the screen width, // width of the rectangle on the screen height); // height of the rectangle on the screen

If your window or view size is 100 pixels in height and your frustum height is 10 units, then every logical unit of 1 translates to 10 pixels.

Congratulations. In the last few subsections, you have reached an important milestone in understanding OpenGL. Most OpenGL books take multiple chapters to bring you to this stage. This knowledge should keep you in good stead for the rest of the chapter and also for a general understanding of OpenGL on any platform.

This brings us to the next subsection, where we will explain how the standards-based OpenGL ES API is tied to Android. This is done through EGL and Android-specific concepts. We will cover this now, and then go on to the test harness.

0 -1

Post a comment