Hi guys,
I’ve been trying to get my application running on someone else’s computer, so the code that follows is known to work on my PC, as well as on that of another friend. We both have AMD GPUs.
The code is however returning a faulty framebuffer on the PC of an NVIDIA user (unsure if manufacturer is a factor here, but mentioning to be sure).
The status it returns for him is: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
The purpose of this code is to generate a framebuffer with a texture array (GL_TEXTURE_2D_ARRAY) in order to generate cascades for shadowmapping.
m_fbo is a GLuint to store the framebuffer, m_shadowMap is a GLuint to store the shadowMap texture array.
windowWidth and windowHeight are positive integers.
I’ve not had much luck searching the internet for similar problems using GL_TEXTURE_2D_ARRAY, so I’ve taken to the forums.
My question is thus: am I doing certain steps incorrectly, possibly in the wrong order?
Any suggestions are greatly appreciated!
Thanks in advance,
Lodeman
bool ShadowMapFBO::init(unsigned int windowWidth, unsigned int windowHeight)
{
// Create the FBO
glGenFramebuffers(1, &m_fbo);
// Create the depth buffer
glGenTextures(1, &m_shadowMap);
glBindTexture(GL_TEXTURE_2D_ARRAY, m_shadowMap);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT16, windowWidth, windowHeight, NUM_CASCADES, GL_FALSE, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_ARRAY, m_shadowMap, 0, 0);
for(int i = 0; i < NUM_CASCADES; ++i)
{
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_shadowMap, 0, i);
}
// Disable writes to the color buffer
glDrawBuffer(GL_NONE);
GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (Status != GL_FRAMEBUFFER_COMPLETE) {
MessageBox(NULL, "Failed to create ShadowMapFBO, status: "+Status, "Heavy times", MB_ICONERROR | MB_OK);
Debug::printDebugTextWithInt("Failed to create ShadowMapFBO, status: ", Status);
return false;
}
Debug::printDebugText("Succesfully created ShadowMapFBO");
return true;
}