osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarth/TextureCompositorTexArray

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 #ifndef OSGEARTH_TEXTURE_COMPOSITOR_TEX_ARRAY_H
00020 #define OSGEARTH_TEXTURE_COMPOSITOR_TEX_ARRAY_H 1
00021 
00022 #include <osgEarth/TextureCompositor>
00023 #include <osg/Version>
00024 
00025 // only in newer OSG versions.
00026 #if OSG_VERSION_GREATER_OR_EQUAL( 2, 9, 8 )
00027 
00028 namespace osgEarth
00029 {
00033     class TextureCompositorTexArray : public TextureCompositorTechnique
00034     {
00035     public:
00036         TextureCompositorTexArray( const TerrainOptions& options );
00037 
00038     public:
00039         void updateMasterStateSet( osg::StateSet* stateSet, const TextureLayout& layout ) const;
00040 
00041         bool requiresUnitTextureSpace() const { return true; }
00042 
00043         bool usesShaderComposition() const { return true; }
00044 
00045         bool supportsLayerUpdate() const { return true; }
00046 
00047         GeoImage prepareImage( const GeoImage& layerImage, const GeoExtent& tileExtent ) const
00048         {
00049             return prepareImage(layerImage, tileExtent, textureSize() );
00050         }
00051 
00052         GeoImage prepareSecondaryImage( const GeoImage& layerImage, const GeoExtent& tileExtent ) const
00053         {
00054             return prepareImage(layerImage, tileExtent, textureSize() / 2);
00055         }
00056 
00057     protected:
00058         GeoImage prepareImage( const GeoImage& layerImage, const GeoExtent& tileExtent, unsigned size ) const;
00059     public:
00060         void applyLayerUpdate( 
00061             osg::StateSet* stateSet,
00062             UID layerUID, 
00063             const GeoImage& preparedImage,
00064             const TileKey& tileKey,
00065             const TextureLayout& layout,
00066             osg::StateSet* parentStateSet ) const;
00067 
00068         osg::Shader* createSamplerFunction( UID layerUID, const std::string& functionName, osg::Shader::Type type, const TextureLayout& layout ) const;
00069         static inline unsigned textureSize() { return 256; }
00070 
00071     private:
00072         float _lodTransitionTime;
00073     };
00074 }
00075 
00076 #endif // OSG_VERSION_GREATER_OR_EQUAL( 2, 9, 8 )
00077 
00078 #endif // OSGEARTH_TEXTURE_COMPOSITOR_TEX_ARRAY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines