Add Shader::OnCompilationErrorMessag
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 2m6s

This commit is contained in:
2025-04-15 19:11:07 -05:00
parent 2a2410e9bf
commit 4374b83464
3 changed files with 9 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
#include <fstream>
#include <iostream>
#include "glad/glad.h"
#include <Event.h>
// LearnOpenGL::Shader
// OpenGL Shader Class Wrapper
@@ -21,6 +22,8 @@ namespace JGL {
class JGL::Shader {
public:
static inline Event<std::string, std::string> OnCompilationErrorMessage;
/// The default constructor does not initialize any member values.
Shader() = default;

View File

@@ -332,6 +332,10 @@ int main(int argc, char** argv) {
if (!file.is_open())
return -1;
Shader::OnCompilationErrorMessage += [] (std::string type, std::string info) {
std::cout << type << ", " << info << std::endl;
};
/*
std::stringstream buffer;
buffer << file.rdbuf();

View File

@@ -109,13 +109,13 @@ namespace JGL {
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
if (!success) {
glGetShaderInfoLog(shader, 1024, NULL, infoLog);
std::cout << "ERROR::SHADER_COMPILATION_ERROR of " << type << "\n" << infoLog << std::endl;
OnCompilationErrorMessage.Invoke( std::format("COMPILATION_ERROR: {}", type), infoLog);
}
} else {
glGetProgramiv(shader, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(shader, 1024, NULL, infoLog);
std::cout << "ERROR::PROGRAM_LINKING_ERROR of " << type << "\n" << infoLog << std::endl;
OnCompilationErrorMessage.Invoke(std::format("COMPILATION_ERROR: {}", type), infoLog);
}
}