Skip to content

Commit

Permalink
GL: Remove redundant use() call.
Browse files Browse the repository at this point in the history
This is already called in GlUtil.Program().

Tested by confirming that the demo-gl target still runs as expected.

Refactoring change only. No intended functional changes.

PiperOrigin-RevId: 412308564
  • Loading branch information
dway123 authored and kim-vde committed Nov 26, 2021
1 parent 339d99b commit 0e65925
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.util.Map;
import javax.microedition.khronos.egl.EGL10;

/** GL utilities. */
/** OpenGL ES 2.0 utilities. */
public final class GlUtil {

/** Thrown when an OpenGL error occurs and {@link #glAssertionsEnabled} is {@code true}. */
Expand Down Expand Up @@ -85,7 +85,10 @@ public Program(Context context, String vertexShaderFilePath, String fragmentShad
}

/**
* Compiles a GL shader program from vertex and fragment shader GLSL GLES20 code.
* Creates a GL shader program from vertex and fragment shader GLSL GLES20 code.
*
* <p>This involves slow steps, like compiling, linking, and switching the GL program, so do not
* call this in fast rendering loops.
*
* @param vertexShaderGlsl The vertex shader program.
* @param fragmentShaderGlsl The fragment shader program.
Expand Down Expand Up @@ -128,8 +131,14 @@ public Program(String vertexShaderGlsl, String fragmentShaderGlsl) {
checkGlError();
}

/** Uses the program. */
/**
* Uses the program.
*
* <p>Call this in the rendering loop to switch between different programs.
*/
public void use() {
// TODO(http://b/205002913): When multiple GL programs are supported by Transformer, make sure
// to call use() to switch between programs.
GLES20.glUseProgram(programId);
checkGlError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public Renderer(GLSurfaceView surfaceView) {
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
program = new GlUtil.Program(VERTEX_SHADER, FRAGMENT_SHADER);
program.use();
int posLocation = program.getAttributeArrayLocationAndEnable("in_pos");
GLES20.glVertexAttribPointer(
posLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.google.android.exoplayer2.video.spherical;

import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.GlUtil.checkGlError;

import android.opengl.GLES11Ext;
Expand Down Expand Up @@ -139,9 +138,6 @@ public void draw(int textureId, float[] mvpMatrix, boolean rightEye) {
}

// Configure shader.
checkNotNull(program).use();
checkGlError();

float[] texMatrix;
if (stereoMode == C.STEREO_MODE_TOP_BOTTOM) {
texMatrix = rightEye ? TEX_MATRIX_BOTTOM : TEX_MATRIX_TOP;
Expand Down

0 comments on commit 0e65925

Please sign in to comment.