OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Texture2DArray.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_TEXTURE2DARRAY
15 #define OSG_TEXTURE2DARRAY 1
16 
17 #include <osg/Texture>
18 #include <list>
19 
20 namespace osg {
21 
29 {
30 
31  public :
32 
34 
37 
39 
41  virtual int compare(const StateAttribute& rhs) const;
42 
43  virtual GLenum getTextureTarget() const { return GL_TEXTURE_2D_ARRAY_EXT; }
44 
46  virtual bool getModeUsage(StateAttribute::ModeUsage&) const { return false; }
47 
49  virtual void setImage(unsigned int layer, Image* image);
50 
52  virtual Image* getImage(unsigned int layer);
53 
55  virtual const Image* getImage(unsigned int layer) const;
56 
62  virtual unsigned int getNumImages() const { return _images.size(); }
63 
65  inline unsigned int& getModifiedCount(unsigned int layer, unsigned int contextID) const
66  {
67  // get the modified count for the current contextID.
68  return _modifiedCount[layer][contextID];
69  }
70 
75  void setTextureSize(int width, int height, int depth);
76 
77  void setTextureWidth(int width) { _textureWidth=width; }
78  void setTextureHeight(int height) { _textureHeight=height; }
79  void setTextureDepth(int depth);
80 
81  virtual int getTextureWidth() const { return _textureWidth; }
82  virtual int getTextureHeight() const { return _textureHeight; }
83  virtual int getTextureDepth() const { return _textureDepth; }
84 
86  {
87  public:
88  virtual void load(const Texture2DArray& texture,State& state) const = 0;
89  virtual void subload(const Texture2DArray& texture,State& state) const = 0;
90  };
91 
92 
93  void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
94 
95  SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
96 
97  const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
98 
99 
100 
104  void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
105 
107  unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
108 
117  void copyTexSubImage2DArray(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height );
118 
121  virtual void apply(State& state) const;
122 
123  protected :
124 
125  virtual ~Texture2DArray();
126 
127  bool imagesValid() const;
128 
129  virtual void computeInternalFormat() const;
130  GLsizei computeTextureDepth() const;
131  void allocateMipmap(State& state) const;
132 
133  void applyTexImage2DArray_subload(State& state, Image* image, GLsizei layer, GLsizei inwidth, GLsizei inheight, GLsizei indepth, GLint inInternalFormat, GLsizei& numMipmapLevels) const;
134 
135  typedef std::vector< ref_ptr<Image> > Images;
136  Images _images;
137 
138  // subloaded images can have different texture and image sizes.
139  mutable GLsizei _textureWidth, _textureHeight, _textureDepth;
140 
141  // number of mip map levels the texture has been created with,
142  mutable GLsizei _numMipmapLevels;
143 
145 
147  mutable std::vector<ImageModifiedCount> _modifiedCount;
148 };
149 
150 }
151 
152 #endif
#define OSG_EXPORT
Definition: Export.h:43
SubloadCallback * getSubloadCallback()
void setTextureHeight(int height)
virtual GLenum getTextureTarget() const
virtual bool getModeUsage(StateAttribute::ModeUsage &) const
virtual unsigned int getNumImages() const
GLint GLenum GLsizei GLsizei GLsizei depth
Definition: GLU.h:71
#define GL_TEXTURE_2D_ARRAY_EXT
Definition: GLDefines.h:577
buffered_value< unsigned int > ImageModifiedCount
virtual int getTextureWidth() const
virtual int getTextureDepth() const
GLint GLenum GLsizei width
Definition: GLU.h:71
std::vector< ref_ptr< Image > > Images
void setSubloadCallback(SubloadCallback *cb)
unsigned int getNumMipmapLevels() const
#define META_StateAttribute(library, name, type)
GLint GLenum GLsizei GLsizei height
Definition: GLU.h:71
virtual int getTextureHeight() const
const SubloadCallback * getSubloadCallback() const
std::vector< ImageModifiedCount > _modifiedCount
Definition: AlphaFunc.h:19
unsigned int & getModifiedCount(unsigned int layer, unsigned int contextID) const
void setNumMipmapLevels(unsigned int num) const
void setTextureWidth(int width)
ref_ptr< SubloadCallback > _subloadCallback