Added support for osg::Texture::setBorderWidth().
This commit is contained in:
@@ -173,6 +173,7 @@ Texture::Texture():
|
||||
_useHardwareMipMapGeneration(true),
|
||||
_unrefImageDataAfterApply(false),
|
||||
_borderColor(0.0, 0.0, 0.0, 0.0),
|
||||
_borderWidth(0),
|
||||
_internalFormatMode(USE_IMAGE_DATA_FORMAT),
|
||||
_internalFormat(0),
|
||||
_use_shadow_comparison(false),
|
||||
@@ -192,6 +193,7 @@ Texture::Texture(const Texture& text,const CopyOp& copyop):
|
||||
_useHardwareMipMapGeneration(text._useHardwareMipMapGeneration),
|
||||
_unrefImageDataAfterApply(text._unrefImageDataAfterApply),
|
||||
_borderColor(text._borderColor),
|
||||
_borderWidth(text._borderWidth),
|
||||
_internalFormatMode(text._internalFormatMode),
|
||||
_internalFormat(text._internalFormat),
|
||||
_use_shadow_comparison(text._use_shadow_comparison),
|
||||
@@ -508,8 +510,8 @@ void Texture::computeRequiredTextureDimensions(State& state, const osg::Image& i
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
int width = Image::computeNearestPowerOfTwo(image.s());
|
||||
int height = Image::computeNearestPowerOfTwo(image.t());
|
||||
int width = Image::computeNearestPowerOfTwo(image.s()-2*_borderWidth)+2*_borderWidth;
|
||||
int height = Image::computeNearestPowerOfTwo(image.t()-2*_borderWidth)+2*_borderWidth;
|
||||
|
||||
// cap the size to what the graphics hardware can handle.
|
||||
if (width>extensions->maxTextureSize()) width = extensions->maxTextureSize();
|
||||
@@ -628,7 +630,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
numMipmapLevels = 1;
|
||||
|
||||
glTexImage2D( target, 0, _internalFormat,
|
||||
inwidth, inheight, 0,
|
||||
inwidth, inheight, _borderWidth,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
data );
|
||||
@@ -672,7 +674,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
height = 1;
|
||||
|
||||
glTexImage2D( target, k, _internalFormat,
|
||||
width, height, 0,
|
||||
width, height, _borderWidth,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->getMipmapData(k));
|
||||
@@ -694,7 +696,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
|
||||
|
||||
size = ((width+3)/4)*((height+3)/4)*blockSize;
|
||||
extensions->glCompressedTexImage2D(target, k, _internalFormat,
|
||||
width, height, 0,
|
||||
width, height, _borderWidth,
|
||||
size, image->getMipmapData(k));
|
||||
|
||||
width >>= 1;
|
||||
|
||||
@@ -207,7 +207,7 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
{
|
||||
numMipmapLevels = 1;
|
||||
glTexImage1D( target, 0, _internalFormat,
|
||||
image->s(), 0,
|
||||
image->s(), _borderWidth,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->data() );
|
||||
@@ -219,7 +219,7 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
GLint blockSize = ( _internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? 8 : 16 );
|
||||
GLint size = ((image->s()+3)/4)*((image->t()+3)/4)*blockSize;
|
||||
glCompressedTexImage1D_ptr(target, 0, _internalFormat,
|
||||
image->s(), 0,
|
||||
image->s(), _borderWidth,
|
||||
size,
|
||||
image->data());
|
||||
|
||||
@@ -251,7 +251,7 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
{
|
||||
|
||||
glTexImage1D( target, k, _internalFormat,
|
||||
width,0,
|
||||
width,_borderWidth,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->getMipmapData(k));
|
||||
@@ -268,7 +268,7 @@ void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsiz
|
||||
|
||||
size = ((width+3)/4)*blockSize;
|
||||
glCompressedTexImage1D_ptr(target, k, _internalFormat,
|
||||
width, 0, size, image->getMipmapData(k));
|
||||
width, _borderWidth, size, image->getMipmapData(k));
|
||||
|
||||
width >>= 1;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
|
||||
{
|
||||
numMipmapLevels = 1;
|
||||
extensions->glTexImage3D( target, 0, _internalFormat,
|
||||
image->s(), image->t(), image->r(), 0,
|
||||
image->s(), image->t(), image->r(), _borderWidth,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->data() );
|
||||
@@ -260,7 +260,7 @@ void Texture3D::applyTexImage3D(GLenum target, Image* image, State& state, GLsiz
|
||||
depth = 1;
|
||||
|
||||
extensions->glTexImage3D( target, k, _internalFormat,
|
||||
width, height, depth, 0,
|
||||
width, height, depth, _borderWidth,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->getMipmapData(k));
|
||||
|
||||
@@ -83,6 +83,27 @@ bool Texture_readLocalData(Object& obj, Input& fr)
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("borderWidth %f %f %f %f"))
|
||||
{
|
||||
Vec4 color;
|
||||
fr[1].getFloat(color[0]);
|
||||
fr[2].getFloat(color[1]);
|
||||
fr[3].getFloat(color[2]);
|
||||
fr[4].getFloat(color[3]);
|
||||
texture.setBorderColor(color);
|
||||
fr +=5 ;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("borderWidth %i"))
|
||||
{
|
||||
int width=0;
|
||||
fr[1].getInt(width);
|
||||
texture.setBorderWidth(width);
|
||||
fr +=2 ;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("useHardwareMipMapGeneration"))
|
||||
{
|
||||
if (fr[1].matchWord("TRUE"))
|
||||
@@ -151,6 +172,9 @@ bool Texture_writeLocalData(const Object& obj, Output& fw)
|
||||
fw.indent() << "mag_filter " << Texture_getFilterStr(texture.getFilter(Texture::MAG_FILTER)) << std::endl;
|
||||
fw.indent() << "maxAnisotropy " << texture.getMaxAnisotropy() << std::endl;
|
||||
|
||||
fw.indent() << "borderColor " << texture.getBorderColor() << std::endl;
|
||||
fw.indent() << "borderWidth " << texture.getBorderWidth() << std::endl;
|
||||
|
||||
fw.indent() << "useHardwareMipMapGeneration "<< (texture.getUseHardwareMipMapGeneration()?"TRUE":"FALSE") << std::endl;
|
||||
fw.indent() << "unRefImageDataAfterApply "<< (texture.getUnRefImageDataAfterApply()?"TRUE":"FALSE") << std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user