WGETexture.h 23.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

#ifndef WGETEXTURE_H
#define WGETEXTURE_H

#include <string>

#include <boost/shared_ptr.hpp>

#include <osg/Node>
33
#include <osg/StateSet>
34 35 36 37 38
#include <osg/Texture>
#include <osg/Texture1D>
#include <osg/Texture2D>
#include <osg/Texture3D>

39
#include "callbacks/WGEFunctorCallback.h"
40
#include "../common/WBoundingBox.h"
41 42
#include "../common/WProperties.h"
#include "../common/WPropertyHelper.h"
Sebastian Eichelbaum's avatar
[STYLE]  
Sebastian Eichelbaum committed
43
#include "../common/math/linearAlgebra/WLinearAlgebra.h"
44

45
#include "WGETextureUtils.h"
46 47 48 49 50 51 52 53 54

/**
 * This calls serves a simple purpose: have a texture and its scaling information together which allows very easy binding of textures to nodes
 * with associated shaders. When this texture gets bind using the bindTo methods, uniforms get added containing needed scaling information.
 */
template < typename TextureType = osg::Texture >
class WGETexture: public TextureType
{
public:
55 56 57 58 59 60
    //! We support only 8 textures because some known hardware does not support more texture coordinates.
    static std::size_t const MAX_NUMBER_OF_TEXTURES = 8;

    //! The maximum texture dimension.
    static std::size_t const MAX_TEXTURE_DIMENSION = 2048;

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
    /**
     * Default constructor. Creates an empty instance of the texture.
     *
     * \param scale the scaling factor needed for de-scaling the texture values
     * \param min the minimum value allowing negative values too.
     */
    WGETexture( double scale = 1.0, double min = 0.0 );

    /**
     * Creates texture from given image. Scaling is set to identity.
     *
     * \param image the image to use as texture
     * \param scale the scaling factor needed for de-scaling the texture values
     * \param min the minimum value allowing negative values too.
     */
    WGETexture( osg::Image* image, double scale = 1.0, double min = 0.0 );

    /**
     * Copy the texture.
     *
     * \param texture the texture to copy
     * \param copyop
     */
    WGETexture( const WGETexture< TextureType >& texture, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );

    /**
     * Destructor.
     */
    virtual ~WGETexture();

91 92 93 94 95 96 97
    /**
     * Returns the name property of the texture. You should set it if you create a texture.
     *
     * \return texture name property
     */
    WPropString name() const;

98
    /**
99 100
     * Get the minimum in the de-scaled value space. The property can be changed. A change affects all colormaps using this texture. But be
     * careful as the texture creating depends on these values.
101 102 103
     *
     * \return the minimum
     */
104
    WPropDouble minimum() const;
105 106

    /**
107 108
     * Get the scaling factor for de-scaling the texture. The property can be changed. A change affects all colormaps using this texture. But be
     * careful as the texture creating depends on these values.
109 110 111
     *
     * \return the scale
     */
112
    WPropDouble scale() const;
113 114 115 116 117 118 119 120

    /**
     * Returns the alpha property. The property can be changed. A change affects all colormaps using this texture.
     *
     * \return alpha property
     */
    WPropDouble alpha() const;

121 122 123 124 125 126 127
    /**
     * Clip the values assumed to be zero.
     *
     * \return true to clip.
     */
    WPropBool clipZero() const;

128 129 130 131 132
    /**
     * Returns the threshold property. The property can be changed. A change affects all colormaps using this texture.
     *
     * \return threshold property
     */
133 134 135 136 137 138 139 140
    WPropDouble thresholdLower() const;

    /**
     * Returns the threshold property. The property can be changed. A change affects all colormaps using this texture.
     *
     * \return threshold property
     */
    WPropDouble thresholdUpper() const;
141

142 143 144 145 146 147 148
    /**
     * Returns the property responsible for enabling threshold based clipping. If this is false, the threshold is ignored.
     *
     * \return threshold-enable property.
     */
    WPropBool thresholdEnabled() const;

149 150 151 152 153 154 155 156 157 158 159 160 161 162
    /**
     * Returns the interpolation property. The property can be changed. A change affects all colormaps using this texture.
     *
     * \return interpolation property
     */
    WPropBool interpolation() const;

