Hello, I would like to ask for some clarification about the management of shaders in a multiple window environment.
In my application, I have the following setup, and I'm unsure if this is the right way to do it. Additionally, I'm facing problems... I have multiple windows which renders OpenSG scenes (handled by scene managers one for each scene). In each scene manager, I have created a ShaderProgramChunk for my silhouettes rendering task, which is shared by all concerned materials in the scene. Additionally, some windows can also render the same scene with the same ShaderProgramChunk. Is this a valid setup? I.e. is it allowed to share ShaderProgramChunks between multiple materials and to share one scene graph containing such materials between different windows (i.e. OpenGL contexts)? Now to my problems. Imagine that I have a dialog with an embedded OpenGL window, which renders a mini scene with some silhouettes. The dialog allows me to turn shilhouette rendering ON and OFF globally, i.e for all windows. If I switch the silhouette rendering OFF, the respective silhouette branch of my scene is not rendered anymore (by means of a MultiSwitch core). The important detail here is that the silhouette tree is still part of the scene but not rendered by design. On application start the following happens 1. window and opengl context creation. 2. SceneManager + silhouette ShaderProgramChunk creation 3. No geometry, therefore no shader usage Now I open my dialog and turn silhouette rendering OFF (default is ON). The following happens: 1. window and opengl context creation. 2. SceneManager + silhouette ShaderProgramChunk creation 3. geometry creation in the new SceneManager with sihlouette shader material 4. Silhouettes are shown (initial state was ON) 5. Switch them Off => Silhouettes not shown 6. Close dialog 7. window get destroyed, SceneManager get deleted, geometry get deleted and ShaderProgramChunk is released In my main application window, I then create a geometry with silhouette shader material silenced by the MultiSwitch. This one is shown correctly. Then I reopen my dialog and turn silhouettes on. Until now all is rendered correctly. But now I create an additional geometry in my main window scene. It has the silhouette ShaderProgramChunk handled by SceneManager from the main window. But the geometry is not rendered anymore correctly. It should have rendered silhouettes and gourand shaded faces but I only see a white imprint of the geometry on my colored background. I have then tested the following. Just before redraw I added the following to my code: ShaderProgramChunk* shl = view->getSceneManager()->getSilhouetteShaderChunk(); ShaderProgram* vertShader = shl->getVertexShader(0); ShaderProgram* geomShader = shl->getGeometryShader(0); ShaderProgram* fragShader = shl->getFragmentShader(0); if (_win->getGLObjectId(vertShader->getGLId()) == 0) int test = 2354; if (_win->getGLObjectId(geomShader->getGLId()) == 0) int test = 2354; if (_win->getGLObjectId(fragShader->getGLId()) == 0) int test = 2354; If I have silhouette rendering turned ON, I do not run into the if-branches and the geometry with silhouettes get rendered correctly. That is fine and expected. If I turn silhouette rendering OFF (without the dialog), the correct geometry is rendered without silhouettes. I do run into the if-branches. Correct and also expected. If, however, I turn them OFF and then ON with the dialog, like I described above, I have no rendered silhouettes, and I run into the if-branches. That is not expected! What could be happening here? After that, I have added a validateAllGLObjects() call. But that leads to a program crash with the call stack shown below Thread::getCurrentChangeList()->fillStatistic(_action->getStatCollector( )); Thread::getCurrentChangeList()->commitChanges(); _win->validateAllGLObjects(); _win->render(_action); > OSGSystemD.dll!OSG::ShaderExecutableChunkBase::getGLId() Line 182 + 0x11 bytes C++ OSGSystemD.dll!OSG::ShaderExecutableChunk::handleGL(OSG::DrawEnv * pEnv=0x0000000014365920, unsigned int id=413, OSG::Window::GLObjectStatusE mode=needrefresh, unsigned int uiOptions=0) Line 212 + 0xd bytes C++ OSGSystemD.dll!boost::_mfi::mf4<unsigned int,OSG::ShaderExecutableChunk,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>::call<OSG::MTRefCountPtr<OSG::ShaderExecutableChunk,OSG::NoRefCount Policy>,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>(OSG::MTRefCountPtr<OSG::ShaderExecutableChunk,OSG::NoRefCountPolicy > & u={...}, const void * __formal=0x0000000000000000, OSG::DrawEnv * & b1=0x0000000014365920, unsigned int & b2=413, OSG::Window::GLObjectStatusE & b3=needrefresh, unsigned int & b4=0) Line 498 C++ OSGSystemD.dll!boost::_mfi::mf4<unsigned int,OSG::ShaderExecutableChunk,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>::operator()<OSG::MTRefCountPtr<OSG::ShaderExecutableChunk,OSG::NoRe fCountPolicy> >(OSG::MTRefCountPtr<OSG::ShaderExecutableChunk,OSG::NoRefCountPolicy> & u={...}, OSG::DrawEnv * a1=0x0000000014365920, unsigned int a2=413, OSG::Window::GLObjectStatusE a3=needrefresh, unsigned int a4=0) Line 513 C++ OSGSystemD.dll!boost::_bi::list5<boost::_bi::value<OSG::MTRefCountPtr<OS G::ShaderExecutableChunk,OSG::NoRefCountPolicy> >,boost::arg<1>,boost::arg<2>,boost::arg<3>,boost::arg<4> >::operator()<unsigned int,boost::_mfi::mf4<unsigned int,OSG::ShaderExecutableChunk,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>,boost::_bi::list4<OSG::DrawEnv * __ptr64 & __ptr64,unsigned int & __ptr64,enum OSG::Window::GLObjectStatusE & __ptr64,unsigned int & __ptr64> >(boost::_bi::type<unsigned int> __formal={...}, boost::_mfi::mf4<unsigned int,OSG::ShaderExecutableChunk,OSG::DrawEnv *,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int> & f={...}, boost::_bi::list4<OSG::DrawEnv * &,unsigned int &,enum OSG::Window::GLObjectStatusE &,unsigned int &> & a={...}, boost::_bi::type<unsigned int> __formal={...}) Line 516 C++ OSGSystemD.dll!boost::_bi::bind_t<unsigned int,boost::_mfi::mf4<unsigned int,OSG::ShaderExecutableChunk,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>,boost::_bi::list5<boost::_bi::value<OSG::MTRefCountPtr<OSG::ShaderE xecutableChunk,OSG::NoRefCountPolicy> >,boost::arg<1>,boost::arg<2>,boost::arg<3>,boost::arg<4> > >::operator()<OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>(OSG::DrawEnv * & a1=0x0000000014365920, unsigned int & a2=413, OSG::Window::GLObjectStatusE & a3=needrefresh, unsigned int & a4=0) Line 146 C++ OSGSystemD.dll!boost::detail::function::function_obj_invoker4<boost::_bi ::bind_t<unsigned int,boost::_mfi::mf4<unsigned int,OSG::ShaderExecutableChunk,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>,boost::_bi::list5<boost::_bi::value<OSG::MTRefCountPtr<OSG::ShaderE xecutableChunk,OSG::NoRefCountPolicy> >,boost::arg<1>,boost::arg<2>,boost::arg<3>,boost::arg<4> > >,unsigned int,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>::invoke(boost::detail::function::function_buffer & function_obj_ptr={...}, OSG::DrawEnv * a0=0x0000000014365920, unsigned int a1=413, OSG::Window::GLObjectStatusE a2=needrefresh, unsigned int a3=0) Line 133 C++ OSGSystemD.dll!boost::function4<unsigned int,OSG::DrawEnv * __ptr64,unsigned int,enum OSG::Window::GLObjectStatusE,unsigned int>::operator()(OSG::DrawEnv * a0=0x0000000014365920, unsigned int a1=413, OSG::Window::GLObjectStatusE a2=needrefresh, unsigned int a3=0) Line 761 C++ OSGSystemD.dll!OSG::Window::validateGLObject(unsigned int osgId=413, OSG::DrawEnv * pEnv=0x0000000014365920, unsigned int uiOptions=0) Line 700 + 0x33 bytes C++ OSGSystemD.dll!OSG::Window::validateAllGLObjects() Line 724 C++ RenderEngineD.dll!RenderEngine::graphic::CompositeViewer::redraw() Line 405 C++ - this 0x0000004000081ae2 {_mfVertexShader={...} _mfGeometryShader={...} _mfFragmentShader={...} ...} const OSG::ShaderExecutableChunkBase * const + OSG::StateChunk {...} OSG::StateChunk + _type {_baseType=IsAttachment _pPrototype=0x0000000009ab9f60 _fPrototypeCreate=0x000007fee4c134b0 ...} OSG::FieldContainerType + _mfVertexShader {...} OSG::PointerMField<OSG::ShaderProgram *,OSG::NoRefCountPolicy,0> + _mfGeometryShader {...} OSG::PointerMField<OSG::ShaderProgram *,OSG::NoRefCountPolicy,0> + _mfFragmentShader {...} OSG::PointerMField<OSG::ShaderProgram *,OSG::NoRefCountPolicy,0> + _sfVariables {...} OSG::ChildPointerSField<OSG::ShaderProgramVariables *,OSG::UnrecordedRefCountPolicy,1> + _mfVariableLocations {_values={...} _uiSharedWith=??? } OSG::MField<int,0,std::allocator<int> > + _mfProceduralVariableLocations {_values={...} _uiSharedWith=??? } OSG::MField<int,0,std::allocator<int> > + _sfGeometryVerticesOut {_fieldValue=??? } OSG::SField<unsigned int,0> + _sfGeometryInputType {_fieldValue=??? } OSG::SField<unsigned int,1> + _sfGeometryOutputType {_fieldValue=??? } OSG::SField<unsigned int,1> + _mfAttributes {_fieldType={...} _values={...} _uiSharedWith=??? } OSG::MField<std::pair<unsigned short,std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,0,std::allocator<std::pair<unsigned short,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > > - _sfGLId {_fieldValue=??? } OSG::SField<unsigned int,0> _fieldValue CXX0030: Error: expression cannot be evaluated + _sfPointSize {_fieldValue=??? } OSG::SField<bool,2> So, I suspect, that I do something fundamentally wrong here and hope to get some insight into a proper handling of my application scenario. After destroying of my dialog window, should the ShaderProgramChunk contained in my main scene and hold by my main SceneManager be valid and functioning? Sorry for the lengthy mail... Best, Johannes ____________ Virus checked by G DATA AntiVirusKit Version: AVF 22.555 from 27.02.2012 Virus news: www.antiviruslab.com ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users