~saiarcot895/ubuntu/trusty/openscenegraph/armhf-support

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osg/TextureCubeMap.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Loic Dachary (OuoU)
  • Date: 2009-03-23 14:08:20 UTC
  • mfrom: (1.1.7 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090323140820-i4j3jozdlhyn4lre
rules prevent lib64 with -D LIB_POSTFIX="" (Closes: #517671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#include <osg/Image>
16
16
#include <osg/State>
17
17
#include <osg/TextureCubeMap>
 
18
#include <osg/ImageSequence>
18
19
#include <osg/Notify>
19
20
 
20
21
#include <osg/GLU>
128
129
 
129
130
void TextureCubeMap::setImage( unsigned int face, Image* image)
130
131
{
 
132
    if (_images[face] == image) return;
 
133
 
 
134
    unsigned numImageSequencesBefore = 0;
 
135
    for (unsigned int i=0; i<getNumImages(); ++i)
 
136
    {
 
137
        osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get());
 
138
        if (is) ++numImageSequencesBefore;
 
139
    }
 
140
 
131
141
    _images[face] = image;
132
142
    _modifiedCount[face].setAllElementsTo(0);
 
143
 
 
144
 
 
145
    // find out if we need to reset the update callback to handle the animation of ImageSequence
 
146
    unsigned numImageSequencesAfter = 0;
 
147
    for (unsigned int i=0; i<getNumImages(); ++i)
 
148
    {
 
149
        osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get());
 
150
        if (is) ++numImageSequencesAfter;
 
151
    }
 
152
 
 
153
    if (numImageSequencesBefore>0)
 
154
    {
 
155
        if (numImageSequencesAfter==0)
 
156
        {
 
157
            setUpdateCallback(0);
 
158
            setDataVariance(osg::Object::STATIC);
 
159
        }
 
160
    }
 
161
    else if (numImageSequencesAfter>0)
 
162
    {
 
163
        setUpdateCallback(new ImageSequence::UpdateCallback());
 
164
        setDataVariance(osg::Object::DYNAMIC);
 
165
    }
133
166
}
134
167
 
135
168
Image* TextureCubeMap::getImage(unsigned int face)
227
260
            _textureWidth = _textureHeight = minimum( _textureWidth , _textureHeight );
228
261
        }
229
262
 
230
 
        _textureObjectBuffer[contextID] = textureObject = generateTextureObject(
 
263
        textureObject = generateTextureObject(
231
264
                contextID,GL_TEXTURE_CUBE_MAP,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0);
232
265
        
233
266
        textureObject->bind();
253
286
 
254
287
        }
255
288
 
 
289
        _textureObjectBuffer[contextID] = textureObject;
 
290
 
256
291
        if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
257
292
        {
258
293
            TextureCubeMap* non_const_this = const_cast<TextureCubeMap*>(this);
344
379
        bool hardwareMipMapOn = false;
345
380
        if (needHardwareMipMap)
346
381
        {
347
 
            const Texture::Extensions* tex_extensions = Texture::getExtensions(contextID,true);
348
 
            bool generateMipMapSupported = tex_extensions->isGenerateMipMapSupported();
349
 
 
350
 
            hardwareMipMapOn = _useHardwareMipMapGeneration && generateMipMapSupported;
 
382
            hardwareMipMapOn = isHardwareMipmapGenerationEnabled(state);
351
383
 
352
384
            if (!hardwareMipMapOn)
353
385
            {
354
 
                // have to swtich off mip mapping
355
 
                notify(NOTICE)<<"Warning: TextureCubeMap::copyTexImage2D(,,,,) switch of mip mapping as hardware support not available."<<std::endl;
 
386
                // have to switch off mip mapping
 
387
                notify(NOTICE)<<"Warning: TextureCubeMap::copyTexImage2D(,,,,) switch off mip mapping as hardware support not available."<<std::endl;
356
388
                _min_filter = LINEAR;
357
389
            }
358
390
        }
359
391
 
360
 
        if (hardwareMipMapOn) glTexParameteri( target, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
 
392
        GenerateMipmapMode mipmapResult = mipmapBeforeTexImage(state, hardwareMipMapOn);
361
393
 
362
394
        glCopyTexSubImage2D( target , 0, xoffset, yoffset, x, y, width, height);
363
395
 
364
 
        if (hardwareMipMapOn) glTexParameteri( target, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
 
396
        mipmapAfterTexImage(state, mipmapResult);
365
397
 
366
398
        // inform state that this texture is the current one bound.
367
399
        state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);