    /**
     * Returns the colormap property. The property can be changed. A change affects all colormaps using this texture.
     *
     * \return colormap property
     */
    WPropSelection colormap() const;

163 164 165 166 167 168 169
    /**
     * Returns the active property. The property can be changed. A change affects all colormaps using this texture.
     *
     * \return active property
     */
    WPropBool active() const;

170 171 172
    /**
     * Returns the window level definition for the colormap. The property can be changed. A change affects all colormaps using this texture.
     *
173
     * \return window colormap
174 175 176
     */
    WPropInterval window() const;

177 178 179 180 181 182 183
    /**
     * Returns the property responsible for enabling window based interval scaling. If this is false, the window setting is ignored.
     *
     * \return windowing-enable property.
     */
    WPropBool windowEnabled() const;

184
    /**
Sebastian Eichelbaum's avatar
Sebastian Eichelbaum committed
185 186
     * Returns the texture transformation matrix. The property can be changed. A change affects all colormaps using this texture. This matrix
     * converts an world-space coordinate to an texture coordinate! This can be seen as a scaled inverse matrix of the grid's transformation.
187
     *
188
     * \return the matrix
189
     */
190
    WPropMatrix4X4 transformation() const;
191

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
    /**
     * Binds the texture to the specified node and texture unit. It also adds two uniforms: u_textureXMin and u_textureXScale, where X
     * is the unit number. This can be used in shaders to unscale it.
     *
     * \param node the node where to bind the texture to
     * \param unit the unit, by default 0
     */
    void bind( osg::ref_ptr< osg::Node > node, size_t unit = 0 );

    /**
     * Return a pointer to the properties object of the dataset. Add all the modifiable settings here. This allows the user to modify several
     * properties of a dataset.
     *
     * \return the properties.
     */
    boost::shared_ptr< WProperties > getProperties() const;

    /**
     * Return a pointer to the information properties object of the dataset. The dataset intends these properties to not be modified.
     *
     * \return the properties.
     */
    boost::shared_ptr< WProperties > getInformationProperties() const;

216 217 218 219 220 221 222 223
    /**
     * Applies some custom uniforms to the specified state-set which directly relate to this texture
     *
     * \param prefix the prefix used for the uniforms
     * \param states the state where to add the uniforms
     */
    virtual void applyUniforms( std::string prefix, osg::StateSet* states ) const;

224 225 226 227 228 229 230 231 232 233 234 235 236 237
    /**
     * For all the lazy guys to set the filter MIN and MAG at once.
     *
     * \param mode the new mode for MIN_FILTER and MAG_FILTER.
     */
    void setFilterMinMag( osg::Texture::FilterMode mode );

    /**
     * For all the lazy guys to set the wrapping for s,t and r directions at once.
     *
     * \param mode the new mode for WRAP_S, WRAP_T and WRAP_R.
     */
    void setWrapSTR( osg::Texture::WrapMode mode );

238 239 240 241 242 243 244 245
    /**
     * Returns the texture's bounding box. This is const. Although there exists the transformation() property, it is an information property and
     * can't be changed.
     *
     * \return the bounding box.
     */
    virtual WBoundingBox getBoundingBox() const;

246
protected:
247 248 249
    /**
     * Handles all property updates. Called by m_propCondition.
     */
250 251 252 253 254 255 256 257 258 259 260 261 262
    virtual void handleUpdate();

    /**
     * Creates the texture data. Overwrite this method if you want to provide a custom texture creation procedure.
     */
    virtual void create();

