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

Revision 10924, 25.3 kB (checked in by robert, 4 years ago)

Refactored the way that osg::Image/ImageSequence manages the update callback that needs to be attached to Textures to make it possible to use the Image::update() mechansim in other subclasses from osg::Image.
To enable the automatic attachment of the required update callback to call osg::Image::update(..) subclasses from osg::Image will
need to implement the osg::Image::requestUpdateCall() and return true, and implement the osg::Image::update(NodeVisitor?*) method to recieve the update call during the update traversal.

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