3#include <Core/Tasks/TaskQueue.hpp>
4#include <Core/Utils/Color.hpp>
5#include <Engine/OpenGL.hpp>
6#include <Engine/RaEngine.hpp>
24 GLenum
wrapS { GL_CLAMP_TO_EDGE };
26 GLenum
wrapT { GL_CLAMP_TO_EDGE };
28 GLenum
wrapR { GL_CLAMP_TO_EDGE };
46 template <
typename TexelType>
48 return std::holds_alternative<TexelType>( texels );
53 return std::get<ImageType>( texels );
55 void setImage(
ImageType image ) { texels = image; }
67 return std::get<CubeMapType>( texels );
69 void setCubeMap( CubeMapType cubeMap ) { texels = cubeMap; }
71 GLenum target { GL_TEXTURE_2D };
75 GLenum format { GL_RGB };
78 GLenum type { GL_UNSIGNED_BYTE };
81 std::variant<ImageType, CubeMapType> texels {
nullptr };
154 void initializeNow();
176 GLenum
getFormat()
const {
return m_textureParameters.image.format; }
179 size_t getWidth()
const {
return m_textureParameters.image.width; }
182 size_t getHeight()
const {
return m_textureParameters.image.height; }
185 size_t getDepth()
const {
return m_textureParameters.image.depth; }
188 const void*
getTexels() {
return m_textureParameters.image.getTexels(); }
244 void bind(
int unit = -1 );
255 void bindImageTexture(
int unit, GLint level, GLboolean layered, GLint layer, GLenum access );
268 void registerUpdateImageDataTask();
273 void registerUpdateSamplerParametersTask();
276 void sendImageDataToGpu();
277 void readFromGpu(
int level = 0 );
280 void sendSamplerParametersToGpu();
289 bool isSupportedTarget();
292 void computeIsMipMappedFlag();
299 bool createTexture();
312 static void srgbToLinearRgb( uint8_t* texels,
317 bool hasAlphaChannel );
320 static void linearizeCubeMap(
ImageParameters& image, uint numComponent,
bool hasAlphaChannel );
324 bool m_isMipMapped {
false };
Utils::Index TaskId
Identifier for a task in the task queue.
Represent a Texture of the engine.
void setName(const std::string &name)
void operator=(const Texture &)=delete
Textures are not copyable, delete operator =.
globjects::Texture * getGpuTexture() const
Get ptr to the managed globjects::Texture.
const TextureParameters & getParameters() const
get read access to texture parameters
std::string getName() const
Texture(const Texture &)=delete
Textures are not copyable, delete copy constructor.
TextureParameters & getParameters()
read/write access to texture parameters
hepler function to manage enum as underlying types in VariableSet
bool isLinear
set to true when linearize texture rgb component. If true, linearize has no effect.
const CubeMapType getCubeMap() const
std::shared_ptr< void > ImageType
Types for texels variant.
GLenum internalFormat
OpenGL internal format (WARNING, for Integer textures, must be GL_XXX_INTEGER)
const void * getTexels() const
bool isTexelOfType() const
check which type is held by texels
GPU Sampler configuration.
GLenum wrapT
OpenGL wrap mode in the t direction.
GLenum minFilter
OpenGL minification filter ( GL_LINEAR or GL_NEAREST or GL_XXX_MIPMAP_YYY )
GLenum wrapS
OpenGL wrap mode in the s direction.
GLenum wrapR
OpenGL wrap mode in the r direction.
GLenum magFilter
OpenGL magnification filter ( GL_LINEAR or GL_NEAREST )
Describes the sampler and image of a texture.