summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--src/Window.cpp1
-rw-r--r--src/main.cpp27
3 files changed, 26 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e838b6f..7fb3c37 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,12 +3,11 @@ project(meowcraft)
set(CMAKE_CXX_STANDARD 17)
-find_package(OpenGL REQUIRED)
find_package(glfw3 3.3 REQUIRED)
find_package(GLEW REQUIRED)
add_executable(meowcraft src/main.cpp src/Window.cpp src/Window.hpp src/Mesh.cpp src/Mesh.hpp src/Math/Vector.hpp src/Math/Math.hpp src/Binder.cpp src/Binder.hpp src/Shader/ShaderSources.hpp src/Shader/Shader.cpp src/Shader/Shader.hpp src/Shader/ShaderProgram.cpp src/Shader/ShaderProgram.hpp)
-target_link_libraries(meowcraft glfw OpenGL GLEW::GLEW)
+target_link_libraries(meowcraft glfw GLEW::GLEW)
function(make_includable input_file output_file)
file(READ ${input_file} content)
diff --git a/src/Window.cpp b/src/Window.cpp
index 8bb8580..54d70f9 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -8,6 +8,7 @@ Window::Window(const char *title, uint32_t width, uint32_t height) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
+ glfwWindowHint(GLFW_DOUBLEBUFFER, GL_TRUE);
m_window = glfwCreateWindow(width, height, title, nullptr, nullptr);
if (m_window == nullptr) {
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