Hi Robert,

 

Thanks for your help. I could finally get it to work. Now the OSG
renders in a separate thread from the QT4 main thread into a QGLWidget.
I have tweaked the current osgSimpleViewerQT4 example and attached my
modified version osgSimpleViewerQT4_MT to this mail for the osg
community.

 

The main issue with this solution is that it only runs at Win32 systems
as it needs to create an platform dependent
osgViewer::GraphicsWindowWin32::WindowData. It would be great to have a
platform independent possibility to pass Window Handle to the
GraphicsContext (as it was possible with Producer).

 

I also found a bug at your SimpleViewerQT4 implementation. The mouse
positions from the QT mouse events have to be converted to virtual
coordinates before passing them to the osgGA::EventQueue. This fix is
also integrated in the attached version.

 

Thanks,

 

Daniel Kallfass

 

 

 

________________________________

Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Im Auftrag von Robert
Osfield
Gesendet: Donnerstag, 3. Mai 2007 16:38
An: osg users
Betreff: Re: [osg-users] Problems porting Producer to osgViewer

 

Hi Daniel,

I have heard others being successful at getting this working, but don't
have the code first hand.  My best guess would be to try adding a
realize(); before the frame loop.

If you get it working then perhaps you could tweak the OSG's QT example
to work using this method :-) 

Robert.

On 5/3/07, Kallfass, Daniel, SDGE1 <[EMAIL PROTECTED]> wrote:

Robert,

> Yes, but its only support under Windows so far. X11 and OSX will come
along later.
> What you do is create a osg::Traits object with
osgViewer::GraphicsWindowWin32::WindowData attached to it.

Thank you very much for your response with the hint to use WindowData. I
have tried the following code, but I still get an exception when OSG
tries to render a scene:

MyThread::run() {

  osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits; 
  traits->x = 0;
  traits->y = 0;
  traits->width = width();
  traits->height = height();
  traits->windowDecoration = false;
  traits->doubleBuffer = true;
  traits->sharedContext = 0; 
  osg::ref_ptr<osgViewer::GraphicsWindowWin32::WindowData> wdata = new
osgViewer::GraphicsWindowWin32::WindowData( internalWinId() ); //Pass QT
QWidget WindowHandle
  traits->inheritedWindowData = wdata.get ();

  osg::ref_ptr<osg::GraphicsContext> gc =
osg::GraphicsContext::createGraphicsContext(traits.get());
  gc->setClearColor(osg::Vec4f(0.2f,0.2f,0.6f,1.0f));
  gc->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

getCamera()->setGraphicsContext(gc.get());

while( true ) {
  frame();
}
}

I get an exception at lightmodel::apply line 55 at lightmodel.cpp:

  static bool s_separateSpecularSupported = strncmp((const
char*)glGetString(GL_VERSION)," 1.2",3)>=0;

which points to an invalid OpenGL context.

> arghhgh my RSI is killing me, could someone else jump in here and
explain.
Sorry for my painful question. Get well soon!

Thanks,
Daniel
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

 

Attachment: osgSimpleViewerQT4_MT.cpp
Description: osgSimpleViewerQT4_MT.cpp

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to