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

The following examples show how to use android.opengl.GLES20#glClearColor() . 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: ViEAndroidGLES20.java    From LiveVideo with Apache License 2.0 6 votes vote down vote up
public void ClearBackground() {
	GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
	//this.clearAnimation();
	GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

	Log.i("vv", "glClearColor");
	//this.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
	//this.invalidate();
	//this.setBackgroundColor(0xFF000000);

	//this.getBackground();
	//this.getBackground();

	//ReDraw();
	//GLES20.glViewport(0, 0, 0, 0);

}
 
Example 2
Source File: CameraGLRendererBase.java    From OpenCV-android with Apache License 2.0 6 votes vote down vote up
private void initShaders() {
    String strGLVersion = GLES20.glGetString(GLES20.GL_VERSION);
    if (strGLVersion != null)
        Log.i(LOGTAG, "OpenGL ES version: " + strGLVersion);

    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    progOES = loadShader(vss, fssOES);
    vPosOES = GLES20.glGetAttribLocation(progOES, "vPosition");
    vTCOES  = GLES20.glGetAttribLocation(progOES, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPosOES);
    GLES20.glEnableVertexAttribArray(vTCOES);

    prog2D  = loadShader(vss, fss2D);
    vPos2D = GLES20.glGetAttribLocation(prog2D, "vPosition");
    vTC2D  = GLES20.glGetAttribLocation(prog2D, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPos2D);
    GLES20.glEnableVertexAttribArray(vTC2D);
}
 
Example 3
Source File: ContinuousCaptureActivity.java    From grafika with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a bit of extra stuff to the display just to give it flavor.
 */
private static void drawExtra(int frameNum, int width, int height) {
    // We "draw" with the scissor rect and clear calls.  Note this uses window coordinates.
    int val = frameNum % 3;
    switch (val) {
        case 0:  GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);   break;
        case 1:  GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);   break;
        case 2:  GLES20.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);   break;
    }

    int xpos = (int) (width * ((frameNum % 100) / 100.0f));
    GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
    GLES20.glScissor(xpos, 0, width / 32, height / 32);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
}
 
Example 4
Source File: CameraGLRendererBase.java    From MOAAP with MIT License 6 votes vote down vote up
private void initShaders() {
    String strGLVersion = GLES20.glGetString(GLES20.GL_VERSION);
    if (strGLVersion != null)
        Log.i(LOGTAG, "OpenGL ES version: " + strGLVersion);

    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    progOES = loadShader(vss, fssOES);
    vPosOES = GLES20.glGetAttribLocation(progOES, "vPosition");
    vTCOES  = GLES20.glGetAttribLocation(progOES, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPosOES);
    GLES20.glEnableVertexAttribArray(vTCOES);

    prog2D  = loadShader(vss, fss2D);
    vPos2D = GLES20.glGetAttribLocation(prog2D, "vPosition");
    vTC2D  = GLES20.glGetAttribLocation(prog2D, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPos2D);
    GLES20.glEnableVertexAttribArray(vTC2D);
}
 
Example 5
Source File: SphericalViewRenderer.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
/**
 * onSurfaceCreated Method
 * @param gl10 GLObject
 * @param config EGL Setting Object
 */
@Override
public void onSurfaceCreated(final GL10 gl10, final EGLConfig config) {
    int vShader = loadShader(GLES20.GL_VERTEX_SHADER, VSHADER_SRC);
    int fShader = loadShader(GLES20.GL_FRAGMENT_SHADER, FSHADER_SRC);
    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vShader);
    GLES20.glAttachShader(program, fShader);
    GLES20.glLinkProgram(program);
    GLES20.glUseProgram(program);

    mPositionHandle = GLES20.glGetAttribLocation(program, "aPosition");
    mUVHandle = GLES20.glGetAttribLocation(program, "aUV");
    mProjectionMatrixHandle = GLES20.glGetUniformLocation(program, "uProjection");
    mViewMatrixHandle = GLES20.glGetUniformLocation(program, "uView");
    mTexHandle = GLES20.glGetUniformLocation(program, "uTex");
    mModelMatrixHandle = GLES20.glGetUniformLocation(program, "uModel");

    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
 
Example 6
Source File: CameraGLRendererBase.java    From real_time_circle_detection_android with MIT License 6 votes vote down vote up
private void initShaders() {
    String strGLVersion = GLES20.glGetString(GLES20.GL_VERSION);
    if (strGLVersion != null)
        Log.i(LOGTAG, "OpenGL ES version: " + strGLVersion);

    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    progOES = loadShader(vss, fssOES);
    vPosOES = GLES20.glGetAttribLocation(progOES, "vPosition");
    vTCOES  = GLES20.glGetAttribLocation(progOES, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPosOES);
    GLES20.glEnableVertexAttribArray(vTCOES);

    prog2D  = loadShader(vss, fss2D);
    vPos2D = GLES20.glGetAttribLocation(prog2D, "vPosition");
    vTC2D  = GLES20.glGetAttribLocation(prog2D, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPos2D);
    GLES20.glEnableVertexAttribArray(vTC2D);
}
 
