Skip to content

Commit

Permalink
Report setting inexistent uniforms + added ShaderProgram::getLog
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattias Refeyton committed Mar 1, 2024
1 parent 2aef768 commit 5b25aff
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Empty/src/Empty/gl/ShaderProgram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ namespace Empty::gl
if (entry == _uniforms.end())
{
location loc = findUniform(name);
ASSERT(loc > -1);
if (loc < 0)
FATAL("Tried to set non-existing uniform '" << name << "' in shader program '" << label << "'. Make sure the spelling is right and the program is linked.");
auto& u = _uniforms[name] = ProgramUniform{ std::make_shared<Uniform<T>>(name, value), loc };
u.uniform->upload(_id, loc);
}
Expand Down Expand Up @@ -144,6 +145,21 @@ namespace Empty::gl
void registerTexture(const std::string_view& name, const TextureInfo& tex, bool autobind = true);
size_t getTexturesAmount() const { return _textures.size(); }

/**
* Returns the current information log for this program.
*/
std::string getLog() const
{
int logSize = getParameter<ProgramParam::InfoLogLength>();
std::string log;
if (logSize > 0)
{
log.resize(logSize);
glGetProgramInfoLog(*_id, logSize, NULL, log.data());
}
return log;
}

template <ProgramParam CTParam,
std::enable_if_t<CTParam == ProgramParam::DeleteStatus || CTParam == ProgramParam::LinkStatus
|| CTParam == ProgramParam::ValidateStatus, int> = 0>
Expand Down

0 comments on commit 5b25aff

Please sign in to comment.