diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/main.cpp b/src/main.cpp index d69dccd..3a8b55d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,18 +1,15 @@ #include <iostream> #include <GL/glew.h> #include <GLFW/glfw3.h> -#include <cmath> #include <cstdint> -#include "Window.hpp" -#include "Mesh.hpp" -#include "Camera.hpp" -#include "Binder.hpp" +#include "GFX/Window.hpp" +#include "GFX/Camera.hpp" +#include "GFX/Binder.hpp" #include "Math/MVP.hpp" -#include "Shader/ShaderProgram.hpp" -#include "Mouse.hpp" -#include "Texture.hpp" -#include "Image/PPMParser.hpp" +#include "GFX/Shading/Program.hpp" +#include "GFX/Texture.hpp" +#include "GFX/Image/PPMParser.hpp" #include "World/Generator.hpp" #define APP_NAME "Meowcraft" @@ -24,10 +21,10 @@ #define FOV 45 void run(); -void render(MC::BindableMesh&, MC::Texture&); -void process_input(MC::Window&, MC::Mouse&, MC::Camera&); +void render(MC::GFX::BindableMesh&, MC::GFX::Texture&); +void process_input(MC::GFX::Window&, MC::GFX::Camera&); void setup_gl(); -void fix_macos_render(MC::Window&); +void fix_macos_render(MC::GFX::Window&); int main() { glfwInit(); @@ -45,8 +42,7 @@ int main() { } void run() { - MC::Window window(APP_NAME, WINDOW_WIDTH, WINDOW_HEIGHT); - MC::Mouse mouse{}; + MC::GFX::Window window(APP_NAME, WINDOW_WIDTH, WINDOW_HEIGHT); setup_gl(); glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); @@ -54,19 +50,22 @@ void run() { glViewport(0, 0, w, h); }); - auto image = MC::Image::PPMParser(MC::Assets::Images::atlas).parse(); - auto texture = MC::Texture(image); + auto image = MC::GFX::Image::PPMParser(MC::Assets::Images::atlas).parse(); + auto texture = MC::GFX::Texture(image); - MC::Generator generator; + MC::World::Generator generator; auto chunk = generator.generate(0, 0); auto chunk_mesh = chunk.mesh(); - auto mesh = MC::Binder::load(chunk_mesh); + auto mesh = MC::GFX::Binder::load(chunk_mesh); - MC::Camera camera{}; + MC::GFX::Camera camera{}; camera.set_position({0.0f, 0.0f, 3.0f}); - MC::ShaderProgram program(MC::Shader::create_fragment(), MC::Shader::create_vertex()); + MC::GFX::Shading::Program program( + MC::GFX::Shading::Shader::create_fragment(), + MC::GFX::Shading::Shader::create_vertex() + ); auto model_uniform = program.uniform("model_matrix"); auto view_uniform = program.uniform("view_matrix"); @@ -91,7 +90,7 @@ void run() { fix_macos_render(window); #endif - process_input(window, mouse, camera); + process_input(window, camera); program.bind(); @@ -106,23 +105,23 @@ void run() { } } -void render(MC::BindableMesh& mesh, MC::Texture& texture) { +void render(MC::GFX::BindableMesh& mesh, MC::GFX::Texture& texture) { glClearColor(0.85f, 0.85f, 0.85f, 1.0f); // #DBDBDB glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); texture.bind(); mesh.bind(); - glDrawElements(GL_TRIANGLES, mesh.size(), GL_UNSIGNED_INT, 0); + glDrawElements(GL_TRIANGLES, mesh.size(), GL_UNSIGNED_INT, nullptr); mesh.unbind(); texture.unbind(); } -void process_input(MC::Window& window, MC::Mouse& mouse, MC::Camera& camera) { +void process_input(MC::GFX::Window& window, MC::GFX::Camera& camera) { if (window.key(GLFW_KEY_ESCAPE, GLFW_PRESS)) { window.close(); } - auto r = mouse.update(window); + auto r = window.mouse_delta(); auto key = [&](int key) -> float { return window.key(key, GLFW_PRESS); }; @@ -145,7 +144,7 @@ void setup_gl() { } } -void fix_macos_render(MC::Window& window) { +void fix_macos_render(MC::GFX::Window& window) { static bool moved = false; if(!moved) { |
