remove last of outline code.

main
Brett 2024-07-26 20:07:16 -04:00
parent 4e34161bcb
commit bd9db11827
6 changed files with 29 additions and 81 deletions

View File

@ -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})

View File

@ -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();

@ -1 +1 @@
Subproject commit 60f77961fbbd4a1a06adbef984d838c5b49b3718
Subproject commit 394dff9cc4c31ea29867c5e2507edc831a34c19b

@ -1 +1 @@
Subproject commit 0e4dcfa55299eebd4659181b3622d24566f2f764
Subproject commit 231cbee0fc4f59dbe5b8b853a11b08dc84e57c65

@ -1 +1 @@
Subproject commit 0ee47a1ef91e6e887fa2e7eeeb10efcff9bbdb34
Subproject commit 111397c71a5f1c2c88e05da9c84edfdba2e472a4

View File

@ -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();
}
}
}