Texture compression set as an option

This commit is contained in:
Enrico Turri 2019-05-28 12:53:16 +02:00
parent 61c41aa90f
commit 886da08f89
9 changed files with 133 additions and 28 deletions

View file

@ -38,8 +38,13 @@ namespace GUI {
GLTexture();
virtual ~GLTexture();
#if ENABLE_COMPRESSED_TEXTURES
bool load_from_file(const std::string& filename, bool use_mipmaps, bool compress);
bool load_from_svg_file(const std::string& filename, bool use_mipmaps, bool compress, unsigned int max_size_px);
#else
bool load_from_file(const std::string& filename, bool use_mipmaps);
bool load_from_svg_file(const std::string& filename, bool use_mipmaps, unsigned int max_size_px);
#endif // ENABLE_COMPRESSED_TEXTURES
// meanings of states: (std::pair<int, bool>)
// first field (int):
// 0 -> no changes
@ -48,7 +53,11 @@ namespace GUI {
// second field (bool):
// false -> no changes
// true -> add background color
#if ENABLE_COMPRESSED_TEXTURES
bool load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px, bool compress);
#else
bool load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px);
#endif // ENABLE_COMPRESSED_TEXTURES
void reset();
unsigned int get_id() const { return m_id; }
@ -61,10 +70,20 @@ namespace GUI {
static void render_sub_texture(unsigned int tex_id, float left, float right, float bottom, float top, const Quad_UVs& uvs);
protected:
#if ENABLE_COMPRESSED_TEXTURES
unsigned int generate_mipmaps(wxImage& image, bool compress);
#else
unsigned int generate_mipmaps(wxImage& image);
#endif // ENABLE_COMPRESSED_TEXTURES
private:
#if ENABLE_COMPRESSED_TEXTURES
bool load_from_png(const std::string& filename, bool use_mipmaps, bool compress);
bool load_from_svg(const std::string& filename, bool use_mipmaps, bool compress, unsigned int max_size_px);
#else
bool load_from_png(const std::string& filename, bool use_mipmaps);
bool load_from_svg(const std::string& filename, bool use_mipmaps, unsigned int max_size_px);
#endif // ENABLE_COMPRESSED_TEXTURES
};
} // namespace GUI