From 04a3f0da1cb4731c118028f8e3be9c525d751df0 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 11 Sep 2008 09:26:14 +0000 Subject: [PATCH] Changed the createGeodeFromImage code to use the non power of two extension, and disabled mipmapping --- src/osg/Image.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index d1600fbf0..2208a239f 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -1210,6 +1210,9 @@ Geode* osg::createGeodeForImage(osg::Image* image) } +#include + + 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);