fixed backface culling bug,
todo: connect headligh
This commit is contained in:
@@ -94,7 +94,7 @@ void OglViewerWidget::initializeGL()
|
||||
|
||||
//TODO: does not work
|
||||
// Enable back face culling
|
||||
glEnable(GL_CULL_FACE);
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
// Enable transparency
|
||||
glEnable(GL_BLEND);
|
||||
@@ -164,7 +164,16 @@ void OglViewerWidget::paintGL()
|
||||
m_program.setUniformValue("cameraPosition", rotateBack * (-m_translation));
|
||||
|
||||
// Draw cube geometry
|
||||
m_dataEngine->drawGeometry(&m_program, m_wireframe);
|
||||
if (m_backfaceCulling)
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
if (m_wireframe)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
m_dataEngine->drawGeometry(&m_program);
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
// Inputs ///////////////////////////////////////////////////////////////
|
||||
@@ -410,11 +419,7 @@ void OglViewerWidget::setAmbCoef(double value)
|
||||
|
||||
void OglViewerWidget::setBackfaceCulling(bool value)
|
||||
{
|
||||
if (value)
|
||||
glCullFace(GL_FRONT_AND_BACK);
|
||||
else if(!value)
|
||||
glCullFace(GL_FRONT);
|
||||
|
||||
m_backfaceCulling = value;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user