summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-09 07:09:23 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-09 07:09:23 +0200
commit5b97a6de06e7c44e7960159dc98c54860170203b (patch)
treed251705c2db0f7c9f53127e7dcc3e8c7d3737afa /main
parent1f1951218e715e12eaf5d8cd338b6e5459872acb (diff)
a
Diffstat (limited to 'main')
-rw-r--r--main/app.hpp5
-rw-r--r--main/debug.cpp3
-rw-r--r--main/main.cpp26
3 files changed, 29 insertions, 5 deletions
diff --git a/main/app.hpp b/main/app.hpp
index c691f85d..35fb9481 100644
--- a/main/app.hpp
+++ b/main/app.hpp
@@ -7,6 +7,7 @@
#include "draw/wall-mesh.hpp"
#include "draw/wireframe-mesh.hpp"
#include "draw/wireframe-quad.hpp"
+#include "draw/wireframe-box.hpp"
#include "compat/enum-bitset.hpp"
#include <Magnum/Timeline.h>
#include <Magnum/Platform/Sdl2Application.h>
@@ -30,7 +31,8 @@ struct app final : Platform::Application
void keyReleaseEvent(KeyEvent& event) override;
void do_key(KeyEvent::Key k, KeyEvent::Modifiers m, bool pressed, bool repeated);
void draw_chunk(chunk& c);
- void draw_wireframe();
+ void draw_wireframe_quad();
+ void draw_wireframe_box();
void update_window_scale(Vector2i window_size);
void viewportEvent(ViewportEvent& event) override;
void debug_callback(GL::DebugOutput::Source src, GL::DebugOutput::Type type, UnsignedInt id,
@@ -55,6 +57,7 @@ struct app final : Platform::Application
floor_mesh _floor_mesh;
wall_mesh _wall_mesh;
wireframe_mesh<wireframe::quad> _wireframe_quad;
+ wireframe_mesh<wireframe::box> _wireframe_box;
Vector2 camera_offset;
enum_bitset<key> keys;
diff --git a/main/debug.cpp b/main/debug.cpp
index ae545678..f9b48958 100644
--- a/main/debug.cpp
+++ b/main/debug.cpp
@@ -18,11 +18,14 @@ void app::debug_callback(GL::DebugOutput::Source src, GL::DebugOutput::Type type
static thread_local auto clock = std::chrono::steady_clock{};
static const auto t0 = clock.now();
+#if 0
[[maybe_unused]] volatile auto _type = type;
[[maybe_unused]] volatile auto _id = id;
[[maybe_unused]] volatile auto _src = src;
[[maybe_unused]] volatile auto _severity = severity;
[[maybe_unused]] volatile const char* _str = str.data();
+#endif
+ (void)src; (void)type;
const char* p = str.c_str();
if (str.starts_with("Buffer detailed info: "))
diff --git a/main/main.cpp b/main/main.cpp
index bbbf8d87..ec065523 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -41,7 +41,8 @@ void app::drawEvent() {
}
draw_chunk(_chunk);
- draw_wireframe();
+ draw_wireframe_quad();
+ draw_wireframe_box();
swapBuffers();
redraw();
@@ -50,20 +51,37 @@ void app::drawEvent() {
void app::draw_chunk(chunk& c)
{
+ _shader.set_tint({1, 1, 1, 1});
_floor_mesh.draw(_shader, c);
_wall_mesh.draw(_shader, c);
}
-void app::draw_wireframe()
+void app::draw_wireframe_quad()
{
+ constexpr float LINE_WIDTH = 1;
+
constexpr auto X = TILE_SIZE[0], Y = TILE_SIZE[1];
constexpr float N = TILE_MAX_DIM/2.f;
- const Vector3 center {(float)(X*N), (float)(Y*N), 0};
+ const Vector3 center {X*N, Y*N, 0};
_shader.set_tint({1, 0, 0, 1});
- _wireframe_quad.draw(_shader, {center, {TILE_SIZE[0], TILE_SIZE[1]}});
+ _wireframe_quad.draw(_shader, {center, {TILE_SIZE[0], TILE_SIZE[1]}, LINE_WIDTH});
_shader.set_tint({1, 1, 1, 1});
}
+void app::draw_wireframe_box()
+{
+ constexpr float LINE_WIDTH = 1;
+
+ constexpr auto X = TILE_SIZE[0], Y = TILE_SIZE[1];
+ constexpr float N = TILE_MAX_DIM/2.f;
+ constexpr Vector3 size{TILE_SIZE[0], TILE_SIZE[1], TILE_SIZE[2]};
+ const Vector3 center1{X*(N+3), Y*(N+2), 0},
+ center2{X*(N-2), Y*(N-4), 0};
+ _shader.set_tint({0, 1, 0, 1});
+ _wireframe_box.draw(_shader, {center1, size, LINE_WIDTH});
+ _wireframe_box.draw(_shader, {center2, size, LINE_WIDTH});
+}
+
} // namespace Magnum::Examples
MAGNUM_APPLICATION_MAIN(Magnum::Examples::app)