[osg-users] Glut/OSG occlusion

2008-06-27 Thread Mark Henderson
Hi,

When I was playing around with the osgviewerGlut example, I realized that
there was no actual interaction between the what I was drawing with openGL
and with osg.  It seems like whatever is drawn later occludes what is
already there.  When viewer-frame() is called, even what should be clear
background blocks out already drawn objects.

I've tried messing around with camera settings (and broken my application in
many interesting ways), but I can't figure out how to avoid losing all of my
already rendered stuff when I call viewer-frame.  I would prefer to have
the osg objects interact enough with the openGL drawing to render by depth,
but even getting OSG to not occlude everything already drawn would be nice.


Thanks for your help,
Mark Henderson
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Glut/OSG occlusion

2008-06-27 Thread Jean-Sébastien Guay

Hello Mark,

I've tried messing around with camera settings (and broken my 
application in many interesting ways), but I can't figure out how to 
avoid losing all of my already rendered stuff when I call 
viewer-frame.  I would prefer to have the osg objects interact enough 
with the openGL drawing to render by depth, but even getting OSG to not 
occlude everything already drawn would be nice. 


Mixing straight OpenGL code with OSG is always a bit perilous as you 
leave yourself open to all kinds of issues with leftover state frm one 
side of the app affecting the other side.


But to answer your question,

viewer-getCamera()-setClearMask(0x0);

will make it so that OSG does not clear either the depth buffer or the 
color buffer when it starts to render, so what was there before stays. 
That means that any information in the z-buffer and color buffer from 
your OpenGL render will stay there and be tested when OSG renders.


If you need the opposite, then just don't call glClear() at the 
beginning of your OpenGL rendering.


Note that you need at least one of the two paths to clear the depth and 
color buffers, the first one to render in a given frame (OpenGL or OSG) 
should be the one to do it.


Also note that transparency / blending probably won't work right, since 
transparent objects will be drawn by OSG at the end of its drawing, then 
your OpenGL opaque objects will get drawn over them and then your own 
OpenGL transparent objects (or the opposite, OpenGL then OSG). Just 
another reason not to mix OpenGL and OSG. OSG takes care of that for you.


Hope this helps,

J-S
--
__
Jean-Sebastien Guay[EMAIL PROTECTED]
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org