mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 09:53:50 +00:00
better workaround
This commit is contained in:
parent
0829548106
commit
dbfc39468b
3 changed files with 43 additions and 84 deletions
|
@ -153,80 +153,19 @@ 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;
|
|
||||||
for (int i = 0; i < mScreenCount; i++)
|
|
||||||
{
|
|
||||||
screens.append(QString("Screen ") + QString::number(i + 1));
|
|
||||||
}
|
|
||||||
screenComboBox->addItems(screens);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_DisplayMode mode;
|
|
||||||
int displayIndex, modeIndex, displays = SDL_GetNumVideoDisplays();
|
|
||||||
mScreenCount = displays;
|
|
||||||
|
|
||||||
if(displays < 0)
|
if(displays < 0)
|
||||||
{
|
{
|
||||||
std::cout << "SDL_GetNumVideoDisplays failed: " << SDL_GetError() << std::endl;
|
qDebug() << "SDL_GetNumVideoDisplays failed: " << QString::fromStdString(SDL_GetError());
|
||||||
SDL_Quit();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (displayIndex = 0; displayIndex < displays; displayIndex++)
|
for (int i = 0; i < displays; i++)
|
||||||
{
|
{
|
||||||
int modes = SDL_GetNumDisplayModes(displayIndex);
|
screenComboBox->addItem(QString("Screen ") + QString::number(i + 1));
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,10 +276,35 @@ 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;
|
qDebug() << "SDL_GetNumDisplayModes failed: " << QString::fromStdString(SDL_GetError());
|
||||||
if(mode.screen != screen)
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<SDL_DisplayMode> resolutions;
|
||||||
|
for (modeIndex = 0; modeIndex < modes; modeIndex++)
|
||||||
|
{
|
||||||
|
if (SDL_GetDisplayMode(screen, modeIndex, &mode) < 0)
|
||||||
|
{
|
||||||
|
qDebug() << "SDL_GetDisplayMode failed: " << QString::fromStdString(SDL_GetError());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isDuplicate = false;
|
||||||
|
for (int i = 0; i < resolutions.count(); i++)
|
||||||
|
{
|
||||||
|
SDL_DisplayMode omode = resolutions.at(i);
|
||||||
|
if (omode.w == mode.w && omode.h == mode.h)
|
||||||
|
{
|
||||||
|
isDuplicate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isDuplicate)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString aspect = getAspect(mode.w, mode.h);
|
QString aspect = getAspect(mode.w, mode.h);
|
||||||
|
@ -353,8 +317,10 @@ QStringList GraphicsPage::getAvailableResolutions(int screen)
|
||||||
resolution.append(tr("\t(Standard 4:3)"));
|
resolution.append(tr("\t(Standard 4:3)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolutions.append(mode);
|
||||||
result.append(resolution);
|
result.append(resolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,9 +32,6 @@ 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(const QString &screen);
|
||||||
|
@ -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,11 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// SDL woraround
|
if (SDL_Init(SDL_INIT_VIDEO) != 0)
|
||||||
GraphicsPage::setupSDLWordaround();
|
{
|
||||||
|
qDebug() << "SDL_Init failed: " << QString::fromStdString(SDL_GetError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
@ -46,6 +50,8 @@ int main(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
int returnValue = app.exec();
|
||||||
|
SDL_Quit();
|
||||||
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue