Updates the osg::Texture3D::Extensions interface to support the standardisation
of extensions supported across multiple graphics contexts.
This commit is contained in:
@@ -100,6 +100,12 @@ class SG_EXPORT Texture3D : public Texture
|
||||
public:
|
||||
Extensions();
|
||||
|
||||
Extensions(const Extensions& rhs);
|
||||
|
||||
void lowestCommonDenominator(const Extensions& rhs);
|
||||
|
||||
void setupGLExtenions();
|
||||
|
||||
bool isTexture3DSupported() const { return _isTexture3DSupported; }
|
||||
bool isTexture3DFast() const { return _isTexture3DFast; }
|
||||
GLint maxTexture3DSize() const { return _maxTexture3DSize; }
|
||||
@@ -113,11 +119,6 @@ class SG_EXPORT Texture3D : public Texture
|
||||
|
||||
~Extensions() {}
|
||||
|
||||
typedef void (APIENTRY * GLTexImage3DProc) ( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
typedef void (APIENTRY * GLTexSubImage3DProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
typedef void (APIENTRY * GLCopyTexSubImageProc) ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
typedef void (APIENTRY * GLUBuild3DMipMapsProc) ( GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *data);
|
||||
|
||||
bool _isTexture3DSupported;
|
||||
bool _isTexture3DFast;
|
||||
GLint _maxTexture3DSize;
|
||||
@@ -137,6 +138,11 @@ class SG_EXPORT Texture3D : public Texture
|
||||
* only be created with the graphics context associated with ContextID..*/
|
||||
static const Extensions* getExtensions(uint contextID,bool createIfNotInitalized);
|
||||
|
||||
/** setExtensions allows users to override the extensions across graphics contexts.
|
||||
* typically used when you have different extensions supported across graphics pipes
|
||||
* but need to ensure that they all use the same low common denominator extensions.*/
|
||||
static void setExtensions(uint contextID,Extensions* extensions);
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~Texture3D();
|
||||
|
||||
@@ -276,21 +276,55 @@ 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(uint contextID,bool createIfNotInitalized)
|
||||
{
|
||||
typedef buffered_value< ref_ptr<Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions;
|
||||
|
||||
return s_extensions[contextID].get();
|
||||
}
|
||||
|
||||
void Texture3D::setExtensions(uint contextID,Extensions* extensions)
|
||||
{
|
||||
s_extensions[contextID] = extensions;
|
||||
}
|
||||
|
||||
#ifndef GL_MAX_3D_TEXTURE_SIZE
|
||||
#define GL_MAX_3D_TEXTURE_SIZE 0x8073
|
||||
#endif
|
||||
|
||||
Texture3D::Extensions::Extensions()
|
||||
{
|
||||
setupGLExtenions();
|
||||
}
|
||||
|
||||
Texture3D::Extensions::Extensions(const Extensions& rhs):
|
||||
Referenced()
|
||||
{
|
||||
_isTexture3DSupported = rhs._isTexture3DSupported;
|
||||
_isTexture3DFast = rhs._isTexture3DFast;
|
||||
_maxTexture3DSize = rhs._maxTexture3DSize;
|
||||
|
||||
_glTexImage3D = rhs._glTexImage3D;
|
||||
_glTexSubImage3D = rhs._glTexSubImage3D;
|
||||
_glCopyTexSubImage3D = rhs._glCopyTexSubImage3D;
|
||||
_gluBuild3DMipmaps = rhs._gluBuild3DMipmaps;
|
||||
}
|
||||
|
||||
void Texture3D::Extensions::lowestCommonDenominator(const Extensions& rhs)
|
||||
{
|
||||
if (!rhs._isTexture3DSupported) _isTexture3DSupported = false;
|
||||
if (!rhs._isTexture3DFast) _isTexture3DFast = false;
|
||||
if (rhs._maxTexture3DSize<_maxTexture3DSize) _maxTexture3DSize = rhs._maxTexture3DSize;
|
||||
|
||||
if (!rhs._glTexImage3D) _glTexImage3D = 0;
|
||||
if (!rhs._glTexSubImage3D) _glTexSubImage3D = 0;
|
||||
if (!rhs._glCopyTexSubImage3D) _glCopyTexSubImage3D = 0;
|
||||
if (!rhs._gluBuild3DMipmaps) _gluBuild3DMipmaps = 0;
|
||||
}
|
||||
|
||||
void Texture3D::Extensions::setupGLExtenions()
|
||||
{
|
||||
_isTexture3DFast = isGLExtensionSupported("GL_EXT_texture3D");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user