forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'swick/master'
This commit is contained in:
commit
05649a1654
4 changed files with 55 additions and 99 deletions
|
@ -43,7 +43,7 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &g
|
||||||
connect(rendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
connect(rendererComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(rendererChanged(const QString&)));
|
||||||
connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int)));
|
connect(fullScreenCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotFullScreenChanged(int)));
|
||||||
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
|
connect(standardRadioButton, SIGNAL(toggled(bool)), this, SLOT(slotStandardToggled(bool)));
|
||||||
connect(screenComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(screenChanged(const QString&)));
|
connect(screenComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(screenChanged(int)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,80 +153,24 @@ bool GraphicsPage::setupOgre()
|
||||||
|
|
||||||
bool GraphicsPage::setupSDL()
|
bool GraphicsPage::setupSDL()
|
||||||
{
|
{
|
||||||
// FIXME: do setupSDLWordaround here instead.
|
int displays = SDL_GetNumVideoDisplays();
|
||||||
// seems like Qt, SDL and Ogre don't like each other
|
|
||||||
// results in a segfault if SDL is initialized after Qt
|
|
||||||
|
|
||||||
QStringList screens;
|
if (displays < 0)
|
||||||
for (int i = 0; i < mScreenCount; i++)
|
|
||||||
{
|
{
|
||||||
screens.append(QString("Screen ") + QString::number(i + 1));
|
QMessageBox msgBox;
|
||||||
}
|
msgBox.setWindowTitle(tr("Error receiving number of screens"));
|
||||||
screenComboBox->addItems(screens);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
return true;
|
msgBox.setText(tr("<br><b>SDL_GetNumDisplayModes failed:</b><br><br>") + QString::fromStdString(SDL_GetError()) + "<br>");
|
||||||
}
|
msgBox.exec();
|
||||||
|
|
||||||
std::vector<VideoMode> GraphicsPage::mVideoModes;
|
|
||||||
int GraphicsPage::mScreenCount;
|
|
||||||
|
|
||||||
bool GraphicsPage::setupSDLWordaround() {
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0)
|
|
||||||
{
|
|
||||||
std::cout << "SDL_Init failed: " << SDL_GetError() << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DisplayMode mode;
|
for (int i = 0; i < displays; i++)
|
||||||
int displayIndex, modeIndex, displays = SDL_GetNumVideoDisplays();
|
|
||||||
mScreenCount = displays;
|
|
||||||
|
|
||||||
if(displays < 0)
|
|
||||||
{
|
{
|
||||||
std::cout << "SDL_GetNumVideoDisplays failed: " << SDL_GetError() << std::endl;
|
screenComboBox->addItem(QString(tr("Screen ")) + QString::number(i + 1));
|
||||||
SDL_Quit();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (displayIndex = 0; displayIndex < displays; displayIndex++)
|
|
||||||
{
|
|
||||||
int modes = SDL_GetNumDisplayModes(displayIndex);
|
|
||||||
if(modes < 0)
|
|
||||||
{
|
|
||||||
std::cout << "SDL_GetNumDisplayModes failed: " << SDL_GetError() << std::endl;
|
|
||||||
SDL_Quit();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (modeIndex = 0; modeIndex < modes; modeIndex++)
|
|
||||||
{
|
|
||||||
if (SDL_GetDisplayMode(displayIndex, modeIndex, &mode) < 0)
|
|
||||||
{
|
|
||||||
std::cout << "SDL_GetDisplayMode failed: " << SDL_GetError() << std::endl;
|
|
||||||
SDL_Quit();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDouble = false;
|
|
||||||
for (std::vector<VideoMode>::iterator it = mVideoModes.begin(); it != mVideoModes.end(); it++)
|
|
||||||
{
|
|
||||||
if ((*it).w == mode.w && (*it).h == mode.h && (*it).screen == displayIndex)
|
|
||||||
{
|
|
||||||
isDouble = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isDouble)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
VideoMode vmode;
|
|
||||||
vmode.w = mode.w;
|
|
||||||
vmode.h = mode.h;
|
|
||||||
vmode.screen = displayIndex;
|
|
||||||
mVideoModes.push_back(vmode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Quit();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,9 +196,7 @@ bool GraphicsPage::loadSettings()
|
||||||
QString resolution = width + QString(" x ") + height;
|
QString resolution = width + QString(" x ") + height;
|
||||||
QString screen = mGraphicsSettings.value(QString("Video/screen"));
|
QString screen = mGraphicsSettings.value(QString("Video/screen"));
|
||||||
|
|
||||||
int screenIndex = screenComboBox->findText(QString("Screen ") + screen);
|
screenComboBox->setCurrentIndex(screen.toInt());
|
||||||
if (screenIndex != -1)
|
|
||||||
screenComboBox->setCurrentIndex(screenIndex);
|
|
||||||
|
|
||||||
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
int resIndex = resolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
||||||
|
|
||||||
|
@ -295,10 +237,7 @@ void GraphicsPage::saveSettings()
|
||||||
mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value()));
|
mGraphicsSettings.setValue(QString("Video/resolution y"), QString::number(customHeightSpinBox->value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegExp screenRe(QString(".*(\\d+)"));
|
mGraphicsSettings.setValue(QString("Video/screen"), QString::number(screenComboBox->currentIndex()));
|
||||||
if(screenRe.exactMatch(screenComboBox->currentText())) {
|
|
||||||
mGraphicsSettings.setValue(QString("Video/screen"), screenRe.cap(1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer)
|
QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer)
|
||||||
|
@ -337,11 +276,32 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy
|
||||||
QStringList GraphicsPage::getAvailableResolutions(int screen)
|
QStringList GraphicsPage::getAvailableResolutions(int screen)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
for (std::vector<VideoMode>::iterator it = mVideoModes.begin(); it != mVideoModes.end(); it++)
|
SDL_DisplayMode mode;
|
||||||
|
int modeIndex, modes = SDL_GetNumDisplayModes(screen);
|
||||||
|
|
||||||
|
if (modes < 0)
|
||||||
{
|
{
|
||||||
VideoMode mode = *it;
|
QMessageBox msgBox;
|
||||||
if(mode.screen != screen)
|
msgBox.setWindowTitle(tr("Error receiving resolutions"));
|
||||||
continue;
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
msgBox.setText(tr("<br><b>SDL_GetNumDisplayModes failed:</b><br><br>") + QString::fromStdString(SDL_GetError()) + "<br>");
|
||||||
|
msgBox.exec();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (modeIndex = 0; modeIndex < modes; modeIndex++)
|
||||||
|
{
|
||||||
|
if (SDL_GetDisplayMode(screen, modeIndex, &mode) < 0)
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle(tr("Error receiving resolutions"));
|
||||||
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
msgBox.setText(tr("<br><b>SDL_GetDisplayMode failed:</b><br><br>") + QString::fromStdString(SDL_GetError()) + "<br>");
|
||||||
|
msgBox.exec();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QString aspect = getAspect(mode.w, mode.h);
|
QString aspect = getAspect(mode.w, mode.h);
|
||||||
QString resolution = QString::number(mode.w) + QString(" x ") + QString::number(mode.h);
|
QString resolution = QString::number(mode.w) + QString(" x ") + QString::number(mode.h);
|
||||||
|
@ -355,6 +315,8 @@ QStringList GraphicsPage::getAvailableResolutions(int screen)
|
||||||
|
|
||||||
result.append(resolution);
|
result.append(resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.removeDuplicates();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,12 +344,11 @@ void GraphicsPage::rendererChanged(const QString &renderer)
|
||||||
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsPage::screenChanged(const QString &screen)
|
void GraphicsPage::screenChanged(int screen)
|
||||||
{
|
{
|
||||||
QRegExp screenRe(QString(".*(\\d+)"));
|
if (screen >= 0) {
|
||||||
if(screenRe.exactMatch(screen)) {
|
|
||||||
resolutionComboBox->clear();
|
resolutionComboBox->clear();
|
||||||
resolutionComboBox->addItems(getAvailableResolutions(screenRe.cap(1).toInt() - 1));
|
resolutionComboBox->addItems(getAvailableResolutions(screen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,6 @@
|
||||||
|
|
||||||
#include "ui_graphicspage.h"
|
#include "ui_graphicspage.h"
|
||||||
|
|
||||||
struct VideoMode
|
|
||||||
{
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
int screen;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GraphicsSettings;
|
class GraphicsSettings;
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
|
@ -39,12 +32,9 @@ public:
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
bool loadSettings();
|
bool loadSettings();
|
||||||
|
|
||||||
// SDL workaround
|
|
||||||
static bool setupSDLWordaround();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void rendererChanged(const QString &renderer);
|
void rendererChanged(const QString &renderer);
|
||||||
void screenChanged(const QString &screen);
|
void screenChanged(int screen);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotFullScreenChanged(int state);
|
void slotFullScreenChanged(int state);
|
||||||
|
@ -69,9 +59,6 @@ private:
|
||||||
QStringList getAvailableResolutions(int screen);
|
QStringList getAvailableResolutions(int screen);
|
||||||
QRect getMaximumResolution();
|
QRect getMaximumResolution();
|
||||||
|
|
||||||
static std::vector<VideoMode> mVideoModes;
|
|
||||||
static int mScreenCount;
|
|
||||||
|
|
||||||
bool setupOgre();
|
bool setupOgre();
|
||||||
bool setupSDL();
|
bool setupSDL();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "maindialog.hpp"
|
#include "maindialog.hpp"
|
||||||
// SDL workaround
|
// SDL workaround
|
||||||
|
@ -8,8 +9,12 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// SDL woraround
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
|
||||||
GraphicsPage::setupSDLWordaround();
|
if (SDL_Init(SDL_INIT_VIDEO) != 0)
|
||||||
|
{
|
||||||
|
qDebug() << "SDL_Init failed: " << QString::fromStdString(SDL_GetError());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
@ -46,6 +51,8 @@ int main(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
int returnValue = app.exec();
|
||||||
|
SDL_Quit();
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ resolution x = 800
|
||||||
resolution y = 600
|
resolution y = 600
|
||||||
|
|
||||||
fullscreen = false
|
fullscreen = false
|
||||||
|
screen = 0
|
||||||
|
|
||||||
# Render system
|
# Render system
|
||||||
# blank means default
|
# blank means default
|
||||||
|
|
Loading…
Reference in a new issue