Further work on multiple context extensions.

This commit is contained in:
Robert Osfield
2002-09-16 20:58:05 +00:00
parent f006d081e5
commit 91df37b5c8
9 changed files with 272 additions and 89 deletions

View File

@@ -153,7 +153,7 @@ class SG_EXPORT Image : public Object
* Mip Mapped texture require the image dimensions to be
* power of two and are within the maxiumum texture size for
* the host machine.*/
void ensureValidSizeForTexturing();
void ensureValidSizeForTexturing(GLint maxTextureSize);
/** Dirty the image, which increments the modified flag, to force osg::Texture to reload the image.*/
inline void dirty() { ++_modifiedTag; }

View File

@@ -247,17 +247,69 @@ class SG_EXPORT Texture : public osg::StateAttribute
* in the OpenGL context related to contextID.*/
static void flushDeletedTextureObjects(uint contextID);
/** Get the maximum texture size supported, this is the
normally define by GL_MAX_TEXTURE_SIZE, but can be overridden
by the OSG_MAX_TEXTURE_SIZE environmental variable.*/
static GLint getMaxTextureSize();
/** Texture is pure virtual base class, apply must be overriden. */
virtual void apply(State& state) const = 0;
/** Calls apply(state) to compile the texture. */
virtual void compile(State& state) const;
/** Extensions class which encapsulates the querring of extensions and
* associated function pointers, and provide convinience wrappers to
* check for the extensions or use the associated functions.*/
class Extensions : public osg::Referenced
{
public:
Extensions();
Extensions(const Extensions& rhs);
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtenions();
bool isTextureFilterAnisotropicSupported() const { return _isTextureFilterAnisotropicSupported; }
bool isTextureCompressionARBSupported() const { return _isTextureCompressionARBSupported; }
bool isTextureCompressionS3TCSupported() const { return _isTextureCompressionS3TCSupported; }
bool isTextureMirroredRepeatSupported() const { return _isTextureMirroredRepeatSupported; }
bool isTextureEdgeClampSupported() const { return _isTextureEdgeClampSupported; }
bool isTextureBorderClampSupported() const { return _isTextureBorderClampSupported; }
GLint maxTextureSize() const { return _maxTextureSize; }
bool isCompressedTexImage2DSupported() const { return _glCompressedTexImage2D!=0; }
void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) const;
protected:
~Extensions() {}
bool _isTextureFilterAnisotropicSupported;
bool _isTextureCompressionARBSupported;
bool _isTextureCompressionS3TCSupported;
bool _isTextureMirroredRepeatSupported;
bool _isTextureEdgeClampSupported;
bool _isTextureBorderClampSupported;
GLint _maxTextureSize;
void* _glCompressedTexImage2D;
};
/** Function to call to get the extension of a specified context.
* If the Exentsion object for that context has not yet been created then
* and the 'createIfNotInitalized' flag been set to false then returns NULL.
* 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(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 ~Texture();

View File

@@ -108,6 +108,7 @@ class SG_EXPORT Texture3D : public Texture
bool isTexture3DSupported() const { return _isTexture3DSupported; }
bool isTexture3DFast() const { return _isTexture3DFast; }
GLint maxTexture3DSize() const { return _maxTexture3DSize; }
void glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const;

View File

@@ -89,6 +89,45 @@ class SG_EXPORT TextureCubeMap : public Texture
* texture and bind it, subsequent apply will simple bind to texture.*/
virtual void apply(State& state) const;
/** Extensions class which encapsulates the querring of extensions and
* associated function pointers, and provide convinience wrappers to
* check for the extensions or use the associated functions.*/
class Extensions : public osg::Referenced
{
public:
Extensions();
Extensions(const Extensions& rhs);
void lowestCommonDenominator(const Extensions& rhs);
void setupGLExtenions();
bool isCubeMapSupported() const { return _isCubeMapSupported; }
protected:
~Extensions() {}
bool _isCubeMapSupported;
};
/** Function to call to get the extension of a specified context.
* If the Exentsion object for that context has not yet been created then
* and the 'createIfNotInitalized' flag been set to false then returns NULL.
* 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(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 ~TextureCubeMap();