23#include <J3ML/LinearAlgebra.hpp>
24#include <J3ML/LinearAlgebra/Vector2.hpp>
25#include <J3ML/LinearAlgebra/Vector3.hpp>
26#include <J3ML/Geometry/Sphere.hpp>
27#include <J3ML/Geometry/Capsule.hpp>
28#include <J3ML/Geometry/Triangle2D.hpp>
32 using namespace J3ML::LinearAlgebra;
33 using namespace J3ML::Geometry;
37 void Update(
const Vector2& window_size);
63 void DrawPoint(
const Color4& color,
const Vector2& coordinates,
float radius = 1.f);
64 void DrawPoint(
const Color4& color,
float x,
float y,
float radius = 1.f);
71 void DrawPoints(
const Color4& color,
const Vector2* points,
int num_points,
float radius = 1.f);
78 void DrawLine(
const Color4& color,
const Vector2& A,
const Vector2& B,
float thickness = 1);
79 void DrawLine(
const Color4& color,
float x1,
float y1,
float x2,
float y2,
float thickness = 1);
87 void DrawGradientLine(
const Color4& color_a,
const Color4& color_b,
const Vector2& A,
const Vector2& B,
float thickness = 1);
88 void DrawGradientLine(
const Color4& color_a,
const Color4& color_b,
float x,
float y,
float w,
float h,
float thickness = 1);
95 void OutlineRect(
const Color4& color,
const Vector2& pos,
const Vector2& size,
float thickness = 1);
103 void OutlineRoundedRect(
const Color4& color,
const Vector2& pos,
const Vector2& size,
float radius = 5,
float thickness = 1);
111 void OutlineChamferRect(
const Color4& color,
const Vector2& pos,
const Vector2& size,
float radius = 5,
float thickness = 1);
118 void FillRect(
const Color4& color,
const Vector2& pos,
const Vector2& size);
126 void FillGradientRect(
const Color4& color1,
const Color4& color2,
const Direction& gradient,
const Vector2& pos,
const Vector2& size);
134 void FillRoundedRect(
const Color4& color,
const Vector2& pos,
const Vector2& size,
float radius = 5,
unsigned int subdivisions = 8);
141 void FillChamferRect(
const Color4& color,
const Vector2& pos,
const Vector2& size,
float radius = 5);
180 void DrawSprite(
const Texture& texture,
const Vector2& position,
float rad_rotation = 0,
const Vector2& origin = Vector2(0,0),
182 void DrawSprite(
const Texture* texture,
const Vector2& position,
float rad_rotation = 0,
const Vector2& origin = Vector2(0,0),
184 void DrawSprite(
const Texture& texture,
float positionX,
float positionY,
float rad_rotation = 0,
float originX = 0,
float originY = 0,
186 void DrawSprite(
const Texture* texture,
float positionX,
float positionY,
float rad_rotation = 0,
187 float originX = 0,
float originY = 0,
float scaleX = 1,
float scaleY = 1,
199 void DrawPartialSprite(
const Texture& texture,
const Vector2& position,
const Vector2& sub_texture_position,
const Vector2& sub_texture_size,
float rad_rotation = 0,
200 const Vector2& origin = Vector2(0,0),
const Vector2& scale = Vector2(1, 1),
const Color4& color = Colors::White,
Direction inversion =
Direction::None);
201 void DrawPartialSprite(
const Texture* texture,
const Vector2& position,
const Vector2& sub_texture_position,
const Vector2& sub_texture_size,
float rad_rotation = 0,
202 const Vector2& origin = Vector2(0,0),
const Vector2& scale = Vector2(1, 1),
const Color4& color = Colors::White,
Direction inversion =
Direction::None);
203 void DrawPartialSprite(
const Texture& texture,
float positionX,
float positionY,
float sub_texture_positionX,
float sub_texture_positionY,
unsigned int sub_texture_sizeX,
unsigned int sub_texture_sizeY,
204 float rad_rotation = 0,
float originX = 0,
float originY = 0,
float scaleX = 1,
float scaleY = 1,
const Color4& color = Colors::White,
Direction inversion =
Direction::None);
205 void DrawPartialSprite(
const Texture* texture,
float positionX,
float positionY,
float sub_texture_positionX,
float sub_texture_positionY,
unsigned int sub_texture_sizeX,
unsigned int sub_texture_sizeY,
206 float rad_rotation = 0,
float originX = 0,
float originY = 0,
float scaleX = 1,
float scaleY = 1,
const Color4& color = Colors::White,
Direction inversion =
Direction::None);
226 void OutlineCircle(
const Color4& color,
const Vector2& center,
float radius,
unsigned int subdivisions = 16,
float thickness = 1);
233 void FillCircle(
const Color4& color,
const Vector2& center,
float radius,
unsigned int subdivisions = 8);
239 void OutlineTriangle(
const Color4& color,
const Triangle2D& tri,
float thickness = 1);
240 void OutlineTriangle(
const Color4& color,
const Vector2& triA,
const Vector2& triB,
const Vector2& triC,
float thickness = 1);
245 void FillTriangle(
const Color4& color,
const Triangle2D& tri);
246 void FIllTriangle(
const Color4& color,
const Vector2& triA,
const Vector2& triB,
const Vector2& triC);
253 void FillGradientTriangle(
const Color4& a_color,
const Color4& b_color,
const Color4& c_color,
const Triangle2D& tri);
254 void FillGradientTriangle(
const Color4& a_color,
const Color4& b_color,
const Color4& c_color,
const Vector2& tri_a,
const Vector2& tri_b,
const Vector2& tri_c);
265 void DrawCubicBezierCurve(
const Color4& color,
const Vector2& controlA,
const Vector2& pointA,
const Vector2& pointB,
const Vector2& controlB,
266 int subdivisions = 10,
float thickness = 1);
276 void OutlinePolygon(
const Color4& color,
const Vector2* points,
int points_size,
float thickness = 1);
286 void DrawString(
const Color4& color,
const std::string& text,
float x,
float y,
float scale, u32 size,
const Font& font);
297 void DrawArc(
const Color4& color,
const Vector2& center,
float radius,
float arc_begin,
float arc_end,
298 unsigned int subdivisions,
float thickness);
302 void FillPolygon(
const Color4& color,
const std::vector<Vector2>& points);
304 void OutlineEllipse(
const Color4& color,
const Vector2& position,
float radius_x,
float radius_y,
float thickness = 1,
int subdivisions = 8);
305 void FillEllipse(
const Color4& color,
const Vector2& position,
float radius_x,
float radius_y,
int subdivisions = 8);
312 void Init(
const Vector2 &window_size,
float fov,
float far_plane);
331 void SetMatrix(
const std::vector<GLfloat> &matrix,
const Vector2 &window_size);
338 void DrawLine(
const Color4& color,
const Vector3& A,
const Vector3& B,
float thickness = 1.f);
350 void DrawCubicBezierCurve(
const Color4& color,
const Vector3& controlA,
const Vector3& pointA,
const Vector3& pointB,
const Vector3& controlB,
351 int subdivisions = 10,
float thickness = 1);
358 void WireframeIcosahedron(
const Color4& color,
const Vector3& position,
float radius,
float thickness = 1.f);
374 void WireframeSphere(
const Color4& color,
const Vector3& position,
float radius,
float thickness = 1.f, uint sectors = 10, uint stacks = 10);
382 void WireframeSphere(
const Color4& color,
const Sphere& sphere,
float thickness = 1.f, uint sectors = 10, uint stacks = 10);
391 void WireframeIcosphere(
const Color4& color,
const Vector3& position,
float radius,
float thickness = 1.f,
unsigned int subdivisions = 10);
399 void WireframeIcosphere(
const Color4& color,
const Sphere& sphere,
float thickness = 1.f,
unsigned int subdivisions = 10);
408 void WireframeCubesphere(
const Color4& color,
const Vector3& position,
float radius,
float thickness = 1.f,
unsigned int subdivisions = 10);
416 void WireframeCubesphere(
const Color4& color,
const Sphere& sphere,
float thickness = 1.f,
unsigned int subdivisions = 10);
424 void FillSphere(
const Color4& color,
const Vector3& position,
float radius, uint sectors = 10, uint stacks = 10);
431 void FillSphere(
const Color4& color,
const Sphere& sphere, uint sectors = 10, uint stacks = 10);
439 void FillIcosphere(
const Color4& color,
const Vector3& position,
float radius,
unsigned int subdivisions = 10);
446 void FillIcosphere(
const Color4& color,
const Sphere& sphere,
unsigned int subdivisions = 10);
454 void FillCubesphere(
const Color4& color,
const Vector3& position,
float radius,
unsigned int subdivisions = 10);
461 void FillCubesphere(
const Color4& color,
const Sphere& sphere,
unsigned int subdivisions = 10);
468 void WireframeAABB(
const Color4& color,
const Vector3& pos,
const Vector3& radii,
float thickness = 1.f);
473 void WireframeAABB(
const Color4& color,
const AABB& aabb,
float thickness = 1.f);
479 void FillAABB(
const Color4& color,
const Vector3& pos,
const Vector3& radii);
484 void FillAABB(
const Color4& color,
const AABB& aabb);
492 void WireframeOBB(
const Color4& color,
const Vector3& position,
const Vector3& radii,
const EulerAngle& orientation,
float thickness = 1.f);
498 void WireframeOBB(
const Color4& color,
const OBB& obb,
float thickness = 1.f);
505 void FillOBB(
const Color4& color,
const Vector3& position,
const Vector3& radii,
const EulerAngle& orientation);
510 void FillOBB(
const Color4& color,
const OBB& obb);
538 void DrawString(
const Color4& color,
const std::string& text,
const Vector3& pos,
float scale, u32 size,
const Font& font,
const EulerAngle& angle = {0, 0, 0},
bool draw_back_face =
false);
JGL::RenderTarget * render_target
Definition: JGL.cpp:14
void purgeCache()
Definition: FontCache.cpp:94
A Font class implementation.
Definition: Font.h:22
Definition: RenderTarget.h:13
Represents texture data loaded on the GPU. Contains a handle that can be passed to OpenGL draw calls.
Definition: Texture.h:27
void FillChamferRect(const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5)
Draws a filled rectangle with chamfered (beveled) corners on the screen.
Definition: JGL.cpp:850
void FillPolygon(const Color4 &color, const std::vector< Vector2 > &points)
TODO Implement the following. These ones are going to be extremely annoying.
void DrawCubicBezierCurve(const Color4 &color, const Vector2 &controlA, const Vector2 &pointA, const Vector2 &pointB, const Vector2 &controlB, int subdivisions=10, float thickness=1)
Draws a smooth, curved line segment between two control points, with the curve controlled by the two ...
Definition: JGL.cpp:716
void FillCircle(const Color4 &color, const Vector2 ¢er, float radius, unsigned int subdivisions=8)
Draws a filled circle on the screen.
Definition: JGL.cpp:645
void FillGradientTriangle(const Color4 &a_color, const Color4 &b_color, const Color4 &c_color, const Triangle2D &tri)
Fills a triangle defined by the provided vertices with a gradient that transitions smoothly between t...
Definition: JGL.cpp:698
void DrawPoint(const Color4 &color, const Vector2 &coordinates, float radius=1.f)
Plots a single pixel on the screen.
Definition: JGL.cpp:180
void DrawString(const Color4 &color, const std::string &text, float x, float y, float scale, u32 size, const Font &font)
Draws a text string on the screen with a given point-size and font.
Definition: TextRendering.cpp:97
void OutlineChamferRect(const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5, float thickness=1)
Draws an outline of a rectangle with chamfered corners onto the screen.
Definition: JGL.cpp:854
void OutlinePolygon(const Color4 &color, const Vector2 *points, int points_size, float thickness=1)
Draws a series of points where the last point always connects to the first point.
Definition: JGL.cpp:734
void Begin(RenderTarget *render_target=nullptr, bool clear_buffers=false)
Open a 2-D rendering context with the underlying graphics system (In this case& by default OpenGL).
Definition: JGL.cpp:51
void FillRect(const Color4 &color, const Vector2 &pos, const Vector2 &size)
Draws a filled rectangle on the screen.
Definition: JGL.cpp:245
void End()
Closes a 2-D rendering context with the underlying graphics system (In this case& by default OpenGL).
Definition: JGL.cpp:138
void DrawPartialSprite(const Texture &texture, const Vector2 &position, const Vector2 &sub_texture_position, const Vector2 &sub_texture_size, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
Draws a piece of a sprite to the screen, similar to DrawSprite.
Definition: JGL.cpp:447
void FillGradientRect(const Color4 &color1, const Color4 &color2, const Direction &gradient, const Vector2 &pos, const Vector2 &size)
Draws a filled rectangle where the color transitions across it.
Definition: JGL.cpp:256
void OutlineEllipse(const Color4 &color, const Vector2 &position, float radius_x, float radius_y, float thickness=1, int subdivisions=8)
Definition: JGL.cpp:892
void OutlineCircle(const Color4 &color, const Vector2 ¢er, float radius, unsigned int subdivisions=16, float thickness=1)
Draws an outline of a circle on the screen.
Definition: JGL.cpp:618
void LightArray(Light *, size_t size)
Provide a list of lights to be used in 2D space.
void FillEllipse(const Color4 &color, const Vector2 &position, float radius_x, float radius_y, int subdivisions=8)
Definition: JGL.cpp:920
void OutlineRect(const Color4 &color, const Vector2 &pos, const Vector2 &size, float thickness=1)
Draws an outline of a rectangle on the screen.
Definition: JGL.cpp:232
void DrawSprite(const RenderTarget &render_target, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
Draws a sprite (technically, actually a render target) to the screen.
Definition: JGL.cpp:348
void DrawGradientLine(const Color4 &color_a, const Color4 &color_b, const Vector2 &A, const Vector2 &B, float thickness=1)
Draws a line with a color gradient that transitions across it.
Definition: JGL.cpp:211
void OutlineRoundedRect(const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5, float thickness=1)
Draws an outline of a rectangle with rounded corners onto the screen.
Definition: JGL.cpp:786
void FIllTriangle(const Color4 &color, const Vector2 &triA, const Vector2 &triB, const Vector2 &triC)
Definition: JGL.cpp:881
void DrawMirrorSprite(const Texture &texture, const Vector2 &position, Direction mirror_axis=Direction::Horizontal|Direction::Vertical, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White)
To save v-ram, Use if a sprite would be identical if mirrored horizontally, vertically,...
Definition: JGL.cpp:535
void DrawLine(const Color4 &color, const Vector2 &A, const Vector2 &B, float thickness=1)
Plots a line (segment) on the screen.
Definition: JGL.cpp:195
void OutlineTriangle(const Color4 &color, const Triangle2D &tri, float thickness=1)
Draws an outline of a triangle on the screen.
Definition: JGL.cpp:673
void FillRoundedRect(const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5, unsigned int subdivisions=8)
Draws a filled rectangle with rounded corners on the screen.
Definition: JGL.cpp:289
void DrawPoints(const Color4 &color, const Vector2 *points, int num_points, float radius=1.f)
Plots a series of pixel-points on the screen, in a batch.
Definition: JGL.cpp:873
void DrawArc(const Color4 &color, const Vector2 ¢er, float radius, float arc_begin, float arc_end, unsigned int subdivisions, float thickness)
Draws an Arc (section of a circle) to the screen.
Definition: JGL.cpp:753
void FillTriangle(const Color4 &color, const Triangle2D &tri)
Draws a filled triangle on the screen.
Definition: JGL.cpp:686
void DrawRenderTarget(const RenderTarget &render_target, const Vector2 &position, float rad_rotation=0, const Vector2 &origin=Vector2(0, 0), const Vector2 &scale=Vector2(1, 1), const Color4 &color=Colors::White, Direction inversion=Direction::None)
Draws a render-target (runtime-modifiable texture) to the screen.
Definition: JGL.cpp:343
void DrawString(const Color4 &color, const std::string &text, const Vector3 &pos, float scale, u32 size, const Font &font, const EulerAngle &angle={0, 0, 0}, bool draw_back_face=false)
Draws a string of text in 3D space, with an arbitrary rotation.
Definition: TextRendering.cpp:165
void WireframeTriangleMesh(const Color3 &color, const TriangleMesh &mesh, float thickness=1.f)
void DrawCubicBezierCurve(const Color4 &color, const Vector3 &controlA, const Vector3 &pointA, const Vector3 &pointB, const Vector3 &controlB, int subdivisions=10, float thickness=1)
Draws a smooth, curved line segment between two control points, with the curve controlled by the two ...
Definition: JGL.cpp:1451
void FillAABB(const Color4 &color, const Vector3 &pos, const Vector3 &radii)
Draws a solid axis-aligned bounding box in 3D space.
Definition: JGL.cpp:1297
void Init(const Vector2 &window_size, float fov, float far_plane)
Initializes internals for 3D rendering. Probably will be rethought later.
void FillOBB(const Color4 &color, const Vector3 &position, const Vector3 &radii, const EulerAngle &orientation)
Draws an outline of an oriented bounding box in 3D space.
void FillIcosphere(const Color4 &color, const Vector3 &position, float radius, unsigned int subdivisions=10)
Draws a solid Icosphere in 3D space.
void FillCubesphere(const Color4 &color, const Vector3 &position, float radius, unsigned int subdivisions=10)
Draws a solid Cubesphere in 3D space.
void WireframeIcosahedron(const Color4 &color, const Vector3 &position, float radius, float thickness=1.f)
Draws the outline of an Icosahedron in 3D space.
Definition: JGL.cpp:1187
void ChangeFOV(float fov)
Helper function to conveniently change the Field-Of-View.
Definition: JGL.cpp:973
void DrawBillboardString()
Draws a string of text in 3D space that is always facing the exact direction of the camera projection...
void WireframeAABB(const Color4 &color, const Vector3 &pos, const Vector3 &radii, float thickness=1.f)
Draws an outline of an axis-aligned bounding box in 3D space.
Definition: JGL.cpp:1233
void Begin()
Open a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL).
Definition: JGL.cpp:981
void WireframeIcosphere(const Color4 &color, const Vector3 &position, float radius, float thickness=1.f, unsigned int subdivisions=10)
Draws the outline of an Icosphere in 3D space.
Definition: JGL.cpp:1113
void WireframeCubesphere(const Color4 &color, const Vector3 &position, float radius, float thickness=1.f, unsigned int subdivisions=10)
Draws the outline of a Cubesphere in 3D space.
void FillIcosahedron(const Color4 &color, const Vector3 &position, float radius)
Draws a solid Icosahedron in 3D space.
void WireframeOBB(const Color4 &color, const Vector3 &position, const Vector3 &radii, const EulerAngle &orientation, float thickness=1.f)
Draws an outline of an oriented bounding box in 3D space.
void DrawBillboardSprite()
Draws a texture sprite in 3D space that is always facing the exact direction of the camera projection...
void ChangeFarPlane(float far_plane)
Helper function to change the far-plane, which is the cutoff distance for rendering.
Definition: JGL.cpp:977
void WireframeCapsule(const Color3 &color, const Capsule &cap, float thickness=1.f)
void FillSphere(const Color4 &color, const Vector3 &position, float radius, uint sectors=10, uint stacks=10)
Draws a solid Sphere in 3D space.
Definition: JGL.cpp:1363
void FillCapsule(const Color3 &color, const Capsule &capsule)
void DrawLine(const Color4 &color, const Vector3 &A, const Vector3 &B, float thickness=1.f)
Draws a line in 3D space.
Definition: JGL.cpp:1055
void DrawQuaternionGizmo(const Quaternion &, const Vector3 &)
void DrawMatrixGizmo(const Matrix3x3 &, const Vector3 &)
void FillTriangleMesh(const Color3 &color, const TriangleMesh &mesh)
void DrawAxisAngleGizmo(const AxisAngle &, const Vector3 &)
void SetMatrix(const std::vector< GLfloat > &matrix, const Vector2 &window_size)
void End()
Closes a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL).
Definition: JGL.cpp:1031
void WireframeSphere(const Color4 &color, const Vector3 &position, float radius, float thickness=1.f, uint sectors=10, uint stacks=10)
Draws the outline of a Sphere in 3D space.
Definition: JGL.cpp:1068
OpenGL Wrapper for rendering 2D & 3D graphics in both a 2D and 3D context.
Definition: JGL.h:31
bool MeetsRequirements()
Returns true if the graphics driver meets the requirements (GL Version & Extensions).
Definition: JGL.cpp:42
void PurgeFontCache()
Definition: JGL.h:38
void Update(const Vector2 &window_size)
Definition: JGL.cpp:37
std::array< GLfloat, 16 > OpenGLPerspectiveProjectionRH(float fovY, float aspect, float z_near, float z_far)
Definition: JGL.cpp:951
Direction
Definition: Enums.h:4
FontCache fontCache
Definition: FontCache.h:69