diff --git a/resources/arbre_masque.tga b/resources/arbre_masque.tga new file mode 100644 index 0000000..c495d3c Binary files /dev/null and b/resources/arbre_masque.tga differ diff --git a/src/Texture.cpp b/src/Texture.cpp index 6a1a1a2..7fc4b32 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -74,7 +74,46 @@ bool Texture::load_rgb_tga(const std::string& rgb_filename) return load_tga(rgb_filename,image_data); } -bool Texture::load_rgba_tga(const std::string& rgb_filename,const std::string& mask_filename) +bool Texture::load_rgba_tga(const std::string& rgb_filename, const std::string& mask_filename) { - return false; + uint8_t* rgb_data = nullptr; + uint8_t* mask_data = nullptr; + + bool load_successful = true; + // Load rgb and alpha data before merging them + load_successful &= load_tga(rgb_filename, rgb_data); + uint16_t temp_width = width; + uint16_t temp_height = height; + + load_successful &= load_tga(mask_filename, mask_data); + + if (!load_successful) + { + std::cerr << "Error while loading RGBA image" << std::endl; + return false; + } + if (temp_width != width || temp_height != height) + { + std::cerr << "Error while loading RGBA image : image and mask dimensions do no match : " << std::endl; + std::cerr << temp_width << "x" << temp_height << " versus " << width << "x" << height << std::endl; + return false; + } + + + image_data = new uint8_t[width*height*4]; + + // Merge the two images + for(int i = 0;i