Cleanup & Update ReTexture.
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m29s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m29s
This commit is contained in:
@@ -41,7 +41,7 @@ CPMAddPackage(
|
||||
|
||||
CPMAddPackage(
|
||||
NAME ReTexture
|
||||
URL https://git.redacted.cc/Redacted/ReTexture/archive/Prerelease-2.zip
|
||||
URL https://git.redacted.cc/Redacted/ReTexture/archive/Release-1.zip
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
|
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/J3ML.h>
|
||||
|
||||
namespace JGL {
|
||||
enum class Gradient : u8 {
|
||||
Vertical = 0,
|
||||
Horizontal = 1,
|
||||
DiagonalTopLeft = 2,
|
||||
DiagonalBottomLeft = 3
|
||||
};
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace JGL {
|
||||
enum Inversion {
|
||||
None = 0,
|
||||
Vertical = 1,
|
||||
Horizontal = 2,
|
||||
};
|
||||
|
||||
inline Inversion operator|(Inversion a, Inversion b) {
|
||||
return static_cast<Inversion>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
|
||||
}
|
@@ -15,8 +15,7 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <JGL/Color4.h>
|
||||
#include <JGL/Gradient.h>
|
||||
#include <JGL/Inversion.h>
|
||||
#include <JGL/enums.h>
|
||||
#include <JGL/FontCache.h>
|
||||
#include <JGL/Font.h>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
@@ -103,16 +102,16 @@ namespace JGL {
|
||||
void OutlineRect(const Color3& color, const Vector2& pos, const Vector2& size, float thickness = 1);
|
||||
|
||||
///Draws a sprite to the screen.
|
||||
void DrawSprite(GLuint texture, const Vector2& pos, const Vector2& size, u8 opacity = 255, Inversion inversion = Inversion::None);
|
||||
void DrawSprite(GLuint texture, float x, float y, float w, float h, u8 opacity = 255, Inversion inversion = Inversion::None);
|
||||
void DrawSprite(GLuint texture, const Vector2& pos, const Vector2& size, u8 opacity = 255, Inversion::Inversion inversion = Inversion::None);
|
||||
void DrawSprite(GLuint texture, float x, float y, float w, float h, u8 opacity = 255, Inversion::Inversion inversion = Inversion::None);
|
||||
|
||||
/// Draws a filled rectangle on the screen.
|
||||
void FillRect(const Color4& color, const Vector2& pos, const Vector2& size);
|
||||
void FillRect(const Color3& color, const Vector2& pos, const Vector2& size);
|
||||
|
||||
/// Draws a filled rectangle where the color transitions across it.
|
||||
void FillGradientRect(const Color4& color1, const Color4& color2, const Gradient& gradient, const Vector2& pos, const Vector2& size);
|
||||
void FillGradientRect(const Color3& color1, const Color3& color2, const Gradient& gradient, const Vector2& pos, const Vector2& size);
|
||||
void FillGradientRect(const Color4& color1, const Color4& color2, const Gradient::Gradient& gradient, const Vector2& pos, const Vector2& size);
|
||||
void FillGradientRect(const Color3& color1, const Color3& color2, const Gradient::Gradient& gradient, const Vector2& pos, const Vector2& size);
|
||||
|
||||
/// Draws a filled rectangle with rounded corners on the screen.
|
||||
void FillRoundedRect(const Color4& color, const Vector2 &pos, const Vector2 &size, float radius = 5, unsigned int subdivisions = 8);
|
||||
|
26
include/JGL/enums.h
Normal file
26
include/JGL/enums.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
namespace JGL::Inversion {
|
||||
enum Inversion {
|
||||
None = 0,
|
||||
Vertical = 1,
|
||||
Horizontal = 2,
|
||||
};
|
||||
|
||||
inline Inversion operator|(Inversion a, Inversion b) {
|
||||
return static_cast<Inversion>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
}
|
||||
|
||||
namespace JGL::Gradient {
|
||||
enum Gradient {
|
||||
Vertical = 0,
|
||||
Horizontal = 1,
|
||||
DiagonalTopLeft = 2,
|
||||
DiagonalBottomLeft = 3
|
||||
};
|
||||
|
||||
inline Gradient operator|(Gradient a, Gradient b) {
|
||||
return static_cast<Gradient>(static_cast<int>(a) | static_cast<int>(b));
|
||||
}
|
||||
}
|
17
main.cpp
17
main.cpp
@@ -5,12 +5,13 @@
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <JGL/Font.h>
|
||||
#include <jlog/jlog.hpp>
|
||||
#include <ReTexture/rTexture.h>
|
||||
#include <ReTexture/Texture.h>
|
||||
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
using namespace JGL;
|
||||
using namespace ReTexture;
|
||||
|
||||
RTexture* image;
|
||||
Texture* image;
|
||||
GLuint imageID;
|
||||
//The Re3D style base projection.
|
||||
std::vector<GLfloat> perspective(float fov, float aspect, float nearPlane, float farPlane) {
|
||||
@@ -90,7 +91,7 @@ public:
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
image = new RTexture("assets/sprites/Re3D.png");
|
||||
image = new Texture("assets/sprites/Re3D.png");
|
||||
glGenTextures(1, &imageID);
|
||||
glBindTexture(GL_TEXTURE_2D, imageID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
@@ -98,10 +99,10 @@ public:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if (image->format == RTextureFormat::RGBA)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->width, image->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixelData.data());
|
||||
if (image->format == RTextureFormat::RGB)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image->width, image->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixelData.data());
|
||||
if (image->getTextureFormat() == TextureFormat::RGBA)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->getWidth(), image->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixelData.data());
|
||||
if (image->getTextureFormat() == TextureFormat::RGB)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image->getWidth(), image->getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixelData.data());
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
@@ -125,7 +126,7 @@ public:
|
||||
|
||||
J2D::Begin();
|
||||
J2D::FillRect(Colors::Blue, {0,52}, {100,100});
|
||||
J2D::DrawSprite(imageID, {0, 52}, {(float) image->width, (float) image->height}, 128);
|
||||
J2D::DrawSprite(imageID, {0, 52}, {(float) image->getWidth(), (float) image->getHeight()}, 128);
|
||||
J2D::FillRect(Color4::FromColor3(Colors::Pinks::HotPink), {68, 120}, {32, 32});
|
||||
J2D::FillGradientRect(Colors::Red, Colors::Blue, Gradient::DiagonalBottomLeft, {100,52}, {100,100});
|
||||
J2D::FillRoundedRect(JGL::Colors::Red, {200, 52}, {100, 100}, 8, 8);
|
||||
|
@@ -126,7 +126,7 @@ namespace JGL {
|
||||
}
|
||||
|
||||
//TODO rotation, I'm unsure if @josh wants degrees or radians.
|
||||
void J2D::DrawSprite(GLuint texture, const Vector2& pos, const Vector2& size, u8 opacity, Inversion inversion) {
|
||||
void J2D::DrawSprite(GLuint texture, const Vector2& pos, const Vector2& size, u8 opacity, Inversion::Inversion inversion) {
|
||||
if (!inJ2D)
|
||||
ERROR("Attempt to Render J2D element before J2D begin.")
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace JGL {
|
||||
glColor4f(baseColor[0], baseColor[1], baseColor[2], baseColor[3]);
|
||||
}
|
||||
|
||||
void J2D::DrawSprite(GLuint texture, float x, float y, float w, float h, u8 opacity, Inversion inversion) {
|
||||
void J2D::DrawSprite(GLuint texture, float x, float y, float w, float h, u8 opacity, Inversion::Inversion inversion) {
|
||||
J2D::DrawSprite(texture, {x, y}, {w, h}, opacity, inversion);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace JGL {
|
||||
J2D::FillRect({color.r, color.g, color.b, 255}, pos, size);
|
||||
}
|
||||
|
||||
void J2D::FillGradientRect(const Color4& color1, const Color4& color2, const Gradient& gradient, const Vector2& pos, const Vector2& size) {
|
||||
void J2D::FillGradientRect(const Color4& color1, const Color4& color2, const Gradient::Gradient& gradient, const Vector2& pos, const Vector2& size) {
|
||||
if (!inJ2D)
|
||||
ERROR("Attempt to Render J2D element before J2D begin.")
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace JGL {
|
||||
glColor4f(baseColor[0], baseColor[1], baseColor[2], baseColor[3]);
|
||||
}
|
||||
|
||||
void J2D::FillGradientRect(const Color3& color1, const Color3& color2, const Gradient& gradient, const Vector2& pos, const Vector2& size) {
|
||||
void J2D::FillGradientRect(const Color3& color1, const Color3& color2, const Gradient::Gradient& gradient, const Vector2& pos, const Vector2& size) {
|
||||
J2D::FillGradientRect({color1.r, color1.g, color1.b, 255}, {color2.r, color2.g, color2.b, 255}, gradient, pos, size);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@
|
||||
|
||||
namespace JGL::Detail
|
||||
{
|
||||
|
||||
FT_Library ft;
|
||||
|
||||
std::vector<Font> fonts;
|
||||
|
Reference in New Issue
Block a user