23 auto texture = std::make_unique<Texture>( parameters );
27 m_textures.begin(), m_textures.end(), [](
const auto& texture_ ) { return !texture_; } );
28 if ( it != m_textures.end() ) {
34 m_textures.push_back(
std::move( texture ) );
35 handle.setValue( m_textures.size() - 1 );
37 m_textures[handle.getValue()]->initialize();
42 stbi_set_flip_vertically_on_load(
true );
47 unsigned char* data = stbi_load( filename.
c_str(), &width, &height, &n, 0 );
49 image.height = height;
51 LOG( logERROR ) <<
"Something went wrong when loading image \"" << filename <<
"\".";
52 image.width = image.height = 0;
58 image.format = GL_RED;
69 image.format = GL_RGB;
74 image.format = GL_RGBA;
78 image.format = GL_RGBA;
83 CORE_ASSERT( data,
"Data is null" );
86 image.type = GL_UNSIGNED_BYTE;
96 auto it =
std::find_if( m_textures.begin(), m_textures.end(), [name](
const auto& texture ) {
97 return texture->getName() == name;
100 return it != m_textures.end() ? TextureHandle {
std::distance( m_textures.begin(), it ) }
101 : TextureHandle::Invalid();
TextureHandle getTextureHandle(const std::string &name)
Get a texture handle from textue name.
void deleteTexture(const TextureHandle &handle)
Remove a managed texture identified by handle.
static ImageParameters loadTextureImage(const std::string &filename, bool linearize=false)
Load filename and fill ImageParameters according to filename content.
Texture * getTexture(const TextureHandle &handle)
Get raw texture ptr from handle.
TextureHandle addTexture(const TextureParameters &p)
Add a texture given its TextureParameters.
Represent a Texture of the engine.
static void linearize(ImageParameters &image)
Convert a color texture from sRGB to Linear RGB spaces.
Describes the sampler and image of a texture.