summaryrefslogtreecommitdiffstats
path: root/libs/rs/java
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2010-12-13 15:32:35 -0800
committerJason Sams <rjsams@android.com>2010-12-13 15:32:35 -0800
commitd4b23b54445b13dacaafad97d100999abb36ea6f (patch)
tree265a246ae22c5b726690c422bc5c5518e6d445a0 /libs/rs/java
parent666a5ed98142867bcd6658c97210b775c828dae5 (diff)
downloadframeworks_base-d4b23b54445b13dacaafad97d100999abb36ea6f.zip
frameworks_base-d4b23b54445b13dacaafad97d100999abb36ea6f.tar.gz
frameworks_base-d4b23b54445b13dacaafad97d100999abb36ea6f.tar.bz2
More API updates.
Change-Id: I754dc645ac08fa25019eed8fd8b7b3c47f178ff2
Diffstat (limited to 'libs/rs/java')
-rw-r--r--libs/rs/java/Balls/src/com/android/balls/BallsRS.java27
-rw-r--r--libs/rs/java/Balls/src/com/android/balls/balls.rs22
2 files changed, 11 insertions, 38 deletions
diff --git a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
index 4338f33..0a06394 100644
--- a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
+++ b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java
@@ -34,11 +34,12 @@ public class BallsRS {
private ProgramFragment mPFPoints;
private ProgramVertex mPV;
private ScriptField_Point mPoints;
- private ScriptField_Point mArcs;
private ScriptField_VpConsts mVpConsts;
void updateProjectionMatrices() {
- mVpConsts = new ScriptField_VpConsts(mRS, 1);
+ mVpConsts = new ScriptField_VpConsts(mRS, 1,
+ Allocation.USAGE_SCRIPT |
+ Allocation.USAGE_GRAPHICS_CONSTANTS);
ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item();
Matrix4f mvp = new Matrix4f();
mvp.loadOrtho(0, mRS.getWidth(), mRS.getHeight(), 0, -1, 1);
@@ -67,9 +68,10 @@ public class BallsRS {
}
private Allocation loadTexture(int id) {
- final Allocation allocation = Allocation.createFromBitmapResource(mRS, mRes,
- id, Element.RGB_565(mRS), false);
- allocation.uploadToTexture(0);
+ final Allocation allocation =
+ Allocation.createFromBitmapResource(mRS, mRes,
+ id, Allocation.MipmapControl.MIPMAP_NONE,
+ Allocation.USAGE_GRAPHICS_TEXTURE);
return allocation;
}
@@ -88,31 +90,24 @@ public class BallsRS {
pfb.setVaryingColor(true);
mPFLines = pfb.create();
+ android.util.Log.e("rs", "Load texture");
mPFPoints.bindTexture(loadTexture(R.drawable.flares), 0);
- mPoints = new ScriptField_Point(mRS, PART_COUNT);
- mArcs = new ScriptField_Point(mRS, PART_COUNT * 2);
+ mPoints = new ScriptField_Point(mRS, PART_COUNT, Allocation.USAGE_SCRIPT);
Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
smb.addVertexAllocation(mPoints.getAllocation());
smb.addIndexType(Primitive.POINT);
Mesh smP = smb.create();
- smb = new Mesh.AllocationBuilder(mRS);
- smb.addVertexAllocation(mArcs.getAllocation());
- smb.addIndexType(Primitive.LINE);
- Mesh smA = smb.create();
-
mPhysicsScript = new ScriptC_ball_physics(mRS, mRes, R.raw.ball_physics);
mScript = new ScriptC_balls(mRS, mRes, R.raw.balls);
mScript.set_partMesh(smP);
- mScript.set_arcMesh(smA);
mScript.set_physics_script(mPhysicsScript);
mScript.bind_point(mPoints);
- mScript.bind_arc(mArcs);
- mScript.bind_balls1(new ScriptField_Ball(mRS, PART_COUNT));
- mScript.bind_balls2(new ScriptField_Ball(mRS, PART_COUNT));
+ mScript.bind_balls1(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT));
+ mScript.bind_balls2(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT));
mScript.set_gPFLines(mPFLines);
mScript.set_gPFPoints(mPFPoints);
diff --git a/libs/rs/java/Balls/src/com/android/balls/balls.rs b/libs/rs/java/Balls/src/com/android/balls/balls.rs
index c41ed0f..fed9963 100644
--- a/libs/rs/java/Balls/src/com/android/balls/balls.rs
+++ b/libs/rs/java/Balls/src/com/android/balls/balls.rs
@@ -10,18 +10,14 @@
rs_program_fragment gPFPoints;
rs_program_fragment gPFLines;
rs_mesh partMesh;
-rs_mesh arcMesh;
typedef struct __attribute__((packed, aligned(4))) Point {
float2 position;
- //uchar4 color;
float size;
} Point_t;
Point_t *point;
-Point_t *arc;
typedef struct VpConsts {
- //rs_matrix4x4 Proj;
rs_matrix4x4 MVP;
} VpConsts_t;
VpConsts_t *vpConstants;
@@ -42,8 +38,6 @@ void initParts(int w, int h)
balls1[ct].position.y = rsRand(0.f, (float)h);
balls1[ct].delta.x = 0.f;
balls1[ct].delta.y = 0.f;
- //balls1[ct].arcID = -1;
- //balls1[ct].color = 0.f;
balls1[ct].size = 1.f;
float r = rsRand(100.f);
@@ -76,28 +70,12 @@ int root() {
rsForEach(physics_script, bc.ain, bc.aout, &bc);
- uint32_t arcIdx = 0;
for (uint32_t ct=0; ct < bc.dimX; ct++) {
point[ct].position = bout[ct].position;
- ///point[ct].color = 0xff;//rsPackColorTo8888(bout[ct].color);
point[ct].size = 6.f /*+ bout[ct].color.g * 6.f*/ * bout[ct].size;
-/*
- if (bout[ct].arcID >= 0) {
- arc[arcIdx].position = bout[ct].position;
- arc[arcIdx].color.r = min(bout[ct].arcStr, 1.f) * 0xff;
- arc[arcIdx].color.g = 0;
- arc[arcIdx].color.b = 0;
- arc[arcIdx].color.a = 0xff;
- arc[arcIdx+1].position = bout[bout[ct].arcID].position;
- arc[arcIdx+1].color = arc[arcIdx].color;
- arcIdx += 2;
- }
- */
}
frame++;
- //rsgBindProgramFragment(gPFLines);
- //rsgDrawMesh(arcMesh, 0, 0, arcIdx);
rsgBindProgramFragment(gPFPoints);
rsgDrawMesh(partMesh);
rsClearObject(&bc.ain);