attempt to have mg shutdown cleanly when opengl version is too low

This commit is contained in:
Mark Vejvoda 2013-10-28 18:27:51 +00:00
parent cc4f4aaa37
commit 8bbcdfbdb3
5 changed files with 78 additions and 8 deletions

View File

@ -7589,12 +7589,12 @@ void Renderer::checkGlCaps() {
if(glActiveTexture == NULL) {
string message;
message += "Your system supports OpenGL version \"";
message += getGlVersion() + string("\"\n");
message += "Your system supports OpenGL version [";
message += getGlVersion() + string("]\n");
message += "MegaGlest needs a version that supports\n";
message += "glActiveTexture (OpenGL 1.3) or the ARB_multitexture extension.";
throw megaglest_runtime_error(message.c_str());
throw megaglest_runtime_error(message.c_str(),true);
}
//opengl 1.3
@ -7602,12 +7602,12 @@ void Renderer::checkGlCaps() {
if(glewIsSupported("GL_VERSION_1_3") == false) {
string message;
message += "Your system supports OpenGL version \"";
message += getGlVersion() + string("\"\n");
message += "Your system supports OpenGL version [";
message += getGlVersion() + string("]\n");
message += "MegaGlest needs at least version 1.3 to work\n";
message += "You may solve this problem by installing your latest video card drivers";
throw megaglest_runtime_error(message.c_str());
throw megaglest_runtime_error(message.c_str(),true);
}
//opengl 1.4 or extension

View File

@ -5431,9 +5431,18 @@ int glestMain(int argc, char** argv) {
soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds);
chronoshutdownFadeSound.start();
}
if(program != NULL &&
program->getTryingRendererInit() == true &&
program->getRendererInitOk() == false) {
message(e.what());
}
}
ExceptionHandler::handleRuntimeError(e);
if(program == NULL || program->getTryingRendererInit() == false ||
(program->getTryingRendererInit() == true &&
program->getRendererInitOk() == true)) {
ExceptionHandler::handleRuntimeError(e);
}
}
catch(const exception &e) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {

View File

@ -172,6 +172,9 @@ void Program::ShowMessageProgramState::update() {
// ===================== PUBLIC ========================
bool Program::rendererInitOk = false;
bool Program::tryingRendererInit = false;
Program::Program() {
//this->masterserverMode = false;
this->window = NULL;
@ -785,7 +788,10 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//init renderer (load global textures)
tryingRendererInit = true;
renderer.init();
tryingRendererInit = false;
rendererInitOk = true;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);

View File

@ -159,11 +159,17 @@ private:
bool shutdownApplicationEnabled;
static bool wantShutdownApplicationAfterGame;
static bool tryingRendererInit;
static bool rendererInitOk;
public:
Program();
virtual ~Program();
static Program *getInstance() {return singleton;}
static bool getTryingRendererInit() { return tryingRendererInit; }
static bool getRendererInitOk() { return rendererInitOk; }
static Program *getInstance() { return singleton; }
static void setWantShutdownApplicationAfterGame(bool value) { wantShutdownApplicationAfterGame = value; }
static bool getWantShutdownApplicationAfterGame() { return wantShutdownApplicationAfterGame; }

View File

@ -33,7 +33,54 @@ namespace Shared{ namespace Platform{
string PlatformExceptionHandler::application_binary="";
bool PlatformExceptionHandler::disableBacktrace = false;
const char * getDialogCommand() {
/*
if (::system(NULL)) {
if (::system("which gdialog") == 0)
return "gdialog";
else if (::system("which kdialog") == 0)
return "kdialog";
}
*/
FILE *file = popen("which gdialog","r");
//printf("File #1 [%p]\n",file);
if (file != NULL) {
pclose(file);
return "gdialog";
}
file = popen("which kdialog","r");
//printf("File #2 [%p]\n",file);
if (file != NULL) {
pclose(file);
return "kdialog";
}
return NULL;
}
bool showMessage(const std::string & warning) {
bool guiMessage = false;
const char * dialogCommand = getDialogCommand();
if (dialogCommand) {
std::string command = dialogCommand;
command += " --title \"Error\" --msgbox \"`printf \"" + warning + "\"`\"";
//printf("\n\n\nzenity command [%s]\n\n\n",command.c_str());
FILE *fp = popen(command.c_str(),"r");
if (fp != 0)
guiMessage = true;
pclose(fp);
}
return guiMessage;
}
void message(string message) {
showMessage(message);
std::cerr << "******************************************************\n";
std::cerr << " " << message << "\n";
std::cerr << "******************************************************\n";
@ -47,6 +94,8 @@ bool ask(string message) {
}
void exceptionMessage(const exception &excp) {
//showMessage(excp.what());
std::cerr << "Exception: " << excp.what() << std::endl;
}