I’ve got a piece of code used for high-res screenshots and I’m getting artifacts between tiles (visible borders), but only for 4096^2 tile sizes. I created a standalone app that just does one tile and the problem’s evident there too. The relevant code is:
// Buffer ids.
GLuint uFramebuffer;
GLuint uColourbuffer;
// Generate buffers.
glGenFramebuffersEXT(1, &uFramebuffer);
glGenRenderbuffersEXT(1, &uColourbuffer);
// What are the implementation-defined maximum renderbuffer dimensions? On my GF5200 it'll be 4096.
int nRenderbufferSize(0);
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &nRenderbufferSize);
// If you force the size down to 2048 the problem disappears.
//nRenderbufferSize = 2048;
// Bind the application's framebuffer.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, uFramebuffer);
// Attach a colour renderbuffer image.
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, uColourbuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, nRenderbufferSize, nRenderbufferSize);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, uColourbuffer);
// Make sure it worked.
assert(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT);
// Set the draw and read locations.
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
// Make sure the framebuffer's clean.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// Pixel storage, doubleword aligned.
GLubyte *pPixels = static_cast<GLubyte *>(_aligned_malloc(nRenderbufferSize * nRenderbufferSize * 4, 32));
assert(pPixels);
// Get the framebuffer pixels.
glReadPixels(0, 0, nRenderbufferSize, nRenderbufferSize, GL_BGRA, GL_UNSIGNED_BYTE, static_cast<GLvoid *>(pPixels));
// Save pixels in a Bitmap.
Gdiplus::Bitmap bitmap(nRenderbufferSize, nRenderbufferSize, 4 * nRenderbufferSize, PixelFormat32bppARGB, pPixels);
CLSID jpgClsid;
GetEncoderClsid(L"image/jpeg", &jpgClsid);
Gdiplus::Status stResult(bitmap.Save(L"FBObug.jpg", &jpgClsid, NULL));
assert(stResult == Gdiplus::Status::Ok);
// Free mem.
_aligned_free(pPixels);
// Bind the system's framebuffer.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
// Clean up.
glDeleteFramebuffersEXT(1, &uFramebuffer);
glDeleteRenderbuffersEXT(1, &uColourbuffer);
so nothing extraordinary. It doesn’t matter if I use GDI+ for saving images or a proprietary library (LEADTOOLS). I’ve viewed the image created using IrfanView, Gimp 2.2, ERViewer and some MS utilities and there is a visible band of garbage pixels along the RHS border. Maybe I’m just missing something really obvious? I created some sample code here if you want download, compile and test the problem. It does the same thing using FBOs and pbuffers and shows FBOs have the problem while same-sized pbuffers don’t. You’ll need GDI+ (i.e. WinXP or a free download), GLEW stuff’s included and I built with VS2005 so you’ll need to set up your own project if you’re using another compiler.
Thanks in advance.