当片段输出为vec3时,glBlitFramebuffer()呈现空屏幕

时间:2012-07-02 17:31:05

标签: opengl fbo blit

我正在使用OpenGL 4.0,以前使用的是3.3我有一个带有3个输出的片段着色器 - 每个是vec3。我正在将这些输出写入某个FBO然后尝试使用glBlitFramebuffer()方法测试内容。我是得到空屏幕。现在,我发现将输出设置为vec4类型正常工作。我不明白为什么!我的FBO纹理设置为RGB32F,因此它们应该能够接受片段中的vec3。 这是我的FBO设置(即Java LWJGL包装器,但这里没关系):

    _fbo = glGenFramebuffers();
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo);


    glGenTextures(m_textures);
    _depthTexture = glGenTextures();


   for (int i = 0; i < GBUFFER_NUM_TEXTURES; i++) {


        glBindTexture(GL_TEXTURE_2D, m_textures.get(i));//
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, height, 0, GL_RGB, GL_FLOAT, (ByteBuffer) null);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i , GL_TEXTURE_2D,m_textures.get(i), 0);//

    }

    // depth
    glBindTexture(GL_TEXTURE_2D, _depthTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer) null);
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _depthTexture, 0);





    DrawBuffers = BufferUtils.createIntBuffer(GBUFFER_NUM_TEXTURES);

      DrawBuffers.put(0, GL_COLOR_ATTACHMENT0);
      DrawBuffers.put(1, GL_COLOR_ATTACHMENT1);
      DrawBuffers.put(2, GL_COLOR_ATTACHMENT2);



     glDrawBuffers(DrawBuffers);

0 个答案:

没有答案