Writing JGL library interface

This commit is contained in:
scientiist
2024-01-20 12:14:41 -06:00
parent eec161769c
commit d49084e99e
3 changed files with 20 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.27) cmake_minimum_required(VERSION 3.25)
project(JGL project(JGL
VERSION 1.0 VERSION 1.0
LANGUAGES CXX LANGUAGES CXX

View File

@@ -26,7 +26,18 @@ namespace JGL {
int b; int b;
}; };
namespace Colors { namespace Colors {
static const Color3 BrightRed {255, 0, 0};
static const Color3 BrightGreen { 0, 255, 0};
static const Color3 BrightBlue { 0, 0, 255};
static const Color3 White {255, 255, 255};
static const Color3 Black { 0, 0, 0};
static const Color3 Gray {128, 128, 128};
static const Color3 DarkGray {192, 192, 192};
static const Color3 LightGray { 64, 64, 64};
static const Color3 Maroon {};
static const Color3 Fuchsia {};
static const Color3 Lime {};
static const Color3 Olive {};
} }
struct HSV { struct HSV {
float hue; float hue;
@@ -37,6 +48,12 @@ namespace JGL {
Vector2 ScreenToViewport(const Vector2& v) Vector2 ScreenToViewport(const Vector2& v)
{ {
// TODO: Implement matrix transformation // TODO: Implement matrix transformation
float x = v.x / 600.f;
float y = v.y / 600.f;
return {
x - .5f, y - .5f
};
} }
Vector2 ViewportToScreen(const Vector2& v) Vector2 ViewportToScreen(const Vector2& v)
{ {

View File

@@ -42,7 +42,7 @@ void display() {
glVertex2f(-0.9f, -0.3f); glVertex2f(-0.9f, -0.3f);
glEnd(); glEnd();
JGL::FillRect2D(); JGL::FillRect2D({64, 64}, {128, 128}, JGL::Colors::White);
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
glColor3f(0.0f, 0.0f, 1.f); // Blue glColor3f(0.0f, 0.0f, 1.f); // Blue