1 // model.cxx - manage a 3D aircraft model.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain, and comes with no warranty.
7 #include <simgear_config.h>
10 #include <osg/ref_ptr>
11 #include <osgDB/ReadFile>
12 #include <osgDB/SharedStateManager>
14 #include <simgear/scene/util/SGSceneFeatures.hxx>
16 #include <simgear/structure/exception.hxx>
17 #include <simgear/props/props.hxx>
18 #include <simgear/props/props_io.hxx>
19 #include <simgear/props/condition.hxx>
26 SGLoadTexture2D(bool staticTexture, const std::string& path,
27 const osgDB::ReaderWriter::Options* options,
28 bool wrapu, bool wrapv, int)
32 image = osgDB::readImageFile(path, options);
34 image = osgDB::readImageFile(path);
35 osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
36 texture->setImage(image);
38 texture->setDataVariance(osg::Object::STATIC);
40 texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
42 texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);
44 texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
46 texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);
52 if (s <= t && 32 <= s) {
53 SGSceneFeatures::instance()->setTextureCompression(texture.get());
54 } else if (t < s && 32 <= t) {
55 SGSceneFeatures::instance()->setTextureCompression(texture.get());
59 return texture.release();