virtual framebuffer

How can I create a higher resolution screenshot than my frame buffer can support?

ie I’d like to stitch four (or more!) 1024x768 framebuffers together into a giant 2048x1536 image

Originally posted by titan:
[b]How can I create a higher resolution screenshot than my frame buffer can support?

ie I’d like to stitch four (or more!) 1024x768 framebuffers together into a giant 2048x1536 image[/b]

I have no idea if this would work but,
using a 1024x768 framebuffer,

-specify a 2048x1536 viewport and create two user-defined clipping planes or

-setup custom projection matrices. Be sure to keep aspect and c.o.p. same though.
Then you’ll have some nice seams to handle too.

There is an article in Game Programming Gems 2 about how to do this and some issues to look out for. I could have sworn I also saw something about how to do this on the net somewhere but for the life of me I don’t remember where.

Basically what you do is, let’s say you want to capture an image that is 3072x2304 pixels. What you would have to do is setup 9 frustums 1024x768 pixels each. What you will have is a large rectangle subdivided into 9 smaller rectangles with dimensions 1024x768 pixels. Something like this:


| | | |
| | | |
| | | |

| | | |
| | | |
| | | |

| | | |
| | | |
| | | |

So as you can see, you will have to render 9 times in this case to get the 3072x2304 pixel size image.

Something to watch for is shading mismatches on large trangles that span across multiple frustums from above. There are other issues to watch out for like the quality of some effect being applied to your objects in your scene, animation poses need to be the same for each render, etc. But I’m sure you will discover all of those little issues once you get this working.

-SirKnight

Make offcenter projections, take screen shots of each. Then stitch the images together. Neither GL, nor GLU directly support offcenter perspective projections, so you’ll have to cook up your own matrices in that case.

DFrey — I haven’t sat down and worked out the maths myself, but it’d seem to me that you could do off-centre projections with non-symmetrical left/right and top/bottom planes, something like (I just wrote this off the top of my head):

/* normal, single view camera: */
GLfloat lrbt[4]={ -32.0, 32.0, -24.0, 24.0 };
glFrustum(lrbt[0], lrbt[1], lrbt[2], lrbt[3], near, far);
renderScene(); 

/* generate a set of 9 images that will generate the above scene (maybe?) */
for(int y=0; y<3; y++) {
  for(int x=0; x<3; x++) {
    GLfloat lrbt_[4]={
      ((x+0)/3.0)*(lrbt[1]-lrbt[0])+lrbt[0],        
      ((x+1)/3.0)*(lrbt[1]-lrbt[0])+lrbt[0],
      ((y+0)/3.0)*(lrbt[3]-lrbt[2])+lrbt[2],        
      ((y+1)/3.0)*(lrbt[3]-lrbt[2])+lrbt[2]
    };
    glFrustum(lrbt_[0], lrbt_[1], lrbt_[2], lrbt_[3]);
    renderScene();
  }
}

<shrugs>?

If your hardware supports it, as well as your target hardware… use a pbuffer / render to texture