MCPcopy Create free account
hub / github.com/JeanPhilippeKernel/RendererEngine / Run

Method Run

ZEngine/src/CompilationStage.cpp:14–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 CompilationStage::~CompilationStage() {}
13
14 void CompilationStage::Run(std::vector<ShaderInformation>& information_list) {
15
16 std::for_each(std::begin(information_list), std::end(information_list), [this](ShaderInformation& shader_info) {
17 if (shader_info.CompiledOnce) {
18 return;
19 }
20
21 shader_info.ShaderId = glCreateShader(shader_info.InternalType);
22 const GLchar* source = (const GLchar*) shader_info.Source.c_str();
23 glShaderSource(shader_info.ShaderId, 1, &source, 0);
24
25 glCompileShader(shader_info.ShaderId);
26
27 GLint compile_status;
28 glGetShaderiv(shader_info.ShaderId, GL_COMPILE_STATUS, &compile_status);
29 if (compile_status == GL_FALSE) {
30
31 GLint log_info_length = 0;
32 glGetShaderiv(shader_info.ShaderId, GL_INFO_LOG_LENGTH, &log_info_length);
33
34 std::vector<GLchar> log_message(log_info_length);
35 glGetShaderInfoLog(shader_info.ShaderId, log_info_length, &log_info_length, &log_message[0]);
36 glDeleteShader(shader_info.ShaderId);
37
38 this->m_information.IsSuccess = this->m_information.IsSuccess && false;
39 this->m_information.ErrorMessage.append(std::begin(log_message), std::end(log_message));
40 ZENGINE_CORE_ERROR("------> Failed to compile {} shader", shader_info.Name);
41 }
42 });
43
44 if (!this->m_information.IsSuccess) {
45 ZENGINE_CORE_ERROR("------> Compilation stage completed with errors");
46 ZENGINE_CORE_ERROR("------> {}", this->m_information.ErrorMessage);
47 return;
48 }
49 }
50} // namespace ZEngine::Rendering::Shaders::Compilers

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected