Android Open Source - swipemenu Shader Helper






From Project

Back to project page swipemenu.

License

The source code is released under:

Apache License

If you think the Android project swipemenu listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.orhanobut.android.swipemenu;
//from w  w w .j  a  v a 2 s  .c  om
import android.opengl.GLES20;

public class ShaderHelper {

    public static int initShader(String vertexShaderCode, String fragmentShaderCode) {
        int vertexShaderHandle = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
        int fragmentShaderHandle = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);

        int programHandle = GLES20.glCreateProgram();

        GLES20.glAttachShader(programHandle, vertexShaderHandle);
        GLES20.glAttachShader(programHandle, fragmentShaderHandle);
        GLES20.glBindAttribLocation(programHandle, 0, "vPosition");

        GLES20.glLinkProgram(programHandle);
        return programHandle;
    }

    private static int loadShader(int type, String shaderCode) {
        int shader;

        // create shader object
        shader = GLES20.glCreateShader(type);
        if (shader == 0) {
            return 0;
        }

        // load shader
        GLES20.glShaderSource(shader, shaderCode);

        // compile shader
        GLES20.glCompileShader(shader);

        return shader;
    }
}




Java Source Code List

com.orhanobut.android.swipemenu.MainActivity.java
com.orhanobut.android.swipemenu.MainCircle.java
com.orhanobut.android.swipemenu.MyGLSurfaceView.java
com.orhanobut.android.swipemenu.MyRenderer.java
com.orhanobut.android.swipemenu.RawResourceReader.java
com.orhanobut.android.swipemenu.ShaderHelper.java
com.orhanobut.android.swipemenu.ShapeActivity.java
com.orhanobut.android.swipemenu.Square.java
com.orhanobut.android.swipemenu.TextureActivity.java
com.orhanobut.android.swipemenu.TextureHelper.java
com.orhanobut.android.swipemenu.TextureRenderer.java
com.orhanobut.android.swipemenu.WorldObject.java