Switch fountain to use ProgramVertex rather than hard coded camers in scripts. Remove camera code from scripts.
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
index 0a0b05a..d167b5f 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainRS.java
@@ -18,12 +18,13 @@
import java.io.Writer;
-import android.renderscript.RenderScript;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.renderscript.RenderScript;
+import android.renderscript.ProgramVertexAlloc;
import android.util.Log;
public class FountainRS {
@@ -57,8 +58,10 @@
private RenderScript.ProgramFragmentStore mPFS;
private RenderScript.ProgramFragment mPF;
private RenderScript.ProgramFragment mPF2;
+ private RenderScript.ProgramVertex mPV;
private RenderScript.Allocation mTexture;
private RenderScript.Sampler mSampler;
+ private ProgramVertexAlloc mPVA;
private Bitmap mBackground;
@@ -107,6 +110,16 @@
mPF2.bindSampler(mSampler, 0);
mPF2.setName("PgmFragBackground");
+ mRS.programVertexBegin(null, null);
+ mPV = mRS.programVertexCreate();
+ mPVA = new ProgramVertexAlloc(mRS);
+ mPV.bindAllocation(0, mPVA.mAlloc);
+ mPVA.setupOrthoWindow(320, 480);
+ mRS.contextBindProgramVertex(mPV);
+
+
+
+
mParams[0] = 0;
mParams[1] = partCount;
mParams[2] = 0;
diff --git a/libs/rs/java/RenderScript/android/renderscript/Matrix.java b/libs/rs/java/RenderScript/android/renderscript/Matrix.java
index 03222aa..91e7b34 100644
--- a/libs/rs/java/RenderScript/android/renderscript/Matrix.java
+++ b/libs/rs/java/RenderScript/android/renderscript/Matrix.java
@@ -139,8 +139,8 @@
mMat[5] = 2 / (t - b);
mMat[10]= -2 / (f - n);
mMat[12]= -(r + l) / (r - l);
- mMat[12]= -(t + b) / (t - b);
- mMat[12]= -(f + n) / (f - n);
+ mMat[13]= -(t + b) / (t - b);
+ mMat[14]= -(f + n) / (f - n);
}
public void loadFrustum(float l, float r, float b, float t, float n, float f) {
diff --git a/libs/rs/java/RenderScript/android/renderscript/RenderScript.java b/libs/rs/java/RenderScript/android/renderscript/RenderScript.java
index afb4ae3..4d5c4a0 100644
--- a/libs/rs/java/RenderScript/android/renderscript/RenderScript.java
+++ b/libs/rs/java/RenderScript/android/renderscript/RenderScript.java
@@ -154,10 +154,7 @@
native private void nProgramVertexBindAllocation(int pv, int slot, int mID);
native private void nProgramVertexBegin(int inID, int outID);
native private void nProgramVertexSetType(int slot, int mID);
- native private void nProgramVertexSetCameraMode(boolean isOrtho);
native private void nProgramVertexSetTextureMatrixEnable(boolean enable);
- native private void nProgramVertexSetModelMatrixEnable(boolean enable);
- native private void nProgramVertexSetProjectionMatrixEnable(boolean enable);
native private int nProgramVertexCreate();
@@ -733,22 +730,10 @@
nProgramVertexSetType(slot, t.mID);
}
- public void programVertexSetCameraMode(boolean isOrtho) {
- nProgramVertexSetCameraMode(isOrtho);
- }
-
public void programVertexSetTextureMatrixEnable(boolean enable) {
nProgramVertexSetTextureMatrixEnable(enable);
}
- public void programVertexSetModelMatrixEnable(boolean enable) {
- nProgramVertexSetModelMatrixEnable(enable);
- }
-
- public void programVertexSetProjectionMatrixEnable(boolean enable) {
- nProgramVertexSetProjectionMatrixEnable(enable);
- }
-
public ProgramVertex programVertexCreate() {
int id = nProgramVertexCreate();
return new ProgramVertex(id);
diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c
index b81c567..56ee425 100644
--- a/libs/rs/java/Rollo/res/raw/rollo.c
+++ b/libs/rs/java/Rollo/res/raw/rollo.c
@@ -8,6 +8,7 @@
int x;
renderTriangleMesh(con, NAMED_MeshCard);
+ renderTriangleMesh(con, NAMED_MeshTab);
return 1;
}
diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloMesh.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloMesh.java
index c44a817..d7252fb 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloMesh.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloMesh.java
@@ -24,6 +24,11 @@
class RolloMesh {
+ static public final float mCardHeight = 1.2f;
+ static public final float mCardWidth = 1.8f;
+ static public final float mTabHeight = 0.2f;
+ static public final float mTabs = 3;
+ static public final float mTabGap = 0.1f;
static RenderScript.TriangleMesh createCard(RenderScript rs) {
RenderScript.Element vtx = rs.elementGetPredefined(
@@ -31,12 +36,15 @@
RenderScript.Element idx = rs.elementGetPredefined(
RenderScript.ElementPredefined.INDEX_16);
- rs.triangleMeshBegin(vtx, idx);
- rs.triangleMeshAddVertex_XYZ_ST(0, 0, 0, 0, 0);
- rs.triangleMeshAddVertex_XYZ_ST(0, 1, 0, 0, 1);
- rs.triangleMeshAddVertex_XYZ_ST(1, 1, 0, 1, 1);
- rs.triangleMeshAddVertex_XYZ_ST(1, 0, 0, 1, 0);
+ float w = mCardWidth / 2;
+ float h = mCardHeight;
+ float z = 0;
+ rs.triangleMeshBegin(vtx, idx);
+ rs.triangleMeshAddVertex_XYZ_ST(-w, 0, z, 0, 0);
+ rs.triangleMeshAddVertex_XYZ_ST(-w, h, z, 0, 1);
+ rs.triangleMeshAddVertex_XYZ_ST( w, h, z, 1, 1);
+ rs.triangleMeshAddVertex_XYZ_ST( w, 0, z, 1, 0);
rs.triangleMeshAddTriangle(0,1,2);
rs.triangleMeshAddTriangle(0,2,3);
return rs.triangleMeshCreate();
@@ -48,11 +56,28 @@
RenderScript.Element idx = rs.elementGetPredefined(
RenderScript.ElementPredefined.INDEX_16);
+
+ float tabSlope = 0.1f;
+ float num = 0;
+
+ float w = (mCardWidth - ((mTabs - 1) * mTabGap)) / mTabs;
+ float w1 = -(mCardWidth / 2) + ((w + mTabGap) * num);
+ float w2 = w1 + (w * tabSlope);
+ float w3 = w1 + w - (w * tabSlope);
+ float w4 = w1 + w;
+ float h1 = mCardHeight;
+ float h2 = h1 + mTabHeight;
+ float z = 0;
+
+ float stScale = w / mTabHeight / 2;
+ float stScale2 = stScale * (tabSlope / w);
+
+
rs.triangleMeshBegin(vtx, idx);
- rs.triangleMeshAddVertex_XYZ_ST(0.0f, 0, 0, -1.0f, 0);
- rs.triangleMeshAddVertex_XYZ_ST(0.2f, 1, 0, -0.8f, 1);
- rs.triangleMeshAddVertex_XYZ_ST(1.8f, 1, 0, 0.8f, 1);
- rs.triangleMeshAddVertex_XYZ_ST(2.0f, 0, 0, 1.0f, 0);
+ rs.triangleMeshAddVertex_XYZ_ST(w1, h1, z, -stScale, 0);
+ rs.triangleMeshAddVertex_XYZ_ST(w2, h2, z, -stScale2, 1);
+ rs.triangleMeshAddVertex_XYZ_ST(w3, h2, z, stScale2, 1);
+ rs.triangleMeshAddVertex_XYZ_ST(w4, h1, z, stScale, 0);
rs.triangleMeshAddTriangle(0,1,2);
rs.triangleMeshAddTriangle(0,2,3);
return rs.triangleMeshCreate();
diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
index aa9f338..da0b146 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -74,8 +74,8 @@
//private float[] mBufferPV;
private void initNamed() {
- //mMeshTab = RolloMesh.createTab(mRS);
- //mMeshTab.setName("MeshTab");
+ mMeshTab = RolloMesh.createTab(mRS);
+ mMeshTab.setName("MeshTab");
mMeshCard = RolloMesh.createCard(mRS);
mMeshCard.setName("MeshCard");
Log.e("rs", "Done loading strips");
@@ -117,10 +117,7 @@
mPVAlloc = new ProgramVertexAlloc(mRS);
mRS.programVertexBegin(null, null);
- mRS.programVertexSetCameraMode(true);
mRS.programVertexSetTextureMatrixEnable(true);
- mRS.programVertexSetModelMatrixEnable(true);
- mRS.programVertexSetProjectionMatrixEnable(true);
mPV = mRS.programVertexCreate();
mPV.setName("PV");
mPV.bindAllocation(0, mPVAlloc.mAlloc);