I have been experimenting with some post-processing effects and I have been using FBOs to store stuff.

The problem is, I attempt to resize them when I change resolution. I get no errors, however the image has been stretched so that I only see about the bottom-left quarter of it on my screen.

I have looked over the internet and and found issues such as not using glTexStorage because it is immutable, and being sure to call glViewport after binding a framebuffer. As far as I can see I'm not missing anything simple like that.

Here are some (very dark) screen shots showing the issue:

Please excuse the horrible graphics. I am working on a bloom filter and these images only contain the bright bits so it looks dark and weird.

The Original Scene, before entering full screen mode. The scene in full screen mode, everything has been magnified

My FBOs are initialised with a blank texture attached to GL_COLOR_ATTACHMENT0. Here is the rough pseudo code (in java). (my actual code is abstracted behind a game engine I'm writing)

Generating texture:

    // Creates the texture

    this.id = glGenTextures();

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glBindTexture(GL_TEXTURE_2D, this.id);


    // Set up texture scaling
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magnification);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minification);

Filling it with data: (data is a ByteBuffer filled with 0s)

    glTexImage2D(GL_TEXTURE_2D, 0, colorMode, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

Binding the framebuffer:

   glBindFramebuffer(GL_FRAMEBUFFER, this.id);
   glViewport(0, 0, width, height); // width and height taken from width and height of framebuffer texture

Resizing the framebuffer:

    // stores new width and height to be used with glViewport
    this.width = width;
    this.height = height;
    // resize renderbuffer
    if(renderbuffer != 0) {
        glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
        glBindRenderbuffer(GL_RENDERBUFFER, 0);

    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
    glGenerateMipmap(GL_TEXTURE_2D); // do i need this?

Thanks very much in advance if you can spot an issue with my code. Let me know if you need the full source as well.

I have a couple of ideas for issues:

  • is it possible to resize the renderbuffer like that?
  • do I have to re-attach the textures after resizing them
  • should i just re-create the entire framebuffer/renderbuffer/textures instead of resizing them.

2 Answers 2


To be safe I'd delete and recreate the entire FBO.

Some drivers have strange stability issues when recycling/resizing FBOs. I've had entire screen flickers and occasional crashes.

Switching attached textures to another of the same size & type seem to work fine all the time on all drivers but with some drivers it is much faster (more than 100x) to have multiple FBO objects and never re-attach textures, just switch between entire FBOs, with the same depth buffer attached to all of them.


Double check if you are truly using viewport correctly.

You're not rebinding the texture to the FBO.
That SHOULDN'T be necessary, however the spec makes no guarantee that glTexImage won't screw up any attached framebuffers, so assume that it can.

If that doesn't work then its the way you're sampling from it.

For simply allocating a texture with undefined content, use null as the data pointer, much faster.

Absolutely never use mipmaps with a framebuffer unless you know for sure you will be minifying it, otherwise you'll use a ton of memory.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .