From 3e081d1669622bbc276b038ddc38ecf0600683c3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 18 Oct 2021 01:54:59 +0200 Subject: Initial commit with an example --- src/graphics/Texture.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/graphics/Texture.cpp (limited to 'src/graphics/Texture.cpp') 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 -- cgit v1.2.3