Update rollo and support functions. Includes mockup of some new ui concepts.
diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c
index 56ee425..e6acc9c 100644
--- a/libs/rs/java/Rollo/res/raw/rollo.c
+++ b/libs/rs/java/Rollo/res/raw/rollo.c
@@ -5,10 +5,58 @@
int main(void* con, int ft, int launchID)
{
+ int rowCount;
int x;
+ int y;
+ int row;
+ int col;
+ int imageID;
+ int tx1;
+ int ty1;
+ int tz1;
+ int tx2;
+ int ty2;
+ int tz2;
+ int rot;
+ int rotStep;
+ int tmpSin;
+ int tmpCos;
+ int iconCount;
+ int pressure;
- renderTriangleMesh(con, NAMED_MeshCard);
- renderTriangleMesh(con, NAMED_MeshTab);
+
+ iconCount = 38;//loadI32(0, 1);
+ rotStep = 20 * 0x10000;
+ pressure = loadI32(0, 2);
+
+ rowCount = 4;
+ rot = (-20 + loadI32(0, 0)) * 0x10000;
+
+ while (iconCount) {
+ tmpSin = sinx(rot);
+ tmpCos = cosx(rot);
+
+ tx1 = tmpSin * 8 - tmpCos;
+ tx2 = tx1 + tmpCos * 2;
+
+ tz1 = tmpCos * 8 + tmpSin + pressure;
+ tz2 = tz1 - tmpSin * 2;
+
+ for (y = 0; (y < rowCount) && iconCount; y++) {
+ ty1 = (y * 0x30000) - 0x48000;
+ ty2 = ty1 + 0x20000;
+
+ drawQuad(tx1, ty1, tz1,
+ tx2, ty1, tz2,
+ tx2, ty2, tz2,
+ tx1, ty2, tz1);
+ iconCount--;
+ }
+ rot = rot + rotStep;
+ }
+
+ //renderTriangleMesh(con, NAMED_MeshCard);
+ //renderTriangleMesh(con, NAMED_MeshTab);
return 1;
}
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 da0b146..0f7e26b 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -48,6 +48,12 @@
initRS();
}
+ public void setPosition(float dx, float pressure) {
+ mAllocStateBuf[0] += (int)(dx);
+ mAllocStateBuf[2] = (int)(pressure * 0x40000);
+ mAllocState.data(mAllocStateBuf);
+ }
+
private Resources mRes;
private RenderScript mRS;
@@ -63,23 +69,13 @@
private RenderScript.ProgramVertex mPV;
private ProgramVertexAlloc mPVAlloc;
- private RenderScript.Allocation mAllocEnv;
- private RenderScript.Allocation mAllocPos;
+ private int[] mAllocStateBuf;
private RenderScript.Allocation mAllocState;
- //private RenderScript.Allocation mAllocPV;
- private RenderScript.TriangleMesh mMeshCard;
- private RenderScript.TriangleMesh mMeshTab;
private float[] mBufferPos;
//private float[] mBufferPV;
private void initNamed() {
- mMeshTab = RolloMesh.createTab(mRS);
- mMeshTab.setName("MeshTab");
- mMeshCard = RolloMesh.createCard(mRS);
- mMeshCard.setName("MeshCard");
- Log.e("rs", "Done loading strips");
-
mRS.samplerBegin();
mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
RenderScript.SamplerValue.LINEAR_MIP_LINEAR);
@@ -122,6 +118,8 @@
mPV.setName("PV");
mPV.bindAllocation(0, mPVAlloc.mAlloc);
+
+
mPVAlloc.setupProjectionNormalized(320, 480);
//mPVAlloc.setupOrthoNormalized(320, 480);
mRS.contextBindProgramVertex(mPV);
@@ -131,6 +129,7 @@
}
+
private void initRS() {
mRS.scriptCBegin();
mRS.scriptCSetClearColor(0.0f, 0.7f, 0.0f, 1.0f);
@@ -138,6 +137,11 @@
mRS.scriptCSetRoot(true);
mScript = mRS.scriptCCreate();
+ mAllocStateBuf = new int[] {0, 38, 0};
+ mAllocState = mRS.allocationCreatePredefSized(
+ RenderScript.ElementPredefined.USER_I32, mAllocStateBuf.length);
+ mScript.bindAllocation(mAllocState, 0);
+ setPosition(0, 0);
mRS.contextBindRootScript(mScript);
}
diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java
index 9a30aed..27d2dd6 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java
@@ -74,6 +74,11 @@
if (act == ev.ACTION_UP) {
ret = false;
}
+ float x = ev.getX();
+ x = (x - 180) / 40;
+ //Log.e("rs", Float(x).toString());
+
+ mRender.setPosition(x, ev.getPressure());
//mRender.newTouchPosition((int)ev.getX(), (int)ev.getY());
return ret;
}
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 522ed00..9c99e2b 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -307,6 +307,60 @@
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
+extern "C" void drawQuad(int32_t x1, int32_t y1, int32_t z1,
+ int32_t x2, int32_t y2, int32_t z2,
+ int32_t x3, int32_t y3, int32_t z3,
+ int32_t x4, int32_t y4, int32_t z4)
+{
+ GET_TLS();
+ //x1 = (x1 << 16);
+ //x2 = (x2 << 16);
+ //y1 = (y1 << 16);
+ //y2 = (y2 << 16);
+
+ //LOGE("Quad");
+ //LOGE("0x%08x, 0x%08x, 0x%08x", x1, y1, z1);
+ //LOGE("0x%08x, 0x%08x, 0x%08x", x2, y2, z2);
+ //LOGE("0x%08x, 0x%08x, 0x%08x", x3, y3, z3);
+ //LOGE("0x%08x, 0x%08x, 0x%08x", x4, y4, z4);
+
+ int32_t vtx[] = {x1,y1,z1, x4,y4,z4, x3,y3,z3, x2,y2,z2};
+ static const int32_t tex[] = {0,0, 0,0x10000, 0x10000,0, 0x10000,0x10000};
+
+
+ rsc->setupCheck();
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ //glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+
+ glVertexPointer(3, GL_FIXED, 0, vtx);
+ glTexCoordPointer(2, GL_FIXED, 0, tex);
+ //glColorPointer(4, GL_UNSIGNED_BYTE, 12, ptr);
+
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+}
+
+extern "C" int32_t sinx(int32_t angle)
+{
+ float a = ((float)angle) / 0x10000;
+ a *= 3.14f / 180.f;
+ float s = (float)sin(a);
+ return int32_t(s * 0x10000);
+}
+
+extern "C" int32_t cosx(int32_t angle)
+{
+ float a = ((float)angle) / 0x10000;
+ a *= 3.14f / 180.f;
+ float s = (float)cos(a);
+ return int32_t(s * 0x10000);
+}
+
extern "C" void pfBindTexture(RsProgramFragment vpf, uint32_t slot, RsAllocation va)
{
GET_TLS();