Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC wrote on Friday, November
14, 2008 10:49 AM:

> Mike,
> 
> Thanks for the reply. There was an exchange on this subject back on
August
> 28 in the archives. I tried all the suggested solutions to the problem
to no
> avail. I have tried binding to an "empty" program as you suggest by
using
> the call ss->SetAttributesAndModes(new osg::Program()) which does
indeed
> turn off the shader (back to fixed functionality). But when I attempt
to
> switch back to the shader with another call to
> ss->SetAttributesAndModes(MyShaderProgram), it crashes my
OpenSceneGraph
> app.
> 
> I've tried the other suggestions such as removing the shaders from the
> program and then adding them back on for enable/disable and also the
call
> ss->RemoveAttribute(MyShaderProgram) which have also caused a crash on
the
> ensuing call ss->SetAttributesAndModes(MyShaderProgram). The only
mechanism
> that has worked cleanly for me is if I create two programs, one that
is
> empty and one that has my vertex/fragment shaders attached. When I
call each
> programs "apply" method to switch the shaders off and on, this seems
to
> work. I'm not sure if this the correct way to do it though.

Do these crashes go away if you run OSG single-threaded? It sounds like
you might be changing the scenegraph at a point where it isn't safe to
do so. In general, it is safe to change the scenegraph from an update
callback, but otherwise you could have problems. Also, if you are making
changes to a StateSet, you should mark it as DYNAMIC. See also below.

> I've also noticed that there is no clean way of switching between
multiple
> programs attached to a single object during runtime. At least I
haven't
> found a way to get it to work in OSG. In OpenGL, I've always been able
to
> have multiple programs that I can swap in and out via the call to
> glUseProgram() with the appropriate program handle (including the call
> glUseProgram(0) to switch to the fixed pipe). I don't see an
equivalent
> mechanism in OpenSceneGraph to achieve the same functionality.
> 
> If you or anyone else can enlighten me, it would be most
appreciated...

See osg::Switch; you could create two child nodes, one with an empty
Program, the other with the shaders. Have them both make the actual
scenegraph their child; then you can use the Switch to determine whether
the fixed pipeline is used or not.

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Mike
> Weiblen
> Sent: Thursday, November 13, 2008 11:33 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] shaders in OSG...
> 
> The only way to turn off a glProgram in GL is glUseProgram(0), there
> is no glEnable/glDisable.
> 
> In OSG you do that by creating an "empty" osg::Program, one with no
> osg::Shaders attached.  Just attach that empty osg::Program where you
> want to revert to fixed-function.  Further details in
> http://mew.cx/osg_glsl_july2005.pdf
> 
> cheers
> -- mew
> 
> 
> 
> On Wed, Nov 12, 2008 at 2:55 PM, Tueller,  Shayne R Civ USAF AFMC 519
> SMXS/MXDEC <[EMAIL PROTECTED]> wrote:
>> Hello,
>> 
>> 
>> 
>> Is there a "light weight" way to turn off shaders in OSG without
unloading
>> the vertex and fragment shaders from the shader program?
>> 
>> 
>> 
>> My application needs to switch back and forth from the shader
pipeline to
>> the fixed pipeline and vice versa during runtime. This can be done at
the
>> OpenGL level by calling the function glUseProgramObject() to make the
quick
>> switch. Is there an equivalent in OpenSceneGraph?
>> 
>> 
>> 
>> Thanks in advance,
>> 
>> -Shayne
>> 
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g



-- 
Bryan Thrall
FlightSafety International
[EMAIL PROTECTED]
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to