diff --git a/renderlib/graphics/glsl/shaders.cpp b/renderlib/graphics/glsl/shaders.cpp index b7598e3b..ea7796f9 100644 --- a/renderlib/graphics/glsl/shaders.cpp +++ b/renderlib/graphics/glsl/shaders.cpp @@ -2,18 +2,26 @@ #include "shaders/basicVolume_frag_gen.hpp" -static std::unordered_map shader_src = { { "shader", basicVolume_frag_shader } }; +struct ShaderEntry +{ + std::string src; + GLenum type; +}; + +static std::unordered_map shader_src = { + { "basicVolume", { basicVolume_frag_shader, GL_FRAGMENT_SHADER } } +}; static std::unordered_map shaders; bool ShaderArray::BuildShaders() { - for (auto& shader : shader_src) { - GLShader* s = new GLShader(GL_FRAGMENT_SHADER); - if (s->compileSourceCode(shader.second.c_str())) { - shaders[shader.first] = s; + for (auto& shaderEntry : shader_src) { + GLShader* s = new GLShader(shaderEntry.second.type); + if (s->compileSourceCode(shaderEntry.second.src.c_str())) { + shaders[shaderEntry.first] = s; } else { - LOG_ERROR << "Failed to compile shader " << shader.first; + LOG_ERROR << "Failed to compile shader " << shaderEntry.first; return false; } } diff --git a/renderlib/renderlib.cpp b/renderlib/renderlib.cpp index 44b99082..78e442e7 100644 --- a/renderlib/renderlib.cpp +++ b/renderlib/renderlib.cpp @@ -297,6 +297,8 @@ renderlib::initialize(std::string assetPath, bool headless, bool listDevices, in LOG_INFO << "Compiling all shaders..."; if (!ShaderArray::BuildShaders()) { status = 0; + } else { + LOG_INFO << "Shaders compiled successfully"; } delete dummyHeadlessContext;