Hello Dirk, thanks for your reply,

> I'm trying to remember the reason we used a PassiveBackground there, but
> I'm not sure. I vaguely remember some problems with clearing parts of
> the viewport that were needed later, but as long as it works for you it
> should be fine.

You're the ones who created the OpenSGApp class too? So I gather there's a
collaboration going on between VR Juggler and OpenSG? It's good to know that
using OpenSG in my context was a good choice.

> Do you also assign your SkyBackground to the Viewport somewhere?
> Otherwise it will not be used, unless you do your initialization before
> the Viewport is initialized.

That would be my error, I had not assigned it since the initial background
creation in OpenSGApp... So here's my code now :

void Waverider::setupSky(void) {
    vprDEBUG_OutputGuard(vprDBG_ALL, vprDBG_CRITICAL_LVL,
                         "Waverider::setupSky() called.\n",
                         "Waverider::setupSky() exiting.\n");

    // Create the sky
    // Most of the code here is from testWindowGLUTSky.cpp in the
    // OpenSG source distribution
    OSG::SkyBackgroundPtr sky = OSG::SkyBackground::create();
    OSG::beginEditCP(sky);
        sky->setSphereRes(16);

        sky->getMFSkyColor()->push_back(Color4f(0, 0, 1, 0.5));
        sky->getMFSkyAngle()->push_back(M_PI / 4);
        sky->getMFSkyColor()->push_back(Color4f(0, 1, 0, 0.5));
        sky->getMFSkyAngle()->push_back(M_PI / 2);
        sky->getMFSkyColor()->push_back(Color4f(1, 0, 0, 0.5));

        sky->getMFGroundColor()->push_back(Color4f(0, 1, 1, 0.5));
        sky->getMFGroundAngle()->push_back(M_PI / 8);
        sky->getMFGroundColor()->push_back(Color4f(1, 0, 1, 0.5));
        sky->getMFGroundAngle()->push_back(M_PI / 4);
        sky->getMFGroundColor()->push_back(Color4f(1, 1, 1, 0.5));

        //setSkyCubeImages( tex1 );

        sky->setBackTexture  (
createTexture("textures/g3d/test/testcube_bk.jpg") );
        sky->setFrontTexture (
createTexture("textures/g3d/test/testcube_ft.jpg") );
        sky->setLeftTexture  (
createTexture("textures/g3d/test/testcube_lt.jpg") );
        sky->setRightTexture (
createTexture("textures/g3d/test/testcube_rt.jpg") );
        sky->setBottomTexture(
createTexture("textures/g3d/test/testcube_dn.jpg") );
        sky->setTopTexture   (
createTexture("textures/g3d/test/testcube_up.jpg") );

    OSG::endEditCP(sky);

    // Set the sky as the application's global background
    context_data* c_data = &(*mContextData);  // Context specific data. Should
be one copy per context
    c_data->mBackground = sky;

    // Set the sky as the viewport's background
    OSG::beginEditCP(c_data->mViewport);
        c_data->mViewport->setBackground(c_data->mBackground);
    OSG::endEditCP  (c_data->mViewport);
}


// Utility function to load a texture and attach it to a TextureChunk
OSG::TextureChunkPtr Waverider::createTexture( std::string filename ) {
    OSG::TextureChunkPtr tex = OSG::TextureChunk::create();
    OSG::ImagePtr img;

    OSG::beginEditCP(tex);
        tex->setMinFilter( GL_NEAREST );
        tex->setMagFilter( GL_NEAREST );
        tex->setWrapS    ( GL_CLAMP );
        tex->setWrapT    ( GL_CLAMP );
        tex->setWrapR    ( GL_CLAMP );
        tex->setEnvMode  ( GL_REPLACE );

        img = OSG::Image::create();
        img->read( filename.c_str() );
        tex->setImage(img);
    OSG::endEditCP(tex);

    return tex;
}


That should work right? Because it seems to cause another problem : The program
starts, gets to the setupSky() method, and then starts using up memory like
there's no tomorrow until my machine starts swapping like mad, and then either
the system kills it or I do. It never exits the setupSky() method.

What could be causing that? I've seen it happen a few other times before and
haven't been able to find the cause (it usually just goes away after I change a
few things around).

Thanks again,

J-S
--
______________________________________________________
Jean-Sebastien Guay     [EMAIL PROTECTED]
                         http://whitestar02.webhop.org


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to