    /**
     * This method implements an update callback which updates the texture image if needed and several other properties like texture matrix.
     *
     * \param state the state to update
     */
    virtual void updateCallback( osg::StateAttribute* state );
263

264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
    /**
     * Initialize the size of the texture properly according to real texture type (1D,2D,3D).
     * \note This is needed because osg::Texture::setImage is not virtual and does not set the size from the image.
     *
     * \param texture the texture where to set the size
     * \param width the new width
     * \param height the new height
     * \param depth the new depth
     */
    static void initTextureSize( osg::Texture1D* texture, int width, int height, int depth );

    /**
     * Initialize the size of the texture properly according to real texture type (1D,2D,3D).
     * \note This is needed because osg::Texture::setImage is not virtual and does not set the size from the image.
     *
     * \param texture the texture where to set the size
     * \param width the new width
     * \param height the new height
     * \param depth the new depth
     */
    static void initTextureSize( osg::Texture2D* texture, int width, int height, int depth );

    /**
     * Initialize the size of the texture properly according to real texture type (1D,2D,3D).
     * \note This is needed because osg::Texture::setImage is not virtual and does not set the size from the image.
     *
     * \param texture the texture where to set the size
     * \param width the new width
     * \param height the new height
     * \param depth the new depth
     */
    static void initTextureSize( osg::Texture3D* texture, int width, int height, int depth );

297
private:
298 299 300 301 302 303 304
    /**
     * Creates and assigns all properties.
     *
     * \param min the min value of the texture
     * \param scale the scale value of the texture
     */
    void setupProperties( double scale, double min );
305

306 307 308 309 310
    /**
     * A condition used to notify about changes in several properties.
     */
    boost::shared_ptr< WCondition > m_propCondition;

311 312 313 314 315 316 317 318 319 320 321 322
    /**
     * The property object for the dataset.
     */
    boost::shared_ptr< WProperties > m_properties;

    /**
     * The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION". It is useful to define some property
     * to only be of informational nature. The GUI does not modify them. As it is a WProperties instance, you can use it the same way as
     * m_properties.
     */
    boost::shared_ptr< WProperties > m_infoProperties;

323 324 325 326 327
    /**
     * If true, the texture gets created. This is used to create texture on demand.
     */
    bool m_needCreate;

328 329 330 331 332
    /**
     * The texture name. This might be useful to identify textures.
     */
    WPropString m_name;

333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
    /**
     * The minimum of each value in the texture in unscaled space.
     */
    WPropDouble m_min;

    /**
     * The scaling factor to de-scale a [0-1] texture to original space.
     */
    WPropDouble m_scale;

    /**
     * A list of color map selection types
     */
    boost::shared_ptr< WItemSelection > m_colorMapSelectionsList;

    /**
     * Selection property for color map
     */
    WPropSelection m_colorMap;

    /**
     * Alpha blending value.
     */
    WPropDouble m_alpha;

358 359 360 361 362
    /**
     * If set to true, zero values are clipped by making them transparent
     */
    WPropBool m_clipZero;

363 364 365
    /**
     * Threshold for clipping areas.
     */
366 367 368 369 370 371
    WPropDouble m_thresholdLower;

    /**
     * Threshold for clipping areas.
     */
    WPropDouble m_thresholdUpper;
372

373 374 375 376 377
    /**
     * Threshold-enable flag.
     */
    WPropBool m_thresholdEnabled;

378 379 380 381
    /**
     * True if interpolation should be used.
     */
    WPropBool m_interpolation;
382 383 384 385 386

    /**
     * True if the texture is active.
     */
    WPropBool m_active;
387 388 389 390 391

    /**
     * The texture transformation matrix.
     */
    WPropMatrix4X4 m_texMatrix;
392 393 394 395 396

    /**
     * Window level setting for the current colormap
     */
    WPropInterval m_window;
397 398 399 400 401

    /**
     * Window-Level-Setting-enable flag.
     */
    WPropBool m_windowEnabled;
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
};

// Some convenience typedefs

/**
 * OSG's Texture1D with scaling features
 */
typedef WGETexture< osg::Texture1D > WGETexture1D;

/**
 * OSG's Texture2D with scaling features
 */
typedef WGETexture< osg::Texture2D > WGETexture2D;

