Last active
June 14, 2018 13:12
-
-
Save BALUSANGEM/d9f4d13b9127c7e13eb633d5116d96d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void draw(float[] cameraView, float[] cameraPerspective) { | |
if (done || !prepared) { | |
return; | |
} | |
synchronized (this) { | |
if (frameAvailable) { | |
videoTexture.updateTexImage(); | |
frameAvailable = false; | |
if (videoTexture != null) { | |
videoTexture.getTransformMatrix(mTexCoordTransformationMatrix[0]); | |
setVideoDimensions(mTexCoordTransformationMatrix[0]); | |
createQuadTextCoord(); | |
} | |
} | |
} | |
Matrix.multiplyMM(modelView, 0, cameraView, 0, mModelMatrix, 0); | |
Matrix.multiplyMM(modelViewProjection, 0, cameraPerspective, 0, modelView, 0); | |
// ShaderUtil.checkGLError(TAG, "Before draw"); | |
GLES20.glEnable(GL10.GL_BLEND); | |
GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); | |
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureId); | |
GLES20.glUseProgram(mQuadProgram); | |
// Set the vertex positions. | |
GLES20.glVertexAttribPointer(mQuadPositionParam, COORDS_PER_VERTEX, | |
GLES20.GL_FLOAT, false, 0, mQuadVertices); | |
// Set the texture coordinates. | |
GLES20.glVertexAttribPointer(mQuadTexCoordParam, TEXCOORDS_PER_VERTEX, | |
GLES20.GL_FLOAT, false, 0, fillBuffer(VIDEO_QUAD_TEXTCOORDS_TRANSFORMED)); | |
// Enable vertex arrays | |
GLES20.glEnableVertexAttribArray(mQuadPositionParam); | |
GLES20.glEnableVertexAttribArray(mQuadTexCoordParam); | |
GLES20.glUniformMatrix4fv(mModelViewProjectionUniform, 1, false, | |
modelViewProjection, 0); | |
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); | |
// Disable vertex arrays | |
GLES20.glDisableVertexAttribArray(mQuadPositionParam); | |
GLES20.glDisableVertexAttribArray(mQuadTexCoordParam); | |
ShaderUtil.checkGLError(TAG, "Draw"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment