Game Development Reference
In-Depth Information
Listing 3-1 shows the JavaGLActivity.java file.
Listing 3-1. Main Activity for the OpenGL Sample
package opengl.test;
import opengl.test.MyGLRenderer;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.opengl.GLSurfaceView;
public class JavaGLActivity extends ActionBarActivity {
private GLSurfaceView glView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
glView = new GLSurfaceView(this);
glView.setRenderer(new MyGLRenderer(this));
this.setContentView(glView);
}
@Override
protected void onPause() {
super.onPause();
glView.onPause();
}
@Override
protected void onResume() {
super.onResume();
glView.onResume();
}
}
The JavaGLActivity.java overrides onCreate() , onPause() , and onResume() . Then, override
onCreate() to allocate the GLSurfaceView , set the view's renderer to a custom renderer, and
finally, set this activity to use the view.
The next step is to create two new Java classes such as MyGLRenderer.java and
Mytriangle.java .
 
Search WWH ::




Custom Search