I am attempting to render a scene's depth to a cubemap texture, but upon checking the framebuffer status it returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT and of course no rendering occurs. Obviously I am missing something but I cannot seem to figure that out, I was hoping somebody here could help me with that. My video card is a NVIDIA GeForce 840M that supports OpenGL 4.5. Below is how I set up the rendering to the fbo.
UPDATE: Attach all cubefacetextures before rendering loop
GLuint texhandle;
glGenTextures(1, &texhandle);
glBindTexture(GL_TEXTURE_CUBE_MAP, texhandle);
for (int i = 0; i < 6; i++) {
glTexImage2D(
GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
GL_DEPTH_COMPONENT24, 1600, 900,
0, GL_DEPTH_COMPONENT, GL_FLOAT, 0
);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
GLuint fbohandle;
glGenFramebuffers(num, &fbohandle);
glBindFramebuffer(GL_FRAMEBUFFER, fbohandle);
glCullFace(GL_BACK);
for (int i = 0; i < 6; i++) {
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_DEPTH_ATTACHMENT,
GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
fbohandle,
0
);
}
for (int i = 0; i < 6; i++) {
GLenum cubemapSide = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, cubemapSide, fbohandle, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawBuffer(GL_NONE);
CheckFramebufferStatus();
RenderScene()
}