I once posted a thread about the depth texture problem, and added more and more questions there. Now I summarize my current problems here and hope somebody can give me a hand.
first, to get my Render Buffer work. The code for initialization is as simple as:
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
glGenRenderbuffers(1, &rbo);
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, 512, 512);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
Then in the glutDisplayFunc(), I called
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, rbo);
before rendering, and called
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
after.
The program runs well before I use framebuffer object, only after binding the framebuffer object, I find nothing in the render buffer object.
This problem has bothered me for two days…