Brunot
Loading...
Searching...
No Matches
Line.h
Go to the documentation of this file.
1// File: Line.h
2// Description: A class to represent a line, via 2 points, and a color. designed for DebugDraw system, but can
3// have functionality aside from that
4// Author(s): Aidan Hartman (aidan.hartman@digipen.edu)
5// 2025 / 11 / 06
6// (C) Digipen 2025
7// Line.h
8// ____ __ __ __
9// /\__ _\/\ \ /\ \/\ \
10// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
11// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
12// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
13// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
14// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
15
16#pragma once
19
20// namespace gfx
21// {
22// struct Vertex;
23// }
24
25#include "Graphics/Vertex.h"
26#include <Utility>
27
28namespace gfx
29{
30
31class Line
32{
33public:
34 Line(Vector4D p1, Vector4D p2, Vector4D color = {1.0f, 0.0f, 0.0f, 1.0f})
35 : _p1(std::move(p1))
36 , _p2(std::move(p2))
37 , _color(std::move(color))
38 {
39
40 }
41
42 Line(std::pair<float, float> p1, std::pair<float, float> p2, Vector4D color = {1.0f, 0.f, 0.f, 1.f})
43 : _p1(p1.first, p1.second, 0.f, 1.f)
44 , _p2(p2.first, p2.second, 0.f, 1.f)
45 , _color(std::move(color))
46 {
47
48 }
49
50 Line(const Line& other) = default;
51 Line(Line&& other) noexcept = default;
52 auto operator=(const Line& other) -> Line& = default;
53 auto operator=(Line&& other) noexcept -> Line& = default;
57 explicit operator std::pair<gfx::Vertex, gfx::Vertex>() const;
58
59 [[nodiscard]] auto p1() const -> const Vector4D&;
60 auto p1(const Vector4D& p1) -> void;
61 [[nodiscard]] auto p2() const -> const Vector4D&;
62 auto p2(const Vector4D& p2) -> void;
63 [[nodiscard]] auto color() const -> const Vector4D&;
64 auto color(const Vector4D& color) -> void;
65
66 friend auto operator*(const AffineMatrix& transform, const Line& line) -> Line;
67 friend auto operator*=(Line& line, const AffineMatrix& transform) -> Line&;
68
69private:
70 Vector4D _p1{0.f, 0.f, 0.f, 1.f};
71 Vector4D _p2{0.f, 0.f, 0.f, 1.f};
72 Vector4D _color{1.0f, 0.0f, 0.0f, 1.0f};
73};
74
75
76}
A struct for stroing vertexes and handing them to opengl.
Line(const Line &other)=default
auto operator=(const Line &other) -> Line &=default
Line(Vector4D p1, Vector4D p2, Vector4D color={1.0f, 0.0f, 0.0f, 1.0f})
Definition Line.h:34
auto p2() const -> const Vector4D &
Definition Line.cpp:50
auto p1() const -> const Vector4D &
Definition Line.cpp:40
Vector4D _p2
Definition Line.h:71
auto color() const -> const Vector4D &
Definition Line.cpp:60
Vector4D _color
Definition Line.h:72
Line(Line &&other) noexcept=default
auto operator=(Line &&other) noexcept -> Line &=default
Vector4D _p1
Definition Line.h:70
Line(std::pair< float, float > p1, std::pair< float, float > p2, Vector4D color={1.0f, 0.f, 0.f, 1.f})
Definition Line.h:42
Definition Sprite.h:25
Definition AffineMatrix.h:30
Definition Vector4D.h:23