Account for flip in face culling winding for GL clip origin

* The GL clip origin when changed from lower left to upper left will also invert
  the face culling sense. This is deliberate to counteract the fact that
  otherwise CW wound triangles would be CCW wound, so the flip means that if
  GL_CCW is the front face state and back faces are culled, then visibly CCW
  wound triangles will be culled.
This commit is contained in:
baldurk
2022-06-21 12:51:31 +01:00
parent e903589e95
commit 2020a71cf1
3 changed files with 49 additions and 13 deletions
+4 -1
View File
@@ -2386,7 +2386,8 @@ bool QCollatorSortFilterProxyModel::lessThan(const QModelIndex &source_left,
void addGridLines(QGridLayout *grid, QColor gridColor)
{
QString style =
QFormatStr("border: solid #%1%2%3; border-bottom-width: 1px; border-right-width: 1px;")
QFormatStr(
"QLabel { border: solid #%1%2%3; border-bottom-width: 1px; border-right-width: 1px;")
.arg(gridColor.red(), 2, 16, QLatin1Char('0'))
.arg(gridColor.green(), 2, 16, QLatin1Char('0'))
.arg(gridColor.blue(), 2, 16, QLatin1Char('0'));
@@ -2412,6 +2413,8 @@ void addGridLines(QGridLayout *grid, QColor gridColor)
if(y == 0)
cellStyle += lit("border-top-width: 1px;");
cellStyle += lit(" };");
w->setStyleSheet(cellStyle);
}
}
@@ -686,7 +686,8 @@ void GLPipelineStateViewer::clearState()
ui->fillMode->setText(tr("Solid", "Fill Mode"));
ui->cullMode->setText(tr("Front", "Cull Mode"));
ui->frontCCW->setPixmap(tick);
ui->frontFace->setText(tr("CCW"));
ui->frontFace->setToolTip(QString());
ui->scissorEnabled->setPixmap(tick);
ui->provoking->setText(tr("Last"));
@@ -1788,7 +1789,37 @@ void GLPipelineStateViewer::setState()
ui->fillMode->setText(ToQStr(state.rasterizer.state.fillMode));
ui->cullMode->setText(ToQStr(state.rasterizer.state.cullMode));
ui->frontCCW->setPixmap(state.rasterizer.state.frontCCW ? tick : cross);
if(state.rasterizer.state.frontCCW)
{
if(state.vertexProcessing.clipOriginLowerLeft)
{
ui->frontFace->setText(tr("CCW"));
ui->frontFace->setToolTip(QString());
}
else
{
ui->frontFace->setText(tr("CW (clip origin flipped)"));
ui->frontFace->setToolTip(
tr("The GL state specifies that front faces have CCW winding,\n"
"but this is inverted by the upper-left clip origin."));
}
}
else
{
if(state.vertexProcessing.clipOriginLowerLeft)
{
ui->frontFace->setText(tr("CW"));
ui->frontFace->setToolTip(QString());
}
else
{
ui->frontFace->setText(tr("CCW (clip origin flipped)"));
ui->frontFace->setToolTip(
tr("The GL state specifies that front faces have CW winding,\n"
"but this is inverted by the upper-left clip origin."));
}
}
ui->scissorEnabled->setPixmap(anyScissorEnable ? tick : cross);
ui->provoking->setText(state.vertexInput.provokingVertexLast ? tr("Last") : tr("First"));
@@ -2552,9 +2552,9 @@
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="frontCCWLabel">
<widget class="QLabel" name="rasterizerDiscardLabel">
<property name="text">
<string>Front CCW:</string>
<string>Rasterizer Discard:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -2565,7 +2565,7 @@
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="frontCCW">
<widget class="QLabel" name="rasterizerDiscard">
<property name="text">
<string/>
</property>
@@ -2581,9 +2581,9 @@
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="rasterizerDiscardLabel">
<widget class="QLabel" name="frontFaceLabel">
<property name="text">
<string>Rasterizer Discard:</string>
<string>Front:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -2594,12 +2594,14 @@
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="rasterizerDiscard">
<property name="text">
<string/>
<widget class="QLabel" name="frontFace">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="pixmap">
<pixmap resource="../../Resources/resources.qrc">:/cross.png</pixmap>
<property name="text">
<string>CCW</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>