aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Texture.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-18 01:54:59 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-18 01:54:59 +0200
commit3e081d1669622bbc276b038ddc38ecf0600683c3 (patch)
tree0a92c34f257c75a2b26e63b0ea9da3d594e89cc8 /src/graphics/Texture.cpp
Initial commit with an example
Diffstat (limited to 'src/graphics/Texture.cpp')
-rw-r--r--src/graphics/Texture.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp
new file mode 100644
index 0000000..0e6123c
--- /dev/null
+++ b/src/graphics/Texture.cpp
@@ -0,0 +1,26 @@
+#include "../../include/mglpp/graphics/Texture.hpp"
+
+namespace mgl {
+ Texture::Texture() {
+ texture.id = 0;
+ }
+
+ Texture::~Texture() {
+ mgl_texture_unload(&texture);
+ }
+
+ bool Texture::load_from_file(const char *filepath) {
+ if(texture.id)
+ return false;
+ /* TODO: use the last arg (load options) */
+ return mgl_texture_load_from_file(&texture, filepath, nullptr) == 0;
+ }
+
+ vec2i Texture::size() const {
+ return { texture.width, texture.height };
+ }
+
+ mgl_texture* Texture::internal_texture() {
+ return &texture;
+ }
+} \ No newline at end of file