<div dir="ltr"><div><div>HI Michael,<br><br></div>You can't compile GL objects unless you do if from a thread with the appropriate graphics context current, this means you can't just force a compile from any thread. The way the OSG manages this is to mark GL related objects (textures, shader programs, VBO's etc) as needing to be compile before you and then compiling them once the scene graph needs to dispatch those GL related objects to the OpenGL FIFO. This will all happen automatically so usually you don't need to worry about it, what needs to happen will be done for you.</div><div><br></div><div>In cases where compilation of GL objects might take a while and endanger a break of frame then it can be useful to pre-compile these GL objects prior to them being merged with the main scene graph. The osgViewer has support for forcing a compile GL objects traversal on the first frame that the viewer is run, this will happen automatically, but if you assign scene graph elements after the first frame then the new GL objects will be just compiled just prior to being used. <br></div><div><br></div><div>The exception to this is when using the DatabasePager - it has support for collecting all the GL objects that will be needed to be compiled for any new scene graphs and passes these on to the osgUtil::IncrementalCompileOperation that is run on every frame to compile GL objects, it does so incrementally, only compiling what GL objects it has time available to compile. Once all the required objects are compiled the subgraphs they are associated with then can be merged with the main scene graph without risking breaking a frame.<br></div><div><br></div><div>In your case I can't say whether you need to do anything at all, or whether use of the IncrementalCompileOperation would be appropriate, it all depends upon the performance requirements of your application.<br></div><div><br></div>Robert.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 28 September 2017 at 21:42, michael kapelko <span dir="ltr"><<a href="mailto:kornerr@gmail.com" target="_blank">kornerr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi.<br>
<br>
I want to pre-compile shader programs before they are actually used by<br>
real nodes.<br>
I tried to create empty node (new osg::Node) and assign an<br>
osg::StateSet with an osg::Program, but such action did not trigger<br>
shader compilation.<br>
In the logs I see shader compilation happening only when I assign<br>
osg::StateSet to actual nodes at my screen.<br>
<br>
What am I missing?<br>
______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.<wbr>openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.<wbr>org/listinfo.cgi/osg-users-<wbr>openscenegraph.org</a><br>
</blockquote></div><br></div>