aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------depends/mgl0
-rw-r--r--include/mglpp/graphics/Texture.hpp11
-rw-r--r--include/mglpp/window/Window.hpp1
-rw-r--r--src/graphics/Texture.cpp9
-rw-r--r--src/window/Window.cpp24
5 files changed, 29 insertions, 16 deletions
diff --git a/depends/mgl b/depends/mgl
-Subproject 46962ea3fc83a26fcf0851ccb748b08eecf7f8e
+Subproject 506c271eafec23bf469caf6c29431191fa885e5
diff --git a/include/mglpp/graphics/Texture.hpp b/include/mglpp/graphics/Texture.hpp
index 1ea040e..6ab1fb4 100644
--- a/include/mglpp/graphics/Texture.hpp
+++ b/include/mglpp/graphics/Texture.hpp
@@ -14,24 +14,25 @@ namespace mgl {
struct LoadOptions {
bool compressed = false;
bool pixel_coordinates = false;
- bool mipmap = false; /* available since opengl 3.0 */
+ mgl_texture_scale_type scale_type = MGL_TEXTURE_SCALE_LINEAR;
};
struct ReferenceOptions {
bool pixel_coordinates = false;
+ mgl_texture_scale_type scale_type = MGL_TEXTURE_SCALE_LINEAR;
};
Texture();
- Texture(unsigned int gl_texture_id, mgl_texture_format format, const ReferenceOptions reference_options = {false});
+ Texture(unsigned int gl_texture_id, mgl_texture_format format, const ReferenceOptions reference_options = {false, MGL_TEXTURE_SCALE_LINEAR});
Texture(Texture &&other);
Texture& operator=(Texture &&other);
~Texture();
static Texture reference(mgl_texture ref);
- bool load_from_file(const char *filepath, const LoadOptions load_options = {false, false, false});
- bool load_from_image(Image &image, const LoadOptions load_options = {false, false, false});
- bool load_from_memory(const unsigned char *data, int width, int height, mgl_image_format format, LoadOptions load_options = {false, false, false});
+ bool load_from_file(const char *filepath, const LoadOptions load_options = {false, false, MGL_TEXTURE_SCALE_LINEAR});
+ bool load_from_image(Image &image, const LoadOptions load_options = {false, false, MGL_TEXTURE_SCALE_LINEAR});
+ bool load_from_memory(const unsigned char *data, int width, int height, mgl_image_format format, LoadOptions load_options = {false, false, MGL_TEXTURE_SCALE_LINEAR});
void clear();
vec2i get_size() const;
bool is_valid() const;
diff --git a/include/mglpp/window/Window.hpp b/include/mglpp/window/Window.hpp
index 6bd77f8..eb14e23 100644
--- a/include/mglpp/window/Window.hpp
+++ b/include/mglpp/window/Window.hpp
@@ -123,6 +123,7 @@ namespace mgl {
mgl_window* internal_window();
private:
mgl_window window;
+ bool window_created = false;
};
}
diff --git a/src/graphics/Texture.cpp b/src/graphics/Texture.cpp
index 3b1f410..e22bcfb 100644
--- a/src/graphics/Texture.cpp
+++ b/src/graphics/Texture.cpp
@@ -10,7 +10,8 @@ namespace mgl {
Texture::Texture(unsigned int gl_texture_id, mgl_texture_format format, const ReferenceOptions reference_options) {
memset(&texture, 0, sizeof(mgl_texture));
const mgl_texture_reference_options texture_reference_options = {
- reference_options.pixel_coordinates
+ reference_options.pixel_coordinates,
+ reference_options.scale_type
};
mgl_texture_init_reference_existing_gl_texture(&texture, gl_texture_id, format, &texture_reference_options);
}
@@ -58,7 +59,7 @@ namespace mgl {
const mgl_texture_load_options texture_load_options = {
load_options.compressed,
load_options.pixel_coordinates,
- load_options.mipmap
+ load_options.scale_type
};
if(mgl_texture_load_from_file(&texture, filepath, &texture_load_options) == 0) {
@@ -79,7 +80,7 @@ namespace mgl {
const mgl_texture_load_options texture_load_options = {
load_options.compressed,
load_options.pixel_coordinates,
- load_options.mipmap
+ load_options.scale_type
};
if(mgl_texture_load_from_image(&texture, image.internal_image(), &texture_load_options) == 0) {
@@ -100,7 +101,7 @@ namespace mgl {
const mgl_texture_load_options texture_load_options = {
load_options.compressed,
load_options.pixel_coordinates,
- load_options.mipmap
+ load_options.scale_type
};
if(mgl_texture_load_from_memory(&texture, data, width, height, format, &texture_load_options) == 0) {
diff --git a/src/window/Window.cpp b/src/window/Window.cpp
index ab42de0..fffacca 100644
--- a/src/window/Window.cpp
+++ b/src/window/Window.cpp
@@ -16,24 +16,34 @@ namespace mgl {
}
Window::Window() {
- window.window = 0;
+
}
Window::~Window() {
- if(window.window)
+ if(window_created)
mgl_window_deinit(&window);
}
bool Window::create(const char *title, CreateParams create_params) {
- if(window.window)
+ if(window_created)
return false;
- return mgl_window_create(&window, title, (const mgl_window_create_params*)&create_params) == 0;
+
+ if(mgl_window_create(&window, title, (const mgl_window_create_params*)&create_params) == 0) {
+ window_created = true;
+ return true;
+ }
+ return false;
}
bool Window::create(WindowHandle existing_window) {
- if(window.window)
+ if(window_created)
return false;
- return mgl_window_init_from_existing_window(&window, existing_window) == 0;
+
+ if(mgl_window_init_from_existing_window(&window, existing_window) == 0) {
+ window_created = true;
+ return true;
+ }
+ return false;
}
bool Window::poll_event(Event &event) {
@@ -197,7 +207,7 @@ namespace mgl {
}
WindowHandle Window::get_system_handle() const {
- return window.window;
+ return mgl_window_get_system_handle(&window);
}
mgl_window* Window::internal_window() {