summaryrefslogtreecommitdiff
path: root/modules/basis_universal
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-03-24 18:18:55 +0100
committerreduz <reduzio@gmail.com>2022-03-30 10:39:41 +0200
commit45f74ceb853a2986acbdb44f7b36b409b4e0cea5 (patch)
tree4390fbbe5abad6ec67bbc152fbc93dc4a3c7189c /modules/basis_universal
parentf6ef63635f92c0a8c9c637c488f0ec129217fade (diff)
Add PortableCompressedTexture
* Resource that allows saving textures embedded in scenes or standalone. * Supports only formats that are portable: Lossy, Lossles or BasisUniversal This is something I wanted to add for a long time. I made it now because @fire requires it for importing GLTF2 files with embedded textures, but also this will allow saving Godot scenes as standalone binary files that will run in all platforms (because textures will load everywhere). This is ideal when you want to distribute individual standalone assets online in games that can be built from Godot scenes.
Diffstat (limited to 'modules/basis_universal')
-rw-r--r--modules/basis_universal/register_types.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp
index 8e328a519d..4c2ebe603f 100644
--- a/modules/basis_universal/register_types.cpp
+++ b/modules/basis_universal/register_types.cpp
@@ -143,12 +143,11 @@ static Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::
}
#endif // TOOLS_ENABLED
-static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
+static Ref<Image> basis_universal_unpacker_ptr(const uint8_t *p_data, int p_size) {
Ref<Image> image;
- const uint8_t *r = p_buffer.ptr();
- const uint8_t *ptr = r;
- int size = p_buffer.size();
+ const uint8_t *ptr = p_data;
+ int size = p_size;
basist::transcoder_texture_format format = basist::transcoder_texture_format::cTFTotalTextureFormats;
Image::Format imgfmt = Image::FORMAT_MAX;
@@ -259,6 +258,14 @@ static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
return image;
}
+static Ref<Image> basis_universal_unpacker(const Vector<uint8_t> &p_buffer) {
+ Ref<Image> image;
+
+ const uint8_t *r = p_buffer.ptr();
+ int size = p_buffer.size();
+ return basis_universal_unpacker_ptr(r, size);
+}
+
void register_basis_universal_types() {
#ifdef TOOLS_ENABLED
using namespace basisu;
@@ -267,6 +274,7 @@ void register_basis_universal_types() {
Image::basis_universal_packer = basis_universal_packer;
#endif
Image::basis_universal_unpacker = basis_universal_unpacker;
+ Image::basis_universal_unpacker_ptr = basis_universal_unpacker_ptr;
}
void unregister_basis_universal_types() {
@@ -274,4 +282,5 @@ void unregister_basis_universal_types() {
Image::basis_universal_packer = nullptr;
#endif
Image::basis_universal_unpacker = nullptr;
+ Image::basis_universal_unpacker_ptr = nullptr;
}