aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Texture.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-28 17:33:57 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-29 14:31:31 +0200
commit8d525bc1c3506f15a5f68672245f845cebe18eef (patch)
tree243376e2cae0be40b6870ec8fe0082845996df87 /src/graphics/Texture.cpp
parenta80bf6bb6cb8ab8c5a1430f9f9dbc214f71bdddf (diff)
More, todo interfaces
Diffstat (limited to 'src/graphics/Texture.cpp')
-rw-r--r--src/graphics/Texture.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp
index 14e18df..cdaa3ba 100644
--- a/src/graphics/Texture.cpp
+++ b/src/graphics/Texture.cpp
@@ -1,4 +1,5 @@
#include "../../include/mglpp/graphics/Texture.hpp"
+#include "../../include/mglpp/graphics/Image.hpp"
namespace mgl {
Texture::Texture() {
@@ -6,7 +7,16 @@ namespace mgl {
}
Texture::~Texture() {
- mgl_texture_unload(&texture);
+ if(owned)
+ mgl_texture_unload(&texture);
+ }
+
+ // static
+ Texture Texture::reference(mgl_texture ref) {
+ Texture instance;
+ instance.texture = ref;
+ instance.owned = false;
+ return instance;
}
bool Texture::load_from_file(const char *filepath) {
@@ -16,6 +26,13 @@ namespace mgl {
return mgl_texture_load_from_file(&texture, filepath, nullptr) == 0;
}
+ bool Texture::load_from_image(Image &image) {
+ if(texture.id)
+ return false;
+ /* TODO: use the last arg (load options) */
+ return mgl_texture_load_from_image(&texture, image.internal_image(), nullptr) == 0;
+ }
+
vec2i Texture::get_size() const {
return { texture.width, texture.height };
}