/**
 * OSG's Texture3D with scaling features
 */
typedef WGETexture< osg::Texture3D > WGETexture3D;

421

422 423 424
template < typename TextureType >
WGETexture< TextureType >::WGETexture( double scale, double min ):
    TextureType(),
425
    m_propCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
426
    m_properties( boost::shared_ptr< WProperties >( new WProperties( "Texture Properties", "Properties of a texture." ) ) ),
427 428
    m_infoProperties( boost::shared_ptr< WProperties >( new WProperties( "Texture Info Properties", "Texture's information properties." ) ) ),
    m_needCreate( true )
429
{
430
    setupProperties( scale, min );
431 432 433 434
}

template < typename TextureType >
WGETexture< TextureType >::WGETexture( osg::Image* image, double scale, double min ):
435 436 437
    TextureType( image ),
    m_propCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
    m_properties( boost::shared_ptr< WProperties >( new WProperties( "Texture Properties", "Properties of a texture." ) ) ),
438 439
    m_infoProperties( boost::shared_ptr< WProperties >( new WProperties( "Texture Info Properties", "Texture's information properties." ) ) ),
    m_needCreate( true )
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
{
    setupProperties( scale, min );
    WGETexture< TextureType >::initTextureSize( this, image->s(), image->t(), image->r() );
}

template < typename TextureType >
WGETexture< TextureType >::WGETexture( const WGETexture< TextureType >& texture, const osg::CopyOp& copyop ):
    TextureType( texture, copyop ),
    m_min( texture.m_min ),
    m_scale( texture.m_scale )
{
    // initialize members
}

