Commit af94ecd5 authored by Anakin's avatar Anakin

change background when the light is on

parent 9808cd03
......@@ -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;
......
......@@ -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 ";
......
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment