Example usage for android.opengl GLES20 GL_DEPTH_ATTACHMENT

List of usage examples for android.opengl GLES20 GL_DEPTH_ATTACHMENT

Introduction

In this page you can find the example usage for android.opengl GLES20 GL_DEPTH_ATTACHMENT.

Prototype

int GL_DEPTH_ATTACHMENT

To view the source code for android.opengl GLES20 GL_DEPTH_ATTACHMENT.

Click Source Link

Usage

From source file:Main.java

/**
 * Make a given frameBuffer and texture render targets active. Example of setup for rendering to viewport: PheiffGLUtils.bindFrameBuffer(0, -1, -1);
 * <p/>/*from  ww  w .j a va2  s.c o  m*/
 * Example of setup for rendering to a texture: PheiffGLUtils.bindFrameBuffer(frameBufferHandle, colorRenderTextureHandle, depthRenderTextureHandle);
 *
 * @param frameBufferHandle        GL handle to a frame buffer object to use OR 0 for the main framebuffer (viewport)
 * @param colorRenderTextureHandle GL handle to the texture where colors should be rendered or -1 to not use this feature
 * @param depthRenderTextureHandle GL handle to the texture where depth information should be rendered  or -1 to not use this feature
 */
public static void bindFrameBuffer(int frameBufferHandle, int colorRenderTextureHandle,
        int depthRenderTextureHandle) {
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBufferHandle);
    if (frameBufferHandle != 0) {
        GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,
                colorRenderTextureHandle, 0);
        GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_TEXTURE_2D,
                depthRenderTextureHandle, 0);
    }
}