#endif
#include "TextureBuilder.hxx"
+#include "mipmap.hxx"
#include "Pass.hxx"
typedef boost::tuple<string, Texture::FilterMode, Texture::FilterMode,
Texture::WrapMode, Texture::WrapMode, Texture::WrapMode,
- string> TexTuple;
+ string, MipMapTuple> TexTuple;
EffectNameValue<TexEnv::Mode> texEnvModesInit[] =
{
texture = TextureBuilder::buildFromType(effect, type, prop,
options);
}
- catch (BuilderException& ) {
- SG_LOG(SG_INPUT, SG_ALERT, "No image file, "
+ catch (BuilderException& e) {
+ SG_LOG(SG_INPUT, SG_ALERT, e.getFormattedMessage() << ", "
<< "maybe the reader did not set the filename attribute, "
<< "using white for type '" << type << "' on '" << pass->getName() << "', in " << prop->getPath() );
texture = StateAttributeFactory::instance()->getWhiteTexture();
};
EffectPropertyMap<Texture::WrapMode> wrapModes(wrapModesInit);
-
TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props,
const SGReaderWriterXMLOptions* options,
const string& texType)
string imageName;
if (pImage)
imageName = pImage->getStringValue();
- string absFileName = osgDB::findDataFile(imageName, options);
+ string absFileName = SGModelLib::findDataFile(imageName, options);
+
+ const SGPropertyNode* pMipmapControl
+ = getEffectPropertyChild(effect, props, "mipmap-control");
+ MipMapTuple mipmapFunctions( AUTOMATIC, AUTOMATIC, AUTOMATIC, AUTOMATIC );
+ if ( pMipmapControl )
+ mipmapFunctions = makeMipMapTuple(effect, pMipmapControl, options);
+
return TexTuple(absFileName, minFilter, magFilter, sWrap, tWrap, rWrap,
- texType);
+ texType, mipmapFunctions);
}
void setAttrs(const TexTuple& attrs, Texture* tex,
osgDB::ReaderWriter::ReadResult result
= osgDB::Registry::instance()->readImage(imageName, options);
if (result.success()) {
- osg::Image* image = result.getImage();
- tex->setImage(GL_FRONT_AND_BACK, image);
+ osg::ref_ptr<osg::Image> image = result.getImage();
+ image = computeMipmap( image.get(), attrs.get<7>() );
+ tex->setImage(GL_FRONT_AND_BACK, image.get());
int s = image->s();
int t = image->t();
if (s <= t && 32 <= s) {