main
Brett 2024-05-13 13:14:54 -04:00
parent c6585b27b5
commit 8b7a068aeb
4 changed files with 77 additions and 54 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
project(graphs VERSION 0.0.37) project(graphs VERSION 0.0.38)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

View File

@ -27,7 +27,9 @@ class node
{ {
private: private:
blt::gfx::point2d_t point; blt::gfx::point2d_t point;
float outline_scale = 1.25f;
blt::vec2 velocity; blt::vec2 velocity;
blt::color4 outline_color = blt::make_color(0.0, 1.0, 1.0);
public: public:
explicit node(const blt::gfx::point2d_t& point): point(point) explicit node(const blt::gfx::point2d_t& point): point(point)
{} {}
@ -51,6 +53,26 @@ class node
{ {
return point; return point;
} }
[[nodiscard]] float getOutlineScale() const
{
return outline_scale;
}
void setOutlineScale(float outlineScale)
{
outline_scale = outlineScale;
}
[[nodiscard]] const blt::color4& getOutlineColor() const
{
return outline_color;
}
void setOutlineColor(const blt::color4& c)
{
outline_color = c;
}
}; };
@ -58,6 +80,10 @@ class edge
{ {
private: private:
blt::u64 i1, i2; blt::u64 i1, i2;
float outline_scale = 2.0f;
float thickness = 2.0f;
blt::color4 color = blt::make_color(0, 1, 0);
blt::color4 outline_color = blt::make_color(1, 0, 0);
public: public:
edge(blt::u64 i1, blt::u64 i2): i1(i1), i2(i2) edge(blt::u64 i1, blt::u64 i2): i1(i1), i2(i2)
{ {
@ -78,6 +104,46 @@ class edge
{ {
return i2; return i2;
} }
[[nodiscard]] float getOutlineScale() const
{
return outline_scale;
}
void setOutlineScale(float outlineScale)
{
outline_scale = outlineScale;
}
[[nodiscard]] const blt::color4& getColor() const
{
return color;
}
void setColor(const blt::color4& c)
{
color = c;
}
[[nodiscard]] const blt::color4& getOutlineColor() const
{
return outline_color;
}
void setOutlineColor(const blt::color4& outlineColor)
{
outline_color = outlineColor;
}
[[nodiscard]] float getThickness() const
{
return thickness;
}
void setThickness(float t)
{
thickness = t;
}
}; };
struct edge_hash struct edge_hash

@ -1 +1 @@
Subproject commit 2c85c0f93c9028ae8db7b19c107af4b2fe4978a6 Subproject commit 7c82253251e937b2caa9a0717b1008282d2200ce

View File

@ -228,8 +228,10 @@ class graph_t
for (const auto& point : nodes) for (const auto& point : nodes)
{ {
auto draw_info = blt::gfx::render_info_t::make_info("parker_point", blt::make_color(0, 1, 1)); auto pr = point.getRenderObj();
renderer_2d.drawPointInternal(draw_info, point.getRenderObj(), 10.0f); pr.scale *= point.getOutlineScale();
renderer_2d.drawPointInternal(blt::gfx::render_info_t::make_info(point.getOutlineColor()), pr, 10.0f);
renderer_2d.drawPointInternal(blt::gfx::render_info_t::make_info("parker_point"), point.getRenderObj(), 15.0f);
} }
for (const auto& edge : edges) for (const auto& edge : edges)
{ {
@ -240,8 +242,11 @@ class graph_t
{ {
auto n1 = nodes[edge.getFirst()]; auto n1 = nodes[edge.getFirst()];
auto n2 = nodes[edge.getSecond()]; auto n2 = nodes[edge.getSecond()];
auto draw_info = blt::gfx::render_info_t::make_info(blt::make_color(0, 1, 0), blt::make_color(1, 0, 0)); auto draw_info = blt::gfx::render_info_t::make_info(edge.getColor());
renderer_2d.drawLine(draw_info, 5.0f, n1.getRenderObj().pos, n2.getRenderObj().pos, 2.0f); auto outline_info = blt::gfx::render_info_t::make_info(edge.getOutlineColor());
blt::gfx::line2d_t line{n1.getRenderObj().pos, n2.getRenderObj().pos, edge.getThickness() * edge.getOutlineScale()};
renderer_2d.drawLine(draw_info, 5.0f, n1.getRenderObj().pos, n2.getRenderObj().pos, edge.getThickness());
renderer_2d.drawLineInternal(outline_info, line, 2.0f);
} }
} }
} }
@ -511,56 +516,8 @@ void update(const blt::gfx::window_data& data)
fps = 1 / ft; fps = 1 / ft;
} }
void process_string(const std::string& str)
{
BLT_DEBUG(str);
auto results = blt::template_engine_t::process_string(str);
if (results)
{
auto val = results.value();
for (auto& v : val)
{
BLT_TRACE_STREAM << (blt::template_token_to_string(v.type));
}
BLT_TRACE_STREAM << "\n";
for (auto& v : val)
{
BLT_TRACE("{%s: %s}", blt::template_token_to_string(v.type).c_str(), std::string(v.token).c_str());
}
} else
{
auto error = results.error();
switch (error)
{
case blt::template_tokenizer_failure_t::MISMATCHED_CURLY:
BLT_ERROR("Tokenizer Failure: Mismatched curly");
break;
case blt::template_tokenizer_failure_t::MISMATCHED_PAREN:
BLT_ERROR("Tokenizer Failure: Mismatched parenthesis");
break;
case blt::template_tokenizer_failure_t::MISMATCHED_QUOTE:
BLT_ERROR("Tokenizer Failure: Mismatched Quotes");
break;
}
}
BLT_DEBUG("--------------------------");
}
int main(int, const char**) int main(int, const char**)
{ {
// blt::template_engine_t templateEngine;
// templateEngine.set("LAYOUT_STRING", "layout (location = ${IF(LAYOUT_LOCATION) { LAYOUT_LOCATION } ELSE { ~DISCARD }}) ");
// templateEngine.set("LAYOUT_LOCATION", "1");
//
// auto result = templateEngine.evaluate(shader_pp_screen_frag);
//
// if (result)
// BLT_TRACE(result.value());
// else
// BLT_TRACE("Function Failed: %d", static_cast<int>(result.error()));
//
// return 0;
blt::gfx::init(blt::gfx::window_data{"Graphing Lovers United", init, update, 1440, 720}.setSyncInterval(1)); blt::gfx::init(blt::gfx::window_data{"Graphing Lovers United", init, update, 1440, 720}.setSyncInterval(1));
global_matrices.cleanup(); global_matrices.cleanup();
resources.cleanup(); resources.cleanup();