diff options
Diffstat (limited to 'src/graphics/Texture.cpp')
-rw-r--r-- | src/graphics/Texture.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
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 +} |