no more numerics
This commit is contained in:
28
src/main.cpp
28
src/main.cpp
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "base.hpp"
|
||||
#include "node.hpp"
|
||||
#include "numerics.hpp"
|
||||
#include "worker.hpp"
|
||||
|
||||
#define WIDTH 1024
|
||||
@@ -31,14 +30,14 @@
|
||||
using cw::state::DrawState;
|
||||
using cw::state::State;
|
||||
|
||||
std::pair<std::string, int> fraction_to_string(Fraction f)
|
||||
std::pair<std::string, int> fraction_to_string(cw::node::Fraction f)
|
||||
{
|
||||
std::string s{to_string(f)};
|
||||
int width = MeasureText(s.c_str(), FONT_SIZE);
|
||||
return std::make_pair(s, width);
|
||||
}
|
||||
|
||||
void draw_fraction(Fraction f, word_t x, word_t y)
|
||||
void draw_fraction(cw::node::Fraction f, u64 x, u64 y)
|
||||
{
|
||||
std::string s;
|
||||
int width;
|
||||
@@ -84,14 +83,19 @@ using Ms = std::chrono::milliseconds;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Init general state
|
||||
cw::state::State state;
|
||||
cw::state::DrawState draw_state{state};
|
||||
|
||||
// Init timer
|
||||
auto time_current = Clock::now();
|
||||
auto time_previous = time_current;
|
||||
constexpr auto time_delta = 1;
|
||||
constexpr auto time_delta = 0;
|
||||
|
||||
// Init general state
|
||||
cw::state::State state;
|
||||
state.stop_work = false;
|
||||
state.pause_work = false;
|
||||
state.allocator.alloc(cw::node::Node{{1, 1}, -1, -1});
|
||||
state.queue.push(0);
|
||||
|
||||
cw::state::DrawState draw_state{state};
|
||||
|
||||
// Init meta text (counter, iterations, etc)
|
||||
u64 count = 1, prev_count = 0;
|
||||
@@ -99,11 +103,7 @@ int main(void)
|
||||
std::string format_str;
|
||||
u64 format_str_width = 0;
|
||||
|
||||
// Setup our first node (1/1)
|
||||
state.allocator.alloc(cw::node::Node{{1, 1}, -1, -1});
|
||||
state.queue.push(0);
|
||||
|
||||
// Init thread
|
||||
// Init threads
|
||||
std::thread threads[] = {
|
||||
std::thread(cw::worker::worker, std::ref(state)),
|
||||
std::thread(cw::worker::worker, std::ref(state)),
|
||||
@@ -119,12 +119,12 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
time_current = Clock::now();
|
||||
count = state.allocator.vec.size();
|
||||
if (!state.pause_work &&
|
||||
std::chrono::duration_cast<Ms>(time_current - time_previous).count() >=
|
||||
time_delta)
|
||||
{
|
||||
time_previous = time_current;
|
||||
count = state.allocator.vec.size();
|
||||
}
|
||||
|
||||
if (prev_count != count)
|
||||
|
||||
Reference in New Issue
Block a user