Hi Sanat,

>http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/examples/osgviewerQt/osgviewerQtContext.cpp<http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/examples/osgviewerQt/osgviewerQtContext.cpp>

with this more simple example it would be easier to transit to osg::Viewer

you should know following - before you can derive from Viewer you should set
it as

with the call to setUpViewerAsEmbeddedInWindow

see what is does on Viewer to be prepared to be embedded:

GraphicsWindowEmbedded* Viewer::setUpViewerAsEmbeddedInWindow(int x, int y,
int width, int height)
{
    setThreadingModel(SingleThreaded);
    osgViewer::GraphicsWindowEmbedded* gw = new
osgViewer::GraphicsWindowEmbedded(x,y,width,height);
    getCamera()->setViewport(new osg::Viewport(0,0,width,height));
    getCamera()->setProjectionMatrixAsPerspective(30.0f,
static_cast<double>(width)/static_cast<double>(height), 1.0f, 10000.0f);
    getCamera()->setGraphicsContext(gw);
    return gw;
}

so in osg code you need to connect Viewer.


after that you would be able to create camera and add
setCameraManipulator(new osgGA::TrackballManipulator);
then add to camera your model, then add camera to viewer or directly to
viewere.

you may find complete simple code sample to use Qt and osg::Viewer  here
http://hipersayanx.blogspot.com/2011/04/qt-openscenegraph-offscreen-rendering.html(
it's in spanish but for you most important is code - which I think you
will understand ). I found it by searching osg::Viewer and
setUpViewerAsEmbeddedInWindow there are other useful examples on the net,
but hope the one on the link will help you.

Regards
Sergey


On Wed, May 11, 2011 at 2:27 AM, Sergey Kurdakov <[email protected]>wrote:

> Hi Sanat,
>
> sorry, I might be not very clear ( it is just that thread helped me a lot
> ).
> but why not to  use this example
>
>
> http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/examples/osgviewerQt/osgviewerQtContext.cpp
>
> as a starting point?
>
> Regards
> Sergey
>
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to