Search in sources :

Example 1 with FragmentShader

use of com.android.scenegraph.FragmentShader in project android_frameworks_base by ParanoidAndroid.

the class SceneManager method getColorFS.

public static FragmentShader getColorFS() {
    if (sSceneManager == null) {
        return null;
    }
    if (sSceneManager.mColor == null) {
        RenderScriptGL rs = getRS();
        Element.Builder b = new Element.Builder(rs);
        b.add(Element.F32_4(rs), "color");
        Type.Builder objConstBuilder = new Type.Builder(rs, b.create());
        final String code = "\n" + "varying vec2 varTex0;\n" + "void main() {\n" + "   lowp vec4 col = UNI_color;\n" + "   gl_FragColor = col;\n" + "}\n";
        FragmentShader.Builder fb = new FragmentShader.Builder(rs);
        fb.setShader(code);
        fb.setObjectConst(objConstBuilder.create());
        sSceneManager.mColor = fb.create();
    }
    return sSceneManager.mColor;
}
Also used : FragmentShader(com.android.scenegraph.FragmentShader) RenderScriptGL(android.renderscript.RenderScriptGL)

Example 2 with FragmentShader

use of com.android.scenegraph.FragmentShader in project android_frameworks_base by ParanoidAndroid.

the class SceneManager method getTextureFS.

public static FragmentShader getTextureFS() {
    if (sSceneManager == null) {
        return null;
    }
    if (sSceneManager.mTexture == null) {
        RenderScriptGL rs = getRS();
        final String code = "\n" + "varying vec2 varTex0;\n" + "void main() {\n" + "   lowp vec4 col = texture2D(UNI_color, varTex0).rgba;\n" + "   gl_FragColor = col;\n" + "}\n";
        FragmentShader.Builder fb = new FragmentShader.Builder(rs);
        fb.setShader(code);
        fb.addTexture(Program.TextureType.TEXTURE_2D, "color");
        sSceneManager.mTexture = fb.create();
        sSceneManager.mTexture.mProgram.bindSampler(Sampler.CLAMP_LINEAR_MIP_LINEAR(rs), 0);
    }
    return sSceneManager.mTexture;
}
Also used : FragmentShader(com.android.scenegraph.FragmentShader) RenderScriptGL(android.renderscript.RenderScriptGL)

Aggregations

RenderScriptGL (android.renderscript.RenderScriptGL)2 FragmentShader (com.android.scenegraph.FragmentShader)2