Added osg::TextureCubeMap. submission from Brede Johansen.
This commit is contained in:
@@ -11,6 +11,14 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
#ifndef GL_NORMAL_MAP_ARB
|
||||
#define GL_NORMAL_MAP_ARB 0x8511
|
||||
#endif
|
||||
|
||||
#ifndef GL_REFLECTION_MAP_ARB
|
||||
#define GL_REFLECTION_MAP_ARB 0x8512
|
||||
#endif
|
||||
|
||||
/** TexGen - encapsulates the OpenGL glTexGen (texture coordinate generation) state.*/
|
||||
class SG_EXPORT TexGen : public StateAttribute
|
||||
{
|
||||
@@ -69,9 +77,11 @@ class SG_EXPORT TexGen : public StateAttribute
|
||||
virtual void apply(State& state) const;
|
||||
|
||||
enum Mode {
|
||||
OBJECT_LINEAR = GL_OBJECT_LINEAR,
|
||||
EYE_LINEAR = GL_EYE_LINEAR,
|
||||
SPHERE_MAP = GL_SPHERE_MAP
|
||||
OBJECT_LINEAR = GL_OBJECT_LINEAR,
|
||||
EYE_LINEAR = GL_EYE_LINEAR,
|
||||
SPHERE_MAP = GL_SPHERE_MAP,
|
||||
NORMAL_MAP = GL_NORMAL_MAP_ARB,
|
||||
REFLECTION_MAP = GL_REFLECTION_MAP_ARB
|
||||
};
|
||||
|
||||
inline void setMode( const Mode mode ) { _mode = mode; }
|
||||
|
||||
@@ -81,6 +81,7 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
_modifiedTag(),
|
||||
_textureObjectSize(text._textureObjectSize),
|
||||
_image(copyop(text._image.get())),
|
||||
_target(text._target),
|
||||
_textureUnit(text._textureUnit),
|
||||
_wrap_s(text._wrap_s),
|
||||
_wrap_t(text._wrap_t),
|
||||
@@ -327,6 +328,8 @@ class SG_EXPORT Texture : public StateAttribute
|
||||
// which is const...
|
||||
mutable ref_ptr<Image> _image;
|
||||
|
||||
GLenum _target; // defaults to GL_TEXTURE_2D
|
||||
|
||||
unsigned int _textureUnit;
|
||||
|
||||
WrapMode _wrap_s;
|
||||
|
||||
64
include/osg/TextureCubeMap
Normal file
64
include/osg/TextureCubeMap
Normal file
@@ -0,0 +1,64 @@
|
||||
//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>
|
||||
|
||||
|
||||
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) {}
|
||||
|
||||
META_StateAttribute(TextureCubeMap,(Type)(TEXTURE_0+_textureUnit));
|
||||
|
||||
/** 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
|
||||
};
|
||||
|
||||
/** Set the texture image. */
|
||||
void setImage( const Face, Image* image);
|
||||
|
||||
/** 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;
|
||||
|
||||
/** Method which does the creation of the texture itself, and
|
||||
* does not set or use texture binding. */
|
||||
virtual void applyImmediateMode(State& state) const;
|
||||
virtual void applyFaceImmediateMode(GLenum facetarget, Image* image, State& state) const;
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~TextureCubeMap();
|
||||
bool imagesValid() const;
|
||||
void setImage(Image* image) {} // prevent call to Texture::setImage(Image* image)
|
||||
|
||||
mutable ref_ptr<Image> _images[6];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user