From Art Trevs, "Features of the patch are:

- Implementation of integer textures as in EXT_texture_integer

- setBorderColor(Vec4) changed to setBorderColor(Vec4d) to pass double values
as border color. (Probably we have to provide an overloading function to
still support Vec4f ?)

- new method Texture::getInternalFormatType() added. Gives information if the
internal format normalized, float, signed integer or unsigned integer. Can
help people to write better code ;-)

"

Futher changes to this submission by Robert Osfield, changed the dirty mipmap
flag into a buffer_value<> vector to ensure safe handling of multiple contexts.
This commit is contained in:
Robert Osfield
2007-09-11 12:04:58 +00:00
parent 98763cc4c5
commit 5e83ae4821
22 changed files with 807 additions and 48 deletions

View File

@@ -179,7 +179,7 @@ void Texture1D::apply(State& state) const
applyTexParameters(GL_TEXTURE_1D,state);
// no image present, but dimensions at set so lets create the texture
// no image present, but dimensions are set so lets create the texture
glTexImage1D( GL_TEXTURE_1D, 0, _internalFormat,
_textureWidth, _borderWidth,
_sourceFormat ? _sourceFormat : _internalFormat,
@@ -190,17 +190,24 @@ void Texture1D::apply(State& state) const
{
_readPBuffer->bindPBufferToTexture(GL_FRONT);
}
}
else
{
glBindTexture( GL_TEXTURE_1D, 0 );
}
// if texture object is now valid and we have to allocate mipmap levels, then
if (textureObject != 0 && _texMipmapGenerationDirtyList[contextID])
{
generateMipmap(state);
}
}
void Texture1D::computeInternalFormat() const
{
if (_image.valid()) computeInternalFormatWithImage(*_image);
else computeInternalFormatType();
}
void Texture1D::applyTexImage1D(GLenum target, Image* image, State& state, GLsizei& inwidth, GLsizei& numMipmapLevels) const
@@ -392,3 +399,40 @@ void Texture1D::copyTexSubImage1D(State& state, int xoffset, int x, int y, int w
copyTexImage1D(state,x,y,width);
}
}
void Texture1D::allocateMipmap(State& state) const
{
const unsigned int contextID = state.getContextID();
// get the texture object for the current contextID.
TextureObject* textureObject = getTextureObject(contextID);
if (textureObject && _textureWidth != 0)
{
// bind texture
textureObject->bind();
// compute number of mipmap levels
int width = _textureWidth;
int numMipmapLevels = 1 + (int)floor(log2(width));
// we do not reallocate the level 0, since it was already allocated
width >>= 1;
for( GLsizei k = 1; k < numMipmapLevels && width; k++)
{
if (width == 0)
width = 1;
glTexImage1D( GL_TEXTURE_1D, k, _internalFormat,
width, _borderWidth,
_sourceFormat ? _sourceFormat : _internalFormat,
_sourceType ? _sourceType : GL_UNSIGNED_BYTE, NULL);
width >>= 1;
}
// inform state that this texture is the current one bound.
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
}
}