Hi, I'm trying to create a 3d texture, which will be accessed in a shader
program. I think i'm having problems with the texture creation, because the
following message is always
printed:

WARNING: (..\..\..\Source\System\State\Base\WS\OSGTextureObjChunk.cpp,1187):
TextureObjChunk::initialize image failed: invalid value (0x501)

I found that this error occurs when a invalid value is passed to opengl. But
i can't see what i'm doing wrong. Here is the code:

    OSG::ImageTransitPtr image3D = OSG::Image::create();
    image3D->set( OSG::Image::OSG_L_PF, width, height, depth, 1, 1, 0, data,
OSG::Image::OSG_UINT8_IMAGEDATA );

    // create and configure a 3d texture
    _envChunk = OSG::TextureEnvChunk::create();
    _envChunk->setEnvMode( GL_REPLACE );

    OSG::TextureObjChunkUnrecPtr texture = OSG::TextureObjChunk::create();
    texture->setImage( image3D );
    texture->setTarget( GL_TEXTURE_3D );
    texture->setWrapS( GL_CLAMP_TO_EDGE );
    texture->setWrapT( GL_CLAMP_TO_EDGE );
    texture->setWrapR( GL_CLAMP_TO_EDGE );
    texture->setMagFilter( GL_LINEAR );
    texture->setMinFilter( GL_LINEAR );

    // create a textured material for the 3d texture
    _material = OSG::SimpleMaterial::create();

    _shl = OSG::SimpleSHLChunk::create();

    if( !_shl->readFragmentProgram( ( Application::dataDir() + "/prog.fp"
).data() ) )
        fprintf( stderr, "Couldn't read fragment program 'prog.fp'\n" );

    _shl->addUniformVariable( "tex", 0 );

    _material->setLit( false );
    _material->addChunk( _shl );
    _material->addChunk( texture );
    _material->addChunk( _envChunk );

data is a array of unsigned chars with width * height * depth elements. I'm
using a nvidia quadro fx 5500, so i think the hardware is not the problem
since 3d texture is supported.

Is there anything wrong with the code above?

Tanks in advance,
Daniel
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to