Johannes Brunen
2015-11-19 15:50:59 UTC
Hello Carsten and Gerrit,
after Gerrit was so kind to provide a FBOBackground on my request, I have taken the time to write a FBOGrabForeground and two examples showing these in action.
The first one, named dyndrawing1.cpp uses a FBO that is created from the scene with the help of a SimpleStage, a VisitSubTree and a PassiveViewport. This FBO is then used in the new FBOBackground.
The second one, named dyndrawing2.cpp is quite similar to the first one, but the FBO is filled with the help of my new FBOGrabForeground class that I would like to see in OpenSG.
Both examples work reasonably but nevertheless some things are not perfect or need some clarifications. May I ask for some help here?
Let me enumerate the points:
1.) In the class FBOBackground Gerrit has used the following BlitFramebuffer statement in function clear:
osgGlBlitFramebuffer(
0,
0,
_sfFrameBufferObject.getValue()->getWidth (),
_sfFrameBufferObject.getValue()->getHeight(),
pEnv->getPixelLeft (),
pEnv->getPixelBottom(),
pEnv->getPixelRight (),
pEnv->getPixelTop (),
(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT),
GL_NEAREST);
Is it not better to state the source points also from the pEnv dimensions? I'm unsure here and would like to hear your opinion.
2.) For experimentation I did put some clear buffer code into the FBOBackground clear function. I have provided a modified FBOBackground along with the new stuff in the attached zip file. In this source you can activate the buffer clearing with define DEBUG_CLEAR_BACKGROUND. With that in place and usage of the pEnv dimensions for source as well as for destination of the blit operation I always get a one black pixel seam at the top and the right of the rendered window (in both examples). However, do I add one pixel to the top and right dimension, then the rendered window seems to be ok. That can be done by enabling define ADD_PLUS_ONE_TO_TOP_AND_RIGHT in both the FBOBackground (for example 1) and FBOGrabForeground (for example 1 and 2) sources.
I have inspected other places in OpenSG at where the pEnv->getPixelLeft (),... calls are used and I found that at no place the additional pixels were added. So I'm confused. What is correct and how to explain the black edge in the window? If the additional pixel is correct, however, I have to ask about the correctness of the other code places :-(
3. Beside of these two points I would like to see the examples in OpenSG and I would like to ask for some polishing or review. This is the first foreground I have written and I'm still struggeling with the OpenGL framebuffer object. For instance, I'm still unsure about the implications of an multsampling render GL context of the window.
Anyway, I would really appreciate some help here.
Best,
Johannes
after Gerrit was so kind to provide a FBOBackground on my request, I have taken the time to write a FBOGrabForeground and two examples showing these in action.
The first one, named dyndrawing1.cpp uses a FBO that is created from the scene with the help of a SimpleStage, a VisitSubTree and a PassiveViewport. This FBO is then used in the new FBOBackground.
The second one, named dyndrawing2.cpp is quite similar to the first one, but the FBO is filled with the help of my new FBOGrabForeground class that I would like to see in OpenSG.
Both examples work reasonably but nevertheless some things are not perfect or need some clarifications. May I ask for some help here?
Let me enumerate the points:
1.) In the class FBOBackground Gerrit has used the following BlitFramebuffer statement in function clear:
osgGlBlitFramebuffer(
0,
0,
_sfFrameBufferObject.getValue()->getWidth (),
_sfFrameBufferObject.getValue()->getHeight(),
pEnv->getPixelLeft (),
pEnv->getPixelBottom(),
pEnv->getPixelRight (),
pEnv->getPixelTop (),
(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT),
GL_NEAREST);
Is it not better to state the source points also from the pEnv dimensions? I'm unsure here and would like to hear your opinion.
2.) For experimentation I did put some clear buffer code into the FBOBackground clear function. I have provided a modified FBOBackground along with the new stuff in the attached zip file. In this source you can activate the buffer clearing with define DEBUG_CLEAR_BACKGROUND. With that in place and usage of the pEnv dimensions for source as well as for destination of the blit operation I always get a one black pixel seam at the top and the right of the rendered window (in both examples). However, do I add one pixel to the top and right dimension, then the rendered window seems to be ok. That can be done by enabling define ADD_PLUS_ONE_TO_TOP_AND_RIGHT in both the FBOBackground (for example 1) and FBOGrabForeground (for example 1 and 2) sources.
I have inspected other places in OpenSG at where the pEnv->getPixelLeft (),... calls are used and I found that at no place the additional pixels were added. So I'm confused. What is correct and how to explain the black edge in the window? If the additional pixel is correct, however, I have to ask about the correctness of the other code places :-(
3. Beside of these two points I would like to see the examples in OpenSG and I would like to ask for some polishing or review. This is the first foreground I have written and I'm still struggeling with the OpenGL framebuffer object. For instance, I'm still unsure about the implications of an multsampling render GL context of the window.
Anyway, I would really appreciate some help here.
Best,
Johannes