1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-19 19:53:53 +00:00
openmw/apps/opencs/main.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
1.8 KiB
C++
Raw Normal View History

2012-11-22 12:30:02 +00:00
#include "editor.hpp"
2012-12-04 19:43:47 +00:00
#include <exception>
2014-05-03 11:01:29 +00:00
#include <string>
2012-12-04 19:43:47 +00:00
2013-02-17 13:46:50 +00:00
#include <QIcon>
#include <QSurfaceFormat>
#include <osg/DisplaySettings>
2012-11-22 12:30:02 +00:00
#include <components/debug/debugging.hpp>
#include <components/platform/application.hpp>
#include <components/platform/platform.hpp>
#include "model/doc/messages.hpp"
#include "model/world/universalid.hpp"
#ifdef Q_OS_MAC
#include <QDir>
#endif
2014-05-03 11:01:29 +00:00
Q_DECLARE_METATYPE(std::string)
2022-10-19 17:02:00 +00:00
class QEvent;
class QObject;
void setQSurfaceFormat()
{
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setVersion(2, 1);
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setDepthBufferSize(24);
format.setSamples(ds->getMultiSamples());
format.setStencilBufferSize(ds->getMinimumNumStencilBits());
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
QSurfaceFormat::setDefaultFormat(format);
}
int runApplication(int argc, char* argv[])
2012-11-21 16:31:18 +00:00
{
Platform::init();
#ifdef Q_OS_MAC
setenv("OSG_GL_TEXTURE_STORAGE", "OFF", 0);
#endif
Q_INIT_RESOURCE(resources);
2013-11-02 01:48:30 +00:00
#ifdef WIN32
Q_INIT_RESOURCE(dark);
#endif
qRegisterMetaType<std::string>("std::string");
qRegisterMetaType<CSMWorld::UniversalId>("CSMWorld::UniversalId");
qRegisterMetaType<CSMDoc::Message>("CSMDoc::Message");
2014-05-03 11:01:29 +00:00
setQSurfaceFormat();
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
Platform::Application application(argc, argv);
2012-11-22 12:30:02 +00:00
2024-04-14 04:17:10 +00:00
application.setWindowIcon(QIcon(":openmw-cs"));
2013-02-17 13:46:50 +00:00
CS::Editor editor(argc, argv);
#ifdef __linux__
setlocale(LC_NUMERIC, "C");
#endif
2012-11-21 16:31:18 +00:00
if (!editor.makeIPCServer())
{
editor.connectToIPCServer();
return 0;
}
return editor.run();
}
int main(int argc, char* argv[])
{
return wrapApplication(&runApplication, argc, argv, "OpenMW-CS");
2013-02-17 13:46:50 +00:00
}