Josh's Graphics Library
|
Josh's Graphics Library A C++20 Library for rendering 2D and 3D primitives in an OpenGL context. More...
#include <string>
#include <Color4.hpp>
#include <JGL/types/Texture.h>
#include <JGL/types/Enums.h>
#include <JGL/types/FontCache.h>
#include <JGL/types/Font.h>
#include <JGL/types/RenderTarget.h>
#include <JGL/types/Light.h>
#include <J3ML/LinearAlgebra.hpp>
#include <J3ML/LinearAlgebra/Vector2.hpp>
#include <J3ML/LinearAlgebra/Vector3.hpp>
#include <J3ML/Geometry/Sphere.hpp>
#include <J3ML/Geometry/Capsule.hpp>
#include <J3ML/Geometry/Triangle2D.hpp>
Go to the source code of this file.
Namespaces | |
namespace | JGL |
OpenGL Wrapper for rendering 2D & 3D graphics in both a 2D and 3D context. | |
namespace | JGL::J2D |
Drawing functions for primitive 2D Shapes. | |
namespace | JGL::J3D |
Drawing functions for primitive 3D Shapes. | |
Functions | |
void | JGL::Update (const Vector2 &window_size) |
void | JGL::PurgeFontCache () |
std::array< GLfloat, 16 > | JGL::OpenGLPerspectiveProjectionRH (float fovY, float aspect, float z_near, float z_far) |
bool | JGL::MeetsRequirements () |
Returns true if the graphics driver meets the requirements (GL Version & Extensions). More... | |
void | JGL::J2D::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). More... | |
void | JGL::J2D::End () |
Closes a 2-D rendering context with the underlying graphics system (In this case& by default OpenGL). More... | |
void | JGL::J2D::LightArray (Light *, size_t size) |
Provide a list of lights to be used in 2D space. More... | |
void | JGL::J2D::LightArray (std::vector< Light > lights) |
void | JGL::J2D::DrawPoint (const Color4 &color, const Vector2 &coordinates, float radius=1.f) |
Plots a single pixel on the screen. More... | |
void | JGL::J2D::DrawPoint (const Color4 &color, float x, float y, float radius=1.f) |
void | JGL::J2D::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. More... | |
void | JGL::J2D::DrawLine (const Color4 &color, const Vector2 &A, const Vector2 &B, float thickness=1) |
Plots a line (segment) on the screen. More... | |
void | JGL::J2D::DrawLine (const Color4 &color, float x1, float y1, float x2, float y2, float thickness=1) |
void | JGL::J2D::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. More... | |
void | JGL::J2D::DrawGradientLine (const Color4 &color_a, const Color4 &color_b, float x, float y, float w, float h, float thickness=1) |
void | JGL::J2D::OutlineRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float thickness=1) |
Draws an outline of a rectangle on the screen. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::FillRect (const Color4 &color, const Vector2 &pos, const Vector2 &size) |
Draws a filled rectangle on the screen. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::FillChamferRect (const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius=5) |
Draws a filled rectangle with chamfered (beveled) corners on the screen. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::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) |
void | JGL::J2D::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. More... | |
void | JGL::J2D::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) |
void | JGL::J2D::DrawSprite (const Texture &texture, 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 to the screen by passing a G̶L̶u̶i̶n̶t̶ JGL Texture that represents a handle to a loaded texture. More... | |
void | JGL::J2D::DrawSprite (const Texture *texture, 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) |
void | JGL::J2D::DrawSprite (const Texture &texture, float positionX, float positionY, 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) |
void | JGL::J2D::DrawSprite (const Texture *texture, float positionX, float positionY, 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) |
void | JGL::J2D::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. More... | |
void | JGL::J2D::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) |
void | JGL::J2D::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, 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) |
void | JGL::J2D::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, 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) |
void | JGL::J2D::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, or both. More... | |
void | JGL::J2D::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) |
void | JGL::J2D::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. More... | |
void | JGL::J2D::FillCircle (const Color4 &color, const Vector2 ¢er, float radius, unsigned int subdivisions=8) |
Draws a filled circle on the screen. More... | |
void | JGL::J2D::OutlineTriangle (const Color4 &color, const Triangle2D &tri, float thickness=1) |
Draws an outline of a triangle on the screen. More... | |
void | JGL::J2D::OutlineTriangle (const Color4 &color, const Vector2 &triA, const Vector2 &triB, const Vector2 &triC, float thickness=1) |
void | JGL::J2D::FillTriangle (const Color4 &color, const Triangle2D &tri) |
Draws a filled triangle on the screen. More... | |
void | JGL::J2D::FIllTriangle (const Color4 &color, const Vector2 &triA, const Vector2 &triB, const Vector2 &triC) |
void | JGL::J2D::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 the three specified colors at each corner. More... | |
void | JGL::J2D::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) |
void | JGL::J2D::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 inner points. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::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. More... | |
void | JGL::J2D::FillPolygon (const Color4 &color, const std::vector< Vector2 > &points) |
TODO Implement the following. These ones are going to be extremely annoying. More... | |
void | JGL::J2D::OutlineEllipse (const Color4 &color, const Vector2 &position, float radius_x, float radius_y, float thickness=1, int subdivisions=8) |
void | JGL::J2D::FillEllipse (const Color4 &color, const Vector2 &position, float radius_x, float radius_y, int subdivisions=8) |
void | JGL::J3D::Init (const Vector2 &window_size, float fov, float far_plane) |
Initializes internals for 3D rendering. Probably will be rethought later. More... | |
void | JGL::J3D::ChangeFOV (float fov) |
Helper function to conveniently change the Field-Of-View. More... | |
void | JGL::J3D::ChangeFarPlane (float far_plane) |
Helper function to change the far-plane, which is the cutoff distance for rendering. More... | |
void | JGL::J3D::Begin () |
Open a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL). More... | |
void | JGL::J3D::End () |
Closes a 3-D rendering context with the underlying graphics system (In this case& by default OpenGL). More... | |
void | JGL::J3D::SetMatrix (const std::vector< GLfloat > &matrix, const Vector2 &window_size) |
void | JGL::J3D::DrawLine (const Color4 &color, const Vector3 &A, const Vector3 &B, float thickness=1.f) |
Draws a line in 3D space. More... | |
void | JGL::J3D::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 inner points. More... | |
void | JGL::J3D::WireframeIcosahedron (const Color4 &color, const Vector3 &position, float radius, float thickness=1.f) |
Draws the outline of an Icosahedron in 3D space. More... | |
void | JGL::J3D::FillIcosahedron (const Color4 &color, const Vector3 &position, float radius) |
Draws a solid Icosahedron in 3D space. More... | |
void | JGL::J3D::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. More... | |
void | JGL::J3D::WireframeSphere (const Color4 &color, const Sphere &sphere, float thickness=1.f, uint sectors=10, uint stacks=10) |
Draws the outline of a Sphere in 3D space. More... | |
void | JGL::J3D::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. More... | |
void | JGL::J3D::WireframeIcosphere (const Color4 &color, const Sphere &sphere, float thickness=1.f, unsigned int subdivisions=10) |
Draws the outline of an Icosphere in 3D space. More... | |
void | JGL::J3D::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. More... | |
void | JGL::J3D::WireframeCubesphere (const Color4 &color, const Sphere &sphere, float thickness=1.f, unsigned int subdivisions=10) |
Draws the outline of a Cubesphere in 3D space. More... | |
void | JGL::J3D::FillSphere (const Color4 &color, const Vector3 &position, float radius, uint sectors=10, uint stacks=10) |
Draws a solid Sphere in 3D space. More... | |
void | JGL::J3D::FillSphere (const Color4 &color, const Sphere &sphere, uint sectors=10, uint stacks=10) |
Draws a solid Sphere in 3D space. More... | |
void | JGL::J3D::FillIcosphere (const Color4 &color, const Vector3 &position, float radius, unsigned int subdivisions=10) |
Draws a solid Icosphere in 3D space. More... | |
void | JGL::J3D::FillIcosphere (const Color4 &color, const Sphere &sphere, unsigned int subdivisions=10) |
Draws a solid Icosphere in 3D space. More... | |
void | JGL::J3D::FillCubesphere (const Color4 &color, const Vector3 &position, float radius, unsigned int subdivisions=10) |
Draws a solid Cubesphere in 3D space. More... | |
void | JGL::J3D::FillCubesphere (const Color4 &color, const Sphere &sphere, unsigned int subdivisions=10) |
Draws a solid Cubesphere in 3D space. More... | |
void | JGL::J3D::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. More... | |
void | JGL::J3D::WireframeAABB (const Color4 &color, const AABB &aabb, float thickness=1.f) |
Draws an outline of an axis-aligned bounding box in 3D space. More... | |
void | JGL::J3D::FillAABB (const Color4 &color, const Vector3 &pos, const Vector3 &radii) |
Draws a solid axis-aligned bounding box in 3D space. More... | |
void | JGL::J3D::FillAABB (const Color4 &color, const AABB &aabb) |
Draws a solid axis-aligned bounding box in 3D space. More... | |
void | JGL::J3D::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. More... | |
void | JGL::J3D::WireframeOBB (const Color4 &color, const OBB &obb, float thickness=1.f) |
Draws an outline of an oriented bounding box in 3D space. More... | |
void | JGL::J3D::FillOBB (const Color4 &color, const Vector3 &position, const Vector3 &radii, const EulerAngle &orientation) |
Draws an outline of an oriented bounding box in 3D space. More... | |
void | JGL::J3D::FillOBB (const Color4 &color, const OBB &obb) |
Draws an outline of an oriented bounding box in 3D space. More... | |
void | JGL::J3D::WireframeCylinder () |
void | JGL::J3D::FillCylinder () |
void | JGL::J3D::WireframePrism () |
void | JGL::J3D::FillPrism () |
void | JGL::J3D::WireframePipe () |
void | JGL::J3D::FillPipe () |
void | JGL::J3D::WireframeCone () |
void | JGL::J3D::FillCone () |
void | JGL::J3D::WireframeTorus () |
void | JGL::J3D::FillTorus () |
void | JGL::J3D::FillCapsule (const Color3 &color, const Capsule &capsule) |
void | JGL::J3D::WireframeCapsule (const Color3 &color, const Capsule &cap, float thickness=1.f) |
void | JGL::J3D::FillTriangleMesh (const Color3 &color, const TriangleMesh &mesh) |
void | JGL::J3D::WireframeTriangleMesh (const Color3 &color, const TriangleMesh &mesh, float thickness=1.f) |
void | JGL::J3D::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. More... | |
void | JGL::J3D::DrawBillboardString () |
Draws a string of text in 3D space that is always facing the exact direction of the camera projection. More... | |
void | JGL::J3D::DrawBillboardSprite () |
Draws a texture sprite in 3D space that is always facing the exact direction of the camera projection. More... | |
void | JGL::J3D::DrawSprite () |
void | JGL::J3D::DrawMatrixGizmo (const Matrix3x3 &, const Vector3 &) |
void | JGL::J3D::DrawMatrixGizmo (const Matrix4x4 &) |
void | JGL::J3D::DrawAxisAngleGizmo (const AxisAngle &, const Vector3 &) |
void | JGL::J3D::DrawQuaternionGizmo (const Quaternion &, const Vector3 &) |
Josh's Graphics Library A C++20 Library for rendering 2D and 3D primitives in an OpenGL context.
Developed and Maintained by Josh O'Leary @ Redacted Software. Special Thanks to William Tomasine II and Maxine Hayes. (c) 2024 Redacted Software This work is dedicated to the public domain.
@desc All JGL usable functions are defined here. This is the public API. @edit 2024-10-24