Commit a7446ab2 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'featureGLStereoOption' into 'master'

Feature gl stereo option

Closes #17

See merge request !82
parents 21b24403 6cf6012a
......@@ -14,6 +14,7 @@
* -profile < compat | core > : request Compatibility or %Core context ( Default = %Core )\n
* -glVersion <int.int> : request specified OpenGL version (Default = 3.2)\n
* -samples <int> : request MSAA with <int> samples (Default = 16)\n
* -glStereo <true | false> : request creation of stereo buffers
* \note The OpenGL command line parameters override stored settings temporarily. To permanently store an OpenGL setting, use the options dialog.
*
* Log options:\n
......
......@@ -357,6 +357,9 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, QString *err
QCommandLineOption samplesOption("samples",QCoreApplication::translate("main","Overwrite multisampling sample count"),QCoreApplication::translate("main","< 0 | 1 | 2 | ... | 16 >"));
parser.addOption(samplesOption);
QCommandLineOption glStereoOption("glStereo",QCoreApplication::translate("main","Overwrite OpenGL Stereo setting"),QCoreApplication::translate("main","< true | false >"));
parser.addOption(glStereoOption);
QCommandLineOption profileOption("profile",QCoreApplication::translate("main","Request OpenGL context profile <profile> with profile set as compat or core"),QCoreApplication::translate("main","< compat | core >"));
parser.addOption(profileOption);
const QCommandLineOption helpOption = parser.addHelpOption();
......@@ -430,6 +433,9 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, QString *err
values[1].toInt());
OpenFlipper::Options::glVersion(version,true);
}
if(parser.isSet("glStereo"))
OpenFlipper::Options::glStereo(parser.value("glStereo")=="true");
if(parser.value(profileOption)=="core")
{
......@@ -545,6 +551,7 @@ int main(int argc, char **argv)
format.setOption(format.options() | QSurfaceFormat::DebugContext);
format.setSamples(OpenFlipper::Options::samples());
format.setStereo(OpenFlipper::Options::glStereo());
QSurfaceFormat::setDefaultFormat(format);
......
......@@ -150,6 +150,9 @@ static bool samplesOverride_ = false;
/// Store the opengl stereo support
static bool glStereo_ = true;
static bool overrideGLStereo_ = false;
static bool requestedGLStereo = false;
static bool GLStereoSet = false;
/// Stereo mode
static StereoMode stereoMode_ = OpenGL;
......@@ -453,13 +456,32 @@ int samples() {
}
/// Store opengl stereo mode setting
void glStereo( bool _glStereo ) {
glStereo_ = _glStereo;
void glStereo( bool _glStereo, bool _temporary ) {
if(!GLStereoSet) // store the first set value because it is used to create the context
{ // so we can display it properly later on in options
requestedGLStereo = _glStereo;
GLStereoSet = true;
}
if(_temporary)
{
glStereo_ = _glStereo;
overrideGLStereo_ = true;
}
else
OpenFlipperSettings().setValue("Core/OpenGL/Stereo",_glStereo);
}
/// get current opengl stereo setting
bool glStereo( ) {
return glStereo_;
if(overrideGLStereo_)
return glStereo_;
else
return OpenFlipperSettings().value("Core/OpenGL/Stereo",false).toBool();
}
/// get the glStereo flag that was used to request the opengl context
bool glStereoRequested( ) {
return requestedGLStereo;
}
/// Store stereo mode setting
......
......@@ -456,11 +456,15 @@ QString helpDirStr();
/// Store opengl stereo support setting
DLLEXPORT
void glStereo( bool _stereo );
void glStereo( bool _stereo, bool _temporary = false );
/// will be set in core is opengl stereo is supported
DLLEXPORT
bool glStereo( );
/// will be set in core is opengl stereo is supported
DLLEXPORT
bool glStereoRequested( );
/// Store stereo mode setting
DLLEXPORT
......
......@@ -223,7 +223,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
glScene_ = new QtGLGraphicsScene (&examiner_widgets_, baseLayout_);
// is stereo possible, use it?
OpenFlipper::Options::glStereo(glWidget_->format().stereo());
OpenFlipper::Options::glStereo(glWidget_->format().stereo(), true);
glView_->setViewport(glWidget_);
glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
......
......@@ -299,7 +299,17 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
else
warning.setColor(samplesWarning->foregroundRole(),Qt::black);
samplesWarning->setPalette(warning);
stereoCheckBox->setChecked(OpenFlipper::Options::glStereoRequested());
QPalette stereoWarn = stereoWarning->palette();
QString stereoValue;
QOpenGLContext::currentContext()->format().stereo() ? stereoValue = "true" : stereoValue = "false";
stereoWarning->setText(stereoValue);
QOpenGLContext::currentContext()->format().stereo() == OpenFlipper::Options::glStereoRequested() ?
stereoWarn.setColor(stereoWarning->foregroundRole(), Qt::black) :
stereoWarn.setColor(stereoWarning->foregroundRole(), Qt::red);
stereoWarning->setPalette(stereoWarn);
VersionComboBox->setCurrentIndex( VersionComboBox->findData(QVariant::fromValue(OpenFlipper::Options::glVersion())));
QPalette version = versionWarning->palette();
versionWarning->setText(QString("%1.%2").arg(QOpenGLContext::currentContext()->format().version().first)
......@@ -640,6 +650,7 @@ void OptionsWidget::slotApply() {
OpenFlipperSettings().setValue("Core/OpenGL/Samples",samples_spinBox->value());
OpenFlipper::Options::glVersion(VersionComboBox->currentData().value<QPair<int,int>>());
OpenFlipper::Options::coreProfile(profileComboBox->currentIndex() == 0);
OpenFlipper::Options::glStereo(stereoCheckBox->isChecked());
//Paths settings
OpenFlipperSettings().setValue("Core/File/MaxRecent",maxRecentBox->value() ) ;
......
......@@ -316,7 +316,7 @@
<x>10</x>
<y>9</y>
<width>532</width>
<height>163</height>
<height>191</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
......@@ -491,6 +491,20 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="profileComboBox">
<item>
<property name="text">
<string>Core</string>
</property>
</item>
<item>
<property name="text">
<string>Compatibility</string>
</property>
</item>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="samplesWarning">
<property name="palette">
......@@ -645,20 +659,6 @@
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="profileComboBox">
<item>
<property name="text">
<string>Core</string>
</property>
</item>
<item>
<property name="text">
<string>Compatibility</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_33">
<property name="text">
......@@ -680,6 +680,117 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Stereo Buffers:</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_36">
<property name="text">
<string>Reported value:</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="stereoWarning">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Value</string>
</property>
</widget>
</item>
<item row="3" column="4">
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_28">
<item>
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="stereoCheckBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment