class NexusRS extends RenderScriptScene {
private static final int RSID_STATE = 0;
-
+
private static final int RSID_COMMAND = 1;
private static final int TEXTURES_COUNT = 3;
private final BitmapFactory.Options mOptionsARGB = new BitmapFactory.Options();
private ProgramFragment mPfTexture;
-
+
private ProgramFragment mPfColor;
private ProgramStore mPsSolid;
-
+
private ProgramStore mPsBlend;
-
+
private ProgramVertex mPvOrtho;
-
+
private ProgramVertex.MatrixAllocation mPvOrthoAlloc;
private Sampler mSampler;
private Allocation mState;
-
+
private Type mStateType;
private WorldState mWorldState;
-
+
private Allocation mCommandAllocation;
-
+
private Type mCommandType;
private CommandState mCommand;
+ private Allocation[] mTextures = new Allocation[TEXTURES_COUNT];
+
public NexusRS(int width, int height) {
super(width, height);
mWorldState.xOffset = xOffset;
mState.data(mWorldState);
}
-
+
@Override
public void start() {
super.start();
script.bindAllocation(mState, RSID_STATE);
script.bindAllocation(mCommandAllocation, RSID_COMMAND);
-
+
invokable.execute();
-
+
return script;
}
mStateType = Type.createFromClass(mRS, WorldState.class, 1, "WorldState");
mState = Allocation.createTyped(mRS, mStateType);
mState.data(mWorldState);
-
+
mCommand = new CommandState();
mCommand.x = -1;
mCommand.y = -1;
}
private void loadTextures() {
- final Allocation[] textures = new Allocation[TEXTURES_COUNT];
- textures[0] = loadTexture(R.drawable.pyramid_background, "TBackground");
- textures[1] = loadTextureARGB(R.drawable.pulse, "TPulse");
- textures[2] = loadTextureARGB(R.drawable.glow, "TGlow");
-
- final int count = textures.length;
+ mTextures[0] = loadTexture(R.drawable.pyramid_background, "TBackground");
+ mTextures[1] = loadTextureARGB(R.drawable.pulse, "TPulse");
+ mTextures[2] = loadTextureARGB(R.drawable.glow, "TGlow");
+
+ final int count = mTextures.length;
for (int i = 0; i < count; i++) {
- textures[i].uploadToTexture(0);
+ mTextures[i].uploadToTexture(0);
}
}
mPfTexture = builder.create();
mPfTexture.setName("PFTexture");
mPfTexture.bindSampler(mSampler, 0);
-
+
builder = new ProgramFragment.Builder(mRS, null, null);
builder.setTexEnable(true, 0);
builder.setTexEnvMode(REPLACE, 0);
builder.setDepthMask(true);
mPsSolid = builder.create();
mPsSolid.setName("PSSolid");
-
+
builder = new ProgramStore.Builder(mRS, null, null);
builder.setDepthFunc(ALWAYS);
// builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
final int dw = mWorldState.width;
final int bw = 960;
x = (int) (x + mWorldState.xOffset * (bw-dw));
-
+
if ("android.wallpaper.tap".equals(action)) {
sendCommand(1, x, y);
} else if ("android.home.drop".equals(action)) {