Game Development Reference
In-Depth Information
The way of a triangle through this pipeline looks as follows:
1.
Our brave triangle is first transformed by the model-view matrix. This
means that all its points are multiplied with this matrix. This multiplication
will effectively move the triangle's points around in the world.
2.
The resulting output is then multiplied by the projection matrix, effectively
transforming the 3D points onto the 2D projection plane.
3.
In between these two steps (or parallel to them), the currently set lights
and materials are also applied to our triangle, giving it its color.
4.
Once all that is done, the projected triangle is clipped to our “retina�
and transformed to framebuffer coordinates by applying the viewport
transformation.
5.
As a final step, OpenGL fills in the pixels of the triangle based on the
colors from the lighting stage, textures to be applied to the triangle, and
the blending state in which each pixel of the triangle might or might not
be combined with the pixel in the framebuffer.
All you need to learn is how to throw geometry and textures at OpenGL ES, and to set the states
used by each of the preceding steps. Before you can do that, you need to see how Android
grants you access to OpenGL ES.
Note While the high-level description of the OpenGL ES pipeline is mostly correct, it is heavily
simplified and leaves out some details that will become important in a later chapter. Another
thing to note is that when OpenGL ES performs projections, it doesn't actually project onto a
2D coordinate system; instead, it projects into something called a homogenous coordinate system ,
which is actually four dimensional. This is a very involved mathematical topic, so for the sake of
simplicity, we'll just stick to the simplified premise that OpenGL ES projects to
2D coordinates.
Before We Begin
Throughout the rest of this chapter, we'll provide many brief examples, as we did in Chapter 4
when we discussed Android API basics. We'll use the same starter class that we did in Chapter 4,
which shows you a list of starter activities you can start. The only things that will change are the
names of the activities you instantiate via reflection, and the package in which they are located.
All the examples in the rest of this chapter will be in the package com.badlogic.androidgames.
glbasics . The rest of the code will stay the same. Your new starter activity will be called
GLBasicsStarter . You will also copy over all the source code from Chapter 5, namely the com.
badlogic.androidgames.framework package and all its subpackages. In this chapter, you will
write some new framework and helper classes, which will go in the com.badlogic.androidgames.
framework package and subpackages.
 
Search WWH ::




Custom Search