Added support for modifying the osg::Texture*:Extensions stuctures.
Added an example modifying osg::Texture::Extensions to osgtext. Optionally compiled out by default.
This commit is contained in:
@@ -516,9 +516,27 @@ int main( int argc, char **argv )
|
||||
// set the scene to render
|
||||
viewer.setSceneData(rootNode.get());
|
||||
|
||||
|
||||
// create the windows and run the threads.
|
||||
viewer.realize();
|
||||
|
||||
#if 0
|
||||
// this optional compile block is done as a test against graphics
|
||||
// drivers that claim support for generate mip map, but the actual
|
||||
// implementation is flacky. It is not compiled by default.
|
||||
|
||||
// go through each graphics context and switch off the generate mip map extension.
|
||||
// note, this must be done after the realize so that init of texture state and as
|
||||
// result extension structures have been iniatilized.
|
||||
for(unsigned int contextID = 0;
|
||||
contextID<viewer.getDisplaySettings()->getMaxNumberOfGraphicsContexts();
|
||||
++contextID)
|
||||
{
|
||||
osg::Texture::Extensions* textureExt = osg::Texture::getExtensions(contextID,false);
|
||||
if (textureExt) textureExt->setGenerateMipMapSupported(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
while( !viewer.done() )
|
||||
{
|
||||
// wait for all cull and draw threads to complete.
|
||||
|
||||
@@ -251,20 +251,39 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
||||
|
||||
void setupGLExtenions();
|
||||
|
||||
void setTextureFilterAnisotropicSupported(bool flag) { _isTextureFilterAnisotropicSupported=flag; }
|
||||
bool isTextureFilterAnisotropicSupported() const { return _isTextureFilterAnisotropicSupported; }
|
||||
|
||||
void setTextureCompressionARBSupported(bool flag) { _isTextureCompressionARBSupported=flag; }
|
||||
bool isTextureCompressionARBSupported() const { return _isTextureCompressionARBSupported; }
|
||||
|
||||
void setTextureCompressionS3TCSupported(bool flag) { _isTextureCompressionS3TCSupported=flag; }
|
||||
bool isTextureCompressionS3TCSupported() const { return _isTextureCompressionS3TCSupported; }
|
||||
|
||||
void setTextureMirroredRepeatSupported(bool flag) { _isTextureMirroredRepeatSupported=flag; }
|
||||
bool isTextureMirroredRepeatSupported() const { return _isTextureMirroredRepeatSupported; }
|
||||
|
||||
void setTextureEdgeClampSupported(bool flag) { _isTextureEdgeClampSupported=flag; }
|
||||
bool isTextureEdgeClampSupported() const { return _isTextureEdgeClampSupported; }
|
||||
|
||||
void setTextureBorderClampSupported(bool flag) { _isTextureBorderClampSupported=flag; }
|
||||
bool isTextureBorderClampSupported() const { return _isTextureBorderClampSupported; }
|
||||
|
||||
void setGenerateMipMapSupported(bool flag) { _isGenerateMipMapSupported=flag; }
|
||||
bool isGenerateMipMapSupported() const { return _isGenerateMipMapSupported; }
|
||||
|
||||
void setMaxTextureSize(GLint maxsize) { _maxTextureSize=maxsize; }
|
||||
GLint maxTextureSize() const { return _maxTextureSize; }
|
||||
|
||||
bool isCompressedTexImage2DSupported() const { return _glCompressedTexImage2D!=0; }
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
void setGetCompressedTexImageProc(void* ptr) { _glGetCompressedTexImage = ptr; }
|
||||
void glGetCompressedTexImage(GLenum target, GLint level, GLvoid *data) const;
|
||||
|
||||
protected:
|
||||
@@ -293,7 +312,7 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
||||
* If 'createIfNotInitalized' is true then the Extensions object is
|
||||
* automatically created. However, in this case the extension object
|
||||
* only be created with the graphics context associated with ContextID..*/
|
||||
static const Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
|
||||
/** setExtensions allows users to override the extensions across graphics contexts.
|
||||
* typically used when you have different extensions supported across graphics pipes
|
||||
|
||||
@@ -120,14 +120,25 @@ class SG_EXPORT Texture3D : public Texture
|
||||
|
||||
void setupGLExtenions();
|
||||
|
||||
void setTexture3DSupported(bool flag) { _isTexture3DSupported=flag; }
|
||||
bool isTexture3DSupported() const { return _isTexture3DSupported; }
|
||||
|
||||
void setTexture3DFast(bool flag) { _isTexture3DFast=flag; }
|
||||
bool isTexture3DFast() const { return _isTexture3DFast; }
|
||||
|
||||
void setMaxTexture3DSize(GLint maxsize) { _maxTexture3DSize=maxsize; }
|
||||
GLint maxTexture3DSize() const { return _maxTexture3DSize; }
|
||||
|
||||
void setTexImage3DProc(void* ptr) { _glTexImage3D = ptr; }
|
||||
void glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const;
|
||||
|
||||
void setTexSubImage3DProc(void* ptr) { _glTexSubImage3D = ptr; }
|
||||
void glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) const;
|
||||
|
||||
void setCopyTexSubImage3DProc(void* ptr) { _glCopyTexSubImage3D = ptr; }
|
||||
void glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const;
|
||||
|
||||
void setBuild3DMipmapsProc(void* ptr) { _gluBuild3DMipmaps = ptr; }
|
||||
void gluBuild3DMipmaps( GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data) const;
|
||||
|
||||
protected:
|
||||
@@ -151,7 +162,7 @@ class SG_EXPORT Texture3D : public Texture
|
||||
* If 'createIfNotInitalized' is true then the Extensions object is
|
||||
* automatically created. However, in this case the extension object
|
||||
* only be created with the graphics context associated with ContextID..*/
|
||||
static const Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
|
||||
/** setExtensions allows users to override the extensions across graphics contexts.
|
||||
* typically used when you have different extensions supported across graphics pipes
|
||||
|
||||
@@ -123,6 +123,7 @@ class SG_EXPORT TextureCubeMap : public Texture
|
||||
|
||||
void setupGLExtenions();
|
||||
|
||||
void setCubeMapSupported(bool flag) { _isCubeMapSupported=flag; }
|
||||
bool isCubeMapSupported() const { return _isCubeMapSupported; }
|
||||
|
||||
protected:
|
||||
@@ -139,7 +140,7 @@ class SG_EXPORT TextureCubeMap : public Texture
|
||||
* If 'createIfNotInitalized' is true then the Extensions object is
|
||||
* automatically created. However, in this case the extension object
|
||||
* only be created with the graphics context associated with ContextID..*/
|
||||
static const Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
static Extensions* getExtensions(unsigned int contextID,bool createIfNotInitalized);
|
||||
|
||||
/** setExtensions allows users to override the extensions across graphics contexts.
|
||||
* typically used when you have different extensions supported across graphics pipes
|
||||
|
||||
@@ -831,7 +831,7 @@ void Texture::compile(State& state) const
|
||||
typedef buffered_value< ref_ptr<Texture::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
const Texture::Extensions* Texture::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
Texture::Extensions* Texture::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions;
|
||||
return s_extensions[contextID].get();
|
||||
|
||||
@@ -313,7 +313,7 @@ void Texture3D::copyTexSubImage3D(State& state, int xoffset, int yoffset, int zo
|
||||
typedef buffered_value< ref_ptr<Texture3D::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
const Texture3D::Extensions* Texture3D::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
Texture3D::Extensions* Texture3D::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions;
|
||||
return s_extensions[contextID].get();
|
||||
|
||||
@@ -301,7 +301,7 @@ void TextureCubeMap::apply(State& state) const
|
||||
typedef buffered_value< ref_ptr<TextureCubeMap::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
const TextureCubeMap::Extensions* TextureCubeMap::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
TextureCubeMap::Extensions* TextureCubeMap::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions;
|
||||
return s_extensions[contextID].get();
|
||||
|
||||
Reference in New Issue
Block a user