Browse Source

change hash_str creation to use snprintf

main
cinnaboot 5 years ago
parent
commit
6bd954923d
  1. 6
      src/shader.cpp

6
src/shader.cpp

@ -43,10 +43,10 @@ addShaderProgram(MemoryArena* arena,
const char* name)
{
LOGF(Info, "loading shader, %s\n", name);
// TODO: replace std::string w/ utilAllocCStr() ?
std::string hash_str = std::string(vs) + std::string(fs);
const u32 max_len = 256;
u64 hash = utilFNV64a_str(hash_str.substr(0, max_len).c_str());
char input_str[max_len];
snprintf(input_str, max_len, "%s%s", vs, fs);
u64 hash = utilFNV64a_str(input_str);
if (getShaderByHash(gl_ctx, hash)) {
LOGF(Error, "shader is already loaded\n");

Loading…
Cancel
Save