aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Texture.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-31 20:56:23 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-31 20:56:29 +0200
commitbe41f208c6660a879818321e2904795c7d45fe3e (patch)
tree18b609910be3ca02cfbc6928d8db7c6afd0972f8 /src/graphics/Texture.cpp
parent6c79d44732272b4d8a28abe89a78692a6b7c5cc4 (diff)
Add mipmap, texture load from memory
Diffstat (limited to 'src/graphics/Texture.cpp')
-rw-r--r--src/graphics/Texture.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp
index 86c4ac0..1bcf3af 100644
--- a/src/graphics/Texture.cpp
+++ b/src/graphics/Texture.cpp
@@ -47,9 +47,10 @@ namespace mgl {
if(mgl_texture_init(&texture) != 0)
return false;
- mgl_texture_load_options texture_load_options = {
+ const mgl_texture_load_options texture_load_options = {
load_options.compressed,
- load_options.pixel_coordinates
+ load_options.pixel_coordinates,
+ load_options.mipmap
};
return mgl_texture_load_from_file(&texture, filepath, &texture_load_options) == 0;
}
@@ -61,13 +62,29 @@ namespace mgl {
if(mgl_texture_init(&texture) != 0)
return false;
- mgl_texture_load_options texture_load_options = {
+ const mgl_texture_load_options texture_load_options = {
load_options.compressed,
- load_options.pixel_coordinates
+ load_options.pixel_coordinates,
+ load_options.mipmap
};
return mgl_texture_load_from_image(&texture, image.internal_image(), &texture_load_options) == 0;
}
+ bool Texture::load_from_memory(const unsigned char *data, int width, int height, mgl_image_format format, LoadOptions load_options) {
+ if(texture.id)
+ clear();
+
+ if(mgl_texture_init(&texture) != 0)
+ return false;
+
+ const mgl_texture_load_options texture_load_options = {
+ load_options.compressed,
+ load_options.pixel_coordinates,
+ load_options.mipmap
+ };
+ return mgl_texture_load_from_memory(&texture, data, width, height, format, &texture_load_options) == 0;
+ }
+
void Texture::clear() {
if(owned)
mgl_texture_unload(&texture);