Question

I create a depth/stencil buffer by issuing this series of command to OpenGL:

glBindTexture(GL_TEXTURE_2D, 0)
glGenTextures(1, &TextureId)
glBindTexture(GL_TEXTURE_2D, TextureId)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 640, 480,  0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0)

Then I try and attach it to the framebuffer with

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, TextureId, 0)

But a call to glCheckFramebufferStatusEXT returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT. If I don’t attach the depth-stencil buffer, this very test goes fine (but obviously the display is screwed).

Do you guys have any clue?

EDIT: Changed: I have simplified the texture creation to a basic texture’s format.

Was it helpful?

Solution

Okay, the problem disappeared when I removed all the trailing EXT…

OTHER TIPS

The texture you're attaching to GL_DEPTH_STENCIL_ATTACHMENT has neither depth nor stencil information in it. If you want to attach a texture to GL_DEPTH_STENCIL_ATTACHMENT, you make sure it's image format has depth and stencil data.

Now OpenGL versions does not need EXT extension~~~

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top