Texture.hh 19.1 KB
Newer Older
1
2
3
4
5
/***********************************************************************
 * Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
 * All rights reserved.                                                *
 * Distributed under the terms of the MIT License (see LICENSE.TXT).   *
 **********************************************************************/
Robert Menzel's avatar
Robert Menzel committed
6

7
8
#ifndef ACGL_OPENGL_OBJECTS_TEXTURE_HH
#define ACGL_OPENGL_OBJECTS_TEXTURE_HH
Robert Menzel's avatar
Robert Menzel committed
9

Robert Menzel's avatar
Robert Menzel committed
10
/**
Robert Menzel's avatar
Robert Menzel committed
11
12
13
14
 * A Texture wrapps the OpenGL texture. To fill these with data from image files a
 * matching TextureControllerFile* is needed.
 */

Robert Menzel's avatar
Robert Menzel committed
15
16
#include <ACGL/ACGL.hh>

17
#include <ACGL/Base/Macros.hh>
Robert Menzel's avatar
Robert Menzel committed
18
19
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh>
Janis Born's avatar
Janis Born committed
20
#include <ACGL/OpenGL/Data/TextureData.hh>
Robert Menzel's avatar
Robert Menzel committed
21
22
23
24
25
#include <ACGL/Math/Math.hh>

#include <vector>

namespace ACGL{
Robert Menzel's avatar
Robert Menzel committed
26
namespace OpenGL{
Robert Menzel's avatar
Robert Menzel committed
27

28
29
30
31
32
33
34
// the combination of Image and SharedTextureBase will identify a Rendertarget etc.:
struct Image {
    Image() : mipmapLevel(0), layer(0), cubeMapFace(GL_INVALID_ENUM) {}
    unsigned int      mipmapLevel; // always 0 if texture has no mipmaps
    unsigned int      layer;       // array layer or slice in a 3D texture, always 0 if texture is 1D or 2D
    GLenum            cubeMapFace; // GL_INVALID_ENUM if texture is not a cube map
};
Robert Menzel's avatar
Robert Menzel committed
35

Robert Menzel's avatar
Robert Menzel committed
36
/**
Robert Menzel's avatar
Robert Menzel committed
37
38
39
40
41
42
43
 * A Texture consists of:
 *   1. 1..N Images (e.g. mipmap layers)
 *   2. an internal data format (datatype and number of channels on the GPU)
 *   3. a sampling mode (alternatively a sampler object can be used)
 *
 * The TextureBase class holds the methods to define 2 & 3, the Images (incl. getter and setter)
 * vary between different texture types, so subclasses will take care if that.
Robert Menzel's avatar
Robert Menzel committed
44
 *
Robert Menzel's avatar
Robert Menzel committed
45
46
47
48
49
50
51
52
53
 * Every subclass of TextureBase has:
   * A constructor which defines the internal format (data layout in GPU memory)
     (this can't be changed later)
   * A constructor that reserves memory for a certain texture size.
   * A setImageData with a SharedTextureData and optinally additional parameters
     about which layer/mipmap-level/slice etc. should be set

 * Some might also have:
   * A resize function which differs in the dimensionality from subclass to subclass.
Robert Menzel's avatar
Robert Menzel committed
54
 */
Robert Menzel's avatar
Robert Menzel committed
55
class TextureBase
Robert Menzel's avatar
Robert Menzel committed
56
{
Robert Menzel's avatar
Robert Menzel committed
57
    ACGL_NOT_COPYABLE(TextureBase)
Robert Menzel's avatar
Robert Menzel committed
58
59
60
61
62

    // ========================================================================================================= \/
    // ============================================================================================ CONSTRUCTORS \/
    // ========================================================================================================= \/
public:
63
64
65
66
    //!
    /*!
        Default texture parameters taken from: http://www.opengl.org/sdk/docs/man/xhtml/glTexParameter.xml
     */
Robert Menzel's avatar
Robert Menzel committed
67
    TextureBase(GLenum _target)
68
    :   mObjectName(0),
69
        mTarget(_target),
Robert Menzel's avatar
Robert Menzel committed
70
        mWidth(0),
71
72
        mHeight(1),
        mDepth(1),
73
        mInternalFormat(GL_RGBA)
Robert Menzel's avatar
Robert Menzel committed
74
    {
75
        glGenTextures(1, &mObjectName);
76
77
78
        if (openGLCriticalErrorOccured() ) {
            ACGL::Utils::error() << "could not generate texture!" << std::endl;
        }
Robert Menzel's avatar
Robert Menzel committed
79
80
    }

81
82
83
84
85
86
87
88
89
90
91
92
93
94
    TextureBase(GLenum _target, GLenum _internalFormat)
    :   mObjectName(0),
        mTarget(_target),
        mWidth(0),
        mHeight(1),
        mDepth(1),
        mInternalFormat(_internalFormat)
    {
        glGenTextures(1, &mObjectName);
        if (openGLCriticalErrorOccured() ) {
            ACGL::Utils::error() << "could not generate texture!" << std::endl;
        }
    }

Robert Menzel's avatar
Robert Menzel committed
95
    virtual ~TextureBase(void)
Robert Menzel's avatar
Robert Menzel committed
96
    {
97
98
        // object name 0 will get ignored by OpenGL
        glDeleteTextures(1, &mObjectName);
Robert Menzel's avatar
Robert Menzel committed
99
100
101
102
103
104
    }

    // ==================================================================================================== \/
    // ============================================================================================ GETTERS \/
    // ==================================================================================================== \/
public:
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    inline GLuint     getObjectName     (void) const { return mObjectName;     }
    inline GLenum     getTarget         (void) const { return mTarget;         }
    inline GLsizei    getWidth          (void) const { return mWidth;          }
    inline GLsizei    getHeight         (void) const { return mHeight;         }
    inline GLsizei    getDepth          (void) const { return mDepth;          }
    inline GLenum     getInternalFormat (void) const { return mInternalFormat; }
    inline GLint      getMinFilter      (void) const { return getParameterI(GL_TEXTURE_MIN_FILTER); }
    inline GLint      getMagFilter      (void) const { return getParameterI(GL_TEXTURE_MAG_FILTER); }
    inline GLint      getBaseLevel      (void) const { return getParameterI(GL_TEXTURE_BASE_LEVEL); }
    inline GLint      getMaxLevel       (void) const { return getParameterI(GL_TEXTURE_MAX_LEVEL); }
    inline GLint      getMinLOD         (void) const { return getParameterI(GL_TEXTURE_MIN_LOD); }
    inline GLint      getMaxLOD         (void) const { return getParameterI(GL_TEXTURE_MAX_LOD); }
    inline GLfloat    getLODBias        (void) const { return getParameterF(GL_TEXTURE_LOD_BIAS); }
    inline GLenum     getCompareMode    (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_MODE); }
    inline GLenum     getCompareFunc    (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_FUNC); }
    inline glm::vec4  getBorderColor    (void) const { return getParameter4F(GL_TEXTURE_BORDER_COLOR); }
121
    #ifndef ACGL_OPENGLES_VERSION_20
122
123
124
    inline GLenum     getWrapS          (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_S); }
    inline GLenum     getWrapT          (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_T); }
    inline GLenum     getWrapR          (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_R); }
