Java Code Examples for android.opengl.GLES20#glLinkProgram()
The following examples show how to use
android.opengl.GLES20#glLinkProgram() .
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: Triangle.java From Android-9-Development-Cookbook with MIT License | 6 votes |
public Triangle() { int vertexShader = loadShader( GLES20.GL_VERTEX_SHADER, vertexShaderCode); int fragmentShader = loadShader( GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); mProgram = GLES20.glCreateProgram(); GLES20.glAttachShader(mProgram, vertexShader); GLES20.glAttachShader(mProgram, fragmentShader); GLES20.glLinkProgram(mProgram); ByteBuffer bb = ByteBuffer.allocateDirect( triangleCoords.length * 4); bb.order(ByteOrder.nativeOrder()); vertexBuffer = bb.asFloatBuffer(); vertexBuffer.put(triangleCoords); vertexBuffer.position(0); }
Example 2
Source File: EglUtil.java From SimpleVideoEdit with Apache License 2.0 | 6 votes |
public static int createProgram(final int vertexShader, final int pixelShader) throws GLException { // create empty OpenGL ES Program, store the id in program final int program = glCreateProgram(); if (program == 0) { throw new RuntimeException("Could not create program"); } // add the vertex shader to program GLES20.glAttachShader(program, vertexShader); // add the fragment shader to program GLES20.glAttachShader(program, pixelShader); // creates OpenGL ES program executables GLES20.glLinkProgram(program); final int[] linkStatus = new int[1]; GLES20.glGetProgramiv(program, GL_LINK_STATUS, linkStatus, 0); if (linkStatus[0] != GL_TRUE) { GLES20.glDeleteProgram(program); throw new RuntimeException("Could not link program"); } return program; }
Example 3
Source File: PointCloudRenderer.java From justaline-android with Apache License 2.0 | 5 votes |
/** * Allocates and initializes OpenGL resources needed by the plane renderer. Must be called on the * OpenGL thread, typically in {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}. * * @param context Needed to access shader source. */ public void createOnGlThread(Context context) { ShaderUtil.checkGLError(TAG, "before create"); int[] buffers = new int[1]; GLES20.glGenBuffers(1, buffers, 0); vbo = buffers[0]; GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vbo); vboSize = INITIAL_BUFFER_POINTS * BYTES_PER_POINT; GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, vboSize, null, GLES20.GL_DYNAMIC_DRAW); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); ShaderUtil.checkGLError(TAG, "buffer alloc"); int vertexShader = ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, R.raw.point_cloud_vertex); int passthroughShader = ShaderUtil.loadGLShader( TAG, context, GLES20.GL_FRAGMENT_SHADER, R.raw.passthrough_fragment); programName = GLES20.glCreateProgram(); GLES20.glAttachShader(programName, vertexShader); GLES20.glAttachShader(programName, passthroughShader); GLES20.glLinkProgram(programName); GLES20.glUseProgram(programName); ShaderUtil.checkGLError(TAG, "program"); positionAttribute = GLES20.glGetAttribLocation(programName, "a_Position"); colorUniform = GLES20.glGetUniformLocation(programName, "u_Color"); modelViewProjectionUniform = GLES20.glGetUniformLocation(programName, "u_ModelViewProjection"); pointSizeUniform = GLES20.glGetUniformLocation(programName, "u_PointSize"); ShaderUtil.checkGLError(TAG, "program params"); }
Example 4
Source File: ShaderProgram.java From tilt-game-android with MIT License | 5 votes |
protected void link(final GLState pGLState) throws ShaderProgramLinkException { GLES20.glLinkProgram(this.mProgramID); GLES20.glGetProgramiv(this.mProgramID, GLES20.GL_LINK_STATUS, ShaderProgram.HARDWAREID_CONTAINER, 0); if (ShaderProgram.HARDWAREID_CONTAINER[0] == 0) { throw new ShaderProgramLinkException(GLES20.glGetProgramInfoLog(this.mProgramID)); } this.initAttributeLocations(); this.initUniformLocations(); this.mCompiled = true; }
Example 5
Source File: GLHelper.java From PhotoMovie with Apache License 2.0 | 5 votes |
public static int loadProgram(String vSource, String fSource) { int iVShader; int iFShader; int iProgram; int[] link = new int[1]; iVShader = loadShader(vSource, GLES20.GL_VERTEX_SHADER); if (iVShader == 0) { Log.d(TAG, "Load Vertex Shader Failed"); return 0; } iFShader = loadShader(fSource, GLES20.GL_FRAGMENT_SHADER); if (iFShader == 0) { Log.d(TAG, ":Load Fragment Shader Failed"); return 0; } iProgram = GLES20.glCreateProgram(); GLES20.glAttachShader(iProgram, iVShader); checkGlError(""); GLES20.glAttachShader(iProgram, iFShader); checkGlError(""); GLES20.glLinkProgram(iProgram); checkGlError(""); GLES20.glGetProgramiv(iProgram, GLES20.GL_LINK_STATUS, link, 0); if (link[0] <= 0) { Log.d(TAG, "Linking Failed"); return 0; } GLES20.glDeleteShader(iVShader); checkGlError(""); GLES20.glDeleteShader(iFShader); checkGlError(""); return iProgram; }
Example 6
Source File: FrameRenderer.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void onSurfaceCreated() { // Create the GL program. program = GLES20.glCreateProgram(); // Add the vertex and fragment shaders. addShader(GLES20.GL_VERTEX_SHADER, VERTEX_SHADER, program); addShader(GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER, program); // Link the GL program. GLES20.glLinkProgram(program); int[] result = new int[]{ GLES20.GL_FALSE }; result[0] = GLES20.GL_FALSE; GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, result, 0); abortUnless(result[0] == GLES20.GL_TRUE, GLES20.glGetProgramInfoLog(program)); GLES20.glUseProgram(program); int posLocation = GLES20.glGetAttribLocation(program, "in_pos"); GLES20.glEnableVertexAttribArray(posLocation); GLES20.glVertexAttribPointer( posLocation, 2, GLES20.GL_FLOAT, false, 0, TEXTURE_VERTICES); texLocation = GLES20.glGetAttribLocation(program, "in_tc"); GLES20.glEnableVertexAttribArray(texLocation); checkNoGLES2Error(); bitDepthLocation = GLES20.glGetUniformLocation(program, "bitDepth"); checkNoGLES2Error(); colorMatrixLocation = GLES20.glGetUniformLocation(program, "mColorConversion"); checkNoGLES2Error(); setupTextures(); checkNoGLES2Error(); }
Example 7
Source File: Square.java From opengl with Apache License 2.0 | 5 votes |
/** * Sets up the drawing object data for use in an OpenGL ES context. */ public Square() { // initialize vertex byte buffer for shape coordinates ByteBuffer bb = ByteBuffer.allocateDirect( // (# of coordinate values * 4 bytes per float) squareCoords.length * 4); bb.order(ByteOrder.nativeOrder()); vertexBuffer = bb.asFloatBuffer(); vertexBuffer.put(squareCoords); vertexBuffer.position(0); // initialize byte buffer for the draw list ByteBuffer dlb = ByteBuffer.allocateDirect( // (# of coordinate values * 2 bytes per short) drawOrder.length * 2); dlb.order(ByteOrder.nativeOrder()); drawListBuffer = dlb.asShortBuffer(); drawListBuffer.put(drawOrder); drawListBuffer.position(0); // prepare shaders and OpenGL program int vertexShader = MyGLRenderer.loadShader( GLES20.GL_VERTEX_SHADER, vertexShaderCode); int fragmentShader = MyGLRenderer.loadShader( GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); mProgram = GLES20.glCreateProgram(); // create empty OpenGL Program GLES20.glAttachShader(mProgram, vertexShader); // add the vertex shader to program GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment shader to program GLES20.glLinkProgram(mProgram); // create OpenGL program executables }
Example 8
Source File: GLDrawer2D.java From AudioVideoRecordingSample 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 9
Source File: GlUtil.java From ShapesInOpenGLES2.0 with MIT License | 5 votes |
/** * Creates a new program from the supplied vertex and fragment shaders. * * @return A handle to the program, or 0 on failure. */ public static int createProgram(String vertexSource, String fragmentSource) { int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); if (vertexShader == 0) { return 0; } int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); if (pixelShader == 0) { return 0; } int program = GLES20.glCreateProgram(); checkGlError("glCreateProgram"); if (program == 0) { Log.e(TAG, "Could not create program"); } GLES20.glAttachShader(program, vertexShader); checkGlError("glAttachShader"); GLES20.glAttachShader(program, pixelShader); checkGlError("glAttachShader"); GLES20.glLinkProgram(program); int[] linkStatus = new int[1]; GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); if (linkStatus[0] != GLES20.GL_TRUE) { Log.e(TAG, "Could not link program: "); Log.e(TAG, GLES20.glGetProgramInfoLog(program)); GLES20.glDeleteProgram(program); program = 0; } return program; }
Example 10
Source File: GLDrawer.java From Building-Android-UIs-with-Custom-Views with MIT License | 5 votes |
private void initShaders() { int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode); int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); shaderProgram = GLES20.glCreateProgram(); GLES20.glAttachShader(shaderProgram, vertexShader); GLES20.glAttachShader(shaderProgram, fragmentShader); GLES20.glLinkProgram(shaderProgram); }
Example 11
Source File: RoundedTextureView.java From android-RoundedTextureView with Apache License 2.0 | 5 votes |
private static int createProgram(String vertexSource, String fragmentSource) { int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); if (vertexShader == 0) { return 0; } int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); if (pixelShader == 0) { return 0; } int program = GLES20.glCreateProgram(); if (program != 0) { GLES20.glAttachShader(program, vertexShader); checkGlError("glAttachShader"); GLES20.glAttachShader(program, pixelShader); checkGlError("glAttachShader"); GLES20.glLinkProgram(program); int[] linkStatus = new int[1]; GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); if (linkStatus[0] != GLES20.GL_TRUE) { Log.e(TAG, "Could not link program: "); Log.e(TAG, GLES20.glGetProgramInfoLog(program)); GLES20.glDeleteProgram(program); program = 0; } } return program; }
Example 12
Source File: Program.java From HokoBlur with Apache License 2.0 | 5 votes |
@Override public void create(String vertexShaderCode, String fragmentShaderCode) { int vertexShader = 0; int fragmentShader = 0; try { vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode); fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); if (vertexShader == 0 || fragmentShader == 0) { return; } id = GLES20.glCreateProgram(); if (id != 0) { GLES20.glAttachShader(id, vertexShader); GLES20.glAttachShader(id, fragmentShader); GLES20.glLinkProgram(id); checkGLError("Attach Shader"); final int[] linkStatus = new int[1]; GLES20.glGetProgramiv(id, GLES20.GL_LINK_STATUS, linkStatus, 0); if (linkStatus[0] != 1) { Log.e(TAG, "Failed to link program"); GLES20.glDeleteProgram(id); id = 0; } // } } finally { GLES20.glDetachShader(id, vertexShader); GLES20.glDetachShader(id, fragmentShader); GLES20.glDeleteShader(vertexShader); GLES20.glDeleteShader(fragmentShader); } }
Example 13
Source File: GLToolbox.java From android-MediaEffects with Apache License 2.0 | 5 votes |
public static int createProgram(String vertexSource, String fragmentSource) { int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource); if (vertexShader == 0) { return 0; } int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource); if (pixelShader == 0) { return 0; } int program = GLES20.glCreateProgram(); if (program != 0) { GLES20.glAttachShader(program, vertexShader); checkGlError("glAttachShader"); GLES20.glAttachShader(program, pixelShader); checkGlError("glAttachShader"); GLES20.glLinkProgram(program); int[] linkStatus = new int[1]; GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0); if (linkStatus[0] != GLES20.GL_TRUE) { String info = GLES20.glGetProgramInfoLog(program); GLES20.glDeleteProgram(program); throw new RuntimeException("Could not link program: " + info); } } return program; }
Example 14
Source File: CameraGLRendererBase.java From real_time_circle_detection_android 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 15
Source File: AndroidGL.java From trekarta with GNU General Public License v3.0 | 4 votes |
@Override public void linkProgram(int program) { GLES20.glLinkProgram(program); }
Example 16
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 17
Source File: ShaderHelper.java From Muzesto with GNU General Public License v3.0 | 4 votes |
/** * Helper function to compile and link a program. * * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader. * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader. * @param attributes Attributes that need to be bound to the program. * @return An OpenGL handle to the program. */ public static int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes) { int programHandle = GLES20.glCreateProgram(); if (programHandle != 0) { // Bind the vertex shader to the program. GLES20.glAttachShader(programHandle, vertexShaderHandle); // Bind the fragment shader to the program. GLES20.glAttachShader(programHandle, fragmentShaderHandle); // Bind attributes if (attributes != null) { final int size = attributes.length; for (int i = 0; i < size; i++) { GLES20.glBindAttribLocation(programHandle, i, attributes[i]); } } // Link the two shaders together into a program. GLES20.glLinkProgram(programHandle); // Get the link status. final int[] linkStatus = new int[1]; GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0); // If the link failed, delete the program. if (linkStatus[0] == 0) { Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle)); GLES20.glDeleteProgram(programHandle); programHandle = 0; } } if (programHandle == 0) { throw new RuntimeException("Error creating program."); } return programHandle; }
Example 18
Source File: CameraGLRendererBase.java From LPR 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 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: 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; }