summary refs log tree commit diff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 91e1b23..d025c91 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3,6 +3,9 @@
 #include <GLFW/glfw3.h>
 
 #include "Window.hpp"
+#include "Mesh.hpp"
+#include "Binder.hpp"
+#include "Shader/ShaderProgram.hpp"
 
 #define APP_NAME "Meowcraft"
 
@@ -10,6 +13,7 @@
 #define WINDOW_HEIGHT 800
 
 void run();
+void render(MC::BindableMesh&);
 void setup_gl();
 
 int main() {
@@ -33,19 +37,41 @@ void run() {
 
     glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
 
+    MC::Mesh triangle({
+        {-0.5, -0.5, 0.0},
+        {0.5, -0.5, 0.0},
+        {0.0, 0.5, 0.0},
+    });
+
+    auto mesh = MC::Binder::load(triangle);
+
+    MC::ShaderProgram program(MC::Shader::create_fragment(), MC::Shader::create_vertex());
+    program.bind();
+
     while (!window.should_close()) {
         window.start_frame();
 
         if (window.key(GLFW_KEY_ESCAPE, GLFW_PRESS)) {
             window.close();
         }
+
+        render(mesh);
     }
 }
 
+void render(MC::BindableMesh& mesh) {
+    glClearColor(0.65f, 0.8f, 0.8f, 1.0f);
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    mesh.bind();
+    glDrawArrays(GL_TRIANGLES, 0, mesh.size());
+    mesh.unbind();
+}
+
 void setup_gl() {
     GLenum error;
     if ((error = glewInit()) != GLEW_OK) {
-        std::string error_string = std::string(reinterpret_cast<const char*>(glewGetErrorString(error)));
+        std::string error_string(reinterpret_cast<const char*>(glewGetErrorString(error)));
         throw std::runtime_error("Failed to load GL functions: " + error_string);
     }
 }