Thanks Robert.. That helped... 

But I'm having way too much fun interfacing OSG to Qt to stop there:-).  I seem 
to be able to get it to work now but I'm having trouble running on a LINUX 
machine but shooting my display to a PC running Hummingbird Exceed 3D (my 
actual requirement). I'm logged into the PC and then use exceed to 
remotely login to a LINUX machine.  I seem to have trouble switching to a valid 
Graphics Context (i.e. glGetString(GL_VERSION) returns null string within OSG) 
and causes OSG to seg fault... Logging remotely into a LINUX machine and 
shooting the display to another LINUX machine works fine.

Am I setting up my graphics context incorrectly?  I'm not using the 
AdapterWidget from the example. I'm also having trouble getting 
GraphicsWindowEmbedded to work...

So, here is what I'm doing:

myViewer::myViewer(void)
{
   mViewer = new osgViewer::Viewer;
   mViewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
   mViewer->setCameraManipulator(new osgGA::TrackballManipulator);
   mCamera = mViewer->getCamera();
}

void myViewer::initialize(int height, int width)
{
   osg::ref_ptr<osg::GraphicsContext::Traits> traits =
      new osg::GraphicsContext::Traits;
   
   traits->readDISPLAY();   
   traits->doubleBuffer = true;
   traits->useCursor    = false;
   traits->x            = 0;
   traits->y            = 0;
   traits->width        = width;
   traits->height       = height;
   
   osg::ref_ptr<osg::Referenced> windata =
      new osgViewer::GraphicsWindowX11::WindowData(mGLWindow);
   
   traits->inheritedWindowData = windata;
   
   osg::GraphicsContext* gc;

   gc = osg::GraphicsContext::createGraphicsContext(traits.get());
   mCamera->setGraphicsContext(gc);

   mCamera->setClearColor(osg::Vec4(0.5235, 0.8745, 1.0, 1.0));
   mCamera->setViewport(traits->x,
                        traits->y,
                        traits->width,
                        traits->height);
   mViewer->setCamera(mCamera.get());
   mViewer->setSceneData(osgDB::readNodeFile("cow.osg"));
}

I am calling the myViewer->initialize() method in another class derived from a 
QGLWidget and where it is called in its first paintGL callback. I'm also 
calling the myViewer->frame() call in this callback which simply calls 
mViewer->frame().

I'm using Qt's QGLWidget's window ID (i.e. winId() stored in mGLWindow) to set 
the inheritedWindowData.  Is this okay to do it? If I don't do this 
initialization of the inheritedWindowData data, my widget DOES appear (in all 
cases) except it is detached from my Qt application.

I'm not sure if this is my programming problem, an Hummingbird Exceed problem 
or a Qt problem.

Can anybody help?  I've been working on this for weeks...

Thanks,
Paul P.


 
----- Original Message ----
From: Robert Osfield <robert.osfi...@gmail.com>
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Sent: Friday, May 15, 2009 4:24:08 AM
Subject: Re: [osg-users] Remote execution and OSG

HI Paul, J.P, et. al,

On Fri, May 15, 2009 at 8:56 AM, J.P. Delport <jpdelp...@csir.co.za> wrote:
> Not sure, but it looks like some code ignores the $DISPLAY setting and just
> tries to open :0.0.
>
> I can confirm that I get the same behaviour between two Debian machines:
> osgviewer cow.osg runs at a staggering 2fps
>
> osgkeyboardmouse fails with:
> No protocol specified
> Error: Unable to open display ":0.0".
> Error: unable to create graphics window.

The GraphicsContext::Traits structure is used to control how the
graphics window is created, and in it's default state the display and
screen settings (see osg::GraphicsContext::ScreenIndentifier) are 0:0.
  To override this default one needs to explictly call readDISPLAY()
which reads the DISPLAY env variable to set the display and screen
number.

Now the osgView::setUpView*() methods all call readDISPLAY(), but if
the example does use on of these methods, and instead creates the
GraphicsWindow it requires directly use GraphicsContext::Traits
without calling the readDISPLAY then it won't pick up your settings of
this variable, so you'll get different behavior.

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



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

Reply via email to