change background when the light is on

This commit is contained in:
Anakin 2017-01-20 16:39:17 +01:00
parent 9808cd03c0
commit af94ecd541
3 changed files with 12 additions and 3 deletions

View File

@ -44,6 +44,8 @@ private:
float ambientCoefficient = 0.005f;
} m_light;
QVector4D m_backgroundColor = {0.5f, 0.8f, 1.0f, 1.0f};
QOpenGLShaderProgram m_program;
GeometryEngine *m_dataEngine;

View File

@ -188,6 +188,7 @@ void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int ver
int count(0);
//TODO: mark not opened textures
//TODO: add more information
for (auto& it : *materials)
{
m_fileInfo += "Material ";

View File

@ -184,7 +184,7 @@ void OglViewerWidget::initializeGL()
{
initializeOpenGLFunctions();
glClearColor(0.5000f, 0.8000f, 1.0000f, 0.0000f);
//glClearColor(0.5000f, 0.8000f, 1.0000f, 0.0000f);
initShaders();
@ -222,6 +222,12 @@ void OglViewerWidget::paintGL()
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (m_backgroundColor[3] == 1.0)
{
glClearColor(m_backgroundColor[0], m_backgroundColor[1], m_backgroundColor[2], 0.0000f);
m_backgroundColor[3] = 0.0;
}
// Calculate model view transformation
QMatrix4x4 view;
view.translate(m_translation);
@ -330,13 +336,13 @@ void OglViewerWidget::toggleLight()
if (m_lightOn)
{
glClearColor(m_light.intensities.x() / 100, m_light.intensities.y() / 100, m_light.intensities.z() / 100, 0.0000f);
m_backgroundColor = { m_light.intensities.x() / 100, m_light.intensities.y() / 100, m_light.intensities.z() / 100, 1.0 };
updateLightPosition();
}
else
{
glClearColor(0.5000f, 0.8000f, 1.0000f, 0.0000f);
m_backgroundColor = { 0.5f, 0.8f, 1.0f, 1.0 };
}
update();