Hi, I use a multisample FBO and a normal FBO to save the openGL scene to an image on the disk.
If I render to a small size, e.g. 4096 x 4096, it properly works. I get a good antialias.
But if I set a size to e.g. 6000 x 6000 or 7000 x 7000, even if my GL_MAX_VIEWPORT_DIMS is 8192 x 8192, I get a garbage image.
If I set 8000 x 8000, sometimes I cannot initialize the normal FBO because I get the error GL_FRAMEBUFFER_UNSUPPORTED_EXT or sometimes I can properly initialize the FBOs but later, at the first draw, I get the following crash. Please note, if I don’t use the FBO Multisample, and use only the normal FBO, I can quite use the size 8192 x 8192.
Program received signal: “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all
(gdb) backtrace
#0 0x8f0db3cf in gldAttachDrawable ()
#1 0x8f1a4478 in gldUpdateDispatch ()
#2 0x8f1a4a10 in gldFlush ()
#3 0x163259ba in glFlushRender_Exec ()
#4 0x9973ec28 in glFlushRenderAPPLE () I even tried the traditional glFlush(), same result.
#5 0x00063518 in ?? ()
#6 0x00066e19 in ?? ()
#7 0x0001e2fa in ?? ()
#8 0x00091d99 in ?? ()
#9 0x95289edd in invoking_ ()
#10 0x95289e48 in -[NSInvocation invoke] ()
#11 0x952c6698 in -[NSInvocation invokeWithTarget:] ()
#12 0x9528acd4 in forwarding ()
#13 0x9528a802 in forwarding_prep_0_ ()
#14 0x95289edd in invoking_ ()
#15 0x95289e48 in -[NSInvocation invoke] ()
#16 0x9939f8c6 in -[NSConnection dispatchInvocation:] ()
#17 0x9939e049 in -[NSConnection handleRequest:sequence:] ()
#18 0x99397e52 in -[NSConnection handlePortCoder:] ()
#19 0x99397a81 in -[NSConcretePortCoder dispatch] ()
#20 0x9937f3dd in __NSFireMachPort ()
#21 0x95252772 in __CFMachPortPerform ()
#22 0x9524e4db in __CFRunLoopRun ()
#23 0x9524c464 in CFRunLoopRunSpecific ()
#24 0x9524c291 in CFRunLoopRunInMode ()
#25 0x933bdf9c in RunCurrentEventLoopInMode ()
#26 0x933bdd51 in ReceiveNextEventCommon ()
#27 0x933bdbd6 in BlockUntilNextEventMatchingListInMode ()
#28 0x904f978d in _DPSNextEvent ()
#29 0x904f8fce in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#30 0x904bb247 in -[NSApplication run] ()
#31 0x904b32d9 in NSApplicationMain ()
#32 0x00002756 in ?? ()
kill
quit
Would you please tell me what I do wrong here?
I create the FBOs this way:
// Create Multisample FBO__________________________
GLsizei antialiasSamples = 4; // my max samples is 6 (kCGLRPMaxSamples)
// Create multisample RBO Color
glGenRenderbuffersEXT(1, &mMultiSampleRBOColor);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mMultiSampleRBOColor);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, antialiasSamples, GL_RGBA8, mWidth, mHeight);
// Create multisample RBO Depth
glGenRenderbuffersEXT(1, &mMultiSampleRBODepth);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mMultiSampleRBODepth);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, antialiasSamples, GL_DEPTH_COMPONENT24, mWidth, mHeight);
// Create multisample FBO to render in
glGenFramebuffersEXT(1, &mMultiSampleFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mMultiSampleFBO);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, mMultiSampleRBOColor);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mMultiSampleRBODepth);
// Check the validity of the Multisample FBO…
// Create Normal FBO__________________________
// Create RBO Color
glGenRenderbuffersEXT(1, &mRBOColor);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mRBOColor);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, mWidth, mHeight);
// Create RBO Depth
glGenRenderbuffersEXT(1, &mRBODepth);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mRBODepth);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, mWidth, mHeight);
// Create FBO to get the final image
glGenFramebuffersEXT(1, &mFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, mRBOColor);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mRBODepth);
// Check the validity of the FBO...
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
// This is my draw routine__________________________
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mMultiSampleFBO);
// Draw the scene
glFlushRenderAPPLE();
glFinish();
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, mMultiSampleFBO); //Bind the Multisample FBO to read from
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, mFBO); //Bind the normal FBO to write to
glBlitFramebufferEXT(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
//Bind the standard FBO for reading
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
I run MacOS X 10.6.5, NVIDIA GeForce GT 330M OpenGL Engine, 512MB VRAM, OpenGL Version: 2.1 NVIDIA-1.6.24