[osg-users] Looking for best practice about Shader and memory management

Valerian Merkling niarkoleptik at gmail.com
Fri Oct 7 08:18:09 PDT 2016


Now I am able to play with OSG and shaders, I would like to know what the best "way" to manage shaders in OSG.

I recently had a problem with re using openGL contexts and missing some releaseGLObjects call, so I know I need to be careful.

I have One application, with one composite viewer.
I have multiple views opened (osg::View rendered in a osgQT::GLWidget, and it's own scene)

Now If I want, in my case, draw flat squares, and paint some stripes on some squares, I use a shader for the stripes.

My question could be : how many instance of osg::Program shall I have for my stripes ?

Only one for all the application ? But how can I clean it from the openGL context when I close the application ?

One for each view ? And I should call releaseGLObjects when I delete the last striped square ? 

One for each striped square ? 

Or shall I just get one big osg::Program with every shaders and use uniform to choose which to use ?

Thanks for your help !



Read this topic online here:

More information about the osg-users mailing list