125
    #endif // ACGL_OPENGLES_VERSION_20
126
    inline glm::uvec3 getSize           (void) const { return glm::uvec3( mWidth, mHeight, mDepth ); }
127

Robert Menzel's avatar
Robert Menzel committed
128
129
130
131
    // ===================================================================================================== \/
    // ============================================================================================ WRAPPERS \/
    // ===================================================================================================== \/
public:
Robert Menzel's avatar
Robert Menzel committed
132
    //! Activate texture unit and bind this texture to it. _textureUnit starts at 0!
133
    inline void bind(GLuint _textureUnit) const
Robert Menzel's avatar
Robert Menzel committed
134
135
    {
        glActiveTexture(GL_TEXTURE0 + _textureUnit);
136
        glBindTexture(mTarget, mObjectName);
137
        openGLRareError();
Robert Menzel's avatar
Robert Menzel committed
138
    }
Robert Menzel's avatar
Robert Menzel committed
139
140

    //! Bind this texture to the currently active texture unit.
Robert Menzel's avatar
Robert Menzel committed
141
142
    inline void bind(void) const
    {
143
        glBindTexture(mTarget, mObjectName);
144
        openGLRareError();
Robert Menzel's avatar
Robert Menzel committed
145
146
    }

147
148
    //! sets the minification filter
    void setMinFilter(GLint _value = GL_NEAREST_MIPMAP_LINEAR );
Robert Menzel's avatar
Robert Menzel committed
149

150
151
    //! sets the magnification filter
    void setMagFilter(GLint _value = GL_LINEAR);
Robert Menzel's avatar
Robert Menzel committed
152

Robert Menzel's avatar
Robert Menzel committed
153
154
155
156
#ifndef ACGL_OPENGLES_VERSION_20
    void setWrapS( GLenum _wrapS = GL_REPEAT );
    void setWrapT( GLenum _wrapT = GL_REPEAT );
    void setWrapR( GLenum _wrapR = GL_REPEAT );
