Thanks for the quick answer.

I'm using OSG 2.8.3 with osgOcean.

The 3D views are embedded in an existing MOTIF application which I cannot 
modify. Instead, this application calls my library with the widget that I need 
to draw on.

I use XDisplay(Widget w) to get the screen for each widget (5 widgets per 
screen).

The integration is done with the GLw library. 

I have a class that defines the scene and contains an instance of 
osgViewer::Viewer with its own Camera.

The initialization is something like this (simplified) :

Code:

void initialize(Widget w)
{
  // Create our scene
  Scene s = new Scene;

  // Get the display associated with the widget
  Display* dpy = XDisplay(w);

  osgViewer::Viewer viewer = scene->getViewer();
  osgViewer::GraphicsWindowEmbedded gfx = 
viewer->setUpViewerAsEmbeddedInWindow(w.core.x, w.core.y, w.core.width, 
w.core.height);

  // Build a XVisualInfo object from the traits and the display
  XVisualInfo* info = createVisualInfo(dpy, 
viewer->getCamera()->getGraphicsContext()->getTraits());
  XtSetArg(argsGL[0], (char*) GLwNvisualInfo, info);

  // Create the GLX Context for the active display
  GLXContext glxContext = glXCreateContext(dpy, info, 0, GL_TRUE);
  
  viewer->realize();
  gfx->realize();
  
  // One per widget
  Widget drawArea = GLwCreateMDrawingArea(w, (char*) "View", argsGL, 1);
  XtManageChild(drawArea);
}




The rendering is done in a scheduled method (every 40ms). It can be simplified 
as the following:

Code:

void draw(Widget w)
{
  // Wait for pending X operations before rendering
  glXWaitX();
  
  // Activate current context
  GLwDrawingAreaMakeCurrent(w, glxContext);

  // Computes the new projection
  [...]

  viewer->getCamera()->setProjectionMatrixAsPerspective(...);   
  gfx->resized(0, 0, w.core.width, w.core.height);

  // Render to buffer
  viewer->frame();
  
  GLwDrawingAreaSwapBuffers(w);
}




For each screen, there's 5 widgets, 5 drawArea of various sizes, but only one 
scene, one glxContext. The method draw is called for each widget as long as the 
widget is visible (at most, 4 are visible on a screen).

There's no issue with only one screen, no flickering. But with a second screen 
it's a mess. With only one glxContext, nothing shows up on the second screen. 
When I add a second context and duplicate most of the objects, flickering 
starts and I get a lot of "invalid operations" in the trace.
This is where I am stuck for now...

Cheers,
Vincent

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





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

Reply via email to