This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <J3ML/J3ML.h>
|
|
||||||
namespace JGL {
|
namespace JGL {
|
||||||
enum class Inversion : u8 {
|
enum Inversion {
|
||||||
None = 0,
|
None = 0,
|
||||||
Vertical = 1,
|
Vertical = 1,
|
||||||
Horizontal = 2,
|
Horizontal = 2,
|
||||||
Both = 3
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline Inversion operator|(Inversion a, Inversion b) {
|
||||||
|
return static_cast<Inversion>(static_cast<int>(a) | static_cast<int>(b));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
16
src/JGL.cpp
16
src/JGL.cpp
@@ -130,23 +130,15 @@ namespace JGL {
|
|||||||
if (!inJ2D)
|
if (!inJ2D)
|
||||||
ERROR("Attempt to Render J2D element before J2D begin.")
|
ERROR("Attempt to Render J2D element before J2D begin.")
|
||||||
|
|
||||||
std::array<Vector2, 4> textureCoordinates;
|
std::array<Vector2, 4> 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}};
|
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) {
|
if (inversion & Inversion::Vertical)
|
||||||
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)};
|
textureCoordinates = {Vector2(0, 1), Vector2(0, 0), Vector2(1, 0), Vector2(1, 1)};
|
||||||
break;
|
if (inversion & Inversion::Horizontal)
|
||||||
case Inversion::Horizontal:
|
|
||||||
textureCoordinates = {Vector2(1, 0), Vector2(1, 1), Vector2(0, 1), Vector2(0, 0)};
|
textureCoordinates = {Vector2(1, 0), Vector2(1, 1), Vector2(0, 1), Vector2(0, 0)};
|
||||||
break;
|
if ((inversion& Inversion::Horizontal) && (inversion& Inversion::Vertical))
|
||||||
case Inversion::Both:
|
|
||||||
textureCoordinates = {Vector2(1, 1), Vector2(1, 0), Vector2(0, 0), Vector2(0, 1)};
|
textureCoordinates = {Vector2(1, 1), Vector2(1, 0), Vector2(0, 0), Vector2(0, 1)};
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
glColor4f(baseColor[0],baseColor[1],baseColor[2],opacity / 255.f);
|
glColor4f(baseColor[0],baseColor[1],baseColor[2],opacity / 255.f);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
Reference in New Issue
Block a user