Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | List of all members
Texture Class Reference

Represents a texture containing one or more images, stored on the CPU and/or GPU. More...

#include <Texture.hpp>

Public Member Functions

 Texture (const std::string &name)
 
void upload (const Layout &layout, bool updateMipmaps)
 
void clearImages ()
 
void allocateImages (uint channels, uint firstMip=0, uint mipCount=0xFFFFFFFF)
 
void clean ()
 
glm::vec3 sampleCubemap (const glm::vec3 &dir) const
 
void setupAsDrawable (const Layout &layout, uint width, uint height, TextureShape shape=TextureShape::D2, uint mips=1, uint depth=1)
 
void resize (const glm::vec2 &resolution)
 
void resize (uint w, uint h)
 
const std::string & name () const
 
uint getMaxMipLevel () const
 
Textureoperator= (const Texture &)=delete
 
 Texture (const Texture &)=delete
 
Textureoperator= (Texture &&)=default
 
 Texture (Texture &&)
 

Public Attributes

std::vector< Imageimages
 The images CPU data (optional).
 
std::unique_ptr< GPUTexturegpu
 The GPU data (optional).
 
uint width = 0
 The texture width.
 
uint height = 0
 The texture height.
 
uint depth = 1
 The texture depth.
 
uint levels = 1
 The mipmap count.
 
TextureShape shape = TextureShape::D2
 Texure type.
 
Layout format = Layout::NONE
 Layout used.
 
bool drawable = false
 Can the texture be rendered to.
 

Private Attributes

std::string _name
 Resource name.
 

Detailed Description

Represents a texture containing one or more images, stored on the CPU and/or GPU.

Constructor & Destructor Documentation

◆ Texture() [1/3]

Texture::Texture ( const std::string &  name)

Constructor.

Parameters
namethe texture identifier

◆ Texture() [2/3]

Texture::Texture ( const Texture )
delete

Copy constructor (disabled).

◆ Texture() [3/3]

Texture::Texture ( Texture &&  )
default

Move constructor.

Member Function Documentation

◆ allocateImages()

void Texture::allocateImages ( uint  channels,
uint  firstMip = 0,
uint  mipCount = 0xFFFFFFFF 
)

Allocate the CPU images in the mip range defined as input. Images outside the given range will be left untouched if present, or created empty if not.

Parameters
channelsthe number of channels for each image
firstMipthe first mip to allocate images for
mipCountthe number of mip to allocate, up to the texture level count

◆ clean()

void Texture::clean ( )

Cleanup all data.

Note
The dimensions and shape of the texture are preserved.

◆ clearImages()

void Texture::clearImages ( )

Clear CPU images data.

◆ getMaxMipLevel()

uint Texture::getMaxMipLevel ( ) const

Compute the maximum possible mipmap level based on the texture type and dimensions.

Returns
the maximum level

◆ name()

const std::string & Texture::name ( ) const

Get the resource name.

Returns
the name.

◆ operator=() [1/2]

Texture & Texture::operator= ( const Texture )
delete

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ operator=() [2/2]

Texture & Texture::operator= ( Texture &&  )
default

Move assignment operator .

Returns
a reference to the object assigned to

◆ resize() [1/2]

void Texture::resize ( const glm::vec2 &  resolution)

Resize the GPU texture

Parameters
resolutionthe new texture size

◆ resize() [2/2]

void Texture::resize ( uint  w,
uint  h 
)

Resize the GPU texture

Parameters
wthe new texture width
hthe new texture height

◆ sampleCubemap()

glm::vec3 Texture::sampleCubemap ( const glm::vec3 &  dir) const

Bilinearly sample a cubemap in a given direction.

Parameters
dirthe direction to sample
Returns
the sampled color.

◆ setupAsDrawable()

void Texture::setupAsDrawable ( const Layout layout,
uint  width,
uint  height,
TextureShape  shape = TextureShape::D2,
uint  mips = 1,
uint  depth = 1 
)

Configure and allocate a texture to be used as a rendering attachment.

Parameters
layoutthe pixel format to use
widththe texture width
heightthe texture height
shapethe shape of the texture
mipsthe number of mips
depththe number of layers for array and 3D textures

◆ upload()

void Texture::upload ( const Layout layout,
bool  updateMipmaps 
)

Send to the GPU.

Parameters
layoutthe data layout and type to use for the texture
updateMipmapsgenerate the mipmaps automatically

The documentation for this class was generated from the following files: