OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Computations outside computation node


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgCompute [osgCompute]
View previous topic :: View next topic  
Author Message
jcronje
Newbie


Joined: 30 May 2011
Posts: 3

PostPosted: Mon May 30, 2011 8:41 am    Post subject:
Computations outside computation node
Reply with quote

Hi,

I would like to use osgCompute outside the computation node, similar to your osgEndiannessDemo example.

The only difference is that I want to use osgCuda::Texture objects.

From the example source:
Code:

// You can use modules and buffers in the update cycle or everywhere
// you want. But please make sure that the context is still active at
// computation time if you use osgCuda::Geometry or osgCuda::Texture objects!!!


Can you please give an example on how to make sure the context is still active before I perform the computation ?

Do I need to perform some operations on the context after the computations ?

Thanks,

Jaco
Back to top
View user's profile Send private message
jens.svt
User


Joined: 16 Mar 2009
Posts: 30

PostPosted: Tue Jun 14, 2011 3:30 pm    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgCompute [osgCompute] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Executing subtree multiple times / re... antiro42 General 2 Thu Sep 14, 2017 10:10 am View latest post
No new posts How to get Node object from PositionA... nghien_rbc General 1 Sat Apr 15, 2017 3:05 am View latest post
No new posts Fix FBX rotation matrix computation Farshid Lashkari Submission 1 Tue Apr 11, 2017 11:21 pm View latest post
No new posts How to replace the texture data in th... xdfanfan General 1 Wed Apr 05, 2017 12:44 pm View latest post
No new posts Merge Shader::Program from differents... Paradox General 1 Tue Feb 28, 2017 3:53 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP