List of usage examples for android.opengl GLES20 glCompileShader
public static native void glCompileShader(int shader);
From source file:Triangle.java
public int loadShader(int type, String shaderCode) { int shader = GLES20.glCreateShader(type); GLES20.glShaderSource(shader, shaderCode); GLES20.glCompileShader(shader); return shader; }
From source file:Main.java
public static int buildShader(int type, String shaderSource) { final int shader = GLES20.glCreateShader(type); if (shader == 0) { return 0; }/* w ww . java2 s. com*/ GLES20.glShaderSource(shader, shaderSource); GLES20.glCompileShader(shader); int[] status = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, status, 0); if (status[0] == 0) { Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); GLES20.glDeleteShader(shader); return 0; } return shader; }
From source file:helloopengles.example.com.MyGLRenderer.java
/** * Utility method for compiling a OpenGL shader. * * <p><strong>Note:</strong> When developing shaders, use the checkGlError() * method to debug shader coding errors.</p> * * @param type - Vertex or fragment shader type. * @param shaderCode - String containing the shader code. * @return - Returns an id for the shader. *//* w ww . ja v a 2 s. c o m*/ public static int loadShader(int type, String shaderCode) { // create a vertex shader type (GLES20.GL_VERTEX_SHADER) // or a fragment shader type (GLES20.GL_FRAGMENT_SHADER) int shader = GLES20.glCreateShader(type); // add the source code to the shader and compile it GLES20.glShaderSource(shader, shaderCode); GLES20.glCompileShader(shader); return shader; }
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 av a 2 s .c o m */ 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./* w ww. j av a2 s.com*/ */ @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 ww . jav a2 s.c om */ 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); // 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);/*ww w .j a v a2 s . c om*/ shader = 0; } if (shader == 0) { throw new RuntimeException("Error creating shader."); } return shader; }