mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
~ | Shader hot reloading
This commit is contained in:
@ -50,12 +50,13 @@ void ShaderProgram::link()
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderProgram::use() const
|
||||
void ShaderProgram::use()
|
||||
{
|
||||
glUseProgram(_program);
|
||||
this->watchForChanges();
|
||||
}
|
||||
|
||||
void ShaderProgram::dispathCompute(GLuint x, GLuint y, GLuint z) const
|
||||
void ShaderProgram::dispathCompute(GLuint x, GLuint y, GLuint z)
|
||||
{
|
||||
this->use();
|
||||
glDispatchCompute(x, y, z);
|
||||
@ -67,6 +68,19 @@ void ShaderProgram::bindImageTexture(GLuint texture_id, GLuint unit, GLenum acce
|
||||
glBindImageTexture(unit, texture_id, 0, GL_FALSE, 0, access, format);
|
||||
}
|
||||
|
||||
void ShaderProgram::watchForChanges(void)
|
||||
{
|
||||
for (Shader *shader : _shaders)
|
||||
{
|
||||
if (shader->hasChanged())
|
||||
{
|
||||
std::cout << "Shader " << shader->getFilePath() << " has changed" << std::endl;
|
||||
this->reloadShaders();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderProgram::reloadShaders(void)
|
||||
{
|
||||
std::cout << "Reloading shaders" << std::endl;
|
||||
|
Reference in New Issue
Block a user