Writing JGL library interface
This commit is contained in:
@@ -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
|
||||||
|
@@ -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)
|
||||||
{
|
{
|
||||||
|
2
main.cpp
2
main.cpp
@@ -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
|
||||||
|
Reference in New Issue
Block a user