Changeset 13041 for OpenSceneGraph/trunk/include/osg/Texture2DArray
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osg/Texture2DArray (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/Texture2DArray
r12139 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 20 20 namespace osg { 21 21 22 /** Texture2DArray state class which encapsulates OpenGL 2D array texture functionality. 22 /** Texture2DArray state class which encapsulates OpenGL 2D array texture functionality. 23 23 * Texture arrays were introduced with Shader Model 4.0 hardware. 24 * 24 * 25 25 * A 2D texture array does contain textures sharing the same properties (e.g. size, bitdepth,...) 26 26 * in a layered structure. See http://www.opengl.org/registry/specs/EXT/texture_array.txt for more info. … … 30 30 31 31 public : 32 32 33 33 Texture2DArray(); 34 34 … … 37 37 38 38 META_StateAttribute(osg, Texture2DArray, TEXTURE); 39 39 40 40 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */ 41 41 virtual int compare(const StateAttribute& rhs) const; … … 52 52 virtual const Image* getImage(unsigned int layer) const; 53 53 54 /** Get the number of images that are assigned to the Texture. 54 /** Get the number of images that are assigned to the Texture. 55 55 * The number is equal to the texture depth. To get the maximum possible 56 56 * image/layer count, you have to use the extension subclass, since it provides 57 57 * graphic context dependent information. 58 58 */ 59 virtual unsigned int getNumImages() const { return getTextureDepth(); } 59 virtual unsigned int getNumImages() const { return getTextureDepth(); } 60 60 61 61 /** Check how often was a certain layer in the given context modified */ … … 86 86 virtual void subload(const Texture2DArray& texture,State& state) const = 0; 87 87 }; 88 89 88 89 90 90 void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; } 91 91 92 92 SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); } 93 93 94 94 const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); } 95 96 95 96 97 97 98 98 /** Set the number of mip map levels the the texture has been created with. … … 102 102 103 103 /** Get the number of mip map levels the the texture has been created with. */ 104 unsigned int getNumMipmapLevels() const { return _numMipmapLevels; } 104 unsigned int getNumMipmapLevels() const { return _numMipmapLevels; } 105 105 106 106 /** Copies a two-dimensional texture subimage, as per … … 109 109 * contents at position \a x, \a y with width \a width and height 110 110 * \a height. Loads framebuffer data into the texture using offsets 111 * \a xoffset and \a yoffset. \a zoffset specifies the layer of the texture 112 * array to which the result is copied. 111 * \a xoffset and \a yoffset. \a zoffset specifies the layer of the texture 112 * array to which the result is copied. 113 113 */ 114 114 void copyTexSubImage2DArray(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height ); … … 117 117 */ 118 118 virtual void apply(State& state) const; 119 119 120 120 121 121 /** Extensions class which encapsulates the querying of extensions and 122 * associated function pointers, and provides convenience wrappers to 122 * associated function pointers, and provides convenience wrappers to 123 123 * check for the extensions or use the associated functions. 124 124 */ … … 129 129 130 130 Extensions(const Extensions& rhs); 131 131 132 132 void lowestCommonDenominator(const Extensions& rhs); 133 133 134 134 void setupGLExtensions(unsigned int contextID); 135 135 136 136 void setTexture2DArraySupported(bool flag) { _isTexture2DArraySupported=flag; } 137 137 bool isTexture2DArraySupported() const { return _isTexture2DArraySupported; } 138 138 139 139 void setTexture3DSupported(bool flag) { _isTexture3DSupported=flag; } 140 140 bool isTexture3DSupported() const { return _isTexture3DSupported; } … … 142 142 void setMaxLayerCount(GLint count) { _maxLayerCount = count; } 143 143 GLint maxLayerCount() const { return _maxLayerCount; } 144 144 145 145 void setMax2DSize(GLint size) { _max2DSize = size; } 146 146 GLint max2DSize() const { return _max2DSize; } 147 147 148 148 void glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const; 149 149 150 150 void glTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) const; 151 151 152 152 void glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const; 153 153 154 154 bool isCompressedTexImage3DSupported() const { return _glCompressedTexImage3D!=0; } 155 155 void glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) const; … … 161 161 162 162 ~Extensions() {} 163 163 164 164 bool _isTexture2DArraySupported; 165 165 bool _isTexture3DSupported; 166 166 167 167 GLint _maxLayerCount; 168 168 GLint _max2DSize; … … 179 179 CompressedTexSubImage3DArbProc _glCompressedTexSubImage3D; 180 180 GLCopyTexSubImageProc _glCopyTexSubImage3D; 181 181 182 182 }; 183 183 184 184 /** Function to call to get the extension of a specified context. 185 185 * If the Extension object for that context has not yet been created 186 186 * and the 'createIfNotInitalized' flag been set to false then returns NULL. 187 * If 'createIfNotInitalized' is true then the Extensions object is 187 * If 'createIfNotInitalized' is true then the Extensions object is 188 188 * automatically created. However, in this case the extension object will 189 189 * only be created with the graphics context associated with ContextID. … … 201 201 202 202 virtual ~Texture2DArray(); 203 203 204 204 bool imagesValid() const; 205 205 206 206 virtual void computeInternalFormat() const; 207 207 void allocateMipmap(State& state) const; … … 216 216 // subloaded images can have different texture and image sizes. 217 217 mutable GLsizei _textureWidth, _textureHeight, _textureDepth; 218 219 // number of mip map levels the the texture has been created with, 218 219 // number of mip map levels the the texture has been created with, 220 220 mutable GLsizei _numMipmapLevels; 221 221
