package jp.vixar.aquamotion3d;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.Display;
import android.view.MotionEvent;

public class MainActivity extends Activity
{
    private AquaMotion3D _renderer;
    private GLSurfaceView mGLSurfaceView;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        mGLSurfaceView = new GLSurfaceView(this);
        mGLSurfaceView.setEGLContextClientVersion(2);
        _renderer = new AquaMotion3D(this);
        mGLSurfaceView.setRenderer(_renderer);
        setContentView(mGLSurfaceView);
   }

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
    	float x = event.getX();
    	float y = event.getY();
    	switch (event.getAction())
    	{
    	case MotionEvent.ACTION_DOWN:
   			_renderer.actionDown(x,y);
    		break;
    	case MotionEvent.ACTION_MOVE:
   			_renderer.actionMove(x,y);
   		break;
    	case MotionEvent.ACTION_UP:
    		_renderer.actionUp(x,y);
            break;
    	}
    	return true;
    }

    @Override
    protected void onResume()
    {
        super.onResume();
        mGLSurfaceView.onResume();
    }

    @Override
    protected void onPause()
    {
        super.onPause();
        mGLSurfaceView.onPause();
    }
}
