Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I use frame buffer objects in a JOGL application to do many things, from shadow maps to picking, and everything works as expected. However, as soon as I bind and unbind an FBO, errors are thrown when trying to get a screenshot of the default frame buffer and a null is returned.
I unbind an FBO by setting GL_FRAMEBUFFER to 0: gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); I then use AWTGLReadBufferUtil to get a BufferedImage (the true parameter at the end flips the image vertically): new AWTGLReadBufferUtil(GLProfile.get(GLProfile.GL2), !renderBackgroundInScreenshot).readPixelsToBufferedImage(gl, true); The following error occurs: Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x502 GLReadBufferUtil.readPixels: readPixels error 0x502 1038x633 When no FBO is bound or unbound, the BufferedImage is created without issue. I can also create BufferedImages from bound FBOs without issue. It is only when I unbind an FBO by setting GL_FRAMEBUFFER to 0 that I receive this error, so I am unsure how to get a screenshot from the default frame buffer after using an FBO. In fact, just calling gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); at the beginning of the render loop causes this error to occur. To make things even weirder, if I use the following code to get the default frame buffer binding at the beginning of my render loop, 1 is returned. But setting GL_FRAMEBUFFER back to 1 does not fix this issue. int[] ifbodefault = new int[1]; gl.glGetIntegerv(GL.GL_FRAMEBUFFER_BINDING, ifbodefault, 0); System.out.println(ifbodefault[0]); Does anyone have any ideas about what is happening here? Also, I use JOGL 2.3 and glGetError right before calling readPixelsToBufferedImage returns no errors. I know of a possible workaround where I create yet another FBO for screenshots and render to that FBO and read from it when a screenshot is needed, but it seems like unnecessary overhead when I should just be able to read from the default frame buffer as I can when no FBO objects are used. Thank you for your feedback. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Try to do it manually as I suggested you on SO
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thanks for the suggestion. Unfortunately, that function only gives me a black image. I currently just implemented a workaround where textures generated from FBOs are just cached and then reused in the next render loop so I don't need to bind/unbind any FBOs when taking a screenshot. I am still looking into why this doesn't work though.
I should add that the first of the two err.println (Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x502 ) is actually coming from my testing.
The second comes from line 237 of GLReadBufferUtil. No error is found at any time before from glGetError().
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
If you get the black image without error, it means it is a logic error but the code is correct.
|
Free forum by Nabble | Edit this page |