Home Forums GAMES在线课程(现代计算机图形学入门)讨论区 遇到glCheckFramebufferStatus()返回0的问题

Viewing 0 reply threads
  • Author
    Posts
    • #7920 Score: 0
      eddieeee
      Participant

      哈喽大家好,我最近在尝试在framebuffer上进行渲染,然后再把渲染结果通过glReadPixels来读到cpu的内存中来。我的一部分代码在我的电脑上运行完全没有问题,但是在另一台电脑上,遇到glCheckFramebufferStatus()返回0的问题。在opengl官方文档里写着

      Additionally, if an error occurs, zero is returned.

      但是我用glGetError()但是返回的值仍然是0显示没有error. 不知道有没有人遇到过这种情况?感谢帮助啊!!

      (opengl version是4.6.0, 我的nvidia driver是418.56,另外一台电脑是nvidia driver 450.51.06, 不知道这会不会是driver版本引起的问题?)

      
          glGenFramebuffers(1, &f.FBO);
          glGenRenderbuffers(1, &f.color_buf);
          glGenRenderbuffers(1, &f.depth_buf);
      
          glBindRenderbuffer(GL_RENDERBUFFER, f.color_buf);
          glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, w, h);
      
          glBindRenderbuffer(GL_RENDERBUFFER, f.depth_buf);
          glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, w, h);
      
          glBindFramebuffer(GL_FRAMEBUFFER, f.FBO);
      
          glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, f.color_buf);
          glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, f.depth_buf);
      
          GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
          if (status != GL_FRAMEBUFFER_COMPLETE)
            std::cout << "create frame buffer fail!" << std::endl;
          glBindFramebuffer(GL_FRAMEBUFFER, 0);
      
      • This topic was modified 3 years, 8 months ago by eddieeee.
Viewing 0 reply threads
  • You must be logged in to reply to this topic.