Example usage for android.opengl GLES20 glDeleteShader

List of usage examples for android.opengl GLES20 glDeleteShader

Introduction

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

Prototype

public static native void glDeleteShader(int shader);

Source Link

Usage

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

/**
 * Converts a raw text file, saved as a resource, into an OpenGL ES shader.
 *
 * @param type The type of shader we will be creating.
 * @param resId The resource ID of the raw text file about to be turned into a shader.
 * @return The shader object handler.//from  ww w .  j a  v  a  2s. c om
 */
private int loadGLShader(int type, int resId) {
    String code = readRawTextFile(resId);
    int shader = GLES20.glCreateShader(type);
    GLES20.glShaderSource(shader, code);
    GLES20.glCompileShader(shader);

    // Get the compilation status.
    final int[] compileStatus = new int[1];
    GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);

    // If the compilation failed, delete the shader.
    if (compileStatus[0] == 0) {
        Log.e(TAG, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
        GLES20.glDeleteShader(shader);
        shader = 0;
    }

    if (shader == 0) {
        throw new RuntimeException("Error creating shader.");
    }

    return shader;
}

From source file:com.aimfire.gallery.cardboard.PhotoActivity.java

/**
 * Converts a raw text file, saved as a resource, into an OpenGL ES shader.
 *
 * @param type The type of shader we will be creating.
 * @param resId The resource ID of the raw text file about to be turned into a shader.
 * @return The shader object handler./*from   ww  w . jav a 2s  . c  o  m*/
 */
@SuppressWarnings("unused")
private int loadGLShader(int type, int resId) {
    String code = readRawTextFile(resId);
    int shader = GLES20.glCreateShader(type);
    GLES20.glShaderSource(shader, code);
    GLES20.glCompileShader(shader);

    // Get the compilation status.
    final int[] compileStatus = new int[1];
    GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);

    // If the compilation failed, delete the shader.
    if (compileStatus[0] == 0) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
        GLES20.glDeleteShader(shader);
        shader = 0;
    }

    if (shader == 0) {
        throw new RuntimeException("Error creating shader.");
    }

    return shader;
}

From source file:com.sveder.cardboardpassthrough.MainActivity.java

/**
 * Converts a raw text file, saved as a resource, into an OpenGL ES shader
 * @param type The type of shader we will be creating.
 * @param code The resource ID of the raw text file about to be turned into a shader.
 * @return/*from   w  w  w  .  j a v  a 2s.co m*/
 */
private int loadGLShader(int type, String code) {
    int shader = GLES20.glCreateShader(type);
    GLES20.glShaderSource(shader, code);
    GLES20.glCompileShader(shader);

    // Get the compilation status.
    final int[] compileStatus = new int[1];
    GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);

    // If the compilation failed, delete the shader.
    if (compileStatus[0] == 0) {
        Log.e(TAG, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
        GLES20.glDeleteShader(shader);
        shader = 0;
    }

    if (shader == 0) {
        throw new RuntimeException("Error creating shader.");
    }

    return shader;
}

From source file:com.aimfire.gallery.cardboard.PhotoActivity.java

private int loadGLShader(int type, String code) {
    int shader = GLES20.glCreateShader(type);
    GLES20.glShaderSource(shader, code);
    GLES20.glCompileShader(shader);//w ww  .j  a  v a  2 s .co m

    // Get the compilation status.
    final int[] compileStatus = new int[1];
    GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0);

    // If the compilation failed, delete the shader.
    if (compileStatus[0] == 0) {
        if (BuildConfig.DEBUG)
            Log.e(TAG, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shader));
        GLES20.glDeleteShader(shader);
        shader = 0;
    }

    if (shader == 0) {
        throw new RuntimeException("Error creating shader.");
    }

    return shader;
}