parent
538453c1db
commit
fbb51563c9
|
@ -530,9 +530,6 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Backface Culling</string>
|
<string>Backface Culling</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -36,7 +36,7 @@ private:
|
||||||
void clearData();
|
void clearData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void drawGeometry(QOpenGLShaderProgram *program, bool wireframe);
|
void drawGeometry(QOpenGLShaderProgram *program);
|
||||||
void loadFile(QString filePath);
|
void loadFile(QString filePath);
|
||||||
|
|
||||||
// signals
|
// signals
|
||||||
|
|
|
@ -27,6 +27,7 @@ private:
|
||||||
|
|
||||||
bool m_wireframe = false;
|
bool m_wireframe = false;
|
||||||
bool m_lightOn = false;
|
bool m_lightOn = false;
|
||||||
|
bool m_backfaceCulling = false;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
QVector4D position = { 1,1,1,0 };
|
QVector4D position = { 1,1,1,0 };
|
||||||
|
|
|
@ -51,7 +51,7 @@ void GeometryEngine::clearData()
|
||||||
m_drawList.clear();
|
m_drawList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
|
void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||||
{
|
{
|
||||||
if (!m_arrayBuf.isCreated() || !m_indexBuf.isCreated())
|
if (!m_arrayBuf.isCreated() || !m_indexBuf.isCreated())
|
||||||
return;
|
return;
|
||||||
|
@ -133,12 +133,8 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
|
||||||
program->setUniformValue("materialSpecularColor", specularColor);
|
program->setUniformValue("materialSpecularColor", specularColor);
|
||||||
|
|
||||||
// Draw cube geometry using indices from VBO 1
|
// Draw cube geometry using indices from VBO 1
|
||||||
if (wireframe)
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
||||||
|
|
||||||
glDrawElements(GL_TRIANGLES, it.size, GL_UNSIGNED_INT, (void*)(it.offset * sizeof(GLuint)));
|
glDrawElements(GL_TRIANGLES, it.size, GL_UNSIGNED_INT, (void*)(it.offset * sizeof(GLuint)));
|
||||||
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ void OglViewerWidget::initializeGL()
|
||||||
|
|
||||||
//TODO: does not work
|
//TODO: does not work
|
||||||
// Enable back face culling
|
// Enable back face culling
|
||||||
glEnable(GL_CULL_FACE);
|
//glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
// Enable transparency
|
// Enable transparency
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -164,7 +164,16 @@ void OglViewerWidget::paintGL()
|
||||||
m_program.setUniformValue("cameraPosition", rotateBack * (-m_translation));
|
m_program.setUniformValue("cameraPosition", rotateBack * (-m_translation));
|
||||||
|
|
||||||
// Draw cube geometry
|
// 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 ///////////////////////////////////////////////////////////////
|
// Inputs ///////////////////////////////////////////////////////////////
|
||||||
|
@ -410,11 +419,7 @@ void OglViewerWidget::setAmbCoef(double value)
|
||||||
|
|
||||||
void OglViewerWidget::setBackfaceCulling(bool value)
|
void OglViewerWidget::setBackfaceCulling(bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
m_backfaceCulling = value;
|
||||||
glCullFace(GL_FRONT_AND_BACK);
|
|
||||||
else if(!value)
|
|
||||||
glCullFace(GL_FRONT);
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue