@jsulm There're no calls to paintEvent() or update() inside updateGL()
void OpenGLWidget::updateGL()
{
makeCurrent();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); //LEQUAL
glEnable(GL_CULL_FACE);
glFrontFace(GL_CW);
glLineWidth(1.0f);
// glDisable(GL_DITHER);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_MULTISAMPLE);
glViewport(0,0,m_width , m_height);
m_camera = m_cameraController.toMatrix();
QVector3D lightDirection;
switch (m_currView) {
case TopView:
lightDirection = QVector3D(0.0,0.0,1.0);
break;
case BottomView:
lightDirection = QVector3D(0.0,0.0,-1.0);
break;
case LeftView:
lightDirection = QVector3D(-1.0,0.0,0.0);
break;
case RightView:
lightDirection = QVector3D(1.0,0.0,0.0);
break;
case FrontView:
lightDirection = QVector3D(0.0,-1.0,0.0);
break;
case BackView:
lightDirection = QVector3D(0.0,1.0,0.0);
break;
}
lightDirection.normalize();
QVector3D directionalColor = QVector3D(0.3,0.3,0.3);
QVector3D ambientLight = QVector3D(0.5,0.5,0.5);
m_world.setToIdentity();
m_world.translate(m_modelBox.getCenterPoint());
m_world.rotate(m_rotation);
m_world.scale(1.0f, 1.0f, m_worldZScalar);
m_world.translate(-m_modelBox.getCenterPoint());
QMatrix3x3 normalMatrix = m_world.normalMatrix();
if(geometries){
if(!m_drawWireFrame){
m_programGrid->bind();
//Set MVP Uniforms
m_programGrid->setUniformValue(m_projMatrixLoc, m_proj);
m_programGrid->setUniformValue(m_mvMatrixLoc, m_camera * m_world);
m_programGrid->setUniformValue(m_normalMatrixLoc, normalMatrix);
//Set Lighting Uniforms.
m_programGrid->setUniformValue(m_lightDirectionLoc, lightDirection);
m_programGrid->setUniformValue(m_directionalColorLoc, directionalColor);
m_programGrid->setUniformValue(m_ambientColorLoc, ambientLight);
//Draw Grid Geometry
geometries->drawGeometry(m_programGrid);
m_programGrid->release();
//Draw Border Lines
if(m_showBorders){
m_programLines->bind();
m_programLines->setUniformValue(m_projMatrixLocLines, m_proj);
m_programLines->setUniformValue(m_mvMatrixLocLines, m_camera * m_world);
geometries->drawLines(m_programLines, QVector3D(0.0,0.0,0.0));
m_programLines->release();
}
}else{
m_programLines->bind();
m_programLines->setUniformValue(m_projMatrixLocLines, m_proj);
m_programLines->setUniformValue(m_mvMatrixLocLines, m_camera * m_world);
geometries->drawLines(m_programLines, QVector3D(1.0,1.0,1.0));
m_programLines->release();
}
}
if(wellgeometries){
glLineWidth(4.0f);
m_programLines->bind();
m_programLines->setUniformValue(m_projMatrixLocLines, m_proj);
m_programLines->setUniformValue(m_mvMatrixLocLines, m_camera * m_world);
wellgeometries->drawLines(m_programLines, QVector3D(1.0,0.0,0.0));
m_programLines->release();
}
if(m_showCompass){
glDisable(GL_DEPTH_TEST);
glViewport(0,0,100,100);
m_world.setToIdentity();
m_world.translate(0,0,-5);
m_world.rotate(m_cameraController.rotation().inverted());
m_world.rotate(m_rotation);
QMatrix4x4 proj;
// Set near plane, far plane , field of view
const qreal zNear = 1.0f, zFar = 150.0f, fov = 45.0;
proj.setToIdentity();
proj.perspective(fov, 1.0f, zNear, zFar);
m_programGrid->bind();
m_programGrid->setUniformValue(m_projMatrixLoc, proj);
m_programGrid->setUniformValue(m_mvMatrixLoc, m_world);
m_programGrid->setUniformValue(m_normalMatrixLoc, normalMatrix);
//Set Lighting Uniforms.
m_programGrid->setUniformValue(m_lightDirectionLoc, lightDirection);
m_programGrid->setUniformValue(m_directionalColorLoc, directionalColor);
m_programGrid->setUniformValue(m_ambientColorLoc, ambientLight);
compass->drawCompassGeometry(m_programGrid);
m_programGrid->release();
}
//doneCurrent();
}