Radium Engine
1.5.0
|
#include <Engine/Data/Texture.hpp>
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 TextureParameters & | getParameters () const |
get read access to texture parameters | |
TextureParameters & | getParameters () |
void | setParameters (const TextureParameters &textureParameters) |
Represent a Texture of the engine See TextureManager for information about how unique texture are defined.
Definition at line 86 of file Texture.hpp.
|
delete |
Textures are not copyable, delete copy constructor.
|
explicit |
Texture constructor. No OpenGL initialization is done there.
texParameters | Name of the texture |
Definition at line 16 of file Texture.cpp.
Ra::Engine::Data::Texture::~Texture | ( | ) |
Texture destructor. Both internal data and OpenGL stuff are deleted.
Definition at line 22 of file Texture.cpp.
void Ra::Engine::Data::Texture::bind | ( | int | unit = -1 | ) |
Bind the texture to enable its use in a shader.
Need active OpenGL context.
unit | Index of the texture to be bound. If -1 only calls glBindTexture. |
Definition at line 88 of file Texture.cpp.
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.
Definition at line 93 of file Texture.cpp.
|
inline |
Definition at line 197 of file Texture.hpp.
|
inline |
Definition at line 185 of file Texture.hpp.
|
inline |
Definition at line 151 of file Texture.hpp.
|
inline |
get read/write access to texture parameters, need to update representation afterward,
Definition at line 226 of file Texture.hpp.
|
inline |
Definition at line 193 of file Texture.hpp.
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.
linearize | (default false) : convert the texture from sRGB to Linear RGB color space before OpenGL initialisation |
Definition at line 28 of file Texture.cpp.
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.
|
delete |
Textures are not copyable, delete operator =.
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.
w | width of the texture |
h | height of the texture |
d | depth of the texture |
pix | the new texels array corresponding the the new texture dimension |
Definition at line 313 of file Texture.cpp.
|
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.
|
inline |
Definition at line 203 of file Texture.hpp.
void Ra::Engine::Data::Texture::updateData | ( | void * | newData | ) |
Update the cpu representation of data contained by the texture
newData | user 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.
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.
|
inline |
Definition at line 189 of file Texture.hpp.