Example 7
Source File: MagicBaseGroupFilter.java    From TikTok with Apache License 2.0 6 votes vote down vote up
@Override
public int onDrawFrame(final int textureId, final FloatBuffer cubeBuffer,
		final FloatBuffer textureBuffer) {
	if (frameBuffers == null || frameBufferTextures == null) {
        return OpenGlUtils.NOT_INIT;
    }
	int size = filters.size();
    int previousTexture = textureId;
    for (int i = 0; i < size; i++) {
    	GPUImageFilter filter = filters.get(i);
        boolean isNotLast = i < size - 1;
        if (isNotLast) {
        	GLES20.glViewport(0, 0, mIntputWidth, mIntputHeight);
            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffers[i]);
            GLES20.glClearColor(0, 0, 0, 0);
            filter.onDrawFrame(previousTexture, mGLCubeBuffer, mGLTextureBuffer);
            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
            previousTexture = frameBufferTextures[i];
        }else{
        	GLES20.glViewport(0, 0, mOutputWidth, mOutputHeight);
        	filter.onDrawFrame(previousTexture, cubeBuffer, textureBuffer);
        }
    }
	return OpenGlUtils.ON_DRAWN;
}
 
Example 8
Source File: VideoSurfaceView.java    From VidEffects with Apache License 2.0 5 votes vote down vote up
@Override
public void onDrawFrame(GL10 glUnused) {
    synchronized (this) {
        if (updateSurface) {
            mSurface.updateTexImage();
            mSurface.getTransformMatrix(getTransformMatrix());
            updateSurface = false;
        }
    }

    GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
    draw();
}
 
Example 9
Source File: TextureRender.java    From phoenix with Apache License 2.0 5 votes vote down vote up
public void drawFrame(SurfaceTexture st) {
    checkGlError("onDrawFrame start");
    st.getTransformMatrix(mSTMatrix);
    GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
    GLES20.glUseProgram(mProgram);
    checkGlError("glUseProgram");
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);
    mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
    GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
    checkGlError("glVertexAttribPointer maPosition");
    GLES20.glEnableVertexAttribArray(maPositionHandle);
    checkGlError("glEnableVertexAttribArray maPositionHandle");
    mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
    GLES20.glVertexAttribPointer(maTextureHandle, 2, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
    checkGlError("glVertexAttribPointer maTextureHandle");
    GLES20.glEnableVertexAttribArray(maTextureHandle);
    checkGlError("glEnableVertexAttribArray maTextureHandle");
    Matrix.setIdentityM(mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    checkGlError("glDrawArrays");
    GLES20.glFinish();
}
 
Example 10
Source File: DemoRenderer.java    From LearnOpenGL with MIT License 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    mTable = new Table();
    mMallet = new Mallet();
    mTextureShaderProgram = new TextureShaderProgram(mContext);
    mColorShaderProgram = new ColorShaderProgram(mContext);
    mTexture = Utils.loadTexture(mContext, R.drawable.air_hockey_surface);
}
 
Example 11
Source File: Background.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
public void onDraw(final GLState pGLState, final Camera pCamera) {
	if (this.mColorEnabled) {
		GLES20.glClearColor(this.mColor.getRed(), this.mColor.getGreen(), this.mColor.getBlue(), this.mColor.getAlpha());
		GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); // TODO Does this cause problems when multisampling?
	}
}
 
Example 12
Source File: ScreenRender.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 5 votes vote down vote up
public void draw(int width, int height, boolean keepAspectRatio, int mode, int rotation,
    boolean isPreview, boolean flipStreamVertical, boolean flipStreamHorizontal) {
  GlUtil.checkGlError("drawScreen start");

  SizeCalculator.processMatrix(rotation, width, height, isPreview, isPortrait,
      flipStreamHorizontal, flipStreamVertical, mode, MVPMatrix);
  SizeCalculator.calculateViewPort(keepAspectRatio, mode, width, height, streamWidth,
      streamHeight);

  GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

  GLES20.glUseProgram(program);

  squareVertex.position(BaseRenderOffScreen.SQUARE_VERTEX_DATA_POS_OFFSET);
  GLES20.glVertexAttribPointer(aPositionHandle, 3, GLES20.GL_FLOAT, false,
      BaseRenderOffScreen.SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aPositionHandle);

  squareVertex.position(BaseRenderOffScreen.SQUARE_VERTEX_DATA_UV_OFFSET);
  GLES20.glVertexAttribPointer(aTextureHandle, 2, GLES20.GL_FLOAT, false,
      BaseRenderOffScreen.SQUARE_VERTEX_DATA_STRIDE_BYTES, squareVertex);
  GLES20.glEnableVertexAttribArray(aTextureHandle);

  GLES20.glUniformMatrix4fv(uMVPMatrixHandle, 1, false, MVPMatrix, 0);
  GLES20.glUniformMatrix4fv(uSTMatrixHandle, 1, false, STMatrix, 0);
  GLES20.glUniform2f(uResolutionHandle, width, height);
  GLES20.glUniform1f(uAAEnabledHandle, AAEnabled ? 1f : 0f);

  GLES20.glUniform1i(uSamplerHandle, 5);
  GLES20.glActiveTexture(GLES20.GL_TEXTURE5);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texId);
  //draw
  GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

  GlUtil.checkGlError("drawScreen end");
}
 
