Hi Frederick,

Frederik Didden wrote:
> Hi, I've been trying to setup a sky background. When my scene is being 
> shown it doesn't draw the background. I'm probably missing some settings 
> here. The code i'm using is:
> 
>     OSG::beginEditCP(sky);
>         sky->setBackTexture(createTexture("textures/envdown.jpg") );
>         sky->setFrontTexture(createTexture("textures/envup.jpg") );
>         sky->setLeftTexture(createTexture("textures/envwest.jpg") );
>         sky->setRightTexture(createTexture("textures/enveast.jpg") );
>         sky->setBottomTexture(createTexture("textures/envsouth.jpg") );
>         sky->setTopTexture(createTexture("textures/envnorth.jpg") );
>     endEditCP(sky);
> 
>     beginEditCP(topViewport);
>         topViewport->setCamera(topCamera);
>         topViewport->setBackground(sky);
>         topViewport->setRoot(scene);
>         topViewport->setSize( 0.8,0.8,1,1);
>     endEditCP(topViewport);
> 
> TextureChunkPtr SceneFactory::createTexture(char *file)
> {
>     ImagePtr image = Image::create();
>     beginEditCP(image);
>         image->read(file);
>     endEditCP(image);
> 
>     TextureChunkPtr chunk = TextureChunk::create();
>     beginEditCP(chunk);
>         chunk->setImage(image);
>     endEditCP(chunk);
> 
>     return chunk;
> }
> 
> Can anyone point me in the right direction?

I've used this function in the past:

TextureChunkPtr createTexture(std::string path)
{
     ImagePtr image = Image::create();

     beginEditCP(image);
         image->read( path.c_str() );

     endEditCP(image);

     TextureChunkPtr tex1;
     tex1 = TextureChunk::create();
     beginEditCP(tex1);
     tex1->setImage( image );
     tex1->setMinFilter( GL_LINEAR_MIPMAP_LINEAR );
     tex1->setMagFilter( GL_LINEAR );
     tex1->setWrapS( GL_REPEAT );
     tex1->setWrapT( GL_REPEAT );
     tex1->setEnvMode( GL_REPLACE );
     endEditCP(tex1);

     return tex1;
}

You might not need all those settings, but try it out.

Hope it helps

        Dirk


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to