calculate normal matrix once in cpp (performance),

added bool variable to turn light on/off (still needs button),
This commit is contained in:
Anakin
2017-01-17 20:18:04 +01:00
parent f5863752e2
commit a521dfc292
4 changed files with 34 additions and 17 deletions

View File

@@ -191,6 +191,9 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
// Set model matrix
program->setUniformValue("m_matrix", it.modelMatrix);
// Set normal matrix
program->setUniformValue("n_matrix", (normMatrix * it.modelMatrix).normalMatrix());
// decide if this is transparent
program->setUniformValue("b_transparent", tmp_transparent);

View File

@@ -226,7 +226,8 @@ void OglViewerWidget::paintGL()
// Set view-projection matrix
m_program.setUniformValue("vp_matrix", m_projection * view);
// Set Light
// Set Light values
m_program.setUniformValue("b_light", m_lightOn);
m_program.setUniformValue("light.position", m_light.position);
m_program.setUniformValue("light.intensities", m_light.intensities);