uhhhhhhhhhh yeeeeeeea
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m28s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m28s
This commit is contained in:
30
include/JGL/Font.h
Normal file
30
include/JGL/Font.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace JGL
|
||||
{
|
||||
|
||||
bool InitTextEngine();
|
||||
|
||||
/// A Font class implementation.
|
||||
/// Wraps the font's FreeType asset handle and provides helper functions.
|
||||
class Font {
|
||||
public:
|
||||
/// Default constructor does not initialize any members
|
||||
Font() = default;
|
||||
Font(std::filesystem::path path);
|
||||
/// Destructor handles freeing of the underlying asset handle.
|
||||
~Font();
|
||||
static Font LoadTTF(std::filesystem::path filepath);
|
||||
static std::vector<Font> GetLoadedFonts();
|
||||
Vector2 MeasureString(const std::string& text, float ptSize);
|
||||
public:
|
||||
int index = 0;
|
||||
};
|
||||
}
|
@@ -39,8 +39,8 @@ public:
|
||||
CachedGlyph* getGlyph(char c);
|
||||
std::map<char, CachedGlyph*> getGlyphs();
|
||||
const GLuint* getTexture();
|
||||
const GLsizei getTextureWidth() const;
|
||||
const GLsizei getTextureHeight() const;
|
||||
GLsizei getTextureWidth() const;
|
||||
GLsizei getTextureHeight() const;
|
||||
CachedFont(GLuint texture_id, GLsizei texture_width, GLsizei texture_height, unsigned int font_size, unsigned int font_index);
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,15 @@
|
||||
//
|
||||
// Created by dawsh on 1/17/24.
|
||||
//
|
||||
/// 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.
|
||||
|
||||
/// @file JGL.h
|
||||
/// @desc All JGL usable functions are defined here. This is the public API.
|
||||
/// @edit 2024-07-16
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
@@ -8,6 +17,7 @@
|
||||
#include <JGL/Color4.h>
|
||||
#include <JGL/Gradient.h>
|
||||
#include <JGL/FontCache.h>
|
||||
#include <JGL/Font.h>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
@@ -18,19 +28,10 @@
|
||||
// OpenGL Wrapper for rendering 2D graphics primitives in both a 2D and 3D context
|
||||
namespace JGL {
|
||||
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
using J3ML::LinearAlgebra::Vector3;
|
||||
using J3ML::LinearAlgebra::Matrix3x3;
|
||||
using J3ML::LinearAlgebra::Matrix4x4;
|
||||
using J3ML::LinearAlgebra::AxisAngle;
|
||||
using J3ML::LinearAlgebra::Quaternion;
|
||||
|
||||
using J3ML::Geometry::Sphere;
|
||||
using J3ML::Geometry::OBB;
|
||||
using J3ML::Geometry::Capsule;
|
||||
using J3ML::Geometry::TriangleMesh;
|
||||
using J3ML::Geometry::Plane;
|
||||
using namespace J3ML::LinearAlgebra;
|
||||
using namespace J3ML::Geometry;
|
||||
|
||||
/// TODO:
|
||||
struct HSV {
|
||||
float hue;
|
||||
float saturation;
|
||||
@@ -53,10 +54,10 @@ namespace JGL {
|
||||
|
||||
bool Update(const Vector2& window_size);
|
||||
bool InitTextEngine();
|
||||
int LoadFont(const std::string& font_path);
|
||||
Font LoadFont(const std::string& font_path); // TODO: Fully deprecate
|
||||
void PurgeFontCache();
|
||||
|
||||
void UnloadFont(int font_index);
|
||||
void SetActiveFont(const Font& font); // TODO: Implement
|
||||
// TODO: implement correct coloring
|
||||
|
||||
/// Drawing functions for primitive 2D Shapes.
|
||||
@@ -86,7 +87,7 @@ namespace JGL {
|
||||
/// @param B The end point of the line segment.
|
||||
/// @param thickness The width at which to render the line.
|
||||
void DrawLine(const Color3& color, const Vector2& A, const Vector2& B, float thickness = 1);
|
||||
void DrawLine(const Color3 &color, float x, float y, float w, float h, float thickness = 1);
|
||||
void DrawLine(const Color3& color, float x, float y, float w, float h, float thickness = 1);
|
||||
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);
|
||||
|
||||
@@ -100,6 +101,10 @@ namespace JGL {
|
||||
void OutlineRect(const Color4& color, const Vector2& pos, const Vector2& size, float thickness = 1);
|
||||
void OutlineRect(const Color3& color, const Vector2& pos, const Vector2& size, float thickness = 1);
|
||||
|
||||
///Draws a sprite to the screen.
|
||||
void DrawSprite(GLuint texture, const Vector2& pos, const Vector2& size);
|
||||
void DrawSprite(GLuint texture, float x, float y, float w, float h);
|
||||
|
||||
/// Draws a filled rectangle on the screen.
|
||||
void FillRect(const Color4& color, const Vector2& pos, const Vector2& size);
|
||||
void FillRect(const Color3& color, const Vector2& pos, const Vector2& size);
|
||||
@@ -109,7 +114,7 @@ namespace JGL {
|
||||
void FillGradientRect(const Color3& color1, const Color3& color2, const Gradient& gradient, const Vector2& pos, const Vector2& size);
|
||||
|
||||
/// Draws a filled rectangle with rounded corners on the screen.
|
||||
void FillRoundedRect(const Color4 &color, const Vector2 &pos, const Vector2 &size, float radius = 5, unsigned int subdivisions = 8);
|
||||
void FillRoundedRect(const Color4& color, const Vector2 &pos, const Vector2 &size, float radius = 5, unsigned int subdivisions = 8);
|
||||
void FillRoundedRect(const Color3& color, const Vector2& pos, const Vector2& size, float radius = 5, unsigned int subdivisions = 8);
|
||||
|
||||
/// Draws an outline of a circle on the screen.
|
||||
@@ -130,14 +135,14 @@ namespace JGL {
|
||||
void FillTriangle(const Color3& color, const Triangle2D& tri);
|
||||
// TODO: Implement an overload that simply takes 3 Vector3's
|
||||
|
||||
|
||||
/// Draws a text string on the screen with a given point-size and font.
|
||||
void DrawString(const Color4& color, const std::string& text, float x, float y, float scale, u32 size, unsigned int font_index);
|
||||
void DrawString(const Color3& color, const std::string& text, float x, float y, float scale, u32 size, unsigned int font_index);
|
||||
void DrawString(const Color4& color, const std::string& text, float x, float y, float scale, u32 size, const Font& font);
|
||||
void DrawString(const Color3& color, const std::string& text, float x, float y, float scale, u32 size, const Font& font);
|
||||
|
||||
// TODO: Implement the following:
|
||||
void FillTexturedTriangle();
|
||||
void FillTexturedPolygon();
|
||||
void DrawSprite();
|
||||
void DrawPartialSprite();
|
||||
void DrawCubicBezierCurve();
|
||||
void OutlinePolygon (const Color4& color, std::vector<Vector2> points);
|
||||
@@ -159,7 +164,7 @@ namespace JGL {
|
||||
void WireframeCapsule(const Color3& color, const Capsule& cap, float thickness = 1);
|
||||
void FillTriangleMesh(const Color3& color, const TriangleMesh& mesh);
|
||||
void WireframeTriangleMesh(const Color3& color, const TriangleMesh& mesh, float thickness = 1);
|
||||
void DrawString(const Color3& color, const std::string& text, const Vector3& pos, const Vector3& angle, float scale, u32 size, unsigned int font_index);
|
||||
void DrawString(const Color3& color, const std::string& text, const Vector3& pos, const Vector3& angle, float scale, u32 size, const Font& font);
|
||||
|
||||
void DrawMatrixGizmo (const Matrix3x3&, const Vector3&);
|
||||
void DrawMatrixGizmo (const Matrix4x4&);
|
||||
|
Reference in New Issue
Block a user