Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
TextureImpl Class Reference

The texture implementation supports 2D, cubemap, and 2D array textures. More...

#include <TextureGL.h>

Inherits Texture.

Public Member Functions

 TextureImpl (const TextureDesc &desc)
 TextureImpl (GLuint texture, uint32_t width, uint32_t height)
 Wraps an existing OpenGL texture object.
void updateData (const void *data, int width, int height, int level, int layerIndex) override
 Update a two-dimensional texture image.
void updateCompressedData (const void *data, int width, int height, size_t dataSize, int level, int layerIndex) override
 Update a two-dimensional texture image in a compressed format.
void updateSubData (int xoffset, int yoffset, int width, int height, int level, const void *data, int layerIndex) override
 Update a two-dimensional texture subimage.
void updateCompressedSubData (int xoffset, int yoffset, int width, int height, size_t dataSize, int level, const void *data, int layerIndex) override
 Update a two-dimensional texture subimage in a compressed format.
void updateFaceData (TextureCubeFace side, const void *data) override
 Update texutre cube data in give slice side.
void updateSamplerDesc (const SamplerDesc &sampler) override
 Update sampler.
void generateMipmaps ()
 Generate mipmaps.
void updateTextureDesc (const TextureDesc &descriptor) override
 Update texture description.
GLuint internalHandle () const
 Get internal texture object handle.
void apply (int slot) const
 Set texture to pipeline.
void ensureLevelStorage (int level)
 Allocate GPU storage for a specific mipmap level of a texture array.
Public Member Functions inherited from Texture
PixelFormat getPixelFormat () const
 Get texture format.
TextureUsage getTextureUsage () const
 Get texture usage.
TextureType getTextureType () const
 Get texture type.
bool hasMipmaps () const
 Check if mipmap had generated before.
void zeroTexData ()
 clear texture data to zero.
Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
void release ()
 Releases the ownership immediately.
Object * autorelease ()
 Releases the ownership sometime soon automatically.
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
uint64_t getObjectID () const noexcept
 Returns the process-local diagnostic identifier assigned at construction.
virtual ~Object ()
 Destructor.

Detailed Description

The texture implementation supports 2D, cubemap, and 2D array textures.

Constructor & Destructor Documentation

◆ TextureImpl() [1/2]

TextureImpl ( const TextureDesc & desc)
Parameters
descSpecifies the texture description.

◆ TextureImpl() [2/2]

TextureImpl ( GLuint texture,
uint32_t width,
uint32_t height )

Wraps an existing OpenGL texture object.

The caller retains ownership; this instance will not delete the texture on destruction.

Parameters
textureThe native GL texture handle.
widthWidth of the texture in pixels.
heightHeight of the texture in pixels.

Member Function Documentation

◆ updateData()

void updateData ( const void * data,
int width,
int height,
int level,
int layerIndex )
overridevirtual

Update a two-dimensional texture image.

Parameters
dataSpecifies a pointer to the image data in memory.
widthSpecifies the width of the texture image.
heightSpecifies the height of the texture image.
levelSpecifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap
layerIndexSpecifies the layer index for 2D array textures. reduction image.

Implements Texture.

◆ updateCompressedData()

void updateCompressedData ( const void * data,
int width,
int height,
size_t dataSize,
int level,
int layerIndex )
overridevirtual

Update a two-dimensional texture image in a compressed format.

Parameters
dataSpecifies a pointer to the compressed image data in memory.
widthSpecifies the width of the texture image.
heightSpecifies the height of the texture image.
dataSizeSpecifies the totoal size of compressed image in bytes.
levelSpecifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
layerIndexSpecifies the layer index for 2D array textures.

Implements Texture.

◆ updateSubData()

void updateSubData ( int xoffset,
int yoffset,
int width,
int height,
int level,
const void * data,
int layerIndex )
overridevirtual

Update a two-dimensional texture subimage.

Parameters
xoffsetSpecifies a texel offset in the x direction within the texture array.
yoffsetSpecifies a texel offset in the y direction within the texture array.
widthSpecifies the width of the texture subimage.
heightSpecifies the height of the texture subimage.
levelSpecifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
dataSpecifies a pointer to the image data in memory.
layerIndexSpecifies the layer index for 2D array textures.

Implements Texture.

◆ updateCompressedSubData()

void updateCompressedSubData ( int xoffset,
int yoffset,
int width,
int height,
size_t dataSize,
int level,
const void * data,
int layerIndex )
overridevirtual

Update a two-dimensional texture subimage in a compressed format.

Parameters
xoffsetSpecifies a texel offset in the x direction within the texture array.
yoffsetSpecifies a texel offset in the y direction within the texture array.
widthSpecifies the width of the texture subimage.
heightSpecifies the height of the texture subimage.
dataSizeSpecifies the totoal size of compressed subimage in bytes.
levelSpecifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
dataSpecifies a pointer to the compressed image data in memory.
layerIndexSpecifies the layer index for 2D array textures.

Implements Texture.

◆ updateFaceData()

void updateFaceData ( TextureCubeFace side,
const void * data )
overridevirtual

Update texutre cube data in give slice side.

Parameters
sideSpecifies which slice texture of cube to be update.
dataSpecifies a pointer to the image data in memory.

Implements Texture.

◆ updateSamplerDesc()

void updateSamplerDesc ( const SamplerDesc & sampler)
overridevirtual

Update sampler.

Parameters
samplerSpecifies the sampler descriptor.

Implements Texture.

◆ updateTextureDesc()

void updateTextureDesc ( const TextureDesc & descriptor)
overridevirtual

Update texture description.

Parameters
descriptorSpecifies texture and sampler descriptor.

Reimplemented from Texture.

◆ internalHandle()

GLuint internalHandle ( ) const
inline

Get internal texture object handle.

Returns
Texture object.

◆ apply()

void apply ( int slot) const

Set texture to pipeline.

Parameters
indexSpecifies the texture image unit selector.
targetGL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP

◆ ensureLevelStorage()

void ensureLevelStorage ( int level)

Allocate GPU storage for a specific mipmap level of a texture array.

Ensures that the given mipmap level has valid storage before updating with glTexSubImage3D, preventing GL_INVALID_OPERATION (0x502).

Note
For GL_TEXTURE_ARRAY (arraySize > 1):
  • Updating array elements must use glSubXXX with the zoffset parameter.
  • glSubXXX requires that storage for the target mipmap level be allocated in advance.
Parameters
levelMipmap level index to allocate.

The documentation for this class was generated from the following file:
  • TextureGL.h