I am playing around with Qt4 and OpenSG
basically I am following the Tutorial but using the Qt4 GLWidget
Seems that the OpenSG Qt4 native on MacOs is not enabled (why?),
So I am trying to experiment following the testPassiveQt4 example in
OSG QT4 directory
Everything works fine, but when I close the application I get this error:
LOG: GL Vendor/Renderer: NVIDIA Corporation/NVIDIA GeForce 9400M OpenGL Engine
WARNING: FieldContainerFactoryBase::terminate: Entry [248] is not NULL
([0x50e06f0]).
WARNING: [0] [0x50e1860] [TextureEnvChunk] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [253] is not NULL
([0x5178b70]).
WARNING: [0] [0x51789e0] [PassiveWindow] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [254] is not NULL
([0x51790a0]).
WARNING: [0] [0x5178fd0] [GeoPnt3fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [255] is not NULL
([0x5179250]).
WARNING: [0] [0x5179190] [GeoVec3fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [256] is not NULL
([0x5179370]).
WARNING: [0] [0x51792b0] [GeoVec2fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [257] is not NULL
([0x5179490]).
WARNING: [0] [0x51793c0] [GeoUInt32Property] [16 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [258] is not NULL
([0x5179180]).
WARNING: [0] [0x5179580] [GeoUInt32Property] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [259] is not NULL
([0x5179720]).
WARNING: [0] [0x5179660] [GeoUInt8Property] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [260] is not NULL
([0x50e0660]).
WARNING: [0] [0x5179970] [Geometry] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [261] is not NULL
([0x5179540]).
WARNING: [0] [0x5179e50] [SimpleMaterial] [3 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [262] is not NULL
([0x51794c0]).
WARNING: [0] [0x5179f90] [State] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [263] is not NULL
([0x517a110]).
WARNING: [0] [0x5179fe0] [MaterialChunk] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [264] is not NULL
([0x517a200]).
WARNING: [0] [0x517a130] [BlendChunk] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [265] is not NULL
([0x517a3f0]).
WARNING: [0] [0x517a4b0] [Node] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [266] is not NULL
([0x517a670]).
WARNING: [0] [0x517a5a0] [GeoPnt3fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [267] is not NULL
([0x517a790]).
WARNING: [0] [0x517a6c0] [GeoVec3fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [268] is not NULL
([0x517a8b0]).
WARNING: [0] [0x517a7e0] [GeoVec2fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [269] is not NULL
([0x517a9d0]).
WARNING: [0] [0x517a900] [GeoUInt32Property] [16 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [270] is not NULL
([0x517aaf0]).
WARNING: [0] [0x517aa20] [GeoUInt32Property] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [271] is not NULL
([0x517ac10]).
WARNING: [0] [0x517ab40] [GeoUInt8Property] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [272] is not NULL
([0x517aae0]).
WARNING: [0] [0x517ae60] [Geometry] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [273] is not NULL
([0x5179f10]).
WARNING: [0] [0x517b550] [Node] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [274] is not NULL
([0x517b6e0]).
WARNING: [0] [0x517b610] [GeoPnt3fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [275] is not NULL
([0x517b800]).
WARNING: [0] [0x517b730] [GeoVec3fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [276] is not NULL
([0x517b920]).
WARNING: [0] [0x517b850] [GeoVec2fProperty] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [277] is not NULL
([0x517ba40]).
WARNING: [0] [0x517b970] [GeoUInt32Property] [16 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [278] is not NULL
([0x517bb60]).
WARNING: [0] [0x517ba90] [GeoUInt32Property] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [279] is not NULL
([0x517bc80]).
WARNING: [0] [0x517bbb0] [GeoUInt8Property] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [280] is not NULL
([0x517ba30]).
WARNING: [0] [0x517bed0] [Geometry] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [281] is not NULL
([0x517c380]).
WARNING: [0] [0x517c440] [Node] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [282] is not NULL
([0x517c600]).
WARNING: [0] [0x517c530] [Node] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [283] is not NULL
([0x517c6c0]).
WARNING: [0] [0x517c620] [Group] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [284] is not NULL
([0x517c930]).
WARNING: [0] [0x517c880] [Node] [2 3]
WARNING: FieldContainerFactoryBase::terminate: Entry [285] is not NULL
([0x517ca30]).
WARNING: [0] [0x517c950] [Transform] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [286] is not NULL
([0x517cb40]).
WARNING: [0] [0x517ca70] [Node] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [287] is not NULL
([0x517cc60]).
WARNING: [0] [0x517cb60] [DirectionalLight] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [288] is not NULL
([0x517cd50]).
WARNING: [0] [0x517ccb0] [PerspectiveCamera] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [289] is not NULL
([0x517cf10]).
WARNING: [0] [0x517ce70] [SolidBackground] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [290] is not NULL
([0x517cfe0]).
WARNING: [0] [0x517cf30] [ImageForeground] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [291] is not NULL
([0x517d140]).
WARNING: [0] [0x517d000] [SimpleStatisticsForeground] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [292] is not NULL
([0x517d6f0]).
WARNING: [0] [0x517d620] [Viewport] [2 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [293] is not NULL
([0x517d360]).
WARNING: [0] [0x517d750] [LightChunk] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [294] is not NULL
([0x518f9f0]).
WARNING: [0] [0x518f940] [DrawableStatsAttachment] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [295] is not NULL
([0x5190a30]).
WARNING: [0] [0x5190970] [DrawableStatsAttachment] [1 0]
WARNING: FieldContainerFactoryBase::terminate: Entry [296] is not NULL
([0x5190c40]).
WARNING: [0] [0x5190b90] [DrawableStatsAttachment] [1 0]
WARNING: ThreadManager::shutdown: thread [OSGThread_1|0x58dde00] is
still alive ([1]).
WARNING: ThreadManager::shutdown: lock [OSGLock_6|0x5178c10] is still alive
WARNING: ThreadManager::shutdown: semaphore [OSGSemaphore_0|0x5178c80]
is still alive
This is My Program:
###--------------------------------------------------------------------------------------------------------------------------------------------------------
#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGSimpleGeometry.h>
#include <OpenSG/OSGSimpleSceneManager.h>
#include <OpenSG/OSGCarbonWindow.h>
#include <OSGPassiveWindow.h>
#include <math.h>
#include <QtGui/QApplication>
#include <QtOpenGL/QGLWidget>
#include <QtGui/QMouseEvent>
//In most cases it is useful to add this line, otherwise every OpenSG command
//must be preceeded by an extra OSG::
OSG_USING_NAMESPACE
//The SimpleSceneManager is a useful class which helps us to
//manage simple configurations. It will be discussed in detail later on
// SimpleSceneManager *mgr;
//we have a forward declaration here, just to have a better order
//of codepieces
// int setupGLUT( int *argc, char *argv[] );
class OpenSGWidget : public QGLWidget
{
public:
OpenSGWidget(const QGLFormat &f, QWidget *parent=0);
SimpleSceneManager *getManager(void);
protected:
void initializeGL();
void resizeGL( int, int );
void paintGL();
void mousePressEvent( QMouseEvent *ev );
void mouseMoveEvent( QMouseEvent *ev );
void mouseReleaseEvent( QMouseEvent *ev );
void wheelEvent( QWheelEvent *ev );
SimpleSceneManager *mgr;
PassiveWindowRecPtr pwin;
};
OSG::SimpleSceneManager *OpenSGWidget::getManager(void)
{
return mgr;
}
OpenSGWidget::OpenSGWidget(const QGLFormat &f, QWidget *parent)
: QGLWidget(f, parent)
{
setAutoBufferSwap(false);
mgr = new OSG::SimpleSceneManager;
pwin = OSG::PassiveWindow::create();
mgr->setWindow(pwin);
}
void OpenSGWidget::initializeGL()
{
pwin->init();
}
void OpenSGWidget::resizeGL( int width, int height )
{
mgr->resize(width,height);
}
void OpenSGWidget::paintGL()
{
mgr->redraw();
swapBuffers();
}
void OpenSGWidget::mousePressEvent( QMouseEvent *ev )
{
OSG::UInt32 button;
switch ( ev->button() )
{
case Qt::LeftButton:
button = OSG::SimpleSceneManager::MouseLeft;
break;
case Qt::MidButton:
button = OSG::SimpleSceneManager::MouseMiddle;
break;
case Qt::RightButton:
button = OSG::SimpleSceneManager::MouseRight;
break;
default: return;
}
mgr->mouseButtonPress(button, ev->x(), ev->y());
update();
}
void OpenSGWidget::mouseReleaseEvent( QMouseEvent *ev )
{
OSG::UInt32 button;
switch ( ev->button() )
{
case Qt::LeftButton:
button = OSG::SimpleSceneManager::MouseLeft;
break;
case Qt::MidButton:
button = OSG::SimpleSceneManager::MouseMiddle;
break;
case Qt::RightButton:
button = OSG::SimpleSceneManager::MouseRight;
break;
default: return;
}
mgr->mouseButtonRelease(button, ev->x(), ev->y());
update();
}
void OpenSGWidget::mouseMoveEvent( QMouseEvent *ev )
{
mgr->mouseMove(ev->x(), ev->y());
update();
}
void OpenSGWidget::wheelEvent( QWheelEvent *ev )
{
mgr->mouseButtonPress(ev->delta() > 0 ? OSG::SimpleSceneManager::MouseUp
: OSG::SimpleSceneManager::MouseDown,
ev->x(), ev->y());
ev->accept();
update();
}
NodeTransitPtr createScenegraph(void)
{
// First we will create all needed geometry
// the body of the house
NodeRecPtr houseMain = makeBox(20,20,20,1,1,1);
// now the roof
NodeRecPtr roof = makeBox(14.14, 14.14, 20, 1, 1, 1);
// and the chimney - we have the top and sides generated
// but we have no need for the bottom (it is inside the house)
NodeRecPtr chimney = makeCylinder(10,1,8,true,true,false);
// Now we create the root node and attach the geometry nodes to it
OSG::NodeRecPtr n = OSG::Node::create();
n->setCore(Group::create());
n->addChild(houseMain);
n->addChild(roof);
n->addChild(chimney);
return NodeTransitPtr(n);
}
int main(int argc, char **argv)
{
//the OpenSG subsystem
osgInit(argc,argv);
QApplication::setColorSpec( QApplication::CustomColor );
QApplication a( argc, argv );
OpenSGWidget w(QGLFormat(QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba |
QGL::DirectRendering));
if ( !QGLFormat::hasOpenGL() ) {
qWarning( "This system has no OpenGL support. Exiting." );
return -1;
}
// create the scene
NodeRecPtr scene;
scene = createScenegraph();
w.getManager()->setRoot(scene);
w.getManager()->showAll();
w.show();
return a.exec();
}
Thank You :)
--------------------------
Luck favors the prepared mind. (Pasteur)
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users