Radium Engine  1.5.0
Ra::Engine::Data::Texture Class Referencefinal

#include <Engine/Data/Texture.hpp>

+ Collaboration diagram for Ra::Engine::Data::Texture:

Public Member Functions

 Texture (const Texture &)=delete
 
void operator= (const Texture &)=delete
 
 Texture (const TextureParameters &texParameters)
 
 ~Texture ()
 
void initializeGL (bool linearize=false)
 Generate the OpenGL representation of the texture according to the stored TextureData. More...
 
void bind (int unit=-1)
 Bind the texture to enable its use in a shader. More...
 
void bindImageTexture (int unit, GLint level, GLboolean layered, GLint layer, GLenum access)
 Bind the texture to an image unit for the purpose of reading and writing it from shaders. More...
 
std::string getName () const
 
void updateData (void *newData)
 
void updateParameters ()
 
void linearize ()
 
GLenum format () const
 
size_t width () const
 
size_t height () const
 
size_t depth () const
 
void * texels ()
 
globjects::Texture * texture () const
 
void resize (size_t w=1, size_t h=1, size_t d=1, void *pix=nullptr)
 
const TextureParametersgetParameters () const
 get read access to texture parameters
 
TextureParametersgetParameters ()
 
void setParameters (const TextureParameters &textureParameters)
 

Detailed Description

Represent a Texture of the engine See TextureManager for information about how unique texture are defined.

Definition at line 86 of file Texture.hpp.

Constructor & Destructor Documentation

◆ Texture() [1/2]

Ra::Engine::Data::Texture::Texture ( const Texture )
delete

Textures are not copyable, delete copy constructor.

◆ Texture() [2/2]

Ra::Engine::Data::Texture::Texture ( const TextureParameters texParameters)
explicit

Texture constructor. No OpenGL initialization is done there.

Parameters
texParametersName of the texture

Definition at line 16 of file Texture.cpp.

◆ ~Texture()

Ra::Engine::Data::Texture::~Texture ( )

Texture destructor. Both internal data and OpenGL stuff are deleted.

Definition at line 22 of file Texture.cpp.

Member Function Documentation

◆ bind()

void Ra::Engine::Data::Texture::bind ( int  unit = -1)

Bind the texture to enable its use in a shader.

Need active OpenGL context.

Parameters
unitIndex of the texture to be bound. If -1 only calls glBindTexture.

Definition at line 88 of file Texture.cpp.

◆ bindImageTexture()

void Ra::Engine::Data::Texture::bindImageTexture ( int  unit,
GLint  level,
GLboolean  layered,
GLint  layer,
GLenum  access 
)

Bind the texture to an image unit for the purpose of reading and writing it from shaders.

Need active OpenGL context.

Note
, only available since openGL 4.2, not available on MacOs uses m_parameters.internalFormat as format. see https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindImageTexture.xhtml for documentation

Definition at line 93 of file Texture.cpp.

◆ depth()

size_t Ra::Engine::Data::Texture::depth ( ) const
inline
Returns
the depth of the texture

Definition at line 197 of file Texture.hpp.

◆ format()

GLenum Ra::Engine::Data::Texture::format ( ) const
inline
Returns
the pixel format of the texture

Definition at line 185 of file Texture.hpp.

◆ getName()

std::string Ra::Engine::Data::Texture::getName ( ) const
inline
Returns
Name of the texture.

Definition at line 151 of file Texture.hpp.

◆ getParameters()

TextureParameters& Ra::Engine::Data::Texture::getParameters ( )
inline

get read/write access to texture parameters, need to update representation afterward,

See also
setParameters()

Definition at line 226 of file Texture.hpp.

◆ height()

size_t Ra::Engine::Data::Texture::height ( ) const
inline
Returns
the height of the texture

Definition at line 193 of file Texture.hpp.

◆ initializeGL()

void Ra::Engine::Data::Texture::initializeGL ( bool  linearize = false)

Generate the OpenGL representation of the texture according to the stored TextureData.

Need active OpenGL context.

This method use the available m_textureParameters to generate and configure OpenGL texture.

Before uploading texels to the GPU, this method will apply RGB space conversion if needed.

Parameters
linearize(default false) : convert the texture from sRGB to Linear RGB color space before OpenGL initialisation
Note
This will become soon the only way to generate an Radium Engine OpenGL texture.

Definition at line 28 of file Texture.cpp.

+ Here is the call graph for this function:

◆ linearize()

void Ra::Engine::Data::Texture::linearize ( )

Convert a color texture from sRGB to Linear RGB spaces. This will transform the internal representation of the texture to GL_SCALAR (GL_FLOAT). Only GL_RGB[8, 16, 16F, 32F] and GL_RGBA[8, 16, 16F, 32F] are managed. Full transformation as described at https://en.wikipedia.org/wiki/SRGB

Definition at line 259 of file Texture.cpp.

◆ operator=()

void Ra::Engine::Data::Texture::operator= ( const Texture )
delete

Textures are not copyable, delete operator =.

◆ resize()

void Ra::Engine::Data::Texture::resize ( size_t  w = 1,
size_t  h = 1,
size_t  d = 1,
void *  pix = nullptr 
)

Resize the texture.

Need active OpenGL context.

This allocate GPU memory to store the new resized texture and, if texels are not nullptr, upload the new content.

Note
: If texels are not nullptr, user must ensure the texels array is correctly dimensioned.
Parameters
wwidth of the texture
hheight of the texture
ddepth of the texture
pixthe new texels array corresponding the the new texture dimension

Definition at line 313 of file Texture.cpp.

+ Here is the call graph for this function:

◆ setParameters()

void Ra::Engine::Data::Texture::setParameters ( const TextureParameters textureParameters)
inline

set TextureParameters. If texels is changed, need to call initializeGL() to update GPU representation if only wrap or filter parameters are change, updateParameters() is sufficient to update the GPU representation.

Definition at line 233 of file Texture.hpp.

◆ texture()

globjects::Texture* Ra::Engine::Data::Texture::texture ( ) const
inline
Returns
the globjects::Texture associated with the texture

Definition at line 203 of file Texture.hpp.

◆ updateData()

void Ra::Engine::Data::Texture::updateData ( void *  newData)

Update the cpu representation of data contained by the texture

Parameters
newDatauser image pointer to wrap, must contain the same number of elements than old data (no test perform). Texture use here existing pixel memory owned by the calling application. The texture does not own the pixel storage and will not free/delete that memory, even when the texture is destroyed.

Definition at line 216 of file Texture.cpp.

+ Here is the call graph for this function:

◆ updateParameters()

void Ra::Engine::Data::Texture::updateParameters ( )

Update the parameters contained by the texture.

Need active OpenGL context.

User first modify the public attributes corresponding to the parameter he wants to change the value (e.g wrap* or *Filter) and call this function to update the OpenGL texture state ...

Definition at line 234 of file Texture.cpp.

◆ width()

size_t Ra::Engine::Data::Texture::width ( ) const
inline
Returns
the width of the texture

Definition at line 189 of file Texture.hpp.


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