From 3a29b9984760af0b3a85e35190e1dede39e13891 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 16 Nov 2021 11:07:49 +0100 Subject: Implement all interfaces to mgl --- src/graphics/Texture.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/graphics/Texture.cpp') diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp index cdaa3ba..f543c37 100644 --- a/src/graphics/Texture.cpp +++ b/src/graphics/Texture.cpp @@ -19,18 +19,32 @@ namespace mgl { return instance; } - bool Texture::load_from_file(const char *filepath) { + bool Texture::load_from_file(const char *filepath, const LoadOptions load_options) { if(texture.id) return false; - /* TODO: use the last arg (load options) */ - return mgl_texture_load_from_file(&texture, filepath, nullptr) == 0; + + if(mgl_texture_init(&texture) != 0) + return false; + + mgl_texture_load_options texture_load_options = { + load_options.compressed, + load_options.pixel_coordinates + }; + return mgl_texture_load_from_file(&texture, filepath, &texture_load_options) == 0; } - bool Texture::load_from_image(Image &image) { + bool Texture::load_from_image(Image &image, const LoadOptions load_options) { if(texture.id) return false; - /* TODO: use the last arg (load options) */ - return mgl_texture_load_from_image(&texture, image.internal_image(), nullptr) == 0; + + if(mgl_texture_init(&texture) != 0) + return false; + + mgl_texture_load_options texture_load_options = { + load_options.compressed, + load_options.pixel_coordinates + }; + return mgl_texture_load_from_image(&texture, image.internal_image(), &texture_load_options) == 0; } vec2i Texture::get_size() const { @@ -44,4 +58,4 @@ namespace mgl { mgl_texture* Texture::internal_texture() { return &texture; } -} \ No newline at end of file +} -- cgit v1.2.3