root/OpenSceneGraph/trunk/src/osg/Texture2DArray.cpp @ 10867

Revision 10867, 25.3 kB (checked in by robert, 5 years ago)

Added check for image compatibility with existing texture object, releasing the existing texture object in cases when the new image size/pixel format is not compatible.

Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13#include <osg/GLExtensions>
14#include <osg/Texture2DArray>
15#include <osg/State>
16#include <osg/ImageSequence>
17#include <osg/Notify>
18
19#include <string.h>
20
21
22using namespace osg;
23
24Texture2DArray::Texture2DArray():
25            _textureWidth(0),
26            _textureHeight(0),
27            _textureDepth(0),
28            _numMipmapLevels(0)
29{
30}
31
32Texture2DArray::Texture2DArray(const Texture2DArray& text,const CopyOp& copyop):
33            Texture(text,copyop),
34            _textureWidth(text._textureWidth),
35            _textureHeight(text._textureHeight),
36            _textureDepth(text._textureDepth),
37            _numMipmapLevels(text._numMipmapLevels),
38            _subloadCallback(text._subloadCallback)
39{
40    // copy all images by iterating through all of them
41    for (int i=0; i < text._textureDepth; i++)
42    {
43        _images.push_back(copyop(text._images[i].get()));
44        _modifiedCount.push_back(ImageModifiedCount());
45    }
46}
47
48Texture2DArray::~Texture2DArray()
49{
50}
51
52int Texture2DArray::compare(const StateAttribute& sa) const
53{
54    // check the types are equal and then create the rhs variable
55    // used by the COMPARE_StateAttribute_Parameter macro's below.
56    COMPARE_StateAttribute_Types(Texture2DArray,sa)
57
58    bool noImages = true;
59    for (int n=0; n < _textureDepth; n++)
60    {
61        if (noImages && _images[n].valid()) noImages = false;
62        if (noImages && rhs._images[n].valid()) noImages = false;
63   
64        if (_images[n]!=rhs._images[n]) // smart pointer comparison.
65        {
66            if (_images[n].valid())
67            {
68                if (rhs._images[n].valid())
69                {
70                    int result = _images[n]->compare(*rhs._images[n]);
71                    if (result!=0) return result;
72                }
73                else
74                {
75                    return 1; // valid lhs._image is greater than null.
76                }
77            }
78            else if (rhs._images[n].valid())
79            {
80                return -1; // valid rhs._image is greater than null.
81            }
82        }
83    }
84
85   
86    if (noImages)
87    {
88        int result = compareTextureObjects(rhs);
89        if (result!=0) return result;
90    }
91
92    int result = compareTexture(rhs);
93    if (result!=0) return result;
94
95    // compare each parameter in turn against the rhs.
96    COMPARE_StateAttribute_Parameter(_textureWidth)
97    COMPARE_StateAttribute_Parameter(_textureHeight)
98    COMPARE_StateAttribute_Parameter(_textureDepth)
99    COMPARE_StateAttribute_Parameter(_subloadCallback)
100
101    return 0; // passed all the above comparison macro's, must be equal.
102}
103
104void Texture2DArray::setImage(unsigned int layer, Image* image)
105{
106    // check if the layer exceeds the texture depth
107    if (static_cast<int>(layer) >= _textureDepth)
108    {
109        // print warning and do nothing
110        notify(WARN)<<"Warning: Texture2DArray::setImage(..) failed, the given layer number is bigger then the size of the texture array."<<std::endl;
111        return;
112    }
113   
114    if (_images[layer] == image) return;
115
116    unsigned numImageSequencesBefore = 0;
117    for (unsigned int i=0; i<getNumImages(); ++i)
118    {
119        osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get());
120        if (is) ++numImageSequencesBefore;
121    }
122
123    // set image
124    _images[layer] = image;
125   _modifiedCount[layer].setAllElementsTo(0);
126
127    // find out if we need to reset the update callback to handle the animation of ImageSequence
128    unsigned numImageSequencesAfter = 0;
129    for (unsigned int i=0; i<getNumImages(); ++i)
130    {
131        osg::ImageSequence* is = dynamic_cast<osg::ImageSequence*>(_images[i].get());
132        if (is) ++numImageSequencesAfter;
133    }
134
135    if (numImageSequencesBefore>0)
136    {
137        if (numImageSequencesAfter==0)
138        {
139            setUpdateCallback(0);
140            setDataVariance(osg::Object::STATIC);
141        }
142    }
143    else if (numImageSequencesAfter>0)
144    {
145        setUpdateCallback(new ImageSequence::UpdateCallback());
146        setDataVariance(osg::Object::DYNAMIC);
147    }
148}
149 
150void Texture2DArray::setTextureSize(int width, int height, int depth)
151{
152    // set dimensions
153    _textureWidth = width;
154    _textureHeight = height;
155    setTextureDepth(depth);
156}
157
158void Texture2DArray::setTextureDepth(int depth)
159{   
160    // if we decrease the number of layers, then delete non-used
161    if (depth < _textureDepth)
162    {
163        _images.resize(depth);
164        _modifiedCount.resize(depth);
165    }
166   
167    // if we increase the array, then add new empty elements
168    if (depth > _textureDepth)
169    {
170        _images.resize(depth, ref_ptr<Image>(0));
171        _modifiedCount.resize(depth, ImageModifiedCount());
172    }
173       
174    // resize the texture array
175    _textureDepth = depth;
176}
177
178Image* Texture2DArray::getImage(unsigned int layer)
179{
180    return _images[layer].get();
181}
182
183const Image* Texture2DArray::getImage(unsigned int layer) const
184{
185    return _images[layer].get();
186}
187
188bool Texture2DArray::imagesValid() const
189{
190    if (_textureDepth < 1) return false;
191    for (int n=0; n < _textureDepth; n++)
192    {
193        if (!_images[n].valid() || !_images[n]->data())
194            return false;
195    }
196    return true;
197}
198
199void Texture2DArray::computeInternalFormat() const
200{
201    if (imagesValid()) computeInternalFormatWithImage(*_images[0]);
202    else computeInternalFormatType();
203}
204
205
206void Texture2DArray::apply(State& state) const
207{
208    // get the contextID (user defined ID of 0 upwards) for the
209    // current OpenGL context.
210    const unsigned int contextID = state.getContextID();
211
212    Texture::TextureObjectManager* tom = Texture::getTextureObjectManager(contextID).get();
213    ElapsedTime elapsedTime(&(tom->getApplyTime()));
214    tom->getNumberApplied()++;
215
216    const Extensions* extensions = getExtensions(contextID,true);
217
218    // if not supported, then return
219    if (!extensions->isTexture2DArraySupported() || !extensions->isTexture3DSupported())
220    {
221        notify(WARN)<<"Warning: Texture2DArray::apply(..) failed, 2D texture arrays are not support by OpenGL driver."<<std::endl;
222        return;
223    }
224   
225    // get the texture object for the current contextID.
226    TextureObject* textureObject = getTextureObject(contextID);
227
228    if (textureObject && _textureDepth>0)
229    {
230        const osg::Image* image = _images[0].get();
231        if (image && getModifiedCount(0, contextID) != image->getModifiedCount())
232        {
233            // compute the internal texture format, this set the _internalFormat to an appropriate value.
234            computeInternalFormat();
235
236            GLsizei new_width, new_height, new_numMipmapLevels;
237
238            // compute the dimensions of the texture.
239            computeRequiredTextureDimensions(state, *image, new_width, new_height, new_numMipmapLevels);
240
241            if (!textureObject->match(GL_TEXTURE_2D_ARRAY_EXT, new_numMipmapLevels, _internalFormat, new_width, new_height, 1, _borderWidth))
242            {
243                Texture::releaseTextureObject(contextID, _textureObjectBuffer[contextID].get());
244                _textureObjectBuffer[contextID] = 0;
245                textureObject = 0;
246            }
247        }
248    }
249
250    // if we already have an texture object, then
251    if (textureObject)
252    {
253        // bind texture object
254        textureObject->bind();
255
256        // if texture parameters changed, then reset them
257        if (getTextureParameterDirty(state.getContextID())) applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT,state);
258
259        // if subload is specified, then use it to subload the images to GPU memory
260        if (_subloadCallback.valid())
261        {
262            _subloadCallback->subload(*this,state);
263        }
264        else
265        {
266            // for each image of the texture array do
267            for (GLsizei n=0; n < _textureDepth; n++)
268            {
269                osg::Image* image = _images[n].get();
270               
271                // if image content is modified, then upload it to the GPU memory
272                if (image && getModifiedCount(n,contextID) != image->getModifiedCount())
273                {
274                    applyTexImage2DArray_subload(state, image, _textureWidth, _textureHeight, n, _internalFormat, _numMipmapLevels);
275                    getModifiedCount(n,contextID) = image->getModifiedCount();
276                }
277            }
278        }
279
280    }
281   
282    // there is no texture object, but exists a subload callback, so use it to upload images
283    else if (_subloadCallback.valid())
284    {
285        // generate texture (i.e. glGenTexture) and apply parameters
286        _textureObjectBuffer[contextID] = textureObject = generateTextureObject(this, contextID, GL_TEXTURE_2D_ARRAY_EXT);
287        textureObject->bind();
288        applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT, state);
289        _subloadCallback->load(*this,state);
290    }
291   
292    // nothing before, but we have valid images, so do manual upload and create texture object manually
293    // TODO: we assume _images[0] is valid, however this may not be always the case
294    //       some kind of checking for the first valid image is required (Art, may 2008)
295    else if (imagesValid())
296    {
297        // compute the internal texture format, this set the _internalFormat to an appropriate value.
298        computeInternalFormat();
299
300        // compute the dimensions of the texture.
301        computeRequiredTextureDimensions(state,*_images[0],_textureWidth, _textureHeight, _numMipmapLevels);
302
303        // create texture object
304        textureObject = generateTextureObject(
305                this, contextID,GL_TEXTURE_2D_ARRAY_EXT,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0);
306       
307        // bind texture
308        textureObject->bind();
309        applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT, state);
310
311        // first we need to allocate the texture memory
312        extensions->glTexImage3D( GL_TEXTURE_2D_ARRAY_EXT, 0, _internalFormat,
313                     _textureWidth, _textureHeight, _textureDepth,
314                     _borderWidth,
315                     _sourceFormat ? _sourceFormat : _internalFormat,
316                     _sourceType ? _sourceType : GL_UNSIGNED_BYTE,
317                     0);
318
319        // now for each layer we upload it into the memory
320        for (GLsizei n=0; n<_textureDepth; n++)
321        {
322            // if image is valid then upload it to the texture memory
323            osg::Image* image = _images[n].get();
324            if (image)
325            {
326                // now load the image data into the memory, this will also check if image do have valid properties
327                applyTexImage2DArray_subload(state, image, _textureWidth, _textureHeight, n, _internalFormat, _numMipmapLevels);
328                getModifiedCount(n,contextID) = image->getModifiedCount();
329            }
330        }
331        textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0);
332
333        _textureObjectBuffer[contextID] = textureObject;
334       
335        // no idea what this for ;-)
336        if (state.getMaxTexturePoolSize()==0 && _unrefImageDataAfterApply && areAllTextureObjectsLoaded())
337        {
338            Texture2DArray* non_const_this = const_cast<Texture2DArray*>(this);
339            for (int n=0; n<_textureDepth; n++)
340            {               
341                if (_images[n].valid() && _images[n]->getDataVariance()==STATIC)
342                {
343                    non_const_this->_images[n] = 0;
344                }
345            }
346        }
347       
348    }
349   
350    // No images present, but dimensions are set. So create empty texture
351    else if ( (_textureWidth > 0) && (_textureHeight > 0) && (_textureDepth > 0) && (_internalFormat!=0) )
352    {
353        // generate texture
354        _textureObjectBuffer[contextID] = textureObject = generateTextureObject(
355                this, contextID, GL_TEXTURE_2D_ARRAY_EXT,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,_textureDepth,0);
356       
357        textureObject->bind();
358        applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT,state);
359       
360        extensions->glTexImage3D( GL_TEXTURE_2D_ARRAY_EXT, 0, _internalFormat,
361                     _textureWidth, _textureHeight, _textureDepth,
362                     _borderWidth,
363                     _sourceFormat ? _sourceFormat : _internalFormat,
364                     _sourceType ? _sourceType : GL_UNSIGNED_BYTE,
365                     0);
366       
367    }
368   
369    // nothing before, so just unbind the texture target
370    else
371    {
372        glBindTexture( GL_TEXTURE_2D_ARRAY_EXT, 0 );
373    }
374
375    // if texture object is now valid and we have to allocate mipmap levels, then
376    if (textureObject != 0 && _texMipmapGenerationDirtyList[contextID])
377    {
378        generateMipmap(state);
379    }
380}
381
382void Texture2DArray::applyTexImage2DArray_subload(State& state, Image* image, GLsizei inwidth, GLsizei inheight, GLsizei indepth, GLint inInternalFormat, GLsizei& numMipmapLevels) const
383{
384    // if we don't have a valid image we can't create a texture!
385    if (!imagesValid())
386        return;
387
388    // get the contextID (user defined ID of 0 upwards) for the
389    // current OpenGL context.
390    const unsigned int contextID = state.getContextID();
391    const Extensions* extensions = getExtensions(contextID,true);   
392    const Texture::Extensions* texExtensions = Texture::getExtensions(contextID,true);
393    GLenum target = GL_TEXTURE_2D_ARRAY_EXT;
394   
395    // compute the internal texture format, this set the _internalFormat to an appropriate value.
396    computeInternalFormat();
397
398    // select the internalFormat required for the texture.
399    // bool compressed = isCompressedInternalFormat(_internalFormat);
400    bool compressed_image = isCompressedInternalFormat((GLenum)image->getPixelFormat());
401
402    // if the required layer is exceeds the maximum allowed layer sizes
403    if (indepth > extensions->maxLayerCount())
404    {
405        // we give a warning and do nothing
406        notify(WARN)<<"Warning: Texture2DArray::applyTexImage2DArray_subload(..) the given layer number exceeds the maximum number of supported layers."<<std::endl;
407        return;       
408    }
409
410    //Rescale if resize hint is set or NPOT not supported or dimensions exceed max size
411    if( _resizeNonPowerOfTwoHint || !texExtensions->isNonPowerOfTwoTextureSupported(_min_filter)
412        || inwidth > extensions->max2DSize()
413        || inheight > extensions->max2DSize())
414        image->ensureValidSizeForTexturing(extensions->max2DSize());
415
416    // image size or format has changed, this is not allowed, hence return
417    if (image->s()!=inwidth ||
418        image->t()!=inheight ||
419        image->getInternalTextureFormat()!=inInternalFormat )
420    {
421        notify(WARN)<<"Warning: Texture2DArray::applyTexImage2DArray_subload(..) given image do have wrong dimension or internal format."<<std::endl;
422        return;       
423    }   
424   
425    glPixelStorei(GL_UNPACK_ALIGNMENT,image->getPacking());
426
427    // if no special mipmapping is required, then
428    if( _min_filter == LINEAR || _min_filter == NEAREST )
429    {
430        numMipmapLevels = 1;
431
432        // upload non-compressed image
433        if (!compressed_image)
434        {
435            extensions->glTexSubImage3D( target, 0,
436                                      0, 0, indepth,
437                                      inwidth, inheight, 1,
438                                      (GLenum)image->getPixelFormat(),
439                                      (GLenum)image->getDataType(),
440                                      image->data() );
441        }
442       
443        // if we support compression and image is compressed, then
444        else if (extensions->isCompressedTexImage3DSupported())
445        {
446            // notify(WARN)<<"glCompressedTexImage3D "<<inwidth<<", "<<inheight<<", "<<indepth<<std::endl;
447            numMipmapLevels = 1;
448
449            GLint blockSize, size;
450            getCompressedSize(_internalFormat, inwidth, inheight, 1, blockSize,size);
451
452            extensions->glCompressedTexSubImage3D(target, 0,
453                0, 0, indepth, 
454                inwidth, inheight, 1,
455                (GLenum)image->getPixelFormat(),
456                size,
457                image->data());
458        }
459
460    // we want to use mipmapping, so enable it
461    }else
462    {
463        // image does not provide mipmaps, so we have to create them
464        if(!image->isMipmap())
465        {
466            notify(WARN)<<"Warning: Texture2DArray::applyTexImage2DArray_subload(..) automagic mipmap generation is currently not implemented. Check texture's min/mag filters."<<std::endl;
467
468        // the image object does provide mipmaps, so upload the in the certain levels of a layer
469        }else
470        {
471            numMipmapLevels = image->getNumMipmapLevels();
472
473            int width  = image->s();
474            int height = image->t();
475           
476            for( GLsizei k = 0 ; k < numMipmapLevels  && (width || height ) ;k++)
477            {
478
479                if (width == 0)
480                    width = 1;
481                if (height == 0)
482                    height = 1;
483
484                extensions->glTexSubImage3D( target, k, 0, 0, indepth,
485                                          width, height, 1,
486                                          (GLenum)image->getPixelFormat(),
487                                          (GLenum)image->getDataType(),
488                                          image->getMipmapData(k));
489
490                width >>= 1;
491                height >>= 1;
492            }
493        }
494
495    }
496}
497
498
499void Texture2DArray::copyTexSubImage2DArray(State& state, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height )
500{
501    const unsigned int contextID = state.getContextID();
502    const Extensions* extensions = getExtensions(contextID,true);
503
504    // get the texture object for the current contextID.
505    TextureObject* textureObject = getTextureObject(contextID);
506
507    // if texture object is valid
508    if (textureObject != 0)
509    {
510        textureObject->bind();
511
512        applyTexParameters(GL_TEXTURE_2D_ARRAY_EXT,state);
513        extensions->glCopyTexSubImage3D( GL_TEXTURE_2D_ARRAY_EXT, 0, xoffset,yoffset,zoffset, x, y, width, height);
514
515        // inform state that this texture is the current one bound.
516        state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
517
518    }
519    else
520    {
521        notify(WARN)<<"Warning: Texture2DArray::copyTexSubImage2DArray(..) failed, cannot not copy to a non existant texture."<<std::endl;
522    }
523}
524
525void Texture2DArray::allocateMipmap(State& state) const
526{
527    const unsigned int contextID = state.getContextID();
528
529    // get the texture object for the current contextID.
530    TextureObject* textureObject = getTextureObject(contextID);
531   
532    if (textureObject && _textureWidth != 0 && _textureHeight != 0 && _textureDepth != 0)
533    {
534        const Extensions* extensions = getExtensions(contextID,true);
535        // const Texture::Extensions* texExtensions = Texture::getExtensions(contextID,true);
536       
537        // bind texture
538        textureObject->bind();
539
540        // compute number of mipmap levels
541        int width = _textureWidth;
542        int height = _textureHeight;
543        int numMipmapLevels = Image::computeNumberOfMipmapLevels(width, height);
544
545        // we do not reallocate the level 0, since it was already allocated
546        width >>= 1;
547        height >>= 1;
548       
549        for( GLsizei k = 1; k < numMipmapLevels  && (width || height); k++)
550        {
551            if (width == 0)
552                width = 1;
553            if (height == 0)
554                height = 1;
555
556            extensions->glTexImage3D( GL_TEXTURE_2D_ARRAY_EXT, k, _internalFormat,
557                     width, height, _textureDepth, _borderWidth,
558                     _sourceFormat ? _sourceFormat : _internalFormat,
559                     _sourceType ? _sourceType : GL_UNSIGNED_BYTE, NULL);
560
561            width >>= 1;
562            height >>= 1;
563        }
564               
565        // inform state that this texture is the current one bound.
566        state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);       
567    }
568}
569
570typedef buffered_value< ref_ptr<Texture2DArray::Extensions> > BufferedExtensions;
571static BufferedExtensions s_extensions;
572
573Texture2DArray::Extensions* Texture2DArray::getExtensions(unsigned int contextID,bool createIfNotInitalized)
574{
575    if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
576    return s_extensions[contextID].get();
577}
578
579void Texture2DArray::setExtensions(unsigned int contextID,Extensions* extensions)
580{
581    s_extensions[contextID] = extensions;
582}
583
584Texture2DArray::Extensions::Extensions(unsigned int contextID)
585{
586    setupGLExtensions(contextID);
587}
588
589Texture2DArray::Extensions::Extensions(const Extensions& rhs):
590    Referenced()
591{
592    _isTexture3DSupported = rhs._isTexture3DSupported;
593    _isTexture2DArraySupported = rhs._isTexture2DArraySupported;
594   
595    _max2DSize = rhs._max2DSize;
596    _maxLayerCount = rhs._maxLayerCount;
597   
598    _glTexImage3D = rhs._glTexImage3D;
599    _glTexSubImage3D = rhs._glTexSubImage3D;
600    _glCopyTexSubImage3D = rhs._glCopyTexSubImage3D;
601    _glCompressedTexImage3D = rhs._glCompressedTexImage3D;
602    _glCompressedTexSubImage3D = rhs._glCompressedTexSubImage3D;;
603}
604
605void Texture2DArray::Extensions::lowestCommonDenominator(const Extensions& rhs)
606{
607    if (!rhs._isTexture3DSupported)                 _isTexture3DSupported = false;
608    if (!rhs._isTexture2DArraySupported)            _isTexture2DArraySupported = false;
609    if (rhs._max2DSize<_max2DSize)                  _max2DSize = rhs._max2DSize;
610    if (rhs._maxLayerCount<_maxLayerCount)          _maxLayerCount = rhs._maxLayerCount;
611
612    if (!rhs._glTexImage3D)                         _glTexImage3D = 0;
613    if (!rhs._glTexSubImage3D)                      _glTexSubImage3D = 0;
614    if (!rhs._glCompressedTexImage3D)               _glTexImage3D = 0;
615    if (!rhs._glCompressedTexSubImage3D)            _glTexSubImage3D = 0;
616    if (!rhs._glCopyTexSubImage3D)                  _glCopyTexSubImage3D = 0;
617}
618
619void Texture2DArray::Extensions::setupGLExtensions(unsigned int contextID)
620{
621    _isTexture3DSupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture3D");
622    _isTexture2DArraySupported = OSG_GL3_FEATURES || isGLExtensionSupported(contextID,"GL_EXT_texture_array");
623
624    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_max2DSize);
625    glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &_maxLayerCount);
626
627    setGLExtensionFuncPtr(_glTexImage3D, "glTexImage3D","glTexImage3DEXT");
628    setGLExtensionFuncPtr(_glTexSubImage3D, "glTexSubImage3D","glTexSubImage3DEXT");
629    setGLExtensionFuncPtr(_glCompressedTexImage3D, "glCompressedTexImage3D","glCompressedTexImage3DARB");
630    setGLExtensionFuncPtr(_glCompressedTexSubImage3D, "glCompressedTexSubImage3D","glCompressedTexSubImage3DARB");
631    setGLExtensionFuncPtr(_glCopyTexSubImage3D, "glCopyTexSubImage3D","glCopyTexSubImage3DEXT");
632}
633
634void Texture2DArray::Extensions::glTexImage3D( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) const
635{
636    if (_glTexImage3D)
637    {
638        _glTexImage3D( target, level, internalFormat, width, height, depth, border, format, type, pixels);
639    }
640    else
641    {
642        notify(WARN)<<"Error: glTexImage3D not supported by OpenGL driver"<<std::endl;
643    }
644}
645
646void Texture2DArray::Extensions::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
647{
648    if (_glTexSubImage3D)
649    {
650        _glTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
651    }
652    else
653    {
654        notify(WARN)<<"Error: glTexSubImage3D not supported by OpenGL driver"<<std::endl;
655    }
656}
657
658void Texture2DArray::Extensions::glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) const
659{
660    if (_glCompressedTexImage3D)
661    {
662        _glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
663    }
664    else
665    {
666        notify(WARN)<<"Error: glCompressedTexImage3D not supported by OpenGL driver"<<std::endl;
667    }
668}
669
670void Texture2DArray::Extensions::glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ) const
671{
672    if (_glCompressedTexSubImage3D)
673    {
674        _glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
675    }
676    else
677    {
678        notify(WARN)<<"Error: glCompressedTexImage2D not supported by OpenGL driver"<<std::endl;
679    }
680}
681
682void Texture2DArray::Extensions::glCopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) const
683{
684    if (_glCopyTexSubImage3D)
685    {
686        _glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
687    }
688    else
689    {
690        notify(WARN)<<"Error: glCopyTexSubImage3D not supported by OpenGL driver"<<std::endl;
691    }
692}
Note: See TracBrowser for help on using the browser.