Add Shader::OnCompilationErrorMessag
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 2m6s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 2m6s
This commit is contained in:
@@ -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;
|
||||
|
||||
|
4
main.cpp
4
main.cpp
@@ -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();
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user