Example 13
Source File: AbsFilter.java    From Pano360 with MIT License 4 votes vote down vote up
public void onPreDrawElements(){
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
}
 
Example 14
Source File: GLDrawer.java    From Building-Android-UIs-with-Custom-Views with MIT License 4 votes vote down vote up
@Override
public void onDrawFrame(GL10 unused) {
    angle = ((float) SystemClock.elapsedRealtime() - startTime) * 0.02f;
    GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    Matrix.setLookAtM(mViewMatrix, 0,
            0, 0, -4,
            0f, 0f, 0f,
            0f, 1.0f, 0.0f);

    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
    Matrix.rotateM(mMVPMatrix, 0, angle, 1.f, 1.f, 1.f);

    GLES20.glUseProgram(shaderProgram);

    int positionHandle = GLES20.glGetAttribLocation(shaderProgram, "vPosition");

    GLES20.glVertexAttribPointer(positionHandle, 3,
            GLES20.GL_FLOAT, false,
            0, vertexBuffer);

    int texCoordHandle = GLES20.glGetAttribLocation(shaderProgram, "aTex");
    GLES20.glVertexAttribPointer(texCoordHandle, 2,
            GLES20.GL_FLOAT, false,
            0, texBuffer);

    int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");

    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);

    int texHandle = GLES20.glGetUniformLocation(shaderProgram, "sTex");
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
    GLES20.glUniform1i(texHandle, 0);

    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glEnableVertexAttribArray(texHandle);
    GLES20.glEnableVertexAttribArray(positionHandle);
    GLES20.glDrawElements(
            GLES20.GL_TRIANGLES, index.length,
            GLES20.GL_UNSIGNED_SHORT, indexBuffer);

    GLES20.glDisableVertexAttribArray(positionHandle);
    GLES20.glDisableVertexAttribArray(texHandle);
    GLES20.glDisable(GLES20.GL_DEPTH_TEST);
}
 
Example 15
Source File: MagicBaseView.java    From TikTok with Apache License 2.0 4 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
}
 
Example 16
Source File: CameraSurfaceView.java    From Paddle-Lite-Demo with Apache License 2.0 4 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
    if (surfaceTexture == null) return;

    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
    surfaceTexture.updateTexImage();
    float matrix[] = new float[16];
    surfaceTexture.getTransformMatrix(matrix);

    // camTextureId->fboTexureId
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo[0]);
    GLES20.glViewport(0, 0, textureWidth, textureHeight);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    GLES20.glUseProgram(progCam2FBO);
    GLES20.glVertexAttribPointer(vcCam2FBO, 2, GLES20.GL_FLOAT, false, 4 * 2, vertexCoordsBuffer);
    textureCoordsBuffer.clear();
    textureCoordsBuffer.put(transformTextureCoordinates(textureCoords, matrix));
    textureCoordsBuffer.position(0);
    GLES20.glVertexAttribPointer(tcCam2FBO, 2, GLES20.GL_FLOAT, false, 4 * 2, textureCoordsBuffer);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, camTextureId[0]);
    GLES20.glUniform1i(GLES20.glGetUniformLocation(progCam2FBO, "sTexture"), 0);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glFlush();

    // Check if the draw texture is set
    int targetTexureId = fboTexureId[0];
    if (onTextureChangedListener != null) {
        boolean modified = onTextureChangedListener.onTextureChanged(fboTexureId[0], drawTexureId[0],
                textureWidth, textureHeight);
        if (modified) {
            targetTexureId = drawTexureId[0];
        }
    }

    // fboTexureId/drawTexureId->Screen
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
    GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    GLES20.glUseProgram(progTex2Screen);
    GLES20.glVertexAttribPointer(vcTex2Screen, 2, GLES20.GL_FLOAT, false, 4 * 2, vertexCoordsBuffer);
    textureCoordsBuffer.clear();
    textureCoordsBuffer.put(textureCoords);
    textureCoordsBuffer.position(0);
    GLES20.glVertexAttribPointer(tcTex2Screen, 2, GLES20.GL_FLOAT, false, 4 * 2, textureCoordsBuffer);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, targetTexureId);
    GLES20.glUniform1i(GLES20.glGetUniformLocation(progTex2Screen, "sTexture"), 0);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glFlush();
}
 
