From Sherman Wilcox, added extension checking support for compressed texture subloading.
This commit is contained in:
@@ -514,6 +514,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
void setCompressedTexImage2DProc(void* ptr) { _glCompressedTexImage2D = ptr; }
|
||||
void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const;
|
||||
|
||||
bool isCompressedTexSubImage2DSupported() const { return _glCompressedTexSubImage2D!=0; }
|
||||
|
||||
void setCompressedTexSubImage2DProc(void* ptr) { _glCompressedTexSubImage2D = ptr; }
|
||||
void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei type, const GLvoid *data) const;
|
||||
|
||||
|
||||
@@ -297,17 +297,17 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
|
||||
if(isCompressedInternalFormat(_internalFormat) && extensions->isCompressedTexImage2DSupported())
|
||||
{
|
||||
extensions->glCompressedTexImage2D(target, 0, _internalFormat,
|
||||
image->s(), image->t(), 0,
|
||||
image->getImageSizeInBytes(),
|
||||
image->data() - dataMinusOffset + dataPlusOffset);
|
||||
image->s(), image->t(), 0,
|
||||
image->getImageSizeInBytes(),
|
||||
image->data() - dataMinusOffset + dataPlusOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexImage2D(target, 0, _internalFormat,
|
||||
image->s(), image->t(), 0,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->data() - dataMinusOffset + dataPlusOffset );
|
||||
image->s(), image->t(), 0,
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->data() - dataMinusOffset + dataPlusOffset );
|
||||
}
|
||||
|
||||
|
||||
@@ -341,6 +341,8 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State&
|
||||
// get the contextID (user defined ID of 0 upwards) for the
|
||||
// current OpenGL context.
|
||||
const unsigned int contextID = state.getContextID();
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
|
||||
// update the modified count to show that it is upto date.
|
||||
getModifiedCount(contextID) = image->getModifiedCount();
|
||||
@@ -374,14 +376,25 @@ void TextureRectangle::applyTexImage_subload(GLenum target, Image* image, State&
|
||||
pbo = 0;
|
||||
}
|
||||
|
||||
|
||||
// UH: ignoring compressed for now.
|
||||
glTexSubImage2D(target, 0,
|
||||
0,0,
|
||||
image->s(), image->t(),
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->data() - dataMinusOffset + dataPlusOffset );
|
||||
|
||||
if(isCompressedInternalFormat(_internalFormat) && extensions->isCompressedTexSubImage2DSupported())
|
||||
{
|
||||
extensions->glCompressedTexSubImage2D(target, 0,
|
||||
0,0,
|
||||
image->s(), image->t(),
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->data() - dataMinusOffset + dataPlusOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(target, 0,
|
||||
0,0,
|
||||
image->s(), image->t(),
|
||||
(GLenum)image->getPixelFormat(),
|
||||
(GLenum)image->getDataType(),
|
||||
image->data() - dataMinusOffset + dataPlusOffset );
|
||||
}
|
||||
|
||||
if (pbo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user