Java Code Examples for android.opengl.GLES20#glUniform1fv()

The following examples show how to use android.opengl.GLES20#glUniform1fv() . 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: EffectRendererHolder.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * 映像効果用のパラメータをGPUへ適用
 */
@WorkerThread
private void updateParams() {
	if (DEBUG) Log.v(TAG, "MyRendererTask#updateParams:");
	final int n = Math.min(mCurrentParams != null
		? mCurrentParams.length : 0, MAX_PARAM_NUM);
	if ((muParamsLoc >= 0) && (n > 0)) {
		if (mDrawer != null) {
			mDrawer.glUseProgram();
		} else if (DEBUG) Log.d(TAG, "handleChangeEffect: mDrawer is null");
		if (isGLES3()) {
			GLES30.glUniform1fv(muParamsLoc, n, mCurrentParams, 0);
		} else {
			GLES20.glUniform1fv(muParamsLoc, n, mCurrentParams, 0);
		}
	}
}
 
Example 2
Source File: MediaEffectKernel3x3Drawer.java    From libcommon with Apache License 2.0 5 votes vote down vote up
@Override
protected void preDraw(@NonNull final int[] tex_ids,
	final float[] tex_matrix, final int offset) {

	super.preDraw(tex_ids, tex_matrix, offset);
	// カーネル関数(行列)
	if (muKernelLoc >= 0) {
		GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
		GLHelper.checkGlError("set kernel");
	}
	// テクセルオフセット
	if (muTexOffsetLoc >= 0) {
		GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
	}
}
 
Example 3
Source File: EffectDrawer2D.java    From libcommon with Apache License 2.0 5 votes vote down vote up
private void updateParams() {
	if (DEBUG) Log.v(TAG, "MyRendererTask#updateParams:");
	final int n = Math.min(mCurrentParams != null
		? mCurrentParams.length : 0, MAX_PARAM_NUM);
	if ((muParamsLoc >= 0) && (n > 0)) {
		if (mDrawer != null) {
			mDrawer.glUseProgram();
		} else if (DEBUG) Log.d(TAG, "handleChangeEffect: mDrawer is null");
		if (mDrawer.isGLES3) {
			GLES30.glUniform1fv(muParamsLoc, n, mCurrentParams, 0);
		} else {
			GLES20.glUniform1fv(muParamsLoc, n, mCurrentParams, 0);
		}
	}
}
 
Example 4
Source File: Texture2dProgram.java    From cineio-broadcast-android with MIT License 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix       The 4x4 projection matrix.
 * @param vertexBuffer    Buffer with vertex position data.
 * @param firstVertex     Index of first vertex to use in vertexBuffer.
 * @param vertexCount     Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride    Width, in bytes, of the position data for each vertex (often
 *                        vertexCount * sizeof(float)).
 * @param texMatrix       A 4x4 transformation matrix for texture coords.  (Primarily intended
 *                        for use with SurfaceTexture.)
 * @param texBuffer       Buffer with vertex texture data.
 * @param texStride       Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
                 int vertexCount, int coordsPerVertex, int vertexStride,
                 float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
            GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 5
Source File: Texture2dProgram.java    From VIA-AI with MIT License 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
                 int vertexCount, int coordsPerVertex, int vertexStride,
                 float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
            GLES20.GL_FLOAT, true, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, true, texStride, texBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);

    GLES20.glDisable(GLES20.GL_BLEND);

}
 
Example 6
Source File: Texture2dProgram.java    From AndroidPlayground with MIT License 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
        int vertexCount, int coordsPerVertex, int vertexStride,
        float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
        GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 7
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void uniform1fv(int location, int count, float[] v, int offset) {
    GLES20.glUniform1fv(location, count, v, offset);
}
 
Example 8
Source File: Texture2dProgram.java    From pause-resume-video-recording with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
        int vertexCount, int coordsPerVertex, int vertexStride,
        float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
        GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 9
