aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphics/Texture.cpp9
-rw-r--r--src/mglpp.cpp4
-rw-r--r--src/window/Keyboard.cpp22
-rw-r--r--src/window/Window.cpp34
4 files changed, 56 insertions, 13 deletions
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/mglpp.cpp b/src/mglpp.cpp
index ca0845d..2f0670a 100644
--- a/src/mglpp.cpp
+++ b/src/mglpp.cpp
@@ -4,8 +4,8 @@ extern "C" {
}
namespace mgl {
- Init::Init() {
- if(mgl_init() != 0)
+ Init::Init(WindowSystem window_system) {
+ if(mgl_init((mgl_window_system)window_system) != 0)
throw InitException();
}
diff --git a/src/window/Keyboard.cpp b/src/window/Keyboard.cpp
new file mode 100644
index 0000000..34d28be
--- /dev/null
+++ b/src/window/Keyboard.cpp
@@ -0,0 +1,22 @@
+#include "../../include/mglpp/window/Keyboard.hpp"
+
+extern "C" {
+#include <mgl/window/key.h>
+}
+
+namespace mgl {
+ // static
+ const char* Keyboard::key_to_string(Key key) {
+ return mgl_key_to_string((mgl_key)key);
+ }
+
+ // static
+ bool Keyboard::key_is_modifier(Key key) {
+ return mgl_key_is_modifier((mgl_key)key);
+ }
+
+ // static
+ uint64_t Keyboard::key_to_x11_keysym(Key key) {
+ return mgl_key_to_x11_keysym((mgl_key)key);
+ }
+} \ No newline at end of file
diff --git a/src/window/Window.cpp b/src/window/Window.cpp
index 731ca8e..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) {
@@ -159,6 +169,16 @@ namespace mgl {
return view;
}
+ void Window::set_scissor(const Scissor &scissor) {
+ mgl_window_set_scissor(&window, (mgl_scissor*)&scissor);
+ }
+
+ Scissor Window::get_scissor() {
+ Scissor scissor;
+ mgl_window_get_scissor(&window, (mgl_scissor*)&scissor);
+ return scissor;
+ }
+
bool Window::is_key_pressed(Keyboard::Key key) const {
return mgl_window_is_key_pressed(&window, (mgl_key)key);
}
@@ -187,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() {