55 lines
1.5 KiB
Java
55 lines
1.5 KiB
Java
package com.ea.ironmonkey;
|
|
|
|
import android.opengl.GLSurfaceView;
|
|
import javax.microedition.khronos.egl.EGLConfig;
|
|
import javax.microedition.khronos.opengles.GL10;
|
|
|
|
|
|
public class GameRenderer implements GLSurfaceView.Renderer {
|
|
static GL10 _gl;
|
|
private int _height;
|
|
private int _width;
|
|
private GameActivityMain activity;
|
|
private DrawFrameListener drawFrameListener;
|
|
|
|
public GameRenderer(GameActivityMain gameActivityMain) {
|
|
this.activity = gameActivityMain;
|
|
}
|
|
|
|
public void setDrawFrameListener(DrawFrameListener drawFrameListener) {
|
|
this.drawFrameListener = drawFrameListener;
|
|
}
|
|
|
|
public int getWidth() {
|
|
return this._width;
|
|
}
|
|
|
|
public int getHeight() {
|
|
return this._height;
|
|
}
|
|
|
|
@Override // android.opengl.GLSurfaceView.Renderer
|
|
public void onSurfaceCreated(GL10 gl10, EGLConfig eGLConfig) {
|
|
this.activity.nativeSurfaceCreated(gl10, eGLConfig);
|
|
}
|
|
|
|
@Override // android.opengl.GLSurfaceView.Renderer
|
|
public void onSurfaceChanged(GL10 gl10, int i, int i2) {
|
|
if (gl10 != _gl) {
|
|
this.activity.nativeSurfaceChanged(gl10, i, i2);
|
|
_gl = gl10;
|
|
}
|
|
this._width = i;
|
|
this._height = i2;
|
|
}
|
|
|
|
@Override // android.opengl.GLSurfaceView.Renderer
|
|
public void onDrawFrame(GL10 gl10) {
|
|
if (this.drawFrameListener != null) {
|
|
this.drawFrameListener.onDrawFrame(gl10);
|
|
} else {
|
|
this.activity.getRunLoop().onRunLoopTick();
|
|
}
|
|
}
|
|
}
|