-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add drawLine(const Mat3& modelview, Vec2 end, Rgba color) overload
- Loading branch information
Showing
4 changed files
with
17 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2012-2024 Jan Niklas Hasse <[email protected]> | ||
// Copyright 2012-2025 Jan Niklas Hasse <[email protected]> | ||
// For conditions of distribution and use, see copyright notice in LICENSE.txt | ||
/// Functions for drawing shapes | ||
/// @file | ||
|
@@ -59,6 +59,8 @@ void drawLine(Mat3 modelview, Vec2 start, Vec2 end); | |
/// Draws a line from (0, 0) to \a end | ||
void drawLine(const Mat3& modelview, Vec2 end); | ||
|
||
/// Draws a line from (0, 0) to \a end in \a color | ||
void drawLine(const Mat3& modelview, Vec2 end, Rgba color); | ||
|
||
[[deprecated("Use drawEllipse(Mat3, float, float, float) instead")]] | ||
/// \deprecated Use drawEllipse(Mat3, float, float, float) instead | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2007-2024 Jan Niklas Hasse <[email protected]> | ||
// Copyright 2007-2025 Jan Niklas Hasse <[email protected]> | ||
// For conditions of distribution and use, see copyright notice in LICENSE.txt | ||
|
||
#include "main.hpp" | ||
|
@@ -514,15 +514,19 @@ void drawLine(const double xstart, const double ystart, const double xend, const | |
} | ||
|
||
void drawLine(const Vec2 start, const Vec2 end) { | ||
pWindow->drawLine(jngl::modelview().translate(start), end - start); | ||
pWindow->drawLine(jngl::modelview().translate(start), end - start, gShapeColor); | ||
} | ||
|
||
void drawLine(Mat3 modelview, const Vec2 start, const Vec2 end) { | ||
pWindow->drawLine(modelview.translate(start), end - start); | ||
pWindow->drawLine(modelview.translate(start), end - start, gShapeColor); | ||
} | ||
|
||
void drawLine(const Mat3& modelview, const Vec2 end) { | ||
pWindow->drawLine(modelview, end); | ||
pWindow->drawLine(modelview, end, gShapeColor); | ||
} | ||
|
||
void drawLine(const Mat3& modelview, const Vec2 end, Rgba color) { | ||
pWindow->drawLine(modelview, end, color); | ||
} | ||
|
||
void drawPoint(const double x, const double y) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2007-2024 Jan Niklas Hasse <[email protected]> | ||
// Copyright 2007-2025 Jan Niklas Hasse <[email protected]> | ||
// For conditions of distribution and use, see copyright notice in LICENSE.txt | ||
#include "window.hpp" | ||
|
||
|
@@ -582,10 +582,10 @@ void Window::drawTriangle(Mat3 modelview, Rgba color) { | |
glDrawArrays(GL_TRIANGLES, 0, 3); | ||
} | ||
|
||
void Window::drawLine(Mat3 modelview, const Vec2 b) const { | ||
void Window::drawLine(Mat3 modelview, const Vec2 b, const Rgba color) const { | ||
glBindVertexArray(vaoLine); | ||
auto tmp = ShaderCache::handle().useSimpleShaderProgram(modelview.scale(b * getScaleFactor()), | ||
gShapeColor); | ||
auto tmp = | ||
ShaderCache::handle().useSimpleShaderProgram(modelview.scale(b * getScaleFactor()), color); | ||
glDrawArrays(GL_LINES, 0, 2); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2007-2024 Jan Niklas Hasse <[email protected]> | ||
// Copyright 2007-2025 Jan Niklas Hasse <[email protected]> | ||
// For conditions of distribution and use, see copyright notice in LICENSE.txt | ||
#pragma once | ||
|
||
|
@@ -113,7 +113,7 @@ class Window { | |
void initGlObjects(); | ||
static void drawTriangle(Vec2 a, Vec2 b, Vec2 c); | ||
static void drawTriangle(Mat3 modelview, Rgba color); | ||
void drawLine(Mat3 modelview, Vec2 b) const; | ||
void drawLine(Mat3 modelview, Vec2 b, Rgba color) const; | ||
void drawSquare(Mat3 modelview, Rgba color) const; | ||
void onControllerChanged(std::function<void()>); | ||
|
||
|