Java Code Examples for android.opengl.GLES20#glDeleteShader()
The following examples show how to use
android.opengl.GLES20#glDeleteShader() .
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: ShaderUtils.java From In77Camera with MIT License | 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) { Log.e(TAG, "Could not compile shader " + shaderType + ":"); Log.e(TAG, GLES20.glGetShaderInfoLog(shader)); GLES20.glDeleteShader(shader); shader = 0; } } return shader; }
Example 2
Source File: AnnotationRenderer.java From ARCore-Location with MIT License | 6 votes |
private int loadGLShader(String tag, int type, String source) { int shader = GLES20.glCreateShader(type); GLES20.glShaderSource(shader, source); 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 3
Source File: ShaderUtils.java From Fatigue-Detection with MIT License | 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) { 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: ShaderUtil.java From justaline-android with Apache License 2.0 | 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. */ 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 5
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 6
Source File: VideoSurfaceView.java From VideoChatHeads with The Unlicense | 6 votes |
private 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 7
Source File: GlShader.java From VideoCRE with MIT License | 5 votes |
public GlShader(String vertexSource, String fragmentSource) { final int vertexShader = compileShader(GLES20.GL_VERTEX_SHADER, vertexSource); final int fragmentShader = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); program = GLES20.glCreateProgram(); if (program == 0) { throw new RuntimeException("glCreateProgram() failed. GLES20 error: " + GLES20.glGetError()); } GLES20.glAttachShader(program, vertexShader); GLES20.glAttachShader(program, fragmentShader); GLES20.glLinkProgram(program); int[] linkStatus = new int[] {GLES20.GL_FALSE}; GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); if (linkStatus[0] != GLES20.GL_TRUE) { Logging.e(TAG, "Could not link program: " + GLES20.glGetProgramInfoLog(program)); throw new RuntimeException(GLES20.glGetProgramInfoLog(program)); } // According to the documentation of glLinkProgram(): // "After the link operation, applications are free to modify attached shader objects, compile // attached shader objects, detach shader objects, delete shader objects, and attach additional // shader objects. None of these operations affects the information log or the program that is // part of the program object." // But in practice, detaching shaders from the program seems to break some devices. Deleting the // shaders are fine however - it will delete them when they are no longer attached to a program. GLES20.glDeleteShader(vertexShader); GLES20.glDeleteShader(fragmentShader); GlUtil.checkNoGLES2Error("Creating GlShader"); }
Example 8
Source File: CameraToMpegTest.java From Android-MediaCodec-Examples 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 9
Source File: TextureManager.java From spydroid-ipcamera with GNU General Public License v3.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 10
Source File: GLDrawer2D.java From AudioVideoPlayerSample 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(String vss, 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 11
Source File: TextureRenderer.java From VideoProcessor 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 12
Source File: ShaderHelper.java From sealrtc-android with MIT License | 5 votes |
/** * 编译着色器 * * @param type 着色器类型,顶点/片段 * @param shaderCode 着色器代码 * @return */ private static int compileShader(int type, String shaderCode) { // 1.创建着色器对象,并返回对象的引用地址,如果为0则表示创建失败 int shaderObjId = GLES20.glCreateShader(type); if (shaderObjId == 0) { Log.e(TAG, "compileShader: Create Shader Failed"); return 0; } // 2.上传着色器源码 GLES20.glShaderSource(shaderObjId, shaderCode); // 3.编译着色器对象 GLES20.glCompileShader(shaderObjId); // 获得编译着色器对象的状态 int[] status = new int[1]; GLES20.glGetShaderiv(shaderObjId, GLES20.GL_COMPILE_STATUS, status, 0); // 获取OpenGl中编译着色器相关的log Log.d( TAG, "compileShader: status=" + status[0] + ", info=" + GLES20.glGetShaderInfoLog(shaderObjId)); // 检查编译是否成功,如果状态是0表示失败,则告诉OpenGL删掉这个着色器 if (status[0] == 0) { GLES20.glDeleteShader(shaderObjId); Log.e(TAG, "compileShader: CompileShader Failed"); } return shaderObjId; }
Example 13
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 14
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 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: 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 17
Source File: CameraGLRendererBase.java From MOAAP with MIT License | 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 18
Source File: EffectsShader.java From YCAudioPlayer with Apache License 2.0 | 4 votes |
private void deleteProgram() { GLES20.glDeleteShader(mIdShaderFragment); GLES20.glDeleteShader(mIdShaderVertex); GLES20.glDeleteProgram(mIdProgram); mIdProgram = mIdShaderVertex = mIdShaderFragment = 0; }
Example 19
Source File: CameraGLRendererBase.java From MOAAP with MIT License | 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: Utils.java From Paddle-Lite-Demo with Apache License 2.0 | 4 votes |
public static int createShaderProgram(String vss, String fss) { 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(TAG, 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(TAG, 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(TAG, 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(TAG, GLES20.glGetProgramInfoLog(program)); GLES20.glDeleteProgram(program); program = 0; return 0; } return program; }