Example 17
Source File: BasicCustomVideoRenderer.java    From opentok-android-sdk-samples with MIT License 4 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER,
            vertexShaderCode);
    int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER,
            fragmentShaderCode);

    mProgram = GLES20.glCreateProgram(); // create empty OpenGL ES
    // Program
    GLES20.glAttachShader(mProgram, vertexShader); // add the vertex
    // shader to program
    GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment
    // shader to
    // program
    GLES20.glLinkProgram(mProgram);

    int positionHandle = GLES20.glGetAttribLocation(mProgram,
            "aPosition");
    int textureHandle = GLES20.glGetAttribLocation(mProgram,
            "aTextureCoord");

    GLES20.glVertexAttribPointer(positionHandle, COORDS_PER_VERTEX,
            GLES20.GL_FLOAT, false, COORDS_PER_VERTEX * 4,
            mVertexBuffer);

    GLES20.glEnableVertexAttribArray(positionHandle);

    GLES20.glVertexAttribPointer(textureHandle,
            TEXTURECOORDS_PER_VERTEX, GLES20.GL_FLOAT, false,
            TEXTURECOORDS_PER_VERTEX * 4, mTextureBuffer);

    GLES20.glEnableVertexAttribArray(textureHandle);

    GLES20.glUseProgram(mProgram);
    int i = GLES20.glGetUniformLocation(mProgram, "Ytex");
    GLES20.glUniform1i(i, 0); /* Bind Ytex to texture unit 0 */

    i = GLES20.glGetUniformLocation(mProgram, "Utex");
    GLES20.glUniform1i(i, 1); /* Bind Utex to texture unit 1 */

    i = GLES20.glGetUniformLocation(mProgram, "Vtex");
    GLES20.glUniform1i(i, 2); /* Bind Vtex to texture unit 2 */

    mTextureWidth = 0;
    mTextureHeight = 0;
}
 
Example 18
Source File: RRGLContext.java    From RedReader with GNU General Public License v3.0 4 votes vote down vote up
public void setClearColor(float r, float g, float b, float a) {
	GLES20.glClearColor(r, g, b, a);
}
 
Example 19
Source File: CameraToMpegTest.java    From Android-MediaCodec-Examples with Apache License 2.0 4 votes vote down vote up
public void drawFrame(SurfaceTexture st) {
    checkGlError("onDrawFrame start");
    st.getTransformMatrix(mSTMatrix);

    // (optional) clear to green so we can see if we're failing to set pixels
    GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    GLES20.glUseProgram(mProgram);
    checkGlError("glUseProgram");

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);

    mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
    GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
    checkGlError("glVertexAttribPointer maPosition");
    GLES20.glEnableVertexAttribArray(maPositionHandle);
    checkGlError("glEnableVertexAttribArray maPositionHandle");

    mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
    GLES20.glVertexAttribPointer(maTextureHandle, 2, GLES20.GL_FLOAT, false,
            TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
    checkGlError("glVertexAttribPointer maTextureHandle");
    GLES20.glEnableVertexAttribArray(maTextureHandle);
    checkGlError("glEnableVertexAttribArray maTextureHandle");

    Matrix.setIdentityM(mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    checkGlError("glDrawArrays");

    // IMPORTANT: on some devices, if you are sharing the external texture between two
    // contexts, one context may not see updates to the texture unless you un-bind and
    // re-bind it.  If you're not using shared EGL contexts, you don't need to bind
    // texture 0 here.
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
}
 
Example 20
Source File: TwoPassFilter.java    From AndroidFastImageProcessing with MIT License votes vote down vote up
@Override
	protected void drawFrame() {
		currentPass = 1;
		if(firstPassFrameBuffer == null) {
			if(getWidth() != 0 && getHeight() != 0) {
				initFBO();
			} else {
				return;
			}
		}

		GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, firstPassFrameBuffer[0]);
		
		if(texture_in == 0) {
			return;
		}
		
		GLES20.glViewport(0, 0, getWidth(), getHeight());
        GLES20.glUseProgram(programHandle);

		GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
		GLES20.glClearColor(getBackgroundRed(), getBackgroundGreen(), getBackgroundBlue(), getBackgroundAlpha());
		
		passShaderValues();
		
		GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); 
		
		texture_in = firstPassTextureOut[0];
		
		GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
		
		currentPass = 2;
		super.drawFrame();
	}