On Wed, Oct 6, 2010 at 9:07 AM, BARRAL Adrien <[email protected]> wrote:
> Hello,
>
> I set a texture on a big plane with the following lines :
>
>
> Code:
>
> Image* image = osgDB::readImageFile("resources/textures/sable-jaune.bmp");
> Texture2D* texture = new osg::Texture2D;
> TexMat* tmat = new TexMat;
> tmat->setMatrix(Matrix::scale(100,100,1));
> if (image)
> {
> texture->setDataVariance(Object::DYNAMIC);
> texture->setFilter(Texture::MIN_FILTER, Texture::LINEAR_MIPMAP_LINEAR);
> texture->setFilter(Texture::MAG_FILTER, Texture::LINEAR);
> texture->setWrap(Texture::WRAP_S, Texture::REPEAT);
> texture->setWrap(Texture::WRAP_T, Texture::REPEAT);
> texture->setImage(image);
> }else
> {
> throw runtime_error("Impossible de charger la texture du seab bed.");
> }
> m_geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture,
> StateAttribute::ON);
> m_geode->getStateSet()->setTextureAttribute(0, tmat);
> m_geode->getStateSet()->addUniform( new osg::Uniform( "uTextureMap", 0 ) );
>
I don't know if this is the whole problem, but this use of the Uniform
constructor does not give the uniform binding the correct type. You need to
do something like this:
Uniform* texSampler = new Uniform(Uniform::SAMPLER_2D, "uTextureMap");
texSampler->set(0);
m_geode->getStateSet()->addUniform(texSampler);
m_geode->getStateSet()->setTextureMode(0,GL_TEXTURE_1D,osg::StateAttribute::OFF);
>
> m_geode->getStateSet()->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
>
> m_geode->getStateSet()->setTextureMode(0,GL_TEXTURE_3D,osg::StateAttribute::OFF)
>
>
>
>
> When I execute my application, I can see my plane (m_geode) textured with
> "sable-jaune.bmp" repeated in bothes directions.
> All is right !
>
> Now, I enable my shaders programs, and my texture is scaled to the plane's
> size (not repeated).
> Here is my vertex shader :
>
> Tim
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org