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.
GL SURFACE CHANGED Application
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 Main.java and GLES20Renderer.java from GLSURFACE in-
to the package folder for this application (Eclipse will warn you that Main.java
exists in the selected destination; confirm overwriting of Main.java ).
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-
facechanged/GLES20Renderer.java
Log.d("onSurfaceCreated","invoked");
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-
facechanged/GLES20Renderer.java
public class GLES20Renderer implements Renderer {
public void onSurfaceCreated(GL10 gl, EGLConfig
config) {
 
 
 
 
Search WWH ::




Custom Search