Re: [osg-users] OSG and Qt fullscreen problem

2012-05-09 Thread jamie robertson
Hi,

The paint event is never called if you have zero size margin in a layout.

If you only have a single view then there's no point in having a layout anyway 
instead you can use a GLWidget widget directly 
Code:
GraphicsWindowQt::getGLWidget()



Cheers,

jamie

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] OSG and Qt fullscreen problem

2012-05-09 Thread Markus Husseini
Hi,

I am trying to integrate an osg viewer into a Qt user interface. To do this I 
am using the osg viewer widget from the OpenSceneGraph 3.0 Cookbook. If I set 
the widget to fullscreen with the Qt method showFullScreen(). If I do this I 
have a gray border around my viewport. To eliminate the border I try to set the 
margin of the layout which includes the osgviewer to 0. But if I do this the Qt 
widget with viewer is not shown anymore. If I set the margin value to 1 then it 
works but I have again a small gray border. 

I know that this is working with OpenSG. Is there maybe a problem with osg?? 
Does someone has a solution for this problem??

Here is my code (Sorry I don'T know why the tabs are shown like this):

viewerwidget.h

Code:

#ifndef VIEWERWIDGET_H
#define VIEWERWIDGET_H

// C++ includes
#include 

// Qt includes
#include 
#include 

// OSG includes
#include 
#include 
#include 
#include 
#include 

class ViewerWidget : public QWidget
{
public:
ViewerWidget( QWidget *parent = 0, Qt::WFlags flags = 0 ) 
  : QWidget(parent, flags)
{
osg::Camera* camera = createCamera( 0, 0, 640, 480 );
osg::Node* scene = osgDB::readNodeFile("cow.osg");
m_viewer.setCamera( camera );
m_viewer.setSceneData( scene );
m_viewer.addEventHandler( new osgViewer::StatsHandler );
m_viewer.setCameraManipulator( new osgGA::TrackballManipulator 
);

// Use single thread here to avoid known issues under Linux
m_viewer.setThreadingModel( osgViewer::Viewer::SingleThreaded );

osgQt::GraphicsWindowQt* gw = 
dynamic_cast( camera->getGraphicsContext() );
if ( gw )
{
QVBoxLayout* layout = new QVBoxLayout;

///
layout->setMargin(0);
///

layout->addWidget( gw->getGLWidget() );
setLayout( layout );
}

connect( &m_timer, SIGNAL(timeout()), this, SLOT(update()) );
m_timer.start( 40 );
}

~ViewerWidget() {}

osg::Camera* createCamera( int x, int y, int w, int h )
{
osg::DisplaySettings* ds = 
osg::DisplaySettings::instance().get();

osg::ref_ptr traits = new 
osg::GraphicsContext::Traits;
traits->windowDecoration = false;
traits->x = x;
traits->y = y;
traits->width = w;
traits->height = h;
traits->doubleBuffer = true;

osg::ref_ptr camera = new osg::Camera;
camera->setGraphicsContext( new 
osgQt::GraphicsWindowQt(traits.get()) );
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(traits->width)/static_cast(traits->height), 1.0f, 
1.0f );

return camera.release();
}

protected:
virtual void paintEvent( QPaintEvent* event )   { m_viewer.frame(); }
osgViewer::Viewer   m_viewer;
QTimer  m_timer;
};

#endif  // VIEWERWIDGET_H




main.cpp

Code:

#include 

#include "viewerwidget.h"

int main(int argc, char *argv[])
{
   QApplication app( argc, argv );

   ViewerWidget* widget = new ViewerWidget(0,Qt::WindowStaysOnTopHint | 
Qt::SplashScreen);
   widget->setGeometry( 0, 0, 800, 600 );
   widget->showFullScreen();
   widget->show();

return app.exec();
}





Thank you!

Cheers,
Markus

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org