I want to create a renderscript in android where an array is passed to the .rs file. On these values some calculation is done and sent back to the user.
I have very little understanding of renderscript, so what I have written might be completely wrong also. Please help me with it.
Android activity public class RenderTemp extends Activity {
private RenderScript mRS;
private ScriptC_snow mScript;
int[] indices;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.render);
indices = new int[2];
indices[0] = 1;
indices[1] = 2;
createScript();
}
private void createScript() {
mRS = RenderScript.create(this);
Allocation mIN = Allocation.createSized(mRS, Element.I32(mRS), indices.length);
mIN.copyFrom(indices);
mScript = new ScriptC_snow(mRS);
mScript.forEach_root(mIN);
mIN.copyTo(indices);
}
}
snow.rs
#pragma version(1)
#pragma rs java_package_name(#package name)
int32_t *mIN;
void __attribute__((kernel)) root(int32_t in)
{
in = in + 2;
}