Game Development Reference
In-Depth Information
public class QuakeRenderer implements GLSurfaceView.Renderer {
@Override
public void onDrawFrame(GL10 arg0) {
if (mGameLoaded) {
Natives.RenderFrame();
}
}
@Override
public void onSurfaceChanged(GL10 arg0, int width, int height) {
Log.d(TAG, "onSurfaceChanged w=" + width + " h=" + height);
}
@Override
public void onSurfaceCreated(GL10 arg0, EGLConfig arg1) {
Log.d(TAG, "onSurfaceCreated");
if (mArgs != null) {
mGameLoaded = true;
Natives.QuakeMain(mArgs);
}
}
}
/**
* Native Callbacks
*/
@Override
public void OnInitVideo(int w, int h) {
Log.d(TAG, "OnInitVideo. " + w + "x" + h + " Starting native audio.");
// Native audio
NativeAudio.start();
}}
The class QuakeView from Listing 6-3 extends the built-in class GLSurfaceView , which provides
a surface for rendering using OpenGL. QuakeView also includes the following classes:
QuakeRenderer : An inner class that creates a simple OpenGL renderer,
which can be used to call native functions on the C engine. This class
provides the following events:
onDrawFrame : This event fires whenever the renderer draws a frame
and is used to perform OpenGL API calls. It has one argument:
GL10 , the interface to the OpenGL context. In a pure Java game,
this context will be used to perform GL API calls; however, you are
rendering everything in the native side so this parameter is not used.
 
Search WWH ::




Custom Search