Hi,
>
> #pragma once
> #include "QtOSG.h"
> #include <osg/ShapeDrawable>
>
>
> osg::Camera* createCamera(int x, int y, int w, int h, QTOSG* myQTOSG, const
> std::string& name="", bool windowDecoration=false)
> {
> osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
> osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
> osg::GraphicsContext::Traits;
> traits->windowName = name;
> traits->windowDecoration = windowDecoration;
> traits->x = x;
> traits->y = y;
> traits->width = w;
> traits->height = h;
> traits->doubleBuffer = true;
> traits->alpha = ds->getMinimumNumAlphaBits();
> traits->stencil = ds->getMinimumNumStencilBits();
> traits->sampleBuffers = ds->getMultiSamples();
> traits->samples = ds->getNumMultiSamples();
> traits->inheritedWindowData = new
> osgQt::GraphicsWindowQt::WindowData(NULL, myQTOSG);
> //neuer ref_ptr auf osg::Camera namens camera
> osg::ref_ptr<osg::Camera> camera = new osg::Camera;
> //neuer Pointer auf GraphicsWindowQt mit (traits) namens Window
> osgQt::GraphicsWindowQt* Window = new
> osgQt::GraphicsWindowQt(traits);
> //Setzt den GraphicsContext der camera auf Window
> camera->setGraphicsContext( Window );
> camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
> camera->setViewport( new osg::Viewport(0, 0, traits->width,
> traits->height) );
> camera->setProjectionMatrixAsPerspective(
> 30.0f,
> static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f,
> 10000.0f );
> return camera.release();
> }
>
> QWidget* addViewWidget(osg::Camera* camera, osg::Node* scene)
> {
> /*QTOSG* _QTOSG = new QTOSG();*/
> osgViewer::View* view = new osgViewer::View;
> view->setCamera(camera);
> osgViewer::CompositeViewer * cv = new osgViewer::CompositeViewer;
> cv->addView( view );
> view->setSceneData(scene);
> view->addEventHandler(new osgViewer::StatsHandler);
> view->setCameraManipulator( new osgGA::TrackballManipulator);
> //Wenn camera auf ein GraphicsWindowQt zeigt, erhält man den gw-Zeiger,
> der ein osgQt-zeiger ist, der auf osg::Camera zeigt. Schlägt der Cast fehl,
> gibts einen Nullzeiger zurück.
> osgQt::GraphicsWindowQt* gw =
> dynamic_cast<osgQt::GraphicsWindowQt*>(camera->getGraphicsContext());
> //wenn gw nicht NULL ist, return getGLWidget(), sonst return NULL
> return gw ? gw->getGLWidget() : NULL;
> }
>
> QTOSG::QTOSG() : QWidget()
>
> {
> root = new osg::Group();
> QWidget* widget1 = addViewWidget(createCamera(0,0,100,100, this),
> createPILLE());
> QGridLayout* grid = new QGridLayout;
> grid->addWidget(widget1, 0, 0 );
> setLayout( grid );
> connect( &_timer, SIGNAL(timeout()), this, SLOT(update()) );
> _timer.start( 10 );
> }
>
> QTOSG::~QTOSG()
> {
>
> }
>
>
>
> void QTOSG::paintEvent(QPaintEvent* event)
> {
> frame();
> }
>
> osg::Node* QTOSG::createPILLE()
> {
> /*osg::Node* on = new osg::Node();*/
> //Create a new geode node, derived from the osg::Node class, holds
> osg::Drawable
> osg::ref_ptr<osg::Geode> myshapegeode (new osg::Geode);
> //Create the Capsule
> osg::ref_ptr<osg::Capsule> myCapsule (new
> osg::Capsule(osg::Vec3f(),0.1,2));
> osg::ref_ptr<osg::ShapeDrawable> capsuledrawable (new
> osg::ShapeDrawable(myCapsule.get()));
> myshapegeode->addDrawable(capsuledrawable.get());
> //Capsule being added to the Scenegraph using the osg::Geode
> root->addChild(myshapegeode.get());
>
> return root;
> }
This is my current code; displays a grey window (not white anymore!!)
wheee.... help?
Thank you!
Cheers,
Patrick
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=43817#43817
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org