Reputation: 12953
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.
Upvotes: 1
Views: 2108
Reputation: 473262
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.
Upvotes: 2