summary refs log tree commit diff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-10-02 00:02:16 +0200
committerMel <einebeere@gmail.com>2022-10-02 00:02:16 +0200
commit46ab7c6c8af19dcf537cab25aa468f4afc403940 (patch)
tree09e06a5e31ac1b43adb189c8232f08879d2559ad /src/main.cpp
parentaca1326e7e3cc4c06e29b92dca256673b46aa510 (diff)
downloadmeowcraft-46ab7c6c8af19dcf537cab25aa468f4afc403940.tar.zst
meowcraft-46ab7c6c8af19dcf537cab25aa468f4afc403940.zip
Fix for macOS
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d025c91..ad6148e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,6 +15,7 @@
 void run();
 void render(MC::BindableMesh&);
 void setup_gl();
+void fix_macos_render(MC::Window&);
 
 int main() {
     glfwInit();
@@ -37,13 +38,17 @@ void run() {
 
     glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
 
-    MC::Mesh triangle({
+    MC::Mesh quad({
         {-0.5, -0.5, 0.0},
         {0.5, -0.5, 0.0},
-        {0.0, 0.5, 0.0},
+        {-0.5, 0.5, 0.0},
+
+        {0.5, 0.5, 0.0},
+        {-0.5, 0.5, 0.0},
+        {0.5, -0.5, 0.0},
     });
 
-    auto mesh = MC::Binder::load(triangle);
+    auto mesh = MC::Binder::load(quad);
 
     MC::ShaderProgram program(MC::Shader::create_fragment(), MC::Shader::create_vertex());
     program.bind();
@@ -51,6 +56,10 @@ void run() {
     while (!window.should_close()) {
         window.start_frame();
 
+#ifdef __APPLE__
+        fix_macos_render(window);
+#endif
+
         if (window.key(GLFW_KEY_ESCAPE, GLFW_PRESS)) {
             window.close();
         }
@@ -75,3 +84,15 @@ void setup_gl() {
         throw std::runtime_error("Failed to load GL functions: " + error_string);
     }
 }
+
+void fix_macos_render(MC::Window& window) {
+    static bool moved = false;
+
+    if(!moved) {
+        int x, y;
+        glfwGetWindowPos(window.get(), &x, &y);
+        glfwSetWindowPos(window.get(), ++x, y);
+
+        moved = true;
+    }
+}
\ No newline at end of file