added TODO list; drawing points

This commit is contained in:
incredibleLeitman 2020-11-19 09:46:02 +01:00
parent e16e3d588e
commit cde73ff4c1
3 changed files with 33 additions and 6 deletions

View File

@ -6,13 +6,11 @@
#include <iostream> #include <iostream>
#include "Display.h" #include "Display.h"
#include "Point.h"
void Display::show() void Display::show()
{ {
sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "SFML works!"); sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen()) while (window.isOpen())
{ {
sf::Event event; sf::Event event;
@ -23,7 +21,18 @@ void Display::show()
} }
window.clear(); window.clear();
window.draw(shape); for (auto &pt : m_points)
{
sf::CircleShape shape(10.f);
shape.setPosition(pt.x(), pt.y());
shape.setFillColor(sf::Color::Green);
window.draw(shape);
}
window.display(); window.display();
} }
}
void Display::setData(std::vector<Point> pts)
{
m_points = pts;
} }

View File

@ -1,13 +1,17 @@
#pragma once #pragma once
class Point;
#define WIDTH 800 #define WIDTH 800
#define HEIGHT 600 #define HEIGHT 600
class Display class Display
{ {
private:
std::vector<Point> m_points;
public: public:
void show(); void show();
// TODO: void setData (std::vector<Point>);
// setData for used stuff... current triangle, all points, ladida...
}; };

View File

@ -9,6 +9,17 @@
#include "Point.h" // TODO: check if there is a usable SFML or c++ class #include "Point.h" // TODO: check if there is a usable SFML or c++ class
#include "Timing.h" #include "Timing.h"
// TODOs:
// - use SFML vec2 instead of Point class
// - calc min and max points for x, y
// *) just a loop and save/override points -> maybe in Data Block?
// *) std::minmax_element for x, y -> not saving just temp draw
// https://en.cppreference.com/w/cpp/algorithm/minmax_element
// - actual algorithm :p
// - architecture:
// # vis in own thread, calls "lib" functions?
// # seperate implementation for vis and perf?
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
// read program arguments // read program arguments
@ -65,6 +76,7 @@ int main (int argc, char **argv)
} }
} }
// TODO: need sort here?
for (Point& pt : points) for (Point& pt : points)
{ {
std::cout << "pt: " << pt.x() << ", " << pt.y() << std::endl; std::cout << "pt: " << pt.x() << ", " << pt.y() << std::endl;
@ -72,7 +84,9 @@ int main (int argc, char **argv)
if (vis) if (vis)
{ {
// TODO: use data as ctor argument? pointer?
Display display; Display display;
display.setData(points);
display.show(); display.show();
} }