1

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.

qdii
  • 12,505
  • 10
  • 59
  • 116

3 Answers3

2

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

qdii
  • 12,505
  • 10
  • 59
  • 116
2

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
1

Now OpenGL versions does not need EXT extension~~~

XiaJun
  • 1,855
  • 4
  • 24
  • 41
  • I thought they would still be supported for backward compatibility, but apparently mixing both EXT and non-EXT versions is not okay :) – qdii Mar 24 '12 at 09:36