qt branch: If OpenGL initialization fails, explain to the user why the program does not start. See ticket:2336

master
Per Inge Mathisen 2010-12-04 15:11:56 +01:00
parent 60d7cb6127
commit 28624d0c46
1 changed files with 7 additions and 4 deletions

View File

@ -679,9 +679,7 @@ void WzMainWindow::close()
int wzInit(int argc, char *argv[], int fsaa, bool vsync, int w, int h, bool fullscreen)
{
char buf[256];
QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); /* Workaround for incorrect text rendering on
* many platforms.
*/
QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); // Workaround for incorrect text rendering on nany platforms.
QApplication app(argc, argv);
// Setting up OpenGL
@ -698,6 +696,11 @@ int wzInit(int argc, char *argv[], int fsaa, bool vsync, int w, int h, bool full
format.setSamples(fsaa);
}
WzMainWindow mainwindow(format);
if (!mainwindow.context()->isValid())
{
QMessageBox::critical(NULL, "Oops!", "Warzone2100 failed to create an OpenGL context. This probably means that your graphics drivers are out of date. Try updating them!");
return EXIT_FAILURE;
}
if (fullscreen)
{
QDesktopWidget *desktop = qApp->desktop();
@ -724,7 +727,7 @@ int wzInit(int argc, char *argv[], int fsaa, bool vsync, int w, int h, bool full
if (finalInitialization() != 0)
{
debug(LOG_ERROR, "Failed to carry out final initialization.");
return -1;
return EXIT_FAILURE;
}
debug(LOG_MAIN, "Entering main loop");