OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TextureCubeMap.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_TEXTURECUBEMAP
15 #define OSG_TEXTURECUBEMAP 1
16 
17 #include <osg/Texture>
18 
19 
20 namespace osg {
21 
24 {
25 
26  public :
27 
29 
32 
34 
36  virtual int compare(const StateAttribute& rhs) const;
37 
38  virtual GLenum getTextureTarget() const { return GL_TEXTURE_CUBE_MAP; }
39 
40  enum Face {
41  POSITIVE_X=0,
42  NEGATIVE_X=1,
43  POSITIVE_Y=2,
44  NEGATIVE_Y=3,
45  POSITIVE_Z=4,
46  NEGATIVE_Z=5
47  };
48 
50  virtual void setImage(unsigned int face, Image* image);
51 
53  virtual Image* getImage(unsigned int face);
54 
56  virtual const Image* getImage(unsigned int face) const;
57 
59  virtual unsigned int getNumImages() const { return 6; }
60 
61  inline unsigned int& getModifiedCount(unsigned int face,unsigned int contextID) const
62  {
63  // get the modified count for the current contextID.
64  return _modifiedCount[face][contextID];
65  }
66 
70  inline void setTextureSize(int width, int height) const
71  {
72  _textureWidth = width;
73  _textureHeight = height;
74  }
75 
76  void setTextureWidth(int width) { _textureWidth=width; }
77  void setTextureHeight(int height) { _textureHeight=height; }
78 
79  virtual int getTextureWidth() const { return _textureWidth; }
80  virtual int getTextureHeight() const { return _textureHeight; }
81  virtual int getTextureDepth() const { return 1; }
82 
84  {
85  public:
86  virtual void load(const TextureCubeMap& texture,State& state) const = 0;
87  virtual void subload(const TextureCubeMap& texture,State& state) const = 0;
88  };
89 
90  void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
91 
92  SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
93 
94  const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
95 
96 
100  void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
101 
103  unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
104 
112  void copyTexSubImageCubeMap(State& state, int face, int xoffset, int yoffset, int x, int y, int width, int height );
113 
114 
118  virtual void apply(State& state) const;
119 
120  protected :
121 
122  virtual ~TextureCubeMap();
123 
124  bool imagesValid() const;
125 
126  virtual void computeInternalFormat() const;
127  void allocateMipmap(State& state) const;
128 
129  ref_ptr<Image> _images[6];
130 
131  // subloaded images can have different texture and image sizes.
132  mutable GLsizei _textureWidth, _textureHeight;
133 
134  // number of mip map levels the texture has been created with,
135  mutable GLsizei _numMipmapLevels;
136 
138 
140  mutable ImageModifiedCount _modifiedCount[6];
141 };
142 
143 }
144 
145 #endif
#define OSG_EXPORT
Definition: Export.h:43
buffered_value< unsigned int > ImageModifiedCount
ref_ptr< SubloadCallback > _subloadCallback
virtual unsigned int getNumImages() const
void setTextureWidth(int width)
const SubloadCallback * getSubloadCallback() const
void setTextureSize(int width, int height) const
unsigned int & getModifiedCount(unsigned int face, unsigned int contextID) const
#define GL_TEXTURE_CUBE_MAP
Definition: Texture.h:193
virtual int getTextureDepth() const
GLint GLenum GLsizei width
Definition: GLU.h:71
void setNumMipmapLevels(unsigned int num) const
virtual int getTextureWidth() const
void setSubloadCallback(SubloadCallback *cb)
void setTextureHeight(int height)
#define META_StateAttribute(library, name, type)
GLint GLenum GLsizei GLsizei height
Definition: GLU.h:71
SubloadCallback * getSubloadCallback()
unsigned int getNumMipmapLevels() const
virtual int getTextureHeight() const
Definition: AlphaFunc.h:19
virtual GLenum getTextureTarget() const