Merge pull request #15376 from wwmayer/issue_15369
Gui: Allow to set MSAA 4x option
This commit is contained in:
@@ -265,7 +265,7 @@ but slower response to any scene changes.</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="Gui::PrefComboBox" name="comboAliasing">
|
||||
<widget class="QComboBox" name="comboAliasing">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
@@ -275,12 +275,6 @@ but slower response to any scene changes.</string>
|
||||
<property name="toolTip">
|
||||
<string>What kind of multisample anti-aliasing is used</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>AntiAliasing</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <App/Application.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Gui/Multisample.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
#include "DlgSettings3DViewImp.h"
|
||||
@@ -97,88 +98,35 @@ void DlgSettings3DViewImp::loadSettings()
|
||||
loadMarkerSize();
|
||||
}
|
||||
|
||||
namespace {
|
||||
class GLFormatCheck {
|
||||
public:
|
||||
GLFormatCheck() {
|
||||
context.setFormat(format);
|
||||
context.create();
|
||||
offscreen.setFormat(format);
|
||||
offscreen.create();
|
||||
context.makeCurrent(&offscreen);
|
||||
}
|
||||
|
||||
bool testSamples(int num) {
|
||||
QOpenGLFramebufferObjectFormat fboFormat;
|
||||
fboFormat.setAttachment(QOpenGLFramebufferObject::Depth);
|
||||
fboFormat.setSamples(num);
|
||||
QOpenGLFramebufferObject fbo(100, 100, fboFormat); // NOLINT
|
||||
return fbo.format().samples() == num;
|
||||
}
|
||||
|
||||
private:
|
||||
QSurfaceFormat format;
|
||||
QOpenGLContext context;
|
||||
QOffscreenSurface offscreen;
|
||||
};
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::addAntiAliasing()
|
||||
{
|
||||
QString none = QCoreApplication::translate("Gui::Dialog::DlgSettings3DView", "None");
|
||||
QString line = QCoreApplication::translate("Gui::Dialog::DlgSettings3DView", "Line Smoothing");
|
||||
QString msaa2x = QCoreApplication::translate("Gui::Dialog::DlgSettings3DView", "MSAA 2x");
|
||||
QString msaa4x = QCoreApplication::translate("Gui::Dialog::DlgSettings3DView", "MSAA 4x");
|
||||
QString msaa6x = QCoreApplication::translate("Gui::Dialog::DlgSettings3DView", "MSAA 6x");
|
||||
QString msaa8x = QCoreApplication::translate("Gui::Dialog::DlgSettings3DView", "MSAA 8x");
|
||||
ui->comboAliasing->clear();
|
||||
ui->comboAliasing->addItem(none, int(Gui::View3DInventorViewer::None));
|
||||
ui->comboAliasing->addItem(line, int(Gui::View3DInventorViewer::Smoothing));
|
||||
|
||||
// Do the samples checks only once
|
||||
static std::vector<std::pair<QString, int>> modes;
|
||||
static std::vector<std::pair<QString, AntiAliasing>> modes;
|
||||
static bool formatCheck = true;
|
||||
if (formatCheck) {
|
||||
formatCheck = false;
|
||||
|
||||
GLFormatCheck check;
|
||||
// NOLINTBEGIN
|
||||
if (check.testSamples(2)) {
|
||||
modes.emplace_back(msaa2x, int(Gui::View3DInventorViewer::MSAA2x));
|
||||
}
|
||||
if (check.testSamples(4)) {
|
||||
modes.emplace_back(msaa4x, int(Gui::View3DInventorViewer::MSAA4x));
|
||||
}
|
||||
if (check.testSamples(6)) {
|
||||
modes.emplace_back(msaa6x, int(Gui::View3DInventorViewer::MSAA6x));
|
||||
}
|
||||
if (check.testSamples(8)) {
|
||||
modes.emplace_back(msaa8x, int(Gui::View3DInventorViewer::MSAA8x));
|
||||
}
|
||||
// NOLINTEND
|
||||
Multisample check;
|
||||
modes = check.supported();
|
||||
}
|
||||
|
||||
for (const auto& it : modes) {
|
||||
ui->comboAliasing->addItem(it.first, it.second);
|
||||
ui->comboAliasing->addItem(it.first, int(it.second));
|
||||
}
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::saveAntiAliasing()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
|
||||
int index = ui->comboAliasing->currentIndex();
|
||||
int aliasing = ui->comboAliasing->itemData(index).toInt();
|
||||
hGrp->SetInt("AntiAliasing", aliasing);
|
||||
Multisample::writeMSAAToSettings(static_cast<AntiAliasing>(aliasing));
|
||||
}
|
||||
|
||||
void DlgSettings3DViewImp::loadAntiAliasing()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/View");
|
||||
|
||||
int aliasing = int(hGrp->GetInt("AntiAliasing", int(Gui::View3DInventorViewer::None)));
|
||||
int aliasing = int(Multisample::readMSAAFromSettings());
|
||||
int index = ui->comboAliasing->findData(aliasing);
|
||||
if (index != -1) {
|
||||
ui->comboAliasing->setCurrentIndex(index);
|
||||
|
||||
Reference in New Issue
Block a user