Do not call exit() when app put to background, we'll recreate GL textures from SDL (not done yet!)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package com.sourceforge.sc2;
|
||||
package com.googlecode.opentyrian;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
@@ -23,23 +23,46 @@ import java.lang.Thread;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import android.os.Build;
|
||||
|
||||
abstract class DifferentTouchInput
|
||||
abstract class DifferentTouchInput
|
||||
{
|
||||
public static DifferentTouchInput getInstance()
|
||||
{
|
||||
public static DifferentTouchInput getInstance()
|
||||
if (Integer.parseInt(Build.VERSION.SDK) <= 4)
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
else
|
||||
return MultiTouchInput.Holder.sInstance;
|
||||
}
|
||||
public abstract void process(final MotionEvent event);
|
||||
private static class SingleTouchInput extends DifferentTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
if (Integer.parseInt(Build.VERSION.SDK) <= 4)
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
else
|
||||
return MultiTouchInput.Holder.sInstance;
|
||||
private static final SingleTouchInput sInstance = new SingleTouchInput();
|
||||
}
|
||||
public abstract void process(final MotionEvent event);
|
||||
private static class SingleTouchInput extends DifferentTouchInput
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final SingleTouchInput sInstance = new SingleTouchInput();
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
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 )
|
||||
DemoGLSurfaceView.nativeMouse( (int)event.getX(), (int)event.getY(), action, 0,
|
||||
(int)(event.getPressure() * 1000.0),
|
||||
(int)(event.getSize() * 1000.0) );
|
||||
}
|
||||
}
|
||||
private static class MultiTouchInput extends DifferentTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final MultiTouchInput sInstance = new MultiTouchInput();
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
for( int i = 0; i < event.getPointerCount(); i++ )
|
||||
{
|
||||
int action = -1;
|
||||
if( event.getAction() == MotionEvent.ACTION_DOWN )
|
||||
@@ -49,39 +72,16 @@ import android.os.Build;
|
||||
if( event.getAction() == MotionEvent.ACTION_MOVE )
|
||||
action = 2;
|
||||
if ( action >= 0 )
|
||||
DemoGLSurfaceView.nativeMouse( (int)event.getX(), (int)event.getY(), action, 0,
|
||||
(int)(event.getPressure() * 1000.0),
|
||||
(int)(event.getSize() * 1000.0) );
|
||||
}
|
||||
}
|
||||
private static class MultiTouchInput extends DifferentTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final MultiTouchInput sInstance = new MultiTouchInput();
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
for( int i = 0; i < event.getPointerCount(); i++ )
|
||||
{
|
||||
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 )
|
||||
DemoGLSurfaceView.nativeMouse( (int)event.getX(i),
|
||||
(int)event.getY(i),
|
||||
action,
|
||||
event.getPointerId(i),
|
||||
(int)(event.getPressure(i) * 1000.0),
|
||||
(int)(event.getSize(i) * 1000.0));
|
||||
}
|
||||
DemoGLSurfaceView.nativeMouse( (int)event.getX(i),
|
||||
(int)event.getY(i),
|
||||
action,
|
||||
event.getPointerId(i),
|
||||
(int)(event.getPressure(i) * 1000.0),
|
||||
(int)(event.getSize(i) * 1000.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
@@ -92,13 +92,15 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
}
|
||||
|
||||
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 onSurfaceDestroyed() {
|
||||
nativeGlContextLost();
|
||||
};
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
|
||||
@@ -122,7 +124,6 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
synchronized (this) {
|
||||
this.notify();
|
||||
}
|
||||
//Thread.yield();
|
||||
return super.SwapBuffers() ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -134,6 +135,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
private native void nativeInit();
|
||||
private native void nativeResize(int w, int h);
|
||||
private native void nativeDone();
|
||||
private native void nativeGlContextLost();
|
||||
|
||||
private Activity context = null;
|
||||
|
||||
@@ -177,7 +179,6 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
System.exit(0); // Not implemented yet
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user