GLuint32 fbo[2];
GLuint32 rbo[2];
GLuint32 texture[2];
glGenFramebuffers (2, fbo);
glGenTextures (2, texture);
glGenRenderbuffers (2, rbo);
glBindTexture (GL_TEXTURE_2D, texture[0]);
glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
glBindTexture (GL_TEXTURE_2D, texture[1]);
glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
稍后在我这样做的代码中,
glBindTexture (GL_TEXTURE_2D, texture[0]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
读缓冲区格式和写缓冲区格式是一样的,预期的是:读缓冲区:GL_RGBA32UI,绘制缓冲区:GL_RGBA
但是,当我这样做时(删除 glBindTexture)
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
我得到了预期的结果。我在这里想念什么?有人可以帮助我了解这是如何工作的。