Java Code Examples for android.opengl.GLES20#glGetShaderiv()
The following examples show how to use
android.opengl.GLES20#glGetShaderiv() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShaderUtil.java From ARCore-Location with MIT License | 6 votes |
/** * 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. */ public static int loadGLShader(String tag, Context context, int type, int resId) { String code = readRawTextFile(context, 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; }
Example 2
Source File: GLToolbox.java From Rocko-Android-Demos with Apache License 2.0 | 6 votes |
public static int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); if (shader != 0) { GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { String info = GLES20.glGetShaderInfoLog(shader); GLES20.glDeleteShader(shader); shader = 0; throw new RuntimeException("Could not compile shader " + shaderType + ":" + info); } } return shader; }
Example 3
Source File: GlUtil.java From VIA-AI with MIT License | 6 votes |
/** * Compiles the provided shader source. * * @return A handle to the shader, or 0 on failure. */ public static int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); checkGlError("glCreateShader type=" + shaderType); GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { Log.e(TAG, "Could not compile shader " + shaderType + ":"); Log.e(TAG, " " + GLES20.glGetShaderInfoLog(shader)); GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 4
Source File: GlUtil.java From grafika with Apache License 2.0 | 6 votes |
/** * Compiles the provided shader source. * * @return A handle to the shader, or 0 on failure. */ public static int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); checkGlError("glCreateShader type=" + shaderType); GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { Log.e(TAG, "Could not compile shader " + shaderType + ":"); Log.e(TAG, " " + GLES20.glGetShaderInfoLog(shader)); GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 5
Source File: GLUtil.java From OpenGLESRecorder with Apache License 2.0 | 6 votes |
private static int compileShader(int type, String shaderCode) { int shader = GLES20.glCreateShader(type); if (shader == 0) { Log.e(TAG, "create shader error"); } GLES20.glShaderSource(shader, shaderCode); GLES20.glCompileShader(shader); int [] compileStatus = new int[1]; GLES20.glGetShaderiv(shader,GLES20.GL_COMPILE_STATUS,compileStatus, 0); if (0 == compileStatus[0]) { GLES20.glDeleteShader(shader); Log.e(TAG, "compile shader error"); return 0; } return shader; }
Example 6
Source File: GlUtil.java From kickflip-android-sdk with Apache License 2.0 | 6 votes |
/** * Compiles the provided shader source. * * @return A handle to the shader, or 0 on failure. */ public static int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); checkGlError("glCreateShader type=" + shaderType); GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { Log.e(TAG, "Could not compile shader " + shaderType + ":"); Log.e(TAG, " " + GLES20.glGetShaderInfoLog(shader)); GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 7
Source File: RoundedTextureView.java From android-RoundedTextureView with Apache License 2.0 | 6 votes |
private static int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); if (shader != 0) { GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { Log.e(TAG, "Could not compile shader " + shaderType + ":"); Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); GLES20.glDeleteShader(shader); shader = 0; } } return shader; }
Example 8
Source File: TextureRenderer.java From VideoCompressor with Apache License 2.0 | 5 votes |
private int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); checkGlError("glCreateShader type=" + shaderType); GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 9
Source File: GLToolbox.java From android-MediaEffects with Apache License 2.0 | 5 votes |
public static int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); if (shader != 0) { GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { String info = GLES20.glGetShaderInfoLog(shader); GLES20.glDeleteShader(shader); throw new RuntimeException("Could not compile shader " + shaderType + ":" + info); } } return shader; }
Example 10
Source File: FilterShaders.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static int loadShader(int type, String shaderCode) { int shader = GLES20.glCreateShader(type); GLES20.glShaderSource(shader, shaderCode); GLES20.glCompileShader(shader); int[] compileStatus = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0); if (compileStatus[0] == 0) { if (BuildVars.LOGS_ENABLED) { FileLog.e(GLES20.glGetShaderInfoLog(shader)); } GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 11
Source File: TextureRender.java From LiveMultimedia with Apache License 2.0 | 5 votes |
private int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); checkGlError("glCreateShader type=" + shaderType); GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { Log.e(TAG, "Could not compile shader " + shaderType + ":"); Log.e(TAG, " " + GLES20.glGetShaderInfoLog(shader)); GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 12
Source File: GLES20DrawContext.java From settlers-remake with MIT License | 5 votes |
private int createShader(String name, int type) throws IOException { int shader = GLES20.glCreateShader(type); BufferedReader is = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/"+name))); StringBuilder source = new StringBuilder(); String line; while((line = is.readLine()) != null) { source.append(line); if(line.startsWith("#version")) { //source.append(" es"); } source.append("\n"); } GLES20.glShaderSource(shader, source.toString()); GLES20.glCompileShader(shader); String log = GLES20.glGetShaderInfoLog(shader); if(!log.isEmpty()) System.out.print("info log of " + name + "=====\n" + log + "==== end\n"); int[] compile_status = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compile_status, 0); if(compile_status[0] == 0) { GLES20.glDeleteShader(shader); throw new Error("Could not compile " + name); } return shader; }
Example 13
Source File: GLDrawer2D.java From MegviiFacepp-Android-SDK with Apache License 2.0 | 5 votes |
/** * load, compile and link shader * @param vss source of vertex shader * @param fss source of fragment shader * @return */ public static int loadShader(final String vss, final String fss) { if (DEBUG) Log.v(TAG, "loadShader:"); int vs = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); GLES20.glShaderSource(vs, vss); GLES20.glCompileShader(vs); final int[] compiled = new int[1]; GLES20.glGetShaderiv(vs, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { if (DEBUG) Log.e(TAG, "Failed to compile vertex shader:" + GLES20.glGetShaderInfoLog(vs)); GLES20.glDeleteShader(vs); vs = 0; } int fs = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); GLES20.glShaderSource(fs, fss); GLES20.glCompileShader(fs); GLES20.glGetShaderiv(fs, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { if (DEBUG) Log.w(TAG, "Failed to compile fragment shader:" + GLES20.glGetShaderInfoLog(fs)); GLES20.glDeleteShader(fs); fs = 0; } final int program = GLES20.glCreateProgram(); GLES20.glAttachShader(program, vs); GLES20.glAttachShader(program, fs); GLES20.glLinkProgram(program); return program; }
Example 14
Source File: TextureRenderer.java From talk-android with MIT License | 5 votes |
private int loadShader(int shaderType, String source) { int shader = GLES20.glCreateShader(shaderType); checkGlError("glCreateShader type=" + shaderType); GLES20.glShaderSource(shader, source); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 15
Source File: Program.java From ShaderEditor with MIT License | 5 votes |
private static int compileShader(int type, String src) { int s = GLES20.glCreateShader(type); if (s == 0) { infoLog = "Cannot create shader"; return 0; } GLES20.glShaderSource(s, src); GLES20.glCompileShader(s); int[] compiled = new int[1]; GLES20.glGetShaderiv( s, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { infoLog = GLES20.glGetShaderInfoLog(s); GLES20.glDeleteShader(s); s = 0; } return s; }
Example 16
Source File: InstantCameraView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private int loadShader(int type, String shaderCode) { int shader = GLES20.glCreateShader(type); GLES20.glShaderSource(shader, shaderCode); GLES20.glCompileShader(shader); int[] compileStatus = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compileStatus, 0); if (compileStatus[0] == 0) { if (BuildVars.LOGS_ENABLED) { FileLog.e(GLES20.glGetShaderInfoLog(shader)); } GLES20.glDeleteShader(shader); shader = 0; } return shader; }
Example 17
Source File: ShaderUtils.java From AudioVideoCodec with Apache License 2.0 | 5 votes |
/** * 加载shader * * @param type :shader类型 * @param shadeCode :着色器代码 * @return shader */ private static int loadShader(int type, String shadeCode) { int shader = GLES20.glCreateShader(type); if (0 != shader) { GLES20.glShaderSource(shader, shadeCode); GLES20.glCompileShader(shader); int[] compiled = new int[1]; GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0); if (compiled[0] == 0) { GLES20.glDeleteShader(shader); shader = 0; } } return shader; }
Example 18
Source File: CameraGLRenderer.java From VideoRecorder with Apache License 2.0 | 4 votes |
private int loadShader(String vss, String fss) { LogUtil.logd("loadShader"); int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); GLES20.glShaderSource(vshader, vss); GLES20.glCompileShader(vshader); int[] status = new int[1]; GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0); if (status[0] == 0) { LogUtil.loge("Could not compile vertex shader: " + GLES20.glGetShaderInfoLog(vshader)); GLES20.glDeleteShader(vshader); return 0; } int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); GLES20.glShaderSource(fshader, fss); GLES20.glCompileShader(fshader); GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0); if (status[0] == 0) { LogUtil.loge("Could not compile fragment shader:" + GLES20.glGetShaderInfoLog(fshader)); GLES20.glDeleteShader(vshader); GLES20.glDeleteShader(fshader); return 0; } int program = GLES20.glCreateProgram(); GLES20.glAttachShader(program, vshader); GLES20.glAttachShader(program, fshader); GLES20.glLinkProgram(program); GLES20.glDeleteShader(vshader); GLES20.glDeleteShader(fshader); GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0); if (status[0] == 0) { LogUtil.loge("Could not link shader program: " + GLES20.glGetProgramInfoLog(program)); return 0; } GLES20.glValidateProgram(program); GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0); if (status[0] == 0) { LogUtil.loge("Shader program validation error: " + GLES20.glGetProgramInfoLog(program)); GLES20.glDeleteProgram(program); return 0; } LogUtil.logd("Shader program is built OK"); return program; }
Example 19
Source File: CameraGLRendererBase.java From SmartPaperScan with Apache License 2.0 | 4 votes |
private static int loadShader(String vss, String fss) { Log.d("CameraGLRendererBase", "loadShader"); int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); GLES20.glShaderSource(vshader, vss); GLES20.glCompileShader(vshader); int[] status = new int[1]; GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader)); GLES20.glDeleteShader(vshader); vshader = 0; return 0; } int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); GLES20.glShaderSource(fshader, fss); GLES20.glCompileShader(fshader); GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader)); GLES20.glDeleteShader(vshader); GLES20.glDeleteShader(fshader); fshader = 0; return 0; } int program = GLES20.glCreateProgram(); GLES20.glAttachShader(program, vshader); GLES20.glAttachShader(program, fshader); GLES20.glLinkProgram(program); GLES20.glDeleteShader(vshader); GLES20.glDeleteShader(fshader); GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program)); program = 0; return 0; } GLES20.glValidateProgram(program); GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program)); GLES20.glDeleteProgram(program); program = 0; return 0; } Log.d("CameraGLRendererBase", "Shader program is built OK"); return program; }
Example 20
Source File: CameraGLRendererBase.java From Image-Detection-Samples with Apache License 2.0 | 4 votes |
private static int loadShader(String vss, String fss) { Log.d("CameraGLRendererBase", "loadShader"); int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); GLES20.glShaderSource(vshader, vss); GLES20.glCompileShader(vshader); int[] status = new int[1]; GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader)); GLES20.glDeleteShader(vshader); vshader = 0; return 0; } int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); GLES20.glShaderSource(fshader, fss); GLES20.glCompileShader(fshader); GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader)); GLES20.glDeleteShader(vshader); GLES20.glDeleteShader(fshader); fshader = 0; return 0; } int program = GLES20.glCreateProgram(); GLES20.glAttachShader(program, vshader); GLES20.glAttachShader(program, fshader); GLES20.glLinkProgram(program); GLES20.glDeleteShader(vshader); GLES20.glDeleteShader(fshader); GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program)); program = 0; return 0; } GLES20.glValidateProgram(program); GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0); if (status[0] == 0) { Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program)); GLES20.glDeleteProgram(program); program = 0; return 0; } Log.d("CameraGLRendererBase", "Shader program is built OK"); return program; }