133 lines
3.4 KiB
Java
133 lines
3.4 KiB
Java
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
|
package de.schwardtnet.alienblaster;
|
|
|
|
import javax.microedition.khronos.opengles.GL10;
|
|
|
|
import javax.microedition.khronos.egl.EGL10;
|
|
import javax.microedition.khronos.egl.EGL11;
|
|
import javax.microedition.khronos.egl.EGLConfig;
|
|
import javax.microedition.khronos.egl.EGLContext;
|
|
import javax.microedition.khronos.egl.EGLDisplay;
|
|
import javax.microedition.khronos.egl.EGLSurface;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.view.MotionEvent;
|
|
import android.view.KeyEvent;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
|
|
import android.widget.TextView;
|
|
import java.lang.Thread;
|
|
|
|
|
|
class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
|
|
|
public DemoRenderer(Activity _context)
|
|
{
|
|
context = _context;
|
|
}
|
|
|
|
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
|
// nativeInit();
|
|
}
|
|
|
|
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
|
//gl.glViewport(0, 0, w, h);
|
|
nativeResize(w, h);
|
|
}
|
|
|
|
public void onDrawFrame(GL10 gl) {
|
|
|
|
nativeInitJavaCallbacks();
|
|
|
|
// Make main thread priority lower so audio thread won't get underrun
|
|
// Thread.currentThread().setPriority((Thread.currentThread().getPriority() + Thread.MIN_PRIORITY)/2);
|
|
|
|
System.loadLibrary("application");
|
|
System.loadLibrary("sdl_main");
|
|
|
|
nativeInit(); // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
|
|
System.exit(0);
|
|
}
|
|
|
|
public int swapBuffers() // Called from native code, returns 1 on success, 0 when GL context lost (user put app to background)
|
|
{
|
|
return super.SwapBuffers() ? 1 : 0;
|
|
}
|
|
|
|
public void exitApp() {
|
|
nativeDone();
|
|
};
|
|
|
|
private native void nativeInitJavaCallbacks();
|
|
private native void nativeInit();
|
|
private native void nativeResize(int w, int h);
|
|
private native void nativeDone();
|
|
|
|
private Activity context = null;
|
|
|
|
private EGL10 mEgl = null;
|
|
private EGLDisplay mEglDisplay = null;
|
|
private EGLSurface mEglSurface = null;
|
|
private EGLContext mEglContext = null;
|
|
private int skipFrames = 0;
|
|
|
|
}
|
|
|
|
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
|
public DemoGLSurfaceView(Activity context) {
|
|
super(context);
|
|
mParent = context;
|
|
setEGLConfigChooser(Globals.NeedDepthBuffer);
|
|
accelerometer = new AccelerometerReader(context);
|
|
mRenderer = new DemoRenderer(context);
|
|
setRenderer(mRenderer);
|
|
}
|
|
|
|
@Override
|
|
public boolean onTouchEvent(final MotionEvent event)
|
|
{
|
|
// TODO: add multitouch support (added in Android 2.0 SDK)
|
|
int action = -1;
|
|
if( event.getAction() == MotionEvent.ACTION_DOWN )
|
|
action = 0;
|
|
if( event.getAction() == MotionEvent.ACTION_UP )
|
|
action = 1;
|
|
if( event.getAction() == MotionEvent.ACTION_MOVE )
|
|
action = 2;
|
|
if ( action >= 0 ) {
|
|
nativeMouse( (int)event.getX(), (int)event.getY(), action );
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void exitApp() {
|
|
mRenderer.exitApp();
|
|
accelerometer.stop();
|
|
accelerometer = null;
|
|
};
|
|
|
|
@Override
|
|
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
|
nativeKey( keyCode, 1 );
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
|
nativeKey( keyCode, 0 );
|
|
return true;
|
|
}
|
|
|
|
DemoRenderer mRenderer;
|
|
Activity mParent;
|
|
AccelerometerReader accelerometer = null;
|
|
|
|
public native void nativeMouse( int x, int y, int action );
|
|
public native void nativeKey( int keyCode, int down );
|
|
}
|
|
|
|
|