Changed the createGeodeFromImage code to use the non power of two extension, and disabled mipmapping

This commit is contained in:
Robert Osfield 2008-09-11 09:26:14 +00:00
parent 4f6b405edf
commit 04a3f0da1c

View File

@ -1210,6 +1210,9 @@ Geode* osg::createGeodeForImage(osg::Image* image)
}
#include <osg/TextureRectangle>
Geode* osg::createGeodeForImage(osg::Image* image,float s,float t)
{
if (image)
@ -1221,7 +1224,22 @@ Geode* osg::createGeodeForImage(osg::Image* image,float s,float t)
float x = y*(s/t);
// set up the texture.
#if 0
osg::TextureRectangle* texture = new osg::TextureRectangle;
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
//texture->setResizeNonPowerOfTwoHint(false);
float texcoord_x = image->s();
float texcoord_y = image->t();
#else
osg::Texture2D* texture = new osg::Texture2D;
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
texture->setResizeNonPowerOfTwoHint(false);
float texcoord_x = 1.0f;
float texcoord_y = 1.0f;
#endif
texture->setImage(image);
// set up the drawstate.
@ -1242,10 +1260,10 @@ Geode* osg::createGeodeForImage(osg::Image* image,float s,float t)
geom->setVertexArray(coords);
Vec2Array* tcoords = new Vec2Array(4);
(*tcoords)[0].set(0.0f,1.0f);
(*tcoords)[1].set(0.0f,0.0f);
(*tcoords)[2].set(1.0f,0.0f);
(*tcoords)[3].set(1.0f,1.0f);
(*tcoords)[0].set(0.0f*texcoord_x,1.0f*texcoord_y);
(*tcoords)[1].set(0.0f*texcoord_x,0.0f*texcoord_y);
(*tcoords)[2].set(1.0f*texcoord_x,0.0f*texcoord_y);
(*tcoords)[3].set(1.0f*texcoord_x,1.0f*texcoord_y);
geom->setTexCoordArray(0,tcoords);
osg::Vec4Array* colours = new osg::Vec4Array(1);