Hi Justin,
Look at void osgUtil::RenderStage::draw(osg::RenderInfo&
renderInfo,RenderLeaf*& previous) method.(Line 825 in currnt SVN
src/osgUtil/RenderStage.cpp). Its all there.
1: Prerender cameras add Prerender stages. Prerender stages are drawn first.
Line 833:
drawPreRenderStages(renderInfo,previous);
2: Camera::preDrawCallback is called later
Line 880:
if (_camera && _camera->getPreDrawCallback())
{
// if we have a camera with a post draw callback invoke it.
(*(_camera->getPreDrawCallback()))(*_camera);
}
3: Then Camera graph (its RenderStage) is drawn
Lines 891-921: (it has two paths for multithreaded and singlethreaded
drawing)
Single Threader case is located in:
Line 913:
drawInner( useRenderInfo, previous, doCopyTexture);
4: Camera::postDrawCallback gets called
Line: 943
if (_camera && _camera->getPostDrawCallback())
{
// if we have a camera with a post draw callback invoke it.
(*(_camera->getPostDrawCallback()))(*_camera);
}
5: Post Render stages from PostRender Cameras are drawn (post render HUD is
usually drawn as a result of this call):
Line: 979 (last line of the method)
drawPostRenderStages(renderInfo,previous);
So reassuming:
Main camera postDrawCallback is always called before your postrender HUD
camera preDraw & postDraw callbacks. So you need to use HUD callback but
there is a problem of recognizing which view has called it. I agree with you
here. I had similar problem recently: there is not enough information passed
to DrawCamera callback. Only one parameter - Camera refernce does not allow
to identify view nor identify gl context (I was unable to call some GL
extension functions in this callback). It sounds like some aditional
parameters should be added to Camera::DrawCallback (RenderInfo ?) or Camera
should have methods to find cooresponding state and view objects. I am
afraid Robert is the only one who can solve this issue.
Cheers,
Wojtek Lewandowski
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Vican,
Justin E.
Sent: Thursday, February 28, 2008 6:40 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Camera POST_RENDER vs. postDrawCallback ...
whowins?
Hi Robert,
Thanks for getting back to me. I still seem to be having an issue with
this. I've attached 3 simple images illustrating the issue. The text
overly should say "MOOOOOOOOOOOO!". When I use a post render HUD
camera, it shows up visually correct at runtime
(POST_RENDER_Screenshot.jpg), but I can get the overlay text into the
frame grab (POST_RENDER_FrameGrab.jpg). However, any combination of
NESTED_RENDER and render bins gives me the problem illustrated in
NESTED_RENDER_FrameGrab.jpg. The "world space" objects can obscure the
HUD items.
1.) I have a viewer (osg::Viewer named "viewer1") with a camera
(osg::Camera named "ViewCamera"), and a scene graph that includes a HUD
camera (osg::Camera named "HUDCamera") which has its rendering order set
to POST_RENDER, and I have added a postDrawCallback to the first camera
("ViewCamera"). This is the frame grabbing callback. Your response to
question 1 would indicate to me that the subgraph inside of "HUDCamera"
is supposed to draw before the "ViewCamera" postDrawCallback is called.
It looks like this is happening in the reverse order. The
postDrawCallback of "ViewCamera" is being called before the "HUDCamera"
subgraph is rendering which is why I can't see the text in the frame
grab.
osg::Viewer("viewer1")
|
osg::View("view1")
|
osg::Camera("ViewCamera") ->setPostDrawCallback(foo).
|
osg::Group("SceenRootNode")
/ \
/ \
osg::Group("OtherStuff") osg::Camera("HUDCamera")
->setRenderOrder(POST_RENDER)
2.) I've tried adding a postDrawCallback to the HUD camera, but I'm
using the CompositeViewer class so I have potentially N views into the
scene. These callbacks are doing pixel reads and saving them to images
(frame capturing), so I need the viewport dimensions of the current
viewer's camera (not the HUD camera). I'm also controlling the frame
grabbing on a per-view basis. At present, the osg::Camera class only
allows me to add 1 postDrawCallback, so the HUD cannot support any more
than a single callback. I'm trying to work something out with nested
callbacks, but I'm having trouble figuring out which viewer has finished
rendering by the time the HUD callback is called. Is there any way to
know which viewer is currently rendering the scene inside of the
osg:Camera::DrawCallback::operator(const osg::camera&) method?.
osg::CompositeViewer("CompView")
/ \
/ \
osg::Viewer("viewer1") osg::Viewer("viewer2")
| |
osg::View("view1") osg::View("view2")
| |
osg::Camera("ViewCamera1") osg::Camera("ViewCamera2") <-
postDrawCallbacks attached to each camera.
\ /
\ /
osg::Group("SceenRootNode")
/ \
/ \
osg::Group("OtherStuff") osg::Camera("HUDCamera")
->setRenderOrder(POST_RENDER)
Sorry for the Novel,
Justin
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robert
Osfield
Sent: Thursday, February 28, 2008 4:22 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Camera POST_RENDER vs. postDrawCallback ...
whowins?
On Thu, Feb 28, 2008 at 1:05 AM, Vican, Justin E. <[EMAIL PROTECTED]>
wrote:
Hi Justin,
> 1.) Are postDrawCallbacks supposed to be called before the
POST_RENDER
> camera sub graphs are rendered?
A camera post draw callback should be called after its whole subgraph
is rendered.
> 2.) Is there a way to ensure that the HUD displays are always
drawn on
> top of the world space objects and make sure that the postDrawCallback
will
> be called after they are rendered?
If the HUD is drawn last why not attach the callback to it?
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org