Example usage for android.opengl GLES20 GL_FALSE

List of usage examples for android.opengl GLES20 GL_FALSE

Introduction

In this page you can find the example usage for android.opengl GLES20 GL_FALSE.

Prototype

int GL_FALSE

To view the source code for android.opengl GLES20 GL_FALSE.

Click Source Link

Usage

From source file:Main.java

public static int createProgramFromShaderSrc(String vertexShaderSrc, String fragmentShaderSrc) {
    int vertShader = initShader(GLES20.GL_VERTEX_SHADER, vertexShaderSrc);
    int fragShader = initShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderSrc);

    if (vertShader == 0 || fragShader == 0)
        return 0;

    int program = GLES20.glCreateProgram();
    if (program != 0) {
        GLES20.glAttachShader(program, vertShader);
        checkGLError("glAttchShader(vert)");

        GLES20.glAttachShader(program, fragShader);
        checkGLError("glAttchShader(frag)");

        GLES20.glLinkProgram(program);/*from  w ww .ja  va2s  . c  o m*/
        int[] glStatusVar = { GLES20.GL_FALSE };
        GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, glStatusVar, 0);
        if (glStatusVar[0] == GLES20.GL_FALSE) {
            Log.e(LOGTAG, "Could NOT link program : " + GLES20.glGetProgramInfoLog(program));
            GLES20.glDeleteProgram(program);
            program = 0;
        }
    }

    return program;
}

From source file:Main.java

static int initShader(int shaderType, String source) {
    int shader = GLES20.glCreateShader(shaderType);
    if (shader != 0) {
        GLES20.glShaderSource(shader, source);
        GLES20.glCompileShader(shader);/*  w w w .  j  a v  a 2s  .  com*/

        int[] glStatusVar = { GLES20.GL_FALSE };
        GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, glStatusVar, 0);
        if (glStatusVar[0] == GLES20.GL_FALSE) {
            Log.e(LOGTAG, "Could NOT compile shader " + shaderType + " : " + GLES20.glGetShaderInfoLog(shader));
            GLES20.glDeleteShader(shader);
            shader = 0;
        }

    }

    return shader;
}