Update engine components
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 1m32s

This commit is contained in:
2024-08-24 10:58:37 -04:00
parent 4996288163
commit f96a3851a1
8 changed files with 171 additions and 56 deletions

View File

@@ -28,11 +28,11 @@
#include <J3ML/Geometry/Sphere.hpp>
#include <J3ML/Geometry/Capsule.hpp>
#include <J3ML/Geometry/TriangleMesh.hpp>
#include <JGL/Logger.h>
/// OpenGL Wrapper for rendering 2D graphics primitives in both a 2D and 3D context
namespace JGL {
using namespace J3ML::LinearAlgebra;
using namespace J3ML::Geometry;
@@ -63,7 +63,6 @@ namespace JGL {
/// Drawing functions for primitive 2D Shapes.
/// Each function is overloaded with Color3 and Color4 for optional transparency.
namespace J2D {
/// Open a 2-D rendering context with the underlying graphics system (In this case & by default OpenGL).
/// @note This call may not strictly be necessary on some setups, but is provided to keep the API constant.
/// It is recommended to always open a JGL 2D context to render your content, then close when completed.
@@ -74,9 +73,14 @@ namespace JGL {
void End();
/// Sets the active shader program to be used for rendering.
/// 0 for default shader (fixed-function rendering).
void UseProgram(const Shader& shader);
void UseProgram(unsigned int shader_program_handle);
void UseShaderProgram(Shader& shader);
void UseShaderProgram(Shader* shader);
/// Changes back to fixed-function rendering.
void UseFixedFunction();
/// Returns true if we are not using fixed-function rendering.
bool IsUsingShaderProgram();
/// Plots a single pixel on the screen.
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4

11
include/JGL/Logger.h Normal file
View File

@@ -0,0 +1,11 @@
#pragma once
#include <jlog/Logger.hpp>
namespace JGL::Logger {
using namespace jlog;
extern GenericLogger Fatal;
extern GenericLogger Debug;
extern GenericLogger Error;
}

View File

@@ -3,6 +3,8 @@
#include <J3ML/J3ML.hpp>
#include <J3ML/LinearAlgebra.hpp>
#include <glad/glad.h>
#include <Color4.hpp>
#include <Color3.hpp>
namespace JGL {
class Shader;
@@ -33,7 +35,7 @@ namespace JGL {
class JGL::Uniform {
public:
std::string name;
GLint location = NULL;
GLint location = 0;
};
class JGL::Uniform_Float : public Uniform {
@@ -82,6 +84,7 @@ public:
Matrix4x4 value;
};
//TODO attributes.
class JGL::Shader {
private:
///Shader program.
@@ -118,19 +121,27 @@ public:
[[nodiscard]] GLuint GetGLShaderProgramHandle() const;
[[nodiscard]] ShaderType GetShaderType() const;
public:
void SetFloat(const std::string& uniform_name, float value);
void SetInt(const std::string& uniform_name, int value);
void SetBool(const std::string& uniform_name, bool value);
void SetUF(const std::string& uniform_name, float value);
void SetUI(const std::string& uniform_name, int value);
void SetUB(const std::string& uniform_name, bool value);
void SetVector2(const std::string& uniform_name, const Vector2& value);
void SetVector3(const std::string& uniform_name, const Vector3& value);
void SetVector4(const std::string& uniform_name, const Vector4& value);
void SetUV2(const std::string& uniform_name, const Vector2& value);
void SetUV3(const std::string& uniform_name, const Vector3& value);
void SetUV3(const std::string& uniform_name, const Color3& value);
void SetUV4(const std::string& uniform_name, const Vector4& value);
void SetUV4(const std::string& uniform_name, const Color4& value);
void SetMatrix2x2(const std::string& uniform_name, const Matrix2x2& value);
void SetMatrix3x3(const std::string& uniform_name, const Matrix3x3& value);
void SetMatrix4x4(const std::string& uniform_name, const Matrix4x4& value);
void SetUMat2(const std::string& uniform_name, const Matrix2x2& value);
void SetUMat3(const std::string& uniform_name, const Matrix3x3& value);
void SetUMat4(const std::string& uniform_name, const Matrix4x4& value);
/// Zeroes out all uniforms locally.
void ResetLocalUniforms();
/// Zeroes out all uniforms locally and on the GPU.
void ResetUniforms();
/// DMA the uniforms into the Shader Program.
void SubmitUniforms(bool reset_uniforms_in_local_store = true);
public:
Shader(const char* vertex_shader_file, const char* fragment_shader_file);
Shader(const std::string& vertex_shader_text, const std::string& fragment_shader_text);