Student123
Student123

Reputation: 423

OpenGL FBO colour attachment shrinking

I have an FBO with 4 frame buffer textures. These textures are 4 different sizes.

The problem is that if texture 4 and texture 1 for example are attached using:

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, bl_64, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, bl_128, 0);

When I draw to texture 1 the image on the texture only takes up the size of texture 4.

 m_blurrFBO.DrawingBind();   
 glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, 1, &BlurrPass);  
 glViewport(0, 0, 512, 360);
 glDrawBuffer(GL_COLOR_ATTACHMENT0);
 DrawQuad();       
 FBO::UnbindDrawing();

The reason I'm using 4 different textures with different sizes is that I'm down sampling the same image 4 times each half the size as the last.

The problem is the code has been tested on 5 different computers all with either AMD or NVIDIA cards and it works as expected. I have the up to date drivers for my nvidia gtx 550 is this a known problem ?

The sunset should take up the full size of the screen

Upvotes: 0

Views: 100

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473272

This problem is called "That's how OpenGL works."

The total size of a framebuffer is based on the smallest size, in each dimension, of all of the attached images. You are not allowed to render outside of any attached image. Even if you use write masking or draw buffers state so that you don't actually render to it, the available viewport size is always limited to the smallest size of the attached images.

As a general rule, do not attach an image to a framebuffer unless you are serious about rendering to it. If you want to do downsampling, swap FBOs or change attached images between each sampling pass.

Oh and BTW: it is undefined behavior (unless you're using GL 4.5 or ARB/NV_texture_barrier) to read from any texture object that is currently attached to the FBO. Again, write masks and draw buffers state is irrelevant; what matters is that the image is attached. So again, don't attach something unless you are writing to it.

Upvotes: 1

Related Questions