Hello Christoph,

Christoph Schäfer wrote:
Carsten Neumann schrieb:
bugle (<http://www.opengl.org/sdk/tools/BuGLe/>) normally works fine for me. Tell it to use the "trace" chain and it will write a file with *lots* of information while the program runs. Then search through the file for the first occurrence of GL_INVALID_OPERATION, one of the OpenGL calls preceding that is the one that fails.
 >
Unfortunately I can't produce any usable result with bugl on windows - it was a very bumpy ride getting it running on win btw.

sorry, that seems to have been a miscommunication, you had asked for something that works on linux and that's where bugle normally does a decent job. I don't think it is intended to work on windows at all, though.

I tried a little harder to get some usable output from gDEBugger and came out with a breakpoint at the call of glGetError(). So here are some information on the first stop at glGetError():

is it possible to do conditional breakpoints and then set the condition to something like glGetError() != GL_NO_ERROR ? That should be close to the point where the real error occurs. Alternatively it would be nice if the debugger could just check glGetError() after each OpenGL function call as Marcus suggested, that should pinpoint the location.

If you need further information just let me know where to set breakpoints etc.

hm, it is a bit strange that all the context creation calls seem to happen on context 0 and then all the OpenGL calls are on context 1. I've noticed that I made a mistake with the test program I sent, it creates the SSM in the wrong thread, attached is an updated version.
However, that one occasionally prints a warning:
WARNING: Attachment::unlinkParent: Child <-> Parent link inconsistent.
I'll have to look into what is causing that.

        Cheers,
                Carsten


#ifdef OSG_BUILD_INTEGRATED
// Headers
#include <OSGGLUT.h>
#include <OSGConfig.h>
#include <OSGSimpleGeometry.h>
#include <OSGPassiveWindow.h>
#include <OSGSimpleSceneManager.h>
#include <OSGBaseFunctions.h>
#include <OSGTransform.h>
#include <OSGSimpleSceneManager.h>
#include <OSGSceneFileHandler.h>
#include <OSGFieldContainerUtils.h>

#else

// Headers
#include <OpenSG/OSGGLUT.h>
#include <OpenSG/OSGConfig.h>
#include <OpenSG/OSGSimpleGeometry.h>
#include <OpenSG/OSGPassiveWindow.h>
#include <OpenSG/OSGSimpleSceneManager.h>
#include <OpenSG/OSGBaseFunctions.h>
#include <OpenSG/OSGTransform.h>
#include <OpenSG/OSGSimpleSceneManager.h>
#include <OpenSG/OSGSceneFileHandler.h>
#include <OpenSG/OSGFieldContainerUtils.h>

#endif

OSG_USING_NAMESPACE

struct AppArgs
{
    int    argc;
    char **argv;
};

SimpleSceneManager *mgr;

NodeMTRecPtr          root;
TransformUnrecPtr     trafo;
PassiveWindowMTRecPtr pwin;

Thread             *a0Thread;
Thread             *a1Thread;

Barrier            *syncBarrier;

volatile bool       input       = false;
volatile bool       sceneUpdate = false;


int setupGLUT(int *argc, char *argv[]);


void initAspect0(int argc, char *argv[])
{
    osgInit(argc, argv);

    root = makeCoredNode<Transform>(&trafo);
    NodeUnrecPtr scene;

    if(argc > 1)
    {
        scene = SceneFileHandler::the()->read(argv[1]);
    }

    if(scene == NULL)
    {
        scene = makeTorus(.5, 2, 16, 16);
    }

    root->addChild(scene);

    commitChanges();
}

void runAspect0(void)
{
    Time t0 = getSystemTime();
    Time t1 = getSystemTime();

    while(true)
    {
//         std::cerr << "runAspect0 START LOOP" << std::endl;

        if(input == true)
        {
            syncBarrier->enter(2);

            std::cerr << "runAspect0 pulling input" << std::endl;
            a1Thread->getChangeList()->applyAndClear();
            commitChanges();

            syncBarrier->enter(2);
        }

        if(sceneUpdate == true)
        {
            syncBarrier->enter(2);
            sceneUpdate = false;
            syncBarrier->enter(2);
        }

        Time t2 = getSystemTime();

        if(t2 - t1 > 0.5f)
        {
            std::cerr << "runAspect0 updating trafo: " << (t2 - t1) << " " << 
(t2 - t0) << std::endl;

            Matrix m;
            m.setRotate(Quaternion(Vec3f(0,1,0), osgDegree2Rad((t2 - t0) * 5)));

            trafo->setMatrix(m);

            commitChanges();

            t1 = t2;
            sceneUpdate = true;
        }

//         std::cerr << "runAspect0 END LOOP" << std::endl;
    }
}


void initAspect1(void *args)
{
    AppArgs *appArgs = static_cast<AppArgs *>(args);

    setupGLUT(&appArgs->argc, appArgs->argv);

    // pull in changes from aspect 0
    a0Thread->getChangeList()->applyAndClear();
    commitChanges();

    pwin = PassiveWindow::create();
    pwin->init();

    mgr = new SimpleSceneManager;
    mgr->setWindow(pwin );
    mgr->setRoot  (root );
    mgr->showAll();
}

void runAspect1(void *args)
{
    glutMainLoop();
}


int main(int argc, char *argv[])
{
    AppArgs appArgs;
    appArgs.argc = argc;
    appArgs.argv = argv;

    initAspect0(argc, argv);

    syncBarrier = ThreadManager::the()->getBarrier("syncBarrier");

    a0Thread = dynamic_cast<Thread *>(ThreadManager::the()->getAppThread()      
 );
    a1Thread = dynamic_cast<Thread 
*>(ThreadManager::the()->getThread("a1Thread"));

    // init aspect 1
    a1Thread->runFunction(initAspect1, 1, &appArgs);
    Thread::join(a1Thread);

    // run glutMainLoop on aspect 1
    a1Thread->runFunction(runAspect1, 1, NULL);

    runAspect0();

    return 0;
}

void display(void)
{
    commitChanges();

    // if input
    if(input == true)
    {
        // allow aspect 0 to pull changes from input
        syncBarrier->enter(2);
        input = false;
        syncBarrier->enter(2);
    }

    if(sceneUpdate == true)
    {
        commitChanges();

        syncBarrier->enter(2);

        std::cerr << "runAspect1 pulling sceneUpdate" << std::endl;
        a0Thread->getChangeList()->applyAndClear();
        commitChanges();

        syncBarrier->enter(2);
    }

    mgr->redraw();

    glutSwapBuffers();
}

void reshape(int w, int h)
{
    mgr->resize(w, h);

    input = true;
    glutPostRedisplay();
}

void mouse(int button, int state, int x, int y)
{
    if(state)
        mgr->mouseButtonRelease(button, x, y);
    else
        mgr->mouseButtonPress(button, x, y);

    input = true;
    glutPostRedisplay();
}

void motion(int x, int y)
{
    mgr->mouseMove(x, y);

    input = true;
    glutPostRedisplay();
}

void keyboard(unsigned char k, int , int )
{
    switch(k)
    {
    case 'p':
    {
        SceneGraphPrinter sgp(root);
        sgp.printDownTree(std::cout);
    }
    break;
    }
}

void idle(void)
{
    glutPostRedisplay();
}


int setupGLUT(int *argc, char *argv[])
{
    glutInit(argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    int winid = glutCreateWindow("OpenSG First Application");

    glutDisplayFunc(display);
    glutIdleFunc(idle);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutReshapeFunc(reshape);
    glutKeyboardFunc(keyboard);

    return winid;
}
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to