src/gl/basicshaderprogram.cpp

changeset 216
c7241f504117
parent 215
34c6e7bc4ee1
child 250
2837b549e616
--- a/src/gl/basicshaderprogram.cpp	Sun Jun 12 23:59:37 2022 +0300
+++ b/src/gl/basicshaderprogram.cpp	Mon Jun 13 02:18:25 2022 +0300
@@ -43,7 +43,7 @@
 		this->initializeOpenGLFunctions();
 		this->isInitialized = true;
 		this->program = std::make_unique<gl::ShaderProgram>();
-		gl::buildShaders(&*this->program, vertexShaderSource, fragmentShaderSource);
+		gl::buildShaders(this->program.get(), vertexShaderSource, fragmentShaderSource);
 		this->program->bind();
 		this->buffer.create();
 		this->buffer.bind();
@@ -64,9 +64,23 @@
 
 void BasicShader::setMvpMatrix(const glm::mat4& newMvpMatrix)
 {
+	this->setUniformMatrix("mvp", newMvpMatrix);
+}
+
+void BasicShader::setUniformMatrix(const char* name, const glm::mat4& value)
+{
 	Q_ASSERT(this->isInitialized);
 	this->program->bind();
-	this->program->setUniformMatrix("mvp", newMvpMatrix);
+	this->program->setUniformMatrix(name, value);
+	this->program->release();
+	gl::checkForGLErrors(nullptr);
+}
+
+void BasicShader::setUniformVector(const char* name, const glm::vec4& value)
+{
+	Q_ASSERT(this->isInitialized);
+	this->program->bind();
+	this->program->setUniformVector(name, value);
 	this->program->release();
 	gl::checkForGLErrors(nullptr);
 }

mercurial