summaryrefslogtreecommitdiffstats
path: root/core/io/image.cpp
diff options
context:
space:
mode:
authorMarcin Nowak <marcin.j.nowak@gmail.com>2022-11-24 01:31:04 +0200
committerMarcin Nowak <marcin.j.nowak@gmail.com>2023-07-31 21:31:26 +0200
commit34ab1c8a36e61b386c210fb908b9ebfa86513149 (patch)
tree5456a34b342ff19167fb405dbdb5a9d353b6adc1 /core/io/image.cpp
parentdcd187da9580b41688f4e5110acd767d4deab8de (diff)
downloadredot-engine-34ab1c8a36e61b386c210fb908b9ebfa86513149.tar.gz
Implement loading DDS textures at run-time
Diffstat (limited to 'core/io/image.cpp')
-rw-r--r--core/io/image.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 7326563f18..a5fea09113 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -3017,6 +3017,7 @@ ImageMemLoadFunc Image::_webp_mem_loader_func = nullptr;
ImageMemLoadFunc Image::_tga_mem_loader_func = nullptr;
ImageMemLoadFunc Image::_bmp_mem_loader_func = nullptr;
ScalableImageMemLoadFunc Image::_svg_scalable_mem_loader_func = nullptr;
+ImageMemLoadFunc Image::_dds_mem_loader_func = nullptr;
void (*Image::_image_compress_bc_func)(Image *, Image::UsedChannels) = nullptr;
void (*Image::_image_compress_bptc_func)(Image *, Image::UsedChannels) = nullptr;
@@ -3488,6 +3489,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("load_webp_from_buffer", "buffer"), &Image::load_webp_from_buffer);
ClassDB::bind_method(D_METHOD("load_tga_from_buffer", "buffer"), &Image::load_tga_from_buffer);
ClassDB::bind_method(D_METHOD("load_bmp_from_buffer", "buffer"), &Image::load_bmp_from_buffer);
+ ClassDB::bind_method(D_METHOD("load_dds_from_buffer", "buffer"), &Image::load_dds_from_buffer);
ClassDB::bind_method(D_METHOD("load_svg_from_buffer", "buffer", "scale"), &Image::load_svg_from_buffer, DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("load_svg_from_string", "svg_str", "scale"), &Image::load_svg_from_string, DEFVAL(1.0));
@@ -3863,6 +3865,14 @@ Error Image::load_svg_from_string(const String &p_svg_str, float scale) {
return load_svg_from_buffer(p_svg_str.to_utf8_buffer(), scale);
}
+Error Image::load_dds_from_buffer(const Vector<uint8_t> &p_array) {
+ ERR_FAIL_NULL_V_MSG(
+ _dds_mem_loader_func,
+ ERR_UNAVAILABLE,
+ "The DDS module isn't enabled. Recompile the Godot editor or export template binary with the `module_dds_enabled=yes` SCons option.");
+ return _load_from_buffer(p_array, _dds_mem_loader_func);
+}
+
void Image::convert_rg_to_ra_rgba8() {
ERR_FAIL_COND(format != FORMAT_RGBA8);
ERR_FAIL_COND(!data.size());