Added new osg::TextureBase, osg::Texture1D, osg::Texture2D, and osg::Texture3D
classes, and changed osg::Texture and osg::TextureCubeMap so that they now derive from osg::TextureBase.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#ifndef OSG_TEXTURECUBEMAP
|
||||
#define OSG_TEXTURECUBEMAP 1
|
||||
|
||||
#include <osg/Texture>
|
||||
#include <osg/TextureBase>
|
||||
|
||||
#ifndef GL_TEXTURE_CUBE_MAP
|
||||
#define GL_TEXTURE_CUBE_MAP 0x8513
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace osg {
|
||||
|
||||
/** TextureCubeMap state class which encapsulates OpenGl texture cubemap functionality.*/
|
||||
class SG_EXPORT TextureCubeMap : public Texture
|
||||
class SG_EXPORT TextureCubeMap : public TextureBase
|
||||
{
|
||||
|
||||
public :
|
||||
@@ -24,8 +24,7 @@ class SG_EXPORT TextureCubeMap : public Texture
|
||||
TextureCubeMap();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
TextureCubeMap(const TextureCubeMap& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Texture(cm,copyop) {}
|
||||
TextureCubeMap(const TextureCubeMap& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_StateAttribute(osg, TextureCubeMap,TEXTURE);
|
||||
|
||||
@@ -50,19 +49,65 @@ class SG_EXPORT TextureCubeMap : public Texture
|
||||
/** Get the const texture image for specified face. */
|
||||
const Image* getImage(const Face) const;
|
||||
|
||||
|
||||
/** Set the texture width and height. If width or height are zero then
|
||||
* the repsective size value is calculated from the source image sizes. */
|
||||
inline void setTextureSize(const int width, const int height) const
|
||||
{
|
||||
_textureWidth = width;
|
||||
_textureHeight = height;
|
||||
}
|
||||
|
||||
/** Get the texture subload width. */
|
||||
inline void getTextureSize(int& width, int& height) const
|
||||
{
|
||||
width = _textureWidth;
|
||||
height = _textureHeight;
|
||||
}
|
||||
|
||||
|
||||
class SubloadCallback : public Referenced
|
||||
{
|
||||
public:
|
||||
virtual void load(const TextureCubeMap& texture,State& state) const = 0;
|
||||
virtual void subload(const TextureCubeMap& texture,State& state) const = 0;
|
||||
};
|
||||
|
||||
void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
|
||||
|
||||
SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
|
||||
|
||||
const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
|
||||
|
||||
|
||||
/** Set the number of mip map levels the the texture has been created with,
|
||||
should only be called within an osg::Texuture::apply() and custom OpenGL texture load.*/
|
||||
void setNumMipmapLevels(unsigned int num) const { _numMimpmapLevels=num; }
|
||||
|
||||
/** Get the number of mip map levels the the texture has been created with.*/
|
||||
unsigned int getNumMipmapLevels() const { return _numMimpmapLevels; }
|
||||
|
||||
/** On first apply (unless already compiled), create the minmapped
|
||||
* texture and bind it, subsequent apply will simple bind to texture.*/
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~TextureCubeMap();
|
||||
|
||||
bool imagesValid() const;
|
||||
void setImage(Image*) {} // prevent call to Texture::setImage(Image* image)
|
||||
Image* getImage() { return _image.get(); } // prevent call to Texture::setImage(Image* image)
|
||||
const Image* getImage() const { return _image.get(); } // prevent call to Texture::setImage(Image* image)
|
||||
|
||||
virtual void computeInternalFormat() const;
|
||||
|
||||
mutable ref_ptr<Image> _images[6];
|
||||
|
||||
// subloaded images can have different texture and image sizes.
|
||||
mutable GLsizei _textureWidth, _textureHeight;
|
||||
|
||||
// number of mip map levels the the texture has been created with,
|
||||
mutable GLsizei _numMimpmapLevels;
|
||||
|
||||
ref_ptr<SubloadCallback> _subloadCallback;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user