Game Development Reference
In-Depth Information
Listing 2-3. MyGLRenderer Custom Renderer Class
package robs.demo.robssimplegldemo;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
public class MyGLRenderer implements GLSurfaceView.Renderer
{
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config)
{
// Called when an new surface has been created
// Create OpenGL resources here
}
@Override
public void onSurfaceChanged(GL10 unused, int width, int height)
{
// Called when new GL Surface has been created or changes size
// Set the OpenglES camera viewport here
}
@Override
public void onDrawFrame(GL10 unused)
{
// Put code to draw 3d objects to screen here
}
}
Basic Android OpenGL ES Framework for a Multiple View OpenGL
ES Application
In this section, we will cover the basic framework for an OpenGL program that contains multiple
View objects inside your user interface or layout, such as those including Text views, Edit Box views,
as well as having an OpenGL view. For example, you can have a portion of your screen with an
EditBox view where the user can enter his name using the standard virtual Android keyboard that is
already built into software and another portion of the screen running an OpenGL animation.
The XML Layout File
The following XML layout file is a linear layout with three view components: a TextView component,
an EditText component, and a custom GLSurfaceView component called MyGLSurfaceView.
 
Search WWH ::




Custom Search