Hello *,

I have a program that disables the dlist cache directly after the
startup. The program creates a scene using functions from
OSGSimpleGeometry.h (makeSphere, makeTorus, ...). Doing this several
times, replacing the scene of my SimpleSceneManager, the program crashes
at osggeopumpfactory.cpp, in GeoPump129(Window*,Geometry*), line 896:

   osgGLDrawRangeElementsEXT(*(TypesData + TypesInd++ * TypesStride),
                             0,
                             IndicesSize,
                             count,
                             IndicesPtr->getFormat(),
                             vind);

All pointers seem to be valid (osgGLDrawRangeElementsEXT too), so I'm a
little bit confused... it seems that the crash happens in my NVidia
graphic driver, the frame stack states a address in nvoglnt.dll.

The problem does not occur, if I don't disable the dlist cache.
Also creating my own geometry works (not using makeSphere, ...).
BTW makeBox is ok too.

I've attached a simple test program to demonstrate the problem. Its the
modified tutorial 01hello.cpp. It displays the torus, press SPACE to
replace the scene by a new torus.

my setup: Windows 2000, MS VC++ .NET 2003, OpenSG dailybuild 040108.


Regards,

Joerg.

// 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.
//

#include "stdafx.h"
#pragma warning (disable : 4231)

// 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>

// 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
int setupGLUT( int *argc, char *argv[] );

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

//jbo_begin
        // disable the dlist cache for now
        osg::FieldContainerPtr pProto = 
osg::Geometry::getClassType().getPrototype();
        osg::GeometryPtr pGeoProto = osg::GeometryPtr::dcast(pProto);
        if(pGeoProto != osg::NullFC)
        {
                pGeoProto->setDlistCache(false);
        }
//jbo_end
        
        // GLUT init
    int winid = setupGLUT(&argc, argv);

    // 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;

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

    // show the whole scene
    mgr->showAll();
    
    // GLUT main loop
    glutMainLoop();

    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)
    {
//jbo_begin
        case 32:
                {
                        NodePtr scene = makeTorus(.5, 2, 16, 16);
                        mgr->setRoot(scene);
                        glutPostRedisplay();
                }
                break;
//jbo_end

        case 27:        
        {
            OSG::osgExit();
            exit(0);
        }
        break;
    }
}

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

    return winid;
}

Reply via email to