2002-03-19 07:10:33 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// -*-c++-*-
|
|
|
|
|
|
|
|
#ifndef OSG_TEXTURECUBEMAP
|
|
|
|
#define OSG_TEXTURECUBEMAP 1
|
|
|
|
|
|
|
|
#include <osg/Texture>
|
|
|
|
|
2002-03-21 06:39:51 +08:00
|
|
|
#ifndef GL_TEXTURE_CUBE_MAP
|
|
|
|
#define GL_TEXTURE_CUBE_MAP 0x8513
|
|
|
|
#endif
|
2002-03-19 07:10:33 +08:00
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
|
|
|
/** TextureCubeMap state class which encapsulates OpenGl texture cubemap functionality.*/
|
|
|
|
class SG_EXPORT TextureCubeMap : public Texture
|
|
|
|
{
|
|
|
|
|
|
|
|
public :
|
|
|
|
|
|
|
|
TextureCubeMap();
|
|
|
|
|
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
|
|
|
TextureCubeMap(const TextureCubeMap& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
|
|
|
Texture(cm,copyop) {}
|
|
|
|
|
2002-06-06 21:25:36 +08:00
|
|
|
META_StateAttribute(osg, TextureCubeMap,(Type)(TEXTURE_0+_textureUnit));
|
2002-03-19 07:10:33 +08:00
|
|
|
|
|
|
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
|
|
|
virtual int compare(const StateAttribute& rhs) const;
|
|
|
|
|
|
|
|
enum Face {
|
|
|
|
POSITIVE_X=0,
|
|
|
|
NEGATIVE_X=1,
|
|
|
|
POSITIVE_Y=2,
|
|
|
|
NEGATIVE_Y=3,
|
|
|
|
POSITIVE_Z=4,
|
|
|
|
NEGATIVE_Z=5
|
|
|
|
};
|
|
|
|
|
2002-03-21 06:39:51 +08:00
|
|
|
/** Set the texture image for specified face. */
|
|
|
|
void setImage(const Face, Image* image);
|
|
|
|
|
|
|
|
/** Get the texture image for specified face. */
|
|
|
|
Image* getImage(const Face);
|
|
|
|
|
|
|
|
/** Get the const texture image for specified face. */
|
|
|
|
const Image* getImage(const Face) const;
|
2002-03-19 07:10:33 +08:00
|
|
|
|
|
|
|
/** 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;
|
2002-03-21 06:39:51 +08:00
|
|
|
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)
|
2002-03-19 07:10:33 +08:00
|
|
|
|
|
|
|
mutable ref_ptr<Image> _images[6];
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|