157

Robert Menzel's avatar
Robert Menzel committed
158
    //! Note: The function will bind this texture!
Robert Menzel's avatar
Robert Menzel committed
159
    void setWrap(GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0);
Robert Menzel's avatar
Robert Menzel committed
160
#endif
161

162
163
164
165
166
167
    //! lowest defined mipmap level
    void setBaseLevel(  GLint _level = -1000 );

    //! highest defined mipmap level
    void setMaxLevel(  GLint _level =  1000 );

168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
    //! lowest mipmap level to use
    void setMinLOD(  GLint _lod = -1000 );

    //! highest mipmap level to use
    void setMaxLOD(  GLint _lod =  1000 );

    //! offset to add to the mipmap level calculation
    void setLODBias( GLfloat _bias = 0.0f );

    //! for usage of a texture with depth data
    void setCompareMode( GLenum _mode = GL_NONE );

    //! for usage of a texture with depth data
    void setCompareFunc( GLenum _func = GL_LEQUAL );

183
184
185
    //! color that is sampled outside range if wrap is set to GL_CLAMP_TO_BORDER
    void setBorderColor(const glm::vec4& _color = glm::vec4(0.0));

186
    //! _sampleCount = 1.0 to deactivate anisotrop filtering, maximum is often 16. If a value is too high it will get clamped to the maximum
Robert Menzel's avatar
Robert Menzel committed
187
    void setAnisotropicFilter( GLfloat _sampleCount );
188

Robert Menzel's avatar
Robert Menzel committed
189
190
191
    //! Generate mipmaps from the current base texture (i.e. the texture from level 0)
    void generateMipmaps(void);

Janis Born's avatar
Janis Born committed
192
193
194
195
196
    void resize(const glm::uvec3& _size) { resizeI(glm::uvec3(_size.x, _size.y, _size.z)); }
    void resize(const glm::uvec2& _size) { resizeI(glm::uvec3(_size.x, _size.y, 1      )); }
    void resize(const glm::uvec1& _size) { resizeI(glm::uvec3(_size.x, 1,       1      )); }
    void resize(      GLuint      _size) { resizeI(glm::uvec3(_size,   1,       1      )); }

197
198
199
200
201
202
203
204
#ifndef ACGL_OPENGLES_VERSION_20
    //! get one texture image:
    TextureData *getTextureImageRAW( const Image &_image = Image(), GLenum _format = GL_RGBA, GLenum _type = GL_UNSIGNED_BYTE ) const;
    SharedTextureData getTextureImage( const Image &_image = Image(), GLenum _format = GL_RGBA, GLenum _type = GL_UNSIGNED_BYTE ) const {
        return SharedTextureData( getTextureImageRAW(_image, _format, _type) );
    }
#endif // ES 2

Robert Menzel's avatar
Robert Menzel committed
205
206
207
208
209
210
211
212
    // =================================================================================================== \/
    // ============================================================================================ FIELDS \/
    // =================================================================================================== \/
protected:
    GLuint  mObjectName;

    // kind of texture data:
    GLenum  mTarget;
Robert Menzel's avatar
Robert Menzel committed
213
214
215
    GLsizei mWidth;  // width
    GLsizei mHeight; // height or 1 in case of a 1D texture
    GLsizei mDepth;  // depth or #of layer in a 2D array, 1 otherwise
216
    GLenum  mInternalFormat; // often used, so store it here
Robert Menzel's avatar
Robert Menzel committed
217

218
219
220
221
222
    // Checks what texture is currently bound at the texture target used by this texture
    // to be later used to restore that texture (to be side effect free). Then binds this texture.
    GLuint bindAndGetOldTexture() const;

    // generic get parameter functions:
223
224
225
    GLint     getParameterI ( GLenum _name ) const;
    GLfloat   getParameterF ( GLenum _name ) const;
    glm::vec4 getParameter4F( GLenum _name ) const;
226
227
228
229
230

    //! returns a format compatible with the internal, only used to
    //! reserve memory, not to upload actual data!
    GLenum getCompatibleFormat( GLenum _internalFormat );
    GLenum getCompatibleType(   GLenum _internalFormat );
231
232
233
234
235


    //! to be used by subclasses, will not check if usage is meaningfull for the
    //! texture target, this has to be checked by the subclass (this is why this
    //! function is private here)
236
237
238
    void texImage1D( const SharedTextureData &_data, GLint _mipmapLevel );
    void texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset = 0 );

239
    void texImage2D( const SharedTextureData &_data, GLint _mipmapLevel );
Robert Menzel's avatar
Robert Menzel committed
240
    void texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset = glm::uvec2(0) );
