diff options
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3a8b55d..960112e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,6 @@ #include <iostream> #include <GL/glew.h> #include <GLFW/glfw3.h> -#include <cstdint> #include "GFX/Window.hpp" #include "GFX/Camera.hpp" @@ -10,7 +9,7 @@ #include "GFX/Shading/Program.hpp" #include "GFX/Texture.hpp" #include "GFX/Image/PPMParser.hpp" -#include "World/Generator.hpp" +#include "World/World.hpp" #define APP_NAME "Meowcraft" @@ -18,7 +17,7 @@ #define WINDOW_HEIGHT 800 #define ASPECT static_cast<float>(WINDOW_WIDTH) / WINDOW_HEIGHT -#define FOV 45 +#define FOV 90 void run(); void render(MC::GFX::BindableMesh&, MC::GFX::Texture&); @@ -53,11 +52,7 @@ void run() { auto image = MC::GFX::Image::PPMParser(MC::Assets::Images::atlas).parse(); auto texture = MC::GFX::Texture(image); - MC::World::Generator generator; - auto chunk = generator.generate(0, 0); - auto chunk_mesh = chunk.mesh(); - - auto mesh = MC::GFX::Binder::load(chunk_mesh); + MC::World::World world; MC::GFX::Camera camera{}; camera.set_position({0.0f, 0.0f, 3.0f}); @@ -72,7 +67,7 @@ void run() { auto projection_uniform = program.uniform("projection_matrix"); program.bind(); - auto projection = Math::MVP::projection(ASPECT, FOV, 0.1f, 100.0f); + auto projection = Math::MVP::projection(ASPECT, FOV, 0.1f, 1000.0f); projection_uniform.set(projection); glEnable(GL_DEPTH_TEST); @@ -94,13 +89,14 @@ void run() { program.bind(); - auto model = Math::MVP::model({}, {}); - model_uniform.set(model); - auto view = Math::MVP::view(camera.position(), camera.angles()); view_uniform.set(view); - render(mesh, texture); + for (auto& chunk : world.get_visible_chunks(camera.position())) { + auto model = Math::MVP::model(chunk.chunk->position(), {}); + model_uniform.set(model); + render(chunk.mesh.value(), texture); + } time++; } } @@ -129,7 +125,7 @@ void process_input(MC::GFX::Window& window, MC::GFX::Camera& camera) { float y = key(GLFW_KEY_SPACE) - key(GLFW_KEY_LEFT_SHIFT); float z = key(GLFW_KEY_S) - key(GLFW_KEY_W); - auto move_speed = 0.05f; + auto move_speed = 0.5f; auto rotation_speed = 0.1f; camera.move_relative({x * move_speed, y * move_speed, z * move_speed}); |
