package com.exercise.AndroidRenderScript;
import android.content.Context;
import android.renderscript.Mesh;
import android.renderscript.RSSurfaceView;
import android.renderscript.RenderScriptGL;
import android.renderscript.RenderScriptGL.SurfaceConfig;
public class MyRSSurfaceView extends RSSurfaceView {
private RenderScriptGL renderScriptGL;
private ScriptC_RenderScript myScriptC;
public MyRSSurfaceView(Context context) {
super(context);
// TODO Auto-generated constructor stub
final RenderScriptGL.SurfaceConfig surfaceConfig
= new SurfaceConfig();
renderScriptGL = createRenderScriptGL(surfaceConfig);
myScriptC = new ScriptC_RenderScript(
renderScriptGL, getResources(), R.raw.renderscript);
myScriptC.set_my_rs_mesh(createMesh());
renderScriptGL.bindRootScript(myScriptC);
}
private Mesh createMesh(){
Mesh.TriangleMeshBuilder myMesh
= new Mesh.TriangleMeshBuilder(
renderScriptGL,
2,
Mesh.TriangleMeshBuilder.COLOR);
/* 0 2
* +---+
* |\ |
* | \ |
* | \|
* +---+
* 1 3
*/
myMesh.addVertex(0, 0); //- 0
myMesh.addVertex(0, 100); //- 1
myMesh.addVertex(100, 0); //- 2
myMesh.addVertex(100, 100); //- 3
myMesh.addTriangle(0, 1, 3);
myMesh.addTriangle(0, 3, 2);
return(myMesh.create(true));
};
}
Download the files.
I cannot resolve import.renderscript.Mesh;
ReplyDelete