This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
#include <J3ML/J3ML.h>
|
||||
|
||||
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<Inversion>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
}
|
22
src/JGL.cpp
22
src/JGL.cpp
@@ -130,23 +130,15 @@ namespace JGL {
|
||||
if (!inJ2D)
|
||||
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}};
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user