Sorry, I seem to have a tradition of answering to my own questions I
inserted this piece of code into the osgconv.cpp
CompressTextureVisitor
after the line beginning with osg::ref_ptr<osg::Image> image = ...
This resizes the images to power of 2, up to OSG_MAX_TEXTURE_SIZE on
each 2D dimension. Because it only works in conjunction with the
--compressed switch, it is not a generic solution and it does not
currently deal with 3D textures at all.
Might I suggest that a more general approach to this be implemented in osgconv?
Christian
if (image.valid())
{
#define MIN(a,b) ((a)<(b)?(a):(b))
int w = image->s(), h = image->t(), nw, nh;
int mts = atoi(getenv("OSG_MAX_TEXTURE_SIZE"));
if (mts == 0) {
nw = image->computeNearestPowerOfTwo(w);
nh = image->computeNearestPowerOfTwo(h);
} else {
nw = MIN(image->computeNearestPowerOfTwo(w), mts);
nh = MIN(image->computeNearestPowerOfTwo(h), mts);
}
if (w != nw || h != nh) {
osg::notify(osg::NOTICE) << "Rescaling image from
(" << w << "," << h <<
") to (" << nw << ","
<< nh << ")." << std::endl;
image->scaleImage(nw, nh, image->r());
}
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org