user3181019
user3181019

Reputation: 15

OpenGL ES 2.0 GL_DEPTH_COMPONENT and glTexImage2D

The Chapter 12 of OpenGL ES 2.0 programming guide book has an example, which called Example 12-2 Render to Depth Texture. This example calls glTexImage2D API, and the internalformat parameter is GL_DEPTH_COMPONENT.

But using GL_DEPTH_COMPONENT is not allowed according to https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glTexImage2D.xml.

So I have 2 questions about OpenGL ES 2.0.

Upvotes: 0

Views: 2468

Answers (1)

James Poag
James Poag

Reputation: 2380

Which API will use GL_DEPTH_COMPONENT enumeration?

glRenderbufferStorage uses GL_DEPTH_COMPONENT, specifically GL_DEPTH_COMPONENT16

    glGenRenderbuffers(1, (GLuint*)&_nRenderTargetRboDepthId);
    glBindRenderbuffer(GL_RENDERBUFFER, _nRenderTargetRboDepthId);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, nTexWidth, nTexHeight);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _nRenderTargetRboDepthId);

    GLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if(err != GL_FRAMEBUFFER_COMPLETE) { // error!
         // format harddrive
    }

Upvotes: 1

Related Questions