Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
toloudis committed Dec 30, 2024
1 parent 3f1bb76 commit 2b43edd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 14 additions & 6 deletions renderlib/graphics/glsl/shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@

#include "shaders/basicVolume_frag_gen.hpp"

static std::unordered_map<std::string, std::string> shader_src = { { "shader", basicVolume_frag_shader } };
struct ShaderEntry
{
std::string src;
GLenum type;
};

static std::unordered_map<std::string, ShaderEntry> shader_src = {
{ "basicVolume", { basicVolume_frag_shader, GL_FRAGMENT_SHADER } }
};
static std::unordered_map<std::string, GLShader*> 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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions renderlib/renderlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2b43edd

Please sign in to comment.