template < typename TextureType >
void WGETexture< TextureType >::setupProperties( double scale, double min )
456
{
457 458
    m_propCondition->subscribeSignal( boost::bind( &WGETexture< TextureType >::handleUpdate, this ) );

459 460
    m_name = m_properties->addProperty( "Name", "The name of the texture.", std::string( "Unnamed" ) );

461
    // initialize members
462 463 464 465 466 467 468
    m_min = m_properties->addProperty( "Minimum", "The minimum value in the original space.", min, true );
    m_min->removeConstraint( m_min->getMin() );
    m_min->removeConstraint( m_min->getMax() );

    m_scale = m_properties->addProperty( "Scale", "The scaling factor to un-scale the texture values to the original space.", scale, true );
    m_scale->removeConstraint( m_scale->getMin() );
    m_scale->removeConstraint( m_scale->getMax() );
469

470
    m_alpha = m_properties->addProperty( "Alpha", "The alpha blending value.", 1.0 );
471 472 473
    m_alpha->setMin( 0.0 );
    m_alpha->setMax( 1.0 );

474 475
    m_clipZero = m_properties->addProperty( "Enable Zero Clip", "If enabled, zero values are clipped.", true );

476 477 478
    m_thresholdEnabled = m_properties->addProperty( "Enable Threshold",
                                                    "If enabled, threshold based clipping is used. If not, threshold is ignored.", false );

479 480 481 482 483 484 485
    m_thresholdLower = m_properties->addProperty( "Lower Threshold", "The threshold used to clip areas below the specified value.", 0.0 );
    m_thresholdLower->setMin( min );
    m_thresholdLower->setMax( min + scale );

    m_thresholdUpper = m_properties->addProperty( "Upper Threshold", "The threshold used to clip areas above the specified value.", 1.0 );
    m_thresholdUpper->setMin( min );
    m_thresholdUpper->setMax( min + scale );
486

487 488 489 490
    m_windowEnabled = m_properties->addProperty( "Enable Windowing", "If enabled, window level settings are applied.", false );
    m_window = m_properties->addProperty( "Window Level", "Define the interval in the data which is mapped to the colormap.",
                                          make_interval( 0.0, 1.0 ) );

491
    m_interpolation = m_properties->addProperty( "Interpolate", "Interpolation of the volume data.", true, m_propCondition );
492 493 494 495 496

    m_colorMapSelectionsList = boost::shared_ptr< WItemSelection >( new WItemSelection() );
    m_colorMapSelectionsList->addItem( "Grayscale", "" );
    m_colorMapSelectionsList->addItem( "Rainbow", "" );
    m_colorMapSelectionsList->addItem( "Hot iron", "" );
497
    m_colorMapSelectionsList->addItem( "Negative to positive", "" );
498 499
    m_colorMapSelectionsList->addItem( "Atlas", "" );
    m_colorMapSelectionsList->addItem( "Blue-Green-Purple", "" );
500
    m_colorMapSelectionsList->addItem( "Vector", "" );
501

502
    m_colorMap = m_properties->addProperty( "Colormap", "The colormap of this texture.", m_colorMapSelectionsList->getSelectorFirst() );
503
    WPropertyHelper::PC_SELECTONLYONE::addTo( m_colorMap );
504

505
    m_active = m_properties->addProperty( "Active", "Can dis-enable a texture.", true );
506

507
    WMatrix4d m = WMatrix4d::identity();
508
    m_texMatrix = m_properties->addProperty( "Texture Transformation", "Usable to transform the texture.", m );
509
    m_texMatrix->setHidden();
510
    m_texMatrix->setPurpose( PV_PURPOSE_INFORMATION );
511

512
    TextureType::setResizeNonPowerOfTwoHint( false );
Sebastian Eichelbaum's avatar
Sebastian Eichelbaum committed
513 514 515
    TextureType::setUpdateCallback( new WGEFunctorCallback< osg::StateAttribute >(
        boost::bind( &WGETexture< TextureType >::updateCallback, this, _1 ) )
    );
516 517 518 519

    // init filters
    TextureType::setFilter( osg::Texture::MIN_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
    TextureType::setFilter( osg::Texture::MAG_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
}

template < typename TextureType >
WGETexture< TextureType >::~WGETexture()
{
    // cleanup.
}

template < typename TextureType >
boost::shared_ptr< WProperties > WGETexture< TextureType >::getProperties() const
{
    return m_properties;
}

template < typename TextureType >
boost::shared_ptr< WProperties > WGETexture< TextureType >::getInformationProperties() const
{
    return m_infoProperties;
}

540 541 542 543 544 545
template < typename TextureType >
inline WPropString WGETexture< TextureType >::name() const
{
    return m_name;
}

546
template < typename TextureType >
547
inline WPropDouble WGETexture< TextureType >::minimum() const
548
{
549
    return m_min;
550 551 552
}

template < typename TextureType >
553
inline WPropDouble WGETexture< TextureType >::scale() const
554
{
555
    return m_scale;
556 557 558
}

template < typename TextureType >
559
inline WPropDouble WGETexture< TextureType >::alpha() const
560 561 562 563
{
    return m_alpha;
}

564 565 566 567 568 569
template < typename TextureType >
inline WPropBool WGETexture< TextureType >::clipZero() const
{
    return m_clipZero;
}

570
template < typename TextureType >
571 572 573 574 575 576 577
inline WPropDouble WGETexture< TextureType >::thresholdLower() const
{
    return m_thresholdLower;
}

template < typename TextureType >
inline WPropDouble WGETexture< TextureType >::thresholdUpper() const
578
{
579
    return m_thresholdUpper;
580 581
}

582 583 584 585 586 587
template < typename TextureType >
inline WPropBool WGETexture< TextureType >::thresholdEnabled() const
{
    return m_thresholdEnabled;
}

588
template < typename TextureType >
589
inline WPropBool WGETexture< TextureType >::interpolation() const
590 591 592 593 594
{
    return m_interpolation;
}

template < typename TextureType >
595
inline WPropSelection WGETexture< TextureType >::colormap() const
596 597 598 599
{
    return m_colorMap;
}

600
template < typename TextureType >
601
inline WPropBool WGETexture< TextureType >::active() const
602 603 604 605
{
    return m_active;
}

606 607 608 609 610 611
template < typename TextureType >
inline WPropBool WGETexture< TextureType >::windowEnabled() const
{
    return m_windowEnabled;
}

612 613 614 615 616 617
template < typename TextureType >
inline WPropInterval WGETexture< TextureType >::window() const
{
    return m_window;
}

618 619 620 621 622 623
template < typename TextureType >
inline WPropMatrix4X4 WGETexture< TextureType >::transformation() const
{
    return m_texMatrix;
}

624 625 626
template < typename TextureType >
void  WGETexture< TextureType >::handleUpdate()
{
627
    if( m_interpolation->changed() )
628 629 630 631
    {
        TextureType::setFilter( osg::Texture::MIN_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
        TextureType::setFilter( osg::Texture::MAG_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
    }
632 633
}

634 635 636 637 638 639
template < typename TextureType >
void  WGETexture< TextureType >::applyUniforms( std::string prefix, osg::StateSet* states ) const
{
    states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Min", minimum() ) );
    states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Scale", scale() ) );
    states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Alpha", alpha() ) );
640
    states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "ClipZeroEnabled", clipZero() ) );
641
    states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "ThresholdEnabled", thresholdEnabled() ) );
642 643
    states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdLower", thresholdLower() ) );
    states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdUpper", thresholdUpper() ) );
644 645
    states->addUniform( new WGEPropertyUniform< WPropSelection >( prefix + "Colormap", colormap() ) );
    states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "Active", active() ) );
