osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarth/SparseTexture2DArray

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2008-2010 Pelican Mapping
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 
00020 #ifndef OSGEARTH_SPARSE_TEXTURE_2D_ARRAY_H
00021 #define OSGEARTH_SPARSE_TEXTURE_2D_ARRAY_H 1
00022 
00023 #include <osgEarth/Common>
00024 
00025 // this class is only supported in newer OSG versions.
00026 #if OSG_VERSION_GREATER_OR_EQUAL( 2, 9, 8 )
00027 
00028 #include <osg/Texture2DArray>
00029 
00030 namespace osgEarth
00031 {
00036     class SparseTexture2DArray : public osg::Texture2DArray
00037     {
00038     public:
00039         SparseTexture2DArray() : osg::Texture2DArray() { }
00040 
00041         SparseTexture2DArray( const SparseTexture2DArray& rhs, const osg::CopyOp& copyop =osg::CopyOp::DEEP_COPY_ALL )
00042             : osg::Texture2DArray( rhs, copyop ) { }
00043 
00044         META_StateAttribute( osgEarth, SparseTexture2DArray, TEXTURE );
00045 
00046     public:
00047         virtual void computeInternalFormat() const;
00048 
00049         virtual void apply( osg::State& state ) const;
00050 
00051     protected:
00052 
00053 #if OSG_VERSION_LESS_THAN(2,9,7)
00054         bool isSafeToUnrefImageData(const osg::State& state) const {
00055             return (_unrefImageDataAfterApply && areAllTextureObjectsLoaded());
00056         }
00057 #elif OSG_VERSION_LESS_THAN(2,9,10)
00058         bool isSafeToUnrefImageData(const osg::State& state) const {
00059             return (_unrefImageDataAfterApply && state.getMaxTexturePoolSize()==0 && areAllTextureObjectsLoaded());
00060         }
00061 #endif
00062 
00063     private:
00064         int firstValidImageIndex() const;
00065 
00066         osg::Image* firstValidImage() const;
00067 
00068         // replaces the same func in the superclass
00069         void applyTexImage2DArray_subload( osg::State& state, osg::Image* image, GLsizei inwidth, GLsizei inheight, GLsizei indepth, GLint inInternalFormat, GLsizei& numMipmapLevels) const;
00070     };
00071 }
00072 
00073 #endif // OSG_VERSION_GREATER_OR_EQUAL( 2, 9, 8 )
00074 
00075 #endif // OSGEARTH_TILE_FACTORY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines