From 5212d66cab776abc0b0873ff112d6187b409a7b3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 4 Sep 2006 12:52:09 +0000 Subject: [PATCH] Cleaned up the texture setup code. --- .../osgtexturerectangle/osgtexturerectangle.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/osgtexturerectangle/osgtexturerectangle.cpp b/examples/osgtexturerectangle/osgtexturerectangle.cpp index 99ffe520b..8f6b79d11 100644 --- a/examples/osgtexturerectangle/osgtexturerectangle.cpp +++ b/examples/osgtexturerectangle/osgtexturerectangle.cpp @@ -131,20 +131,18 @@ osg::Node* createRectangle(osg::BoundingBox& bb, // disable display list so our modified tex coordinates show up geom->setUseDisplayList(false); - // setup texture - osg::TextureRectangle* texture = new osg::TextureRectangle; - // load image osg::Image* img = osgDB::readImageFile(filename); - texture->setImage(img); + + // setup texture + osg::TextureRectangle* texture = new osg::TextureRectangle(img); + + osg::TexMat* texmat = new osg::TexMat; + texmat->setScaleByTextureRectangleSize(true); // setup state osg::StateSet* state = geom->getOrCreateStateSet(); state->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); - - // setup state - osg::TexMat* texmat = new osg::TexMat; - texmat->setScaleByTextureRectangleSize(true); state->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON); // turn off lighting