646
    states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "WindowEnabled", windowEnabled() ) );
647
    states->addUniform( new WGEPropertyUniform< WPropInterval >( prefix + "Window", window() ) );
648 649
}

650 651 652 653
template < typename TextureType >
void WGETexture< TextureType >::bind( osg::ref_ptr< osg::Node > node, size_t unit )
{
    // let our utilities do the work
ledig's avatar
ledig committed
654
    wge::bindTexture( node, osg::ref_ptr< WGETexture< TextureType > >( this ), unit ); // to avoid recursive stuff -> explicitly specify the type
655 656
}

657 658 659 660 661 662
template < typename TextureType >
void WGETexture< TextureType >::create()
{
    // do nothing. Derived classes may implement this.
}

Sebastian Eichelbaum's avatar
Sebastian Eichelbaum committed
663
template < typename TextureType >
664 665 666
void WGETexture< TextureType >::updateCallback( osg::StateAttribute* /*state*/ )
{
    // create if not done yet
667
    if( m_needCreate )
668 669 670
    {
        m_needCreate = false;
        create();
671
        TextureType::dirtyTextureObject();
672 673 674
    }
}

675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
template < typename TextureType >
void WGETexture< TextureType >::setFilterMinMag( osg::Texture::FilterMode mode )
{
    this->setFilter( osg::Texture2D::MIN_FILTER, mode );
    this->setFilter( osg::Texture2D::MAG_FILTER, mode );
}

template < typename TextureType >
void WGETexture< TextureType >::setWrapSTR( osg::Texture::WrapMode mode )
{
    this->setWrap( osg::Texture2D::WRAP_S, mode );
    this->setWrap( osg::Texture2D::WRAP_T, mode );
    this->setWrap( osg::Texture2D::WRAP_R, mode );
}

template < typename TextureType >
void WGETexture< TextureType >::initTextureSize( osg::Texture1D* texture, int width, int /*height*/, int /*depth*/ )
{
    texture->setTextureWidth( width );
}

template < typename TextureType >
void WGETexture< TextureType >::initTextureSize( osg::Texture2D* texture, int width, int height, int /*depth*/ )
{
    texture->setTextureSize( width, height );
}

template < typename TextureType >
void WGETexture< TextureType >::initTextureSize( osg::Texture3D* texture, int width, int height, int depth )
{
    texture->setTextureSize( width, height, depth );
}

708 709 710 711 712 713
template < typename TextureType >
WBoundingBox WGETexture< TextureType >::getBoundingBox() const
{
    return WBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 );
}

714 715
#endif  // WGETEXTURE_H