Search in sources :

Example 1 with Mesh

use of android.renderscript.Mesh in project android_frameworks_base by ParanoidAndroid.

the class FountainFboRS method init.

public void init(RenderScriptGL rs, Resources res) {
    mRS = rs;
    mRes = res;
    ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT);
    Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS);
    smb.addVertexAllocation(points.getAllocation());
    smb.addIndexSetType(Mesh.Primitive.POINT);
    Mesh sm = smb.create();
    mScript = new ScriptC_fountainfbo(mRS, mRes, R.raw.fountainfbo);
    mScript.set_partMesh(sm);
    mScript.bind_point(points);
    ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs);
    pfb.setVaryingColor(true);
    mProgramFragment = pfb.create();
    mScript.set_gProgramFragment(mProgramFragment);
    /* Second fragment shader to use a texture (framebuffer object) to draw with */
    pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE, ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
    /* Set the fragment shader in the Renderscript runtime */
    mTextureProgramFragment = pfb.create();
    mScript.set_gTextureProgramFragment(mTextureProgramFragment);
    /* Create the allocation for the color buffer */
    Type.Builder colorBuilder = new Type.Builder(mRS, Element.RGBA_8888(mRS));
    colorBuilder.setX(256).setY(256);
    mColorBuffer = Allocation.createTyped(mRS, colorBuilder.create(), Allocation.USAGE_GRAPHICS_TEXTURE | Allocation.USAGE_GRAPHICS_RENDER_TARGET);
    /* Set the allocation in the Renderscript runtime */
    mScript.set_gColorBuffer(mColorBuffer);
    mRS.bindRootScript(mScript);
}
Also used : Type(android.renderscript.Type) Mesh(android.renderscript.Mesh) ProgramFragmentFixedFunction(android.renderscript.ProgramFragmentFixedFunction)

Example 2 with Mesh

use of android.renderscript.Mesh in project android_frameworks_base by ParanoidAndroid.

the class ShadersTestRS method initMeshes.

private void initMeshes(FileA3D model) {
    int numEntries = model.getIndexEntryCount();
    int numMeshes = 0;
    for (int i = 0; i < numEntries; i++) {
        FileA3D.IndexEntry entry = model.getIndexEntry(i);
        if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
            numMeshes++;
        }
    }
    if (numMeshes > 0) {
        mMeshes = new ScriptField_MeshInfo(mRS, numMeshes);
        for (int i = 0; i < numEntries; i++) {
            FileA3D.IndexEntry entry = model.getIndexEntry(i);
            if (entry != null && entry.getEntryType() == FileA3D.EntryType.MESH) {
                Mesh mesh = entry.getMesh();
                mMeshes.set_mMesh(i, mesh, false);
                mMeshes.set_mNumIndexSets(i, mesh.getPrimitiveCount(), false);
            }
        }
        mMeshes.copyAll();
    } else {
        throw new RSRuntimeException("No valid meshes in file");
    }
    mScript.bind_gMeshes(mMeshes);
    mScript.invoke_updateMeshInfo();
}
Also used : FileA3D(android.renderscript.FileA3D) Mesh(android.renderscript.Mesh) RSRuntimeException(android.renderscript.RSRuntimeException)

Aggregations

Mesh (android.renderscript.Mesh)2 FileA3D (android.renderscript.FileA3D)1 ProgramFragmentFixedFunction (android.renderscript.ProgramFragmentFixedFunction)1 RSRuntimeException (android.renderscript.RSRuntimeException)1 Type (android.renderscript.Type)1