aboutsummaryrefslogtreecommitdiff
path: root/src/window
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-28 17:33:57 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-29 14:31:31 +0200
commit8d525bc1c3506f15a5f68672245f845cebe18eef (patch)
tree243376e2cae0be40b6870ec8fe0082845996df87 /src/window
parenta80bf6bb6cb8ab8c5a1430f9f9dbc214f71bdddf (diff)
More, todo interfaces
Diffstat (limited to 'src/window')
-rw-r--r--src/window/Clipboard.cpp15
-rw-r--r--src/window/Window.cpp65
2 files changed, 77 insertions, 3 deletions
diff --git a/src/window/Clipboard.cpp b/src/window/Clipboard.cpp
new file mode 100644
index 0000000..b5b156e
--- /dev/null
+++ b/src/window/Clipboard.cpp
@@ -0,0 +1,15 @@
+#include "../../include/mglpp/window/Clipboard.hpp"
+
+namespace mgl {
+ // TODO: Implement
+ // static
+ void Clipboard::set_string(std::string str) {
+
+ }
+
+ // TODO: Implement
+ // static
+ std::string Clipboard::get_string() {
+ return "";
+ }
+} \ No newline at end of file
diff --git a/src/window/Window.cpp b/src/window/Window.cpp
index 79e015b..9e1fb75 100644
--- a/src/window/Window.cpp
+++ b/src/window/Window.cpp
@@ -4,7 +4,9 @@
#include "../../include/mglpp/graphics/Shader.hpp"
extern "C" {
+#include <mgl/graphics/vertex.h>
#include <mgl/window/event.h>
+#include <mgl/mgl.h>
}
namespace mgl {
@@ -22,6 +24,12 @@ namespace mgl {
return mgl_window_create_with_params(&window, title, width, height, 0) == 0;
}
+ bool Window::create(WindowHandle existing_window) {
+ if(window.window)
+ return false;
+ return mgl_window_init_from_existing_window(&window, existing_window) == 0;
+ }
+
bool Window::poll_event(Event &event) {
if(!window.window)
return false;
@@ -31,7 +39,7 @@ namespace mgl {
return mgl_window_poll_event(&window, &c_event);
}
- void Window::clear(mgl::Color color) {
+ void Window::clear(Color color) {
if(!window.window)
return;
mgl_window_clear(&window, mgl_color{color.r, color.g, color.b, color.a});
@@ -40,10 +48,22 @@ namespace mgl {
void Window::draw(Drawable &drawable, Shader *shader) {
// TODO: Make the opengl context active for this thread and window, if it already isn't
if(shader)
- mgl::Shader::use(shader);
+ Shader::use(shader);
drawable.draw(*this);
if(shader)
- mgl::Shader::use(nullptr);
+ Shader::use(nullptr);
+ }
+
+ void Window::draw(const Vertex *vertices, size_t vertex_count, PrimitiveType primitive_type, Shader *shader) {
+ // TODO: Make the opengl context active for this thread and window, if it already isn't
+ if(shader)
+ Shader::use(shader);
+
+ mgl_context *context = mgl_get_context();
+ mgl_vertices_draw(context, (const mgl_vertex*)vertices, vertex_count, (mgl_primitive_type)primitive_type);
+
+ if(shader)
+ Shader::use(nullptr);
}
void Window::display() {
@@ -52,6 +72,41 @@ namespace mgl {
mgl_window_display(&window);
}
+ // TODO: Implement
+ bool Window::is_open() const {
+ return true;
+ }
+
+ // TODO: Implement
+ bool Window::has_focus() const {
+ return true;
+ }
+
+ // TODO: Implement
+ void Window::close() {
+
+ }
+
+ // TODO: Implement
+ void Window::set_title(const char *title) {
+
+ }
+
+ // TODO: Implement
+ void Window::set_framerate_limit(unsigned int fps) {
+
+ }
+
+ // TODO: Implement
+ void Window::set_key_repeat_enabled(bool enabled) {
+
+ }
+
+ // TODO: Implement
+ void Window::set_cursor_visible(bool visible) {
+
+ }
+
vec2i Window::get_size() const {
return { window.size.x, window.size.y };
}
@@ -59,4 +114,8 @@ namespace mgl {
vec2i Window::get_cursor_position() const {
return { window.cursor_position.x, window.cursor_position.y };
}
+
+ WindowHandle Window::get_system_handle() const {
+ return window.window;
+ }
} \ No newline at end of file