Throws GL FRAMEBUFFER INCOMPLETE MISSING ATTACHMENT when using renderbuffers

Hi,

I’m trying to draw to a Framebuffer Object and then blit it to the default framebuffer. It’s in two chunks that get combined to one image on screen to avoid scissoring the image to the old window dimensions when the window is resized. It would have a noticeable black bar on the new area of the window until the next frame is sent otherwise. The scissoring indeed happens even when using Framebuffer Objects of larger dimensions than the window. I’ve narrowed down the errors to this part where GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT is thrown. It seems like it was drawing to the defeult framebuffer rather than the Framebuffer Object before I fixed it to the current state.

Init:

MemoryStack stack = stackPush();
IntBuffer buffer = stack.mallocInt(4);
glGenBuffers(buffer​);
MemoryStack stackb = stackPush();
IntBuffer fbuffer = stackb.mallocInt(2);
glGenFramebuffers(fbuffer);
for(int i=0;i<2;i++) {
glBindRenderbuffer(GL_RENDERBUFFER, buffer.get(i));
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 320, 360);
glBindRenderbuffer(GL_RENDERBUFFER, buffer.get(i+2));
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 320, 360);
glBindFramebuffer(GL_FRAMEBUFFER, fbuffer.get(i));
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, buffer.get(i));
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, buffer.get(i+2));
} int framebuffer = fbuffer.get(0);
int framebuffer_b = fbuffer.get(1);

Draw:

public static void render(long win, int rb, int rb_b, int fb, int fb_b) {
for(int i=0;i<2;i++) {
glBindFramebuffer(GL_FRAMEBUFFER, (i==0)?fb:fb_b);
glViewport(0, 0, 320, 360);
//etc.
}

Copy:

glfwSetWindowSize(
win, 320, windowheight
);
        
for(int i=0;i<2;i++) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, (i==0)?fb:fb_b);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glDrawBuffer(GL_BACK_LEFT);
        
glBlitFramebuffer(0,0,320,360-i*(360-(windowheight-360)),0,0+i*360,320,360+i*360-i*(360-(windowheight-360)),GL_COLOR_BUFFER_BIT,GL_NEAREST);
}

for(int i=0;i<2;i++) {
glBindFramebuffer(GL_FRAMEBUFFER, (i==0)?fb:fb_b);
switch (glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
case GL_FRAMEBUFFER_COMPLETE: System.out.println("GL_FRAMEBUFFER_COMPLETE"); break;
//etc.
}}
System.exit(0);

glfwSwapBuffers(win);
}

That is for creating buffer objects. To create renderbuffers, you use glGenRenderbuffers.

Thank you, it is drawing something again.