Hi,
I'm trying to get started on the use of framebuffers and so I figured I'd try write a simple program which just draws to a new framebuffer and then draws that to the screen/main framebuffer. The issue is that it appears to only draw the colour that I cleared the framebuffer to, not the geometry. Let me be a little more specific. On my framebuffer I clear to blue, and then draw 2 overlapping squares. I then clear the screenbuffer to red and draw the contents of the framebuffer to screen-sized quad. What I end up with is an entirely blue screen :< I know that it is in fact drawing *something* from the FBO because the screen is blue, not red. I am also sure that the geometry is indeed getting drawn to the framebuffer because if I print out the pixel contents of that texture, I can see the 2 squares. If I make it draw directly to the screen instead of the FBO, I get the correct image. I am completely stumped, I've been trying to work at this for ages now but to no avail so if anybody has anything that might help I would be most appreciative. Code: http://pastebin.com/B3WwLvKz (Shows the correct image if you comment out lines 82, 92, 97-114) Shaders: http://pastebin.com/7ufxtjd9 |
Administrator
|
On 12/25/2013 07:03 PM, D3zmodos [via jogamp] wrote:
> Hi, > > I'm trying to get started on the use of framebuffers and so I figured I'd try > write a simple program which just draws to a new framebuffer and then draws > that to the screen/main framebuffer. The issue is that it appears to only draw > the colour that I cleared the framebuffer to, not the geometry. > > Let me be a little more specific. On my framebuffer I clear to blue, and then > draw 2 overlapping squares. I then clear the screenbuffer to red and draw the > contents of the framebuffer to screen-sized quad. What I end up with is an > entirely blue screen :< > > I know that it is in fact drawing *something* from the FBO because the screen > is blue, not red. I am also sure that the geometry is indeed getting drawn to > the framebuffer because if I print out the pixel contents of that texture, I > can see the 2 squares. If I make it draw directly to the screen instead of the > FBO, I get the correct image. > > I am completely stumped, I've been trying to work at this for ages now but to > no avail so if anybody has anything that might help I would be most appreciative. > > Code: http://pastebin.com/B3WwLvKz (Shows the correct image if you comment out > lines 82, 92, 97-114) > Shaders: http://pastebin.com/7ufxtjd9 com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2 Set debug property 'jogl.debug.FBObject' to double check .. Your 'renderToFBO()' doesn't use a shader, so I assume a compatibility profile is in use ? Also: 'renderFBOToScreen()' does not disable the shader .. In renderFBOToScreen() you do not use FBObject's 'use(..)' and 'unuse(..)' methods (as FBOMix2DemosES2 does). Are you sure you don't miss any GL state here ? IMHO try to reuse FBOMix2DemosES2 or similar code and go from there. While doing so - please provide us w/ details what went wrong so we may can fix the FBObject API documentation. Thank you! ~Sven signature.asc (911 bytes) Download Attachment |
Works now (at least as far as I can see) :D Thanks so much!
I added a shader in 'renderToFBO()' and disabled the shader after rendering in 'renderFBOToScreen()' I was just confused (and I guess I still am) as to why it wouldn't render properly to an FBO without a shader when it rendered just fine to the screen (IE if I didn't bind the fbo first). I also wouldn't have thought that unbinding a shader would make any difference after things have already been drawn. Also I was trying to stick as closely as possible to the code found at http://jogamp.org/wiki/index.php/FBObject |
Free forum by Nabble | Edit this page |