Added basic line drawing to renderer
This commit is contained in:
parent
ff7e296d92
commit
621760b453
1 changed files with 18 additions and 0 deletions
|
@ -49,6 +49,24 @@ void Render::fill_rectangle_sz(Vector2<int> size, Color color) {
|
|||
);
|
||||
}
|
||||
|
||||
void Render::draw_lines(std::vector<Vector2<float>> points, Color color) {
|
||||
auto prev_cache = m_matrix * m_view_matrix * Vector3<float>(points[0], 1);
|
||||
for(size_t i = 1; i < points.size(); i++) {
|
||||
auto start = prev_cache;
|
||||
auto end = m_matrix * m_view_matrix * Vector3<float>(points[i], 1);
|
||||
|
||||
m_pge->DrawLine(
|
||||
start.x(),
|
||||
start.y(),
|
||||
end.x(),
|
||||
end.y(),
|
||||
olc::Pixel(color.r(), color.g(), color.b())
|
||||
);
|
||||
|
||||
prev_cache = end;
|
||||
}
|
||||
}
|
||||
|
||||
void Render::set_camera_pos(Vector2<int> camera_pos) {
|
||||
m_camera_pos = camera_pos;
|
||||
m_view_matrix = translation_matrix(camera_pos);
|
||||
|
|
Loading…
Reference in a new issue