MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / LoadTexture

Method LoadTexture

PanzerChasm/client/hud_drawer_gl.cpp:315–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

313}
314
315void HudDrawerGL::LoadTexture(
316 const char* const file_name,
317 const unsigned char alpha_color_index,
318 r_Texture& out_texture )
319{
320 const Vfs::FileContent texture_file= game_resources_->vfs->ReadFile( file_name );
321 const CelTextureHeader& cel= *reinterpret_cast<const CelTextureHeader*>( texture_file.data() );
322
323 const unsigned char* const texture_data= texture_file.data() + sizeof(CelTextureHeader);
324 const unsigned int pixel_count= cel.size[0] * cel.size[1];
325 std::vector<unsigned char> texture_data_rgba( 4u * pixel_count );
326 ConvertToRGBA( pixel_count, texture_data, game_resources_->palette, texture_data_rgba.data(), alpha_color_index );
327
328 if( filter_textures_ )
329 FillAlphaTexelsColorRGBA( cel.size[0], cel.size[1], texture_data_rgba.data() );
330
331 out_texture=
332 r_Texture(
333 r_Texture::PixelFormat::RGBA8,
334 cel.size[0], cel.size[1],
335 texture_data_rgba.data() );
336
337 if( filter_textures_ )
338 {
339 out_texture.SetFiltration( r_Texture::Filtration::Linear, r_Texture::Filtration::Linear );
340 out_texture.SetWrapMode( r_Texture::WrapMode::Clamp );
341 }
342 else
343 out_texture.SetFiltration( r_Texture::Filtration::Nearest, r_Texture::Filtration::Nearest );
344}
345
346} // namespace PanzerChasm

Callers

nothing calls this directly

Calls 3

ConvertToRGBAFunction · 0.85
FillAlphaTexelsColorRGBAFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected