21 package com.arm.malideveloper.openglessdk.computeparticles;
24 import java.io.InputStream;
25 import java.io.RandomAccessFile;
26 import android.os.Bundle;
27 import android.app.Activity;
28 import android.content.res.AssetManager;
29 import android.util.Log;
30 import javax.microedition.khronos.egl.EGLConfig;
31 import javax.microedition.khronos.opengles.GL10;
32 import android.content.Context;
33 import android.opengl.GLSurfaceView;
34 import android.os.Bundle;
35 import android.view.Window;
36 import android.view.WindowManager;
37 import android.view.MotionEvent;
38 import android.view.Display;
39 import com.arm.malideveloper.openglessdk.*;
43 public ComputeView(Context context)
45 super(context, GlesVersion.GLES3);
48 @Override
protected void setRendererCallback()
50 setRenderer(
new Renderer());
53 @Override
protected void destroyContextCallback()
55 ComputeParticles.uninit();
58 public boolean onTouchEvent(MotionEvent event)
64 float x = event.getRawX() / 2.0
f;
65 float y = event.getRawY() / 2.0
f;
67 if (event.getAction() == MotionEvent.ACTION_UP)
69 else if (event.getAction() == MotionEvent.ACTION_MOVE)
78 ComputeParticles.step();
97 private static String
LOGTAG =
"ComputeParticles";
100 public static native
void step();
101 public static native
void uninit();
105 @Override
protected void onCreate(Bundle savedInstanceState)
107 super.onCreate(savedInstanceState);
111 this.requestWindowFeature(Window.FEATURE_NO_TITLE);
112 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
113 WindowManager.LayoutParams.FLAG_FULLSCREEN);
135 mView =
new ComputeView(getApplication());
138 Display display = getWindowManager().getDefaultDisplay();
139 int width = display.getWidth();
140 int height = display.getHeight();
141 mView.getHolder().setFixedSize(width / 2, height / 2);
142 setContentView(mView);
167 Log.d(
LOGTAG, assetName +
" already exists. No extraction needed.\n");
169 Log.d(
LOGTAG, assetName +
" doesn't exist. Extraction needed. \n");
172 RandomAccessFile randomAccessFile =
new RandomAccessFile(
assetsDirectory + assetName,
"rw");
173 AssetManager assetManager = applicationContext.getResources().getAssets();
174 InputStream inputStream = assetManager.open(assetName);
176 byte
buffer[] =
new byte[1024];
182 count = inputStream.read(
buffer, 0, 1024);
185 randomAccessFile.close();
187 }
catch(Exception e) {
192 Log.d(
LOGTAG,
"File extracted successfully");
200 System.loadLibrary(
"Native");
void extractAsset(String assetName)
static android.content.Context applicationContext
void onDrawFrame(GL10 gl)
static native void uninit()
GLint GLsizei GLsizei height
void onSurfaceChanged(GL10 gl, int width, int height)
static native void onpointerup(float x, float y)
GLenum GLenum GLsizei count
static native void step()
void onSurfaceCreated(GL10 gl, EGLConfig config)
static native void init(int width, int height)
GLint GLint GLint GLint GLint x
static String assetsDirectory
void onCreate(Bundle savedInstanceState)
static native void onpointerdown(float x, float y)