241
242

    void texImage3D( const SharedTextureData &_data, GLint _mipmapLevel );
Robert Menzel's avatar
Robert Menzel committed
243
    void texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset = glm::uvec3(0) );
244
245
246
247

    //! returns true if space for the texture was allocated
    bool textureStorageIsAllocated()
    {
Robert Menzel's avatar
Robert Menzel committed
248
        return (mWidth != 0);
249
    }
Janis Born's avatar
Janis Born committed
250
251
252

    //! Resizes the texture. Subclasses implementing this method may use only use the first entries of _size if they are of lower dimension
    virtual void resizeI(const glm::uvec3& _size) = 0;
Robert Menzel's avatar
Robert Menzel committed
253
254
255
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureBase)

256
// missing classes:
257
// GL_TEXTURE_1D                        x
258
// GL_TEXTURE_2D                        x
Robert Menzel's avatar
Robert Menzel committed
259
260
// GL_TEXTURE_3D                        x
// GL_TEXTURE_1D_ARRAY                  x
261
262
// GL_TEXTURE_2D_ARRAY                  x
// GL_TEXTURE_RECTANGLE                 x
263
264
// GL_TEXTURE_2D_MULTISAMPLE
// GL_TEXTURE_2D_MULTISAMPLE_ARRAY
265
// GL_TEXTURE_BINDING_CUBE_MAP          x
266
267
// GL_TEXTURE_BINDING_CUBE_MAP_ARRAY

Robert Menzel's avatar
Robert Menzel committed
268
269
270
271
272
273
274
/**
 * In contrast to 'normal' textures these can't have mipmaps and are accessed in the shader by
 * pixel-coordinates instead of texture coordinates from 0 to 1.
 * Ths makes them a good choice for multiple renderpasses (no mipmaps needed and texture access
 * can be done via gl_FragCoord).
 * For all other cases use Texture2D.
 */
275
276
277
class TextureRectangle : public TextureBase
{
public:
278
    TextureRectangle( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_RECTANGLE, _internalFormat )
279
    {
280
        setMinFilter( GL_LINEAR ); // default would be MipMapped but that's not supported for Rect Textures!
281
282
    }

283
    TextureRectangle( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_RECTANGLE, _internalFormat )
284
    {
285
        setMinFilter( GL_LINEAR ); // default would be MipMapped but that's not supported for Rect Textures!
286
287
288
289
        resize( _size );
    }

    //! sets the content to the given TextureData, might resize the texture
290
    void setImageData( const SharedTextureData &_data );
291

292
protected:
293
294
    //! content of the texture is undefined after this, this texture will be bound to the active binding point
    //! nothing should be bound to the pixel unpack buffer when calling this
Janis Born's avatar
Janis Born committed
295
    void resizeI( const glm::uvec3 &_newSize );
296
297
298
299
300
301

private:
    void generateMipmaps(void) { ACGL::Utils::error() << "Rectangle Textures don't support MipMaps!" << std::endl; }
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureRectangle)

302

Robert Menzel's avatar
Robert Menzel committed
303
304
305
306
307
308
/**
 * 1D textures.
 * can be used as general purpose data for a shader if texture filtering is wanted, otherwise look
 * at TextureBuffers!
 * 1D textures can have mipmaps, TextureBuffers can't.
 */
309
310
311
312
313
314
315
316
317
318
319
320
class Texture1D : public TextureBase
{
public:
    Texture1D( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D, _internalFormat ) {}
    Texture1D( const uint32_t _size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D, _internalFormat )
    {
        resize( _size );
    }

    //! sets the content to the given TextureData, might resize the texture
    void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );

321
protected:
322
323
    //! content of the texture is undefined after this, this texture will be bound to the active binding point
    //! nothing should be bound to the pixel unpack buffer when calling this
Janis Born's avatar
Janis Born committed
324
    void resizeI( const glm::uvec3 &_newSize );
325
326
327
328
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1D)


Robert Menzel's avatar
Robert Menzel committed
329
330
331
/**
 * "Normal" 2D texture.
 */
332
333
334
class Texture2D : public TextureBase
{
public:
335
336
337
338
339
    Texture2D( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D, _internalFormat ) {}
    Texture2D( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D, _internalFormat )
    {
        resize( _size );
    }
340

341
    //! sets the content to the given TextureData, might resize the texture
342
    void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
343

344
protected:
345
346
    //! content of the texture is undefined after this, this texture will be bound to the active binding point
    //! nothing should be bound to the pixel unpack buffer when calling this
Janis Born's avatar
Janis Born committed
347
    void resizeI( const glm::uvec3 &_newSize );
348
349
350
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture2D)

