From bd9db118274d5c0db22ec8e1237f3f3db5bbab8f Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 26 Jul 2024 20:07:16 -0400 Subject: [PATCH] remove last of outline code. --- CMakeLists.txt | 2 +- include/blt/gfx/renderer/batch_2d_renderer.h | 36 ++--------- libraries/BLT | 2 +- libraries/imgui | 2 +- libraries/openal-soft | 2 +- src/blt/gfx/renderer/batch_2d_renderer.cpp | 66 ++++++-------------- 6 files changed, 29 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cd9a63..3117b40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25) -set(BLT_GRAPHICS_VERSION 0.13.26) +set(BLT_GRAPHICS_VERSION 0.13.27) set(BLT_GRAPHICS_TEST_VERSION 0.0.1) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) diff --git a/include/blt/gfx/renderer/batch_2d_renderer.h b/include/blt/gfx/renderer/batch_2d_renderer.h index 5aac4dc..da97c29 100644 --- a/include/blt/gfx/renderer/batch_2d_renderer.h +++ b/include/blt/gfx/renderer/batch_2d_renderer.h @@ -105,48 +105,24 @@ namespace blt::gfx color4 color; // how much to blend the texture into the color? note blending is always additive! color4 blend; - // should we outline this object? - bool outline = false; - float outline_thickness = 1.25f; - // what color should we outline with? - color4 outline_color; render_info_t() = default; - static render_info_t make_info(const std::string_view texture, const color4 outline = disabled, float outline_thickness = 1.25f) + static render_info_t make_info(const std::string_view texture) { render_info_t info{texture, empty, full}; - if (outline != disabled) - { - info.outline = true; - info.outline_color = outline; - info.outline_thickness = outline_thickness; - } return info; } - static render_info_t make_info(const color4 color, const color4 outline = disabled, float outline_thickness = 1.25f) + static render_info_t make_info(const color4 color) { render_info_t info{"", color, empty}; - if (outline != disabled) - { - info.outline = true; - info.outline_color = outline; - info.outline_thickness = outline_thickness; - } return info; } - static render_info_t make_info(const std::string_view texture, const color4 color, const color4 blend, const color4 outline = disabled, - float outline_thickness = 1.25f) + static render_info_t make_info(const std::string_view texture, const color4 color, const color4 blend) { render_info_t info{texture, color, blend}; - if (outline != disabled) - { - info.outline = true; - info.outline_color = outline; - info.outline_thickness = outline_thickness; - } return info; } }; @@ -206,11 +182,11 @@ namespace blt::gfx // called after draw_objects() void post_reset(); - void draw_points(bool outlined, bool clear, const f32 denominator); + void draw_points(const f32 denominator); - void draw_lines(bool outlined, bool clear, const f32 denominator); + void draw_lines(const f32 denominator); - void draw_rectangles(bool outlined, bool clear, const f32 denominator); + void draw_rectangles(const f32 denominator); void draw_objects(); diff --git a/libraries/BLT b/libraries/BLT index 60f7796..394dff9 160000 --- a/libraries/BLT +++ b/libraries/BLT @@ -1 +1 @@ -Subproject commit 60f77961fbbd4a1a06adbef984d838c5b49b3718 +Subproject commit 394dff9cc4c31ea29867c5e2507edc831a34c19b diff --git a/libraries/imgui b/libraries/imgui index 0e4dcfa..231cbee 160000 --- a/libraries/imgui +++ b/libraries/imgui @@ -1 +1 @@ -Subproject commit 0e4dcfa55299eebd4659181b3622d24566f2f764 +Subproject commit 231cbee0fc4f59dbe5b8b853a11b08dc84e57c65 diff --git a/libraries/openal-soft b/libraries/openal-soft index 0ee47a1..111397c 160000 --- a/libraries/openal-soft +++ b/libraries/openal-soft @@ -1 +1 @@ -Subproject commit 0ee47a1ef91e6e887fa2e7eeeb10efcff9bbdb34 +Subproject commit 111397c71a5f1c2c88e05da9c84edfdba2e472a4 diff --git a/src/blt/gfx/renderer/batch_2d_renderer.cpp b/src/blt/gfx/renderer/batch_2d_renderer.cpp index 2d414b1..098f60a 100644 --- a/src/blt/gfx/renderer/batch_2d_renderer.cpp +++ b/src/blt/gfx/renderer/batch_2d_renderer.cpp @@ -181,7 +181,7 @@ namespace blt::gfx engine->render(); render_reset(); } - + // void batch_renderer_2d::draw_objects() // { // pre_reset(); @@ -226,9 +226,9 @@ namespace blt::gfx const f32 denominator = 1.0f / (draw.z_max - draw.z_min); glClear(GL_STENCIL_BUFFER_BIT); - draw_points(false, true, denominator); - draw_rectangles(false, true, denominator); - draw_lines(false, true, denominator); + draw_points(denominator); + draw_rectangles(denominator); + draw_lines(denominator); post_reset(); } @@ -248,7 +248,7 @@ namespace blt::gfx } - void batch_renderer_2d::draw_points(const bool outlined, bool clear, const f32 denominator) + void batch_renderer_2d::draw_points(const f32 denominator) { point_shader->bind(); square_vao->bind(); @@ -263,17 +263,9 @@ namespace blt::gfx mat4x4 model; model.translate(point.pos.x(), point.pos.y(), 0.0f); - if (outlined && render_info.outline) - { - model.scale(point.scale * render_info.outline_thickness, point.scale * render_info.outline_thickness, 1.0); - point_shader->setVec4("color", render_info.outline_color); - point_shader->setVec4("use_texture", blt::vec4{0,0,0,0}); - } else - { - model.scale(point.scale, point.scale, 1.0); - point_shader->setVec4("color", render_info.color); - point_shader->setVec4("use_texture", render_info.blend); - } + model.scale(point.scale, point.scale, 1.0); + point_shader->setVec4("color", render_info.color); + point_shader->setVec4("use_texture", render_info.blend); //point_shader->setVec4("outline_color", render_info.outline_color); point_shader->setFloat("z_index", (z_index - draw.z_min) * denominator); @@ -282,12 +274,11 @@ namespace blt::gfx glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); draw.draw_count++; } - if (clear) - objects.clear(); + objects.clear(); } } - void batch_renderer_2d::draw_lines(bool outlined, bool clear, const f32 denominator) + void batch_renderer_2d::draw_lines(const f32 denominator) { mat4x4 empty_model; square_shader->setMatrix("model", empty_model); @@ -304,14 +295,8 @@ namespace blt::gfx auto& [z_index, line] = object; float thickness = line.thickness; - if (outlined && render_info.outline){ - square_shader->setVec4("color", render_info.outline_color); - square_shader->setVec4("use_texture", {0,0,0,0}); - thickness *= render_info.outline_thickness; - } else { - square_shader->setVec4("color", render_info.color); - square_shader->setVec4("use_texture", render_info.blend); - } + square_shader->setVec4("color", render_info.color); + square_shader->setVec4("use_texture", render_info.blend); //square_shader->setVec4("outline_color", render_info.outline_color); square_shader->setFloat("z_index", (z_index - draw.z_min) * denominator); @@ -347,12 +332,11 @@ namespace blt::gfx glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); draw.draw_count++; } - if (clear) - objects.clear(); + objects.clear(); } } - void batch_renderer_2d::draw_rectangles(bool outlined, bool clear, const f32 denominator) + void batch_renderer_2d::draw_rectangles(const f32 denominator) { square_shader->bind(); square_vao->bind(); @@ -366,21 +350,10 @@ namespace blt::gfx auto& [z_index, rect] = object; mat4x4 model; - if (outlined && render_info.outline) { - auto nsx = rect.size.x() * render_info.outline_thickness; - auto nsy = rect.size.y() * render_info.outline_thickness; - auto ns = blt::vec2(nsx, nsy); - auto s = (rect.size - ns) / 2.0f; - model.translate(rect.pos - s); - model.scale(ns); - square_shader->setVec4("color", render_info.outline_color); - square_shader->setVec4("use_texture", {0,0,0,0}); - } else { - model.translate(rect.pos); - model.scale(rect.size); - square_shader->setVec4("color", render_info.color); - square_shader->setVec4("use_texture", render_info.blend); - } + model.translate(rect.pos); + model.scale(rect.size); + square_shader->setVec4("color", render_info.color); + square_shader->setVec4("use_texture", render_info.blend); if (rect.rotation != 0) model.rotateZ(toRadians(rect.rotation)); @@ -390,8 +363,7 @@ namespace blt::gfx glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); draw.draw_count++; } - if (clear) - objects.clear(); + objects.clear(); } } }