Guys,
Anybody successfully used a FBO with a depth texture on iPhone ?
What i am trying is not working (GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT):
GLenum status;
glGenFramebuffers(1, &shadowFBOId);
glBindFramebuffer(GL_FRAMEBUFFER,shadowFBOId);
glGenTextures(1, &colorTextureId);
glBindTexture(GL_TEXTURE_2D, colorTextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, renderWidth, renderHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, colorTextureId, 0);
glGenTextures(1, &shadowMapTextureId);
glBindTexture(GL_TEXTURE_2D, shadowMapTextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, renderWidth, renderHeight, 0, GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,shadowMapTextureId,0 );
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
I’ve tried to use a Renderbuffer for the depth buffer and it is working fine (but I can’t use a renderbuffer in my shader to perform shadowmapping.
I’ve tried to remove the depth buffer attachement and again it is working fine.
I suspect the issue is in the way I set the glTexImage2D’s depth attribute.
Any clue ?