diff -r f7dd937667a5 -r f99d52b1646b src/gl/gridprogram.cpp --- a/src/gl/gridprogram.cpp Fri Feb 28 19:24:33 2020 +0200 +++ b/src/gl/gridprogram.cpp Sat Feb 29 23:43:38 2020 +0200 @@ -28,11 +28,11 @@ uniform mat4 model; smooth out vec2 ex_uv; const mat4 stretch = mat4(vec4(10000, 0, 0, 0), vec4(0, 10000, 0, 0), vec4(0, 0, 10000, 0), vec4(0, 0, 0, 1)); -const mat4 gridmatrix = mat4(vec4(1, 0, 0, 0), vec4(0, 1, 0, 0), vec4(0, 0, 1, 0), vec4(0, 0, 0, 1)); +uniform mat4 grid; void main() { - gl_Position = projection * view * model * gridmatrix * stretch * vec4(in_position, 0.0, 1.0); + gl_Position = projection * view * model * grid * stretch * vec4(in_position, 0.0, 1.0); ex_uv = in_position; } )"; @@ -99,27 +99,29 @@ void GridProgram::setViewMatrix(const glm::mat4& newViewMatrix) { - Q_ASSERT(this->isInitialized); - this->program->bind(); - this->program->setUniformMatrix("view", newViewMatrix); - this->program->release(); - this->checkForGLErrors(); + this->setMatrix("view", newViewMatrix); } void GridProgram::setProjectionMatrix(const glm::mat4& newProjectionMatrix) { - Q_ASSERT(this->isInitialized); - this->program->bind(); - this->program->setUniformMatrix("projection", newProjectionMatrix); - this->program->release(); - this->checkForGLErrors(); + this->setMatrix("projection", newProjectionMatrix); } void GridProgram::setModelMatrix(const glm::mat4& newModelMatrix) { + this->setMatrix("model", newModelMatrix); +} + +void GridProgram::setGridMatrix(const glm::mat4& newGridMatrix) +{ + this->setMatrix("grid", newGridMatrix); +} + +void GridProgram::setMatrix(const char* name, const glm::mat4& matrix) +{ Q_ASSERT(this->isInitialized); this->program->bind(); - this->program->setUniformMatrix("model", newModelMatrix); + this->program->setUniformMatrix(name, matrix); this->program->release(); this->checkForGLErrors(); }