351
352


Robert Menzel's avatar
Robert Menzel committed
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/**
 * 3D volume texture.
 */
class Texture3D : public TextureBase
{
public:
    Texture3D( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_3D, _internalFormat ) {}
    Texture3D( const glm::uvec3 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_3D, _internalFormat )
    {
        resize( _size );
    }

    //! sets the content of one slice to the given TextureData
    void setImageData( const SharedTextureData &_data, uint32_t _slice, uint32_t _mipmapLayer );

    //! sets the content of all slices to the given TextureData
    void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );

371
protected:
Robert Menzel's avatar
Robert Menzel committed
372
373
    //! content of the texture is undefined after this, this texture will be bound to the active binding point
    //! nothing should be bound to the pixel unpack buffer when calling this
Janis Born's avatar
Janis Born committed
374
    void resizeI( const glm::uvec3 &_newSize );
Robert Menzel's avatar
Robert Menzel committed
375
376
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture3D)
377
378


Robert Menzel's avatar
Robert Menzel committed
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/**
 * Array of 1D textures, technically a 2D texture but without filtering between array layers.
 */
class Texture1DArray : public TextureBase
{
public:
    Texture1DArray( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D_ARRAY, _internalFormat ) {}
    Texture1DArray( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D_ARRAY, _internalFormat )
    {
        resize( _size );
    }

    //! sets the content to the given TextureData to one layer of the texture
    void setImageData( const SharedTextureData &_data, uint32_t _layer, uint32_t _mipmapLayer );

    //! sets the content to the given TextureData to fill all layers
    void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );

397
protected:
Robert Menzel's avatar
Robert Menzel committed
398
399
    //! content of the texture is undefined after this, this texture will be bound to the active binding point
    //! nothing should be bound to the pixel unpack buffer when calling this
Janis Born's avatar
Janis Born committed
400
    void resizeI( const glm::uvec3 &_newSize );
Robert Menzel's avatar
Robert Menzel committed
401
402
403
404
405
406
407
408
409
410
411
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1DArray)


/**
 * A "stack" of 2D textures. Each must have the same size.
 * Can be used to access many texture in a shader without having to deal with the
 * texture unit limit.
 * Technically a 3D texture but there is no filtering in between the levels (Z-axis of
 * the 3D texture).
 */
412
413
414
class Texture2DArray : public TextureBase
{
public:
415
416
417
418
419
420
421
    Texture2DArray( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D_ARRAY, _internalFormat ) {}
    Texture2DArray( const glm::uvec3 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D_ARRAY, _internalFormat )
    {
        resize( _size );
    }

    //! sets the content to the given TextureData, might resize the texture
422
    void setImageData( const SharedTextureData &_data, uint32_t _arrayLayer = 0, uint32_t _mipmapLayer = 0 );
423

424
protected:
425
426
    //! content of the texture is undefined after this, this texture will be bound to the active binding point
    //! nothing should be bound to the pixel unpack buffer when calling this
Janis Born's avatar
Janis Born committed
427
    void resizeI( const glm::uvec3 &_newSize );
428
429
430
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture2DArray)

431

Robert Menzel's avatar
Robert Menzel committed
432
433
434
/**
 * For environmant mapping.
 */
435
436
437
class TextureCubeMap : public TextureBase
{
public:
Robert Menzel's avatar
Robert Menzel committed
438
439
    TextureCubeMap( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_CUBE_MAP, _internalFormat ) {}
    TextureCubeMap( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_CUBE_MAP, _internalFormat )
440
441
442
443
444
    {
        resize( _size );
    }

    //! sets the content to the given TextureData, might resize the texture
445
    void setImageData( const SharedTextureData &_data, GLenum _cubeSide, uint32_t _mipmapLayer = 0 );
446

447
protected:
448
449
    //! content of the texture is undefined after this, this texture will be bound to the active binding point
    //! nothing should be bound to the pixel unpack buffer when calling this
Janis Born's avatar
Janis Born committed
450
    void resizeI( const glm::uvec3 &_newSize );
451
452
453
454
455
456
457
458
459
460

private:
    bool cubeSideIsValid( const GLenum _cubeSide ) const;
    void texImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel );
    void texSubImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel, glm::ivec2 _offset = glm::ivec2(0) );
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureCubeMap)



Robert Menzel's avatar
Robert Menzel committed
461
} // OpenGL
Robert Menzel's avatar
Robert Menzel committed
462
463
} // ACGL

464
#endif // ACGL_OPENGL_OBJECTS_TEXTURE_HH