Hi jcronje,

the graphics context is initialized by OSG before 
the first rendering traversal. 
Context handling is not so easy with OSG. 
I usually set the following flag in order 
to not loose the context at the end of each frame:  

Code:
_viewer->setReleaseContextAtEndOfFrameHint(false);


Otherwise you need to call makeCurrent() to the 
context before the first call to osgCuda::Texture::map(). 

Please be aware that osgCompute only  works with a single 
context and a single threaded application. 

Code:
_viewer->setThreadingModel( osgViewer::ViewerBase::SingleThreaded );



There are several options I have in mind with a standard 
osgViewer::Viewer:



OPTION A
After osgViewer::ViewerBase::realize() simply call makeCurrent() to your
osg::GraphicsContext. This can be done during the initialization of your 
viewer e.g. in your "main.cpp".

Code:

_viewer->realize();
...
_viewer->getContexts( contexts );
// There should be only a single context
contexts.front()->makeCurrent();
...
_texmemory->map();



( I would prefer this method )

OPTION B
Wait for osgUtil::GLObjectsVisitor traversing the scene. The first time
it does the context is initialized and set as the current context.

OPTION C
Add your own osg::Operation as osgViewer::ViewerBase::setRealizeOperation(). 
At the time, the context is realized, this operation is called. As the viewer 
calls releaseContext() afterwards, you have to call makeCurrent() once before 
your modules.



Hopefully this answers your question.

Cheers,
Jens

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=40471#40471





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to