Source File: Texture2dProgram.java    From MockCamera with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix       The 4x4 projection matrix.
 * @param vertexBuffer    Buffer with vertex position data.
 * @param firstVertex     Index of first vertex to use in vertexBuffer.
 * @param vertexCount     Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride    Width, in bytes, of the position data for each vertex (often
 *                        vertexCount * sizeof(float)).
 * @param texMatrix       A 4x4 transformation matrix for texture coords.  (Primarily intended
 *                        for use with SurfaceTexture.)
 * @param texBuffer       Buffer with vertex texture data.
 * @param texStride       Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
                 int vertexCount, int coordsPerVertex, int vertexStride,
                 float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(programHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(textureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(mvpMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(texMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(positionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(positionLoc, coordsPerVertex,
            GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(textureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(textureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (kernelLoc >= 0) {
        GLES20.glUniform1fv(kernelLoc, KERNEL_SIZE, kernel, 0);
        GLES20.glUniform2fv(texOffsetLoc, KERNEL_SIZE, texOffset, 0);
        GLES20.glUniform1f(colorAdjustLoc, colorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(positionLoc);
    GLES20.glDisableVertexAttribArray(textureCoordLoc);
    GLES20.glBindTexture(textureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 10
Source File: TextureKernelShaderProgram.java    From Spectaculum with Apache License 2.0 4 votes vote down vote up
public void setKernel(Kernel kernel) {
    GLES20.glUseProgram(getHandle());
    GLES20.glUniform1fv(mKernelHandle, 9, kernel.mKernel, 0);
}
 
Example 11
Source File: Texture2dProgram.java    From IjkVRPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
        int vertexCount, int coordsPerVertex, int vertexStride,
        float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
        GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 12
Source File: Texture2dProgram.java    From LiveVideoBroadcaster with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
                 int vertexCount, int coordsPerVertex, int vertexStride,
                 float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
            GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 13
Source File: Texture2dProgram.java    From FuAgoraDemoDroid with MIT License 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix       The 4x4 projection matrix.
 * @param vertexBuffer    Buffer with vertex position data.
 * @param firstVertex     Index of first vertex to use in vertexBuffer.
 * @param vertexCount     Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride    Width, in bytes, of the position data for each vertex (often
 *                        vertexCount * sizeof(float)).
 * @param texMatrix       A 4x4 transformation matrix for texture coords.  (Primarily intended
 *                        for use with SurfaceTexture.)
 * @param texBuffer       Buffer with vertex texture data.
 * @param texStride       Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
                 int vertexCount, int coordsPerVertex, int vertexStride,
                 float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
            GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 14
Source File: Texture2dProgram.java    From PLDroidShortVideo with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix       The 4x4 projection matrix.
 * @param vertexBuffer    Buffer with vertex position data.
 * @param firstVertex     Index of first vertex to use in vertexBuffer.
 * @param vertexCount     Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride    Width, in bytes, of the position data for each vertex (often
 *                        vertexCount * sizeof(float)).
 * @param texMatrix       A 4x4 transformation matrix for texture coords.  (Primarily intended
 *                        for use with SurfaceTexture.)
 * @param texBuffer       Buffer with vertex texture data.
 * @param texStride       Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
                 int vertexCount, int coordsPerVertex, int vertexStride,
                 float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
            GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 15
Source File: Texture2dProgram.java    From VideoRecorder with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
        int vertexCount, int coordsPerVertex, int vertexStride,
        float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GLUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GLUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GLUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GLUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GLUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
        GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GLUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GLUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GLUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GLUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 16
Source File: Texture2dProgram.java    From PhotoMovie with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
        int vertexCount, int coordsPerVertex, int vertexStride,
        float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
        GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 17
Source File: Texture2dProgram.java    From RtmpPublisher with Apache License 2.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
        int vertexCount, int coordsPerVertex, int vertexStride,
        float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
        GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 18
Source File: Texture2dProgram.java    From mobile-ar-sensor-logger with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Issues the draw call.  Does the full setup on every call.
 *
 * @param mvpMatrix The 4x4 projection matrix.
 * @param vertexBuffer Buffer with vertex position data.
 * @param firstVertex Index of first vertex to use in vertexBuffer.
 * @param vertexCount Number of vertices in vertexBuffer.
 * @param coordsPerVertex The number of coordinates per vertex (e.g. x,y is 2).
 * @param vertexStride Width, in bytes, of the position data for each vertex (often
 *        vertexCount * sizeof(float)).
 * @param texMatrix A 4x4 transformation matrix for texture coords.  (Primarily intended
 *        for use with SurfaceTexture.)
 * @param texBuffer Buffer with vertex texture data.
 * @param texStride Width, in bytes, of the texture data for each vertex.
 */
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
        int vertexCount, int coordsPerVertex, int vertexStride,
        float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
    GlUtil.checkGlError("draw start");

    // Select the program.
    GLES20.glUseProgram(mProgramHandle);
    GlUtil.checkGlError("glUseProgram");

    // Set the texture.
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(mTextureTarget, textureId);

    // Copy the model / view / projection matrix over.
    GLES20.glUniformMatrix4fv(muMVPMatrixLoc, 1, false, mvpMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Copy the texture transformation matrix over.
    GLES20.glUniformMatrix4fv(muTexMatrixLoc, 1, false, texMatrix, 0);
    GlUtil.checkGlError("glUniformMatrix4fv");

    // Enable the "aPosition" vertex attribute.
    GLES20.glEnableVertexAttribArray(maPositionLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect vertexBuffer to "aPosition".
    GLES20.glVertexAttribPointer(maPositionLoc, coordsPerVertex,
        GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);
    GlUtil.checkGlError("glVertexAttribPointer");

    // Enable the "aTextureCoord" vertex attribute.
    GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
    GlUtil.checkGlError("glEnableVertexAttribArray");

    // Connect texBuffer to "aTextureCoord".
    GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,
            GLES20.GL_FLOAT, false, texStride, texBuffer);
        GlUtil.checkGlError("glVertexAttribPointer");

    // Populate the convolution kernel, if present.
    if (muKernelLoc >= 0) {
        GLES20.glUniform1fv(muKernelLoc, KERNEL_SIZE, mKernel, 0);
        GLES20.glUniform2fv(muTexOffsetLoc, KERNEL_SIZE, mTexOffset, 0);
        GLES20.glUniform1f(muColorAdjustLoc, mColorAdjust);
    }

    // Draw the rect.
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, firstVertex, vertexCount);
    GlUtil.checkGlError("glDrawArrays");

    // Done -- disable vertex array, texture, and program.
    GLES20.glDisableVertexAttribArray(maPositionLoc);
    GLES20.glDisableVertexAttribArray(maTextureCoordLoc);
    GLES20.glBindTexture(mTextureTarget, 0);
    GLES20.glUseProgram(0);
}
 
Example 19
Source File: ConvolutionFilter.java    From AndroidFastImageProcessing with MIT License votes vote down vote up
@Override
	protected void passShaderValues() {
		super.passShaderValues();
		GLES20.glUniform1fv(filterHandle, filterSize, filter, 0);
	} 
Example 20
Source File: ConvolutionFilter.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
@Override
	protected void passShaderValues() {
		super.passShaderValues();
		GLES20.glUniform1fv(filterHandle, filterSize, filter, 0);
	}