J2D DrawLines
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m59s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m59s
This commit is contained in:
@@ -106,6 +106,13 @@ namespace JGL::J2D {
|
||||
void DrawLine(const Color4& color, const Vector2& A, const Vector2& B, float thickness = 1);
|
||||
void DrawLine(const Color4& color, float x1, float y1, float x2, float y2, float thickness = 1);
|
||||
|
||||
/// Plots several line segments defined by a series of points to be connected together.
|
||||
/// @param color A 3-or-4 channel color value. @see classes Color3, Color4.
|
||||
/// @param points pointer to the first point in the list.
|
||||
/// @param point_count the number of points to draw.
|
||||
/// @param thickness The width at which to render the line.
|
||||
void DrawLines(const Color4& color, const Vector2* points, const size_t& point_count, float thickness = 1);
|
||||
|
||||
/// Plots a line segment using a series of points separated by a given distance.
|
||||
/// @param color A 3-or-4 channel color value. @see classes Color3, Color4.
|
||||
/// @param A The starting point of the line segment.
|
||||
|
@@ -193,6 +193,17 @@ void JGL::J2D::DrawLine(const Color4& color, float x, float y, float w, float h,
|
||||
JGL::J2D::DrawLine(color, {x, y}, {w, h}, thickness);
|
||||
}
|
||||
|
||||
void J2D::DrawLines(const Color4& color, const Vector2* points, const size_t& point_count, float thickness) {
|
||||
if (!inJ2D)
|
||||
Logger::Error("Drawing J2D element before J2D begin.");
|
||||
|
||||
glLineWidth(thickness);
|
||||
glColor3ubv(color.ptr());
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), points);
|
||||
glDrawArrays(GL_LINE_STRIP, 0, point_count);
|
||||
glColor4fv(OpenGLState::baseColor);
|
||||
}
|
||||
|
||||
void JGL::J2D::DrawDottedLine(const Color4& color, const Vector2& A, const Vector2& B, float spacing, float thickness) {
|
||||
float distance = Vector2::Distance(A, B);
|
||||
Vector2 direction = (B - A).Normalized();
|
||||
@@ -1114,4 +1125,4 @@ void JGL::J2D::FillEllipse(const Color4& color, const Vector2& position, float r
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices.data());
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, (int) vertices.size());
|
||||
glColor4fv(OpenGLState::baseColor);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user