Graphics Programs Reference
In-Depth Information
Inside this loop, as soon as any orientation change is detected, _surfaceView be-
gins the rendering again, starting from the surfaceCreated method.
Listing 3-4 is an attempt to approximately describe the internal functioning of a ren-
derer thread (after an OpenGL surface view has been set as the activity's content
view). However, it is clear enough to help understand the use of abstract methods
implemented by the GLES20Renderer class.
Now, we create an application to test whether these methods get called in the order
we specified in the GL SURFACE application. To do so, create a new Android ap-
plication GL SURFACE CHANGED , and set the “Activity Name” to “Main.” Then,
copy the files and from GLSURFACE in-
to the package folder for this application (Eclipse will warn you that
exists in the selected destination; confirm overwriting of ).
Modify the GLES20Renderer class by adding the line of code shown in Listing
3-5 to its onSurfaceCreated method.
Listing 3-5. GL SURFACE CHANGED/src/com/apress/android/glsur-
We have not yet imported the Log class. Quick fix the error to import this class. Al-
though there are various methods we can use to log messages to the LogCat view (for
example, Log.v and Log.i ), we have used the d method to log a debug message.
Add lines similar to Listing 3-5 in the remaining methods, so the Renderer class be-
comes similar to Listing 3-6 .
Listing 3-6. GL SURFACE CHANGED/src/com/apress/android/glsur-
public class GLES20Renderer implements Renderer {
public void onSurfaceCreated(GL10 gl, EGLConfig
config) {
Search WWH ::

Custom Search