Texture class
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m25s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m25s
This commit is contained in:
@@ -17,6 +17,8 @@ namespace JGL
|
||||
Color3(u8 R, u8 G, u8 B);
|
||||
/// Returns a Color3 parsed from the given hexadecimal string.
|
||||
static Color3 FromHex(const std::string& hexCode);
|
||||
|
||||
Color3() = default;
|
||||
public:
|
||||
/// Returns a Color3 that is somewhere in-between this and the given Color3, determined by the alpha [0-1].
|
||||
Color3 Lerp(const Color3& rhs, float alpha) const;
|
||||
|
@@ -13,6 +13,7 @@ namespace JGL
|
||||
u8 b;
|
||||
u8 a;
|
||||
public:
|
||||
Color4() = default;
|
||||
explicit Color4(const Color3& color3, u8 alpha = 255);
|
||||
Color4(u8 red, u8 green, u8 blue, u8 alpha = 255);
|
||||
static Color4 FromColor3(const Color3& color3, u8 alpha = 255);
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <JGL/Color4.h>
|
||||
#include <JGL/Texture.h>
|
||||
#include <JGL/enums.h>
|
||||
#include <JGL/FontCache.h>
|
||||
#include <JGL/Font.h>
|
||||
@@ -102,8 +103,8 @@ 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 = Inversion::None);
|
||||
void DrawSprite(GLuint texture, float x, float y, float w, float h, u8 opacity = 255, Inversion::Inversion inversion = Inversion::None);
|
||||
void DrawSprite(const GLuint& texture, const Vector2& pos, const Vector2& size, u8 opacity = 255, Inversion::Inversion inversion = Inversion::None);
|
||||
void DrawSprite(const GLuint& texture, float x, float y, float w, float h, u8 opacity = 255, Inversion::Inversion inversion = Inversion::None);
|
||||
|
||||
///Draws a non axis-aligned fill rect to the screen.
|
||||
///The order of the vertices must be such that if you were to connect them you'd never go diagonally across the quad.
|
||||
|
29
include/JGL/Texture.h
Normal file
29
include/JGL/Texture.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include <ReTexture/Texture.h>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <JGL/Color3.h>
|
||||
#include <JGL/Color4.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
namespace JGL {
|
||||
class Texture {
|
||||
private:
|
||||
GLuint texture = 0;
|
||||
Vector2 texture_size = {0, 0};
|
||||
ReTexture::TextureFlag texture_flags;
|
||||
ReTexture::TextureFormat texture_format;
|
||||
public:
|
||||
Texture() = default;
|
||||
explicit Texture(const std::string& file);
|
||||
Texture(const std::string& file, const ReTexture::TextureFlag& flags);
|
||||
Texture(const std::vector<unsigned char>& pixel_data, const Vector2& size, const ReTexture::TextureFormat& format);
|
||||
Texture(const std::vector<Color4>& pixel_data, const Vector2& size, const ReTexture::TextureFormat& format);
|
||||
GLuint getTexture();
|
||||
Vector2 getSize();
|
||||
ReTexture::TextureFlag getFlags();
|
||||
ReTexture::TextureFormat getFormat();
|
||||
void eraseTexture();
|
||||
std::vector<Color4> getPixelData();
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user