why fbo can't generate right size of texture on macOS?

58 Views Asked by At

I want to implement a function on my macOS, with QT.

I have a surface, writes the result to a texture buffer instead of visualizing it Then render it in fragment shader. The size of the result is wrong.

limitFramebuffer is my QOpenGLFramebufferObject.

 // Render limit surface to framebuffer
        limitFramebuffer->bind();
        glClearColor(0, 0, 0, 1);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        renderers["Limit"]->render();
        limitFramebuffer->release();

        // Set limit framebuffer as current texture
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, limitFramebuffer->texture());
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glDrawBuffer(GL_COLOR_ATTACHMENT0);

        QImage image0 = limitFramebuffer->toImage(); 
        QDateTime d = QDateTime::currentDateTime();
        QString date = d.toString("dd.MM.yyyy.hh:mm:ss.zzz") + ".png";
        QString fileName =  "./../../../../MeshTool/examples/texture/" + date;

The image saved is enter image description here

It shoulde be: enter image description here

As we can see, the texture generated contains only a quarter of the original image from the bottom left corner.

I use glBindTexture(GL_TEXTURE_2D, limitFramebuffer->texture()); to bind the texture.

How can I make the texture contain all the data in the FBO? Why does the FBO contain only a quarter of the data?

Thanks!

0

There are 0 best solutions below