diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0995b5b..6a6f9ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include <GL/glew.h> #include <GLFW/glfw3.h> +#include "Common/Sizes.hpp" #include "GFX/Window.hpp" #include "GFX/Camera.hpp" #include "GFX/Binder.hpp" @@ -15,7 +16,7 @@ #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 -#define ASPECT (static_cast<float>(WINDOW_WIDTH) / WINDOW_HEIGHT) +#define ASPECT (static_cast<Real>(WINDOW_WIDTH) / WINDOW_HEIGHT) #define FOV 90 @@ -45,7 +46,7 @@ void run() { setup_gl(); glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); - window.on_size_change([](GLFWwindow* _, int w, int h) { + window.on_size_change([](GLFWwindow* _, I32 w, I32 h) { glViewport(0, 0, w, h); }); @@ -69,13 +70,13 @@ void run() { auto sky_color_uniform = program.uniform("sky_color"); program.bind(); - auto projection = Math::MVP::perspective_projection(ASPECT, FOV, 0.1f, 1000.0f); + auto projection = Math::MVP::perspective_projection<F32>(ASPECT, FOV, 0.1f, 1000.0f); projection_uniform.set(projection); - Vector<3> sun_direction{1.0f, -1.0f, 0.0f}; + Vector<3, F32> sun_direction{1.0f, -1.0f, 0.0f}; sun_direction_uniform.set(sun_direction); - Vector<3> sky_color{0.85f, 0.85f, 0.85f}; // #DBDBDB + Vector<3, F32> sky_color{0.85f, 0.85f, 0.85f}; // #DBDBDB sky_color_uniform.set(sky_color); glEnable(GL_DEPTH_TEST); @@ -84,7 +85,7 @@ void run() { glEnable(GL_CULL_FACE); glCullFace(GL_BACK); - uint64_t time = 0; + U64 time = 0; while (!window.should_close()) { window.start_frame(); @@ -97,13 +98,13 @@ void run() { program.bind(); - auto view = Math::MVP::view(camera.position(), camera.angles()); + auto view = Math::MVP::view<F32>(camera.position(), camera.angles()); view_uniform.set(view); glClearColor(sky_color.x(), sky_color.y(), sky_color.z(), 1.0f); // #DBDBDB glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (auto chunk : world.get_visible_chunks(camera.position())) { - auto model = Math::MVP::model(chunk->chunk.value().position(), {}); + auto model = Math::MVP::model<F32>(chunk->chunk.value().position(), {}); model_uniform.set(model); render(chunk->mesh.value(), texture); } @@ -127,12 +128,12 @@ void process_input(MC::GFX::Window& window, MC::GFX::Camera& camera) { auto r = window.mouse_delta(); - auto key = [&](int k) -> float { return window.key(k, GLFW_PRESS); }; + auto key = [&](Int k) -> Real { return window.key(k, GLFW_PRESS); }; - float x = key(GLFW_KEY_D) - key(GLFW_KEY_A); - float y = key(GLFW_KEY_SPACE) - key(GLFW_KEY_LEFT_SHIFT); - float z = key(GLFW_KEY_S) - key(GLFW_KEY_W); - float boost = key(GLFW_KEY_LEFT_CONTROL) * 2.0f; + Real x = key(GLFW_KEY_D) - key(GLFW_KEY_A); + Real y = key(GLFW_KEY_SPACE) - key(GLFW_KEY_LEFT_SHIFT); + Real z = key(GLFW_KEY_S) - key(GLFW_KEY_W); + Real boost = key(GLFW_KEY_LEFT_CONTROL) * 2.0f; auto move_speed = 0.2f + boost; auto rotation_speed = 0.1f; @@ -145,16 +146,16 @@ void process_input(MC::GFX::Window& window, MC::GFX::Camera& camera) { void setup_gl() { GLenum error; if ((error = glewInit()) != GLEW_OK) { - std::string error_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); } } void fix_macos_render(const MC::GFX::Window& window) { - static bool moved = false; + static Bool moved = false; if(!moved) { - int x, y; + I32 x, y; glfwGetWindowPos(window.get(), &x, &y); glfwSetWindowPos(window.get(), ++x, y); |
