add error popup when opengl isn't supported and safely exit the application
This commit is contained in:
@@ -53,7 +53,12 @@ int main(int argc, char *argv[])
|
|||||||
Command.push_back(parser->isSet("force-changelog"));
|
Command.push_back(parser->isSet("force-changelog"));
|
||||||
|
|
||||||
auto noggit = Noggit::Application::NoggitApplication::instance();
|
auto noggit = Noggit::Application::NoggitApplication::instance();
|
||||||
noggit->initalize(argc, argv, Command);
|
bool initialized = noggit->initalize(argc, argv, Command);
|
||||||
|
|
||||||
|
if (!initialized) [[unlikely]]
|
||||||
|
{
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit);
|
auto project_selection = new Noggit::Ui::Windows::NoggitProjectSelectionWindow(noggit);
|
||||||
// project_selection->show();
|
// project_selection->show();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace
|
|||||||
|
|
||||||
namespace Noggit::Application
|
namespace Noggit::Application
|
||||||
{
|
{
|
||||||
void NoggitApplication::initalize(int argc, char* argv[], std::vector<bool> Parser)
|
bool NoggitApplication::initalize(int argc, char* argv[], std::vector<bool> Parser)
|
||||||
{
|
{
|
||||||
InitLogging();
|
InitLogging();
|
||||||
Command = Parser;
|
Command = Parser;
|
||||||
@@ -133,7 +133,7 @@ namespace Noggit::Application
|
|||||||
};
|
};
|
||||||
|
|
||||||
// confirmed crashes with v14.30.30704.00 and v14.36.32532.00
|
// confirmed crashes with v14.30.30704.00 and v14.36.32532.00
|
||||||
const int required_version = 38;
|
const int required_version = 40;
|
||||||
|
|
||||||
bool redist_found = false;
|
bool redist_found = false;
|
||||||
foreach (const QString & version, versions) {
|
foreach (const QString & version, versions) {
|
||||||
@@ -200,11 +200,27 @@ namespace Noggit::Application
|
|||||||
|
|
||||||
// context creation seems to get stuck sometimes, this ensure the app is killed
|
// context creation seems to get stuck sometimes, this ensure the app is killed
|
||||||
// otherwise it's wasting cpu resources and is annoying when developping
|
// otherwise it's wasting cpu resources and is annoying when developping
|
||||||
auto failsafe = std::async(&opengl_context_creation_stuck_failsafe);
|
// auto failsafe = std::async(&opengl_context_creation_stuck_failsafe);
|
||||||
|
|
||||||
QSurfaceFormat::setDefaultFormat(format);
|
QSurfaceFormat::setDefaultFormat(format);
|
||||||
QOpenGLContext context;
|
QOpenGLContext context;
|
||||||
context.create();
|
if (!context.create()) [[unlikely]]
|
||||||
|
{
|
||||||
|
LogError << "Failed to create OpenGL 4.1 context." << std::endl;
|
||||||
|
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
msgBox.setWindowTitle("OpenGL Context Error");
|
||||||
|
msgBox.setText("Failed to create an OpenGL 4.1 context. Ensure your graphic device and drivers are compatible with OpenGL 4.1"
|
||||||
|
"\nThe application will now close.");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
// qFatal("Noggit : Failed to create OpenGL 4.1 context.\n Ensure your graphic device and drivers are compatible with OpenGL 4.1");
|
||||||
|
QCoreApplication::exit(EXIT_FAILURE);
|
||||||
|
return false;
|
||||||
|
// exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
QOffscreenSurface surface;
|
QOffscreenSurface surface;
|
||||||
surface.create();
|
surface.create();
|
||||||
@@ -227,16 +243,15 @@ namespace Noggit::Application
|
|||||||
{
|
{
|
||||||
LogError << "Default GL minor version is less than 1" << std::endl;
|
LogError << "Default GL minor version is less than 1" << std::endl;
|
||||||
}
|
}
|
||||||
|
auto profile = format.profile();
|
||||||
QOpenGLVersionProfile profile = QOpenGLVersionProfile(format);
|
|
||||||
|
|
||||||
LogDebug << "GL: Version: " << gl.getString(GL_VERSION) << std::endl;
|
LogDebug << "GL: Version: " << gl.getString(GL_VERSION) << std::endl;
|
||||||
LogDebug << "GL: Vendor: " << gl.getString(GL_VENDOR) << std::endl;
|
LogDebug << "GL: Vendor: " << gl.getString(GL_VENDOR) << std::endl;
|
||||||
LogDebug << "GL: Renderer: " << gl.getString(GL_RENDERER) << std::endl;
|
LogDebug << "GL: Renderer: " << gl.getString(GL_RENDERER) << std::endl;
|
||||||
|
|
||||||
if (!profile.isValid())
|
if (profile != QSurfaceFormat::OpenGLContextProfile::CoreProfile) // allow compatibility profile ?
|
||||||
{
|
{
|
||||||
LogError << "OpenGL version profile is not valid." << std::endl;
|
LogError << "OpenGL version profile is not valid. Profile id : " << profile << std::endl;
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"OpenGL version profile is not valid.");
|
"OpenGL version profile is not valid.");
|
||||||
}
|
}
|
||||||
@@ -248,6 +263,8 @@ namespace Noggit::Application
|
|||||||
// TODO : thread count setting
|
// TODO : thread count setting
|
||||||
// AsyncLoader::setup(NoggitSettings.value("async_thread_count", 3).toInt());
|
// AsyncLoader::setup(NoggitSettings.value("async_thread_count", 3).toInt());
|
||||||
AsyncLoader::setup(3);
|
AsyncLoader::setup(3);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> NoggitApplication::getConfiguration()
|
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> NoggitApplication::getConfiguration()
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace Noggit::Application {
|
|||||||
bool hasClientData() const { return _client_data != nullptr; }
|
bool hasClientData() const { return _client_data != nullptr; }
|
||||||
void setClientData(std::shared_ptr<BlizzardArchive::ClientData> data) { _client_data = data; }
|
void setClientData(std::shared_ptr<BlizzardArchive::ClientData> data) { _client_data = data; }
|
||||||
|
|
||||||
void initalize(int argc, char* argv[], std::vector<bool> Parser);
|
bool initalize(int argc, char* argv[], std::vector<bool> Parser);
|
||||||
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> getConfiguration();
|
std::shared_ptr<Noggit::Application::NoggitApplicationConfiguration> getConfiguration();
|
||||||
static void terminationHandler();
|
static void terminationHandler();
|
||||||
bool GetCommand(int index);
|
bool GetCommand(int index);
|
||||||
|
|||||||
Reference in New Issue
Block a user