From 0b7af6fd31657575475aa026333b552da9646c80 Mon Sep 17 00:00:00 2001 From: Redacted Date: Fri, 19 Jul 2024 01:34:43 -0400 Subject: [PATCH] Cleanup --- include/JGL/Inversion.h | 10 +++++++--- src/JGL.cpp | 22 +++++++--------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/include/JGL/Inversion.h b/include/JGL/Inversion.h index 31f5457..f09cb28 100644 --- a/include/JGL/Inversion.h +++ b/include/JGL/Inversion.h @@ -1,10 +1,14 @@ #pragma once -#include + namespace JGL { - enum class Inversion : u8 { + enum Inversion { None = 0, Vertical = 1, Horizontal = 2, - Both = 3 }; + + inline Inversion operator|(Inversion a, Inversion b) { + return static_cast(static_cast(a) | static_cast(b)); + } + } \ No newline at end of file diff --git a/src/JGL.cpp b/src/JGL.cpp index 741d5a4..8ba8a05 100644 --- a/src/JGL.cpp +++ b/src/JGL.cpp @@ -130,23 +130,15 @@ namespace JGL { if (!inJ2D) ERROR("Attempt to Render J2D element before J2D begin.") - std::array textureCoordinates; + std::array textureCoordinates = {Vector2(0, 0), Vector2(0, 1), Vector2(1, 1), Vector2(1, 0)};; const Vector2 vertices[] = {{pos.x, pos.y}, {pos.x, pos.y + size.y}, {pos.x + size.x, pos.y + size.y}, {pos.x + size.x, pos.y}}; - switch (inversion) { - case Inversion::None: - textureCoordinates = {Vector2(0, 0), Vector2(0, 1), Vector2(1, 1), Vector2(1, 0)}; - break; - case Inversion::Vertical: - textureCoordinates = {Vector2(0, 1), Vector2(0, 0), Vector2(1, 0), Vector2(1, 1)}; - break; - case Inversion::Horizontal: - textureCoordinates = {Vector2(1, 0), Vector2(1, 1), Vector2(0, 1), Vector2(0, 0)}; - break; - case Inversion::Both: - textureCoordinates = {Vector2(1, 1), Vector2(1, 0), Vector2(0, 0), Vector2(0, 1)}; - break; - } + if (inversion & Inversion::Vertical) + textureCoordinates = {Vector2(0, 1), Vector2(0, 0), Vector2(1, 0), Vector2(1, 1)}; + if (inversion & Inversion::Horizontal) + textureCoordinates = {Vector2(1, 0), Vector2(1, 1), Vector2(0, 1), Vector2(0, 0)}; + if ((inversion& Inversion::Horizontal) && (inversion& Inversion::Vertical)) + textureCoordinates = {Vector2(1, 1), Vector2(1, 0), Vector2(0, 0), Vector2(0, 1)}; glColor4f(baseColor[0],baseColor[1],baseColor[2],opacity / 255.f); glBindTexture(GL_TEXTURE_2D, texture);