Hello osg users,

Now, I try to migrate my app on MacOSX thanks to the glut window system.
I run a thread (opensg enables sgi-pthread) for glut display and the main thread is used by my application to update opensg scene. There is no problem on Linux or Windows (visual) but on MacOSX, the application displays only the first frame (?)
and then freezes...
The joined source code is based on the 01hello tutorial and has the same behavior
than my application. (OK linux, Windows but fails on MacOS).
(Note that standart tutorials run correctly.)

Any suggestions ?

Thanks on advance.

Jean-Marie

PS: I am wortking with opensg version 1.4 configured with :
./configure --with-compiler=g++ --enable-jpeg --enable-glut --enable-gif --enable-png \
--with-add-libdir=/sw/lib --enable-sgi-pthread


-----------------------------------------------------------------------------------------------------
// OpenSG Tutorial Example: Hello World
//
// Minimalistic OpenSG program
//
// This is the shortest useful OpenSG program
// (if you remove all the comments ;)
//
// It shows how to use OpenSG together with GLUT to create a little
// interactive scene viewer.
//

// GLUT is used for window handling
#include <OpenSG/OSGGLUT.h>

// General OpenSG configuration, needed everywhere
#include <OpenSG/OSGConfig.h>

// Methods to create simple geometry: boxes, spheres, tori etc.
#include <OpenSG/OSGSimpleGeometry.h>

// The GLUT-OpenSG connection class
#include <OpenSG/OSGGLUTWindow.h>

// A little helper to simplify scene management and interaction
#include <OpenSG/OSGSimpleSceneManager.h>

// OSGThread
#include <OpenSG/OSGThread.h>
#include <OpenSG/OSGBarrier.h>

// Activate the OpenSG namespace
// This is not strictly necessary, you can also prefix all OpenSG symbols
// with OSG::, but that would be a bit tedious for this example
OSG_USING_NAMESPACE

// The SimpleSceneManager to manage simple applications
SimpleSceneManager *mgr;

// forward declaration so we can have the interesting stuff upfront
void setupGLUT( void* );

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
   // OSG init
   osgInit(argc,argv);

   // GLUT init
//    int winid = setupGLUT(&argc, argv);



   // tell the manager what to manage
//    mgr->setWindow(gwin );


   Thread* t = dynamic_cast<Thread*> ( Thread::get("threadGLUT") );
   t->runFunction(&setupGLUT,0,0);

   Thread::getCurrent()->join(t) ;

   return 0;
}

//
// GLUT callback functions
//

// redraw the window
void display(void)
{
   mgr->redraw();
}

// react to size changes
void reshape(int w, int h)
{
   mgr->resize(w, h);
   glutPostRedisplay();
}

// react to mouse button presses
void mouse(int button, int state, int x, int y)
{
   if (state)
       mgr->mouseButtonRelease(button, x, y);
   else
       mgr->mouseButtonPress(button, x, y);
glutPostRedisplay();
}

// react to mouse motions with pressed buttons
void motion(int x, int y)
{
   mgr->mouseMove(x, y);
   glutPostRedisplay();
}

// react to keys
void keyboard(unsigned char k, int x, int y)
{
   switch(k)
   {
case 27: {
           OSG::osgExit();
           exit(0);
       }
       break;
   }
}

// setup the GLUT library which handles the windows for us
void setupGLUT(void*)
{
   int nb =1;
   char* bin="biin";
   glutInit(&nb, &bin);
   glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int winid = glutCreateWindow("OpenSG"); glutReshapeFunc(reshape);
   glutDisplayFunc(display);
   glutMouseFunc(mouse);
   glutMotionFunc(motion);
   glutKeyboardFunc(keyboard);



   // the connection between GLUT and OpenSG
   GLUTWindowPtr gwin= GLUTWindow::create();
   gwin->setId(winid);
   gwin->init();

  // create the scene
   NodePtr scene = makeTorus(.5, 2, 16, 16);

   // create the SimpleSceneManager helper
   mgr = new SimpleSceneManager;
   mgr->setWindow(gwin );
   mgr->setRoot  (scene);
// show the whole scene
   mgr->showAll();
// GLUT main loop
   glutMainLoop();

}
-----------------------------------------------------------------------------------------------------



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to