On detecting ATI Radeon 9200, alerts the user and provides an option to automatically disable vertex programs.

ver1_5_1
Da Woon Jung 2006-01-06 16:01:30 +00:00
parent a7c79c614b
commit 2a1ba8254b
5 changed files with 84 additions and 3 deletions

View File

@ -275,6 +275,79 @@ static NSMutableDictionary* tagDict;
confFile = [confFileSetting stdString];
}
#ifndef NO_VP_WORKAROUND
std::string VP_PROBLEM_EXT = "GL_ARB_vertex_program";
NSString *VP_PATCH_SCRIPT = @"vp_patch.sh";
NSString *VP_PATCH_SHELL = @"/bin/zsh";
NSString *CELESTIA_CFG = @"celestia.cfg";
const char *VP_PROBLEM_RENDERERS[] = { "ATI Radeon 9200" };
const char *glRenderer = (const char *) glGetString(GL_RENDERER);
BOOL shouldWorkaround = NO;
size_t i = 0;
if (glRenderer)
{
for (; i < (sizeof VP_PROBLEM_RENDERERS)/sizeof(char *); ++i)
{
if (strstr(glRenderer, VP_PROBLEM_RENDERERS[i]))
{
shouldWorkaround = YES;
break;
}
}
}
if (shouldWorkaround)
{
// Check if workaround is already installed
CelestiaConfig *cfg = ReadCelestiaConfig([CELESTIA_CFG stdString]);
if (cfg && std::find(cfg->ignoreGLExtensions.begin(), cfg->ignoreGLExtensions.end(), VP_PROBLEM_EXT) == cfg->ignoreGLExtensions.end())
{
delete cfg;
if (NSRunAlertPanel([NSString stringWithFormat: NSLocalizedString(@"It appears you are running Celestia on %s hardware. Do you wish to install a workaround?",nil), VP_PROBLEM_RENDERERS[i]],
[NSString stringWithFormat: NSLocalizedString(@"A shell script will be run to modify your %@, adding an IgnoreGLExtensions directive. This can prevent freezing issues.",nil), CELESTIA_CFG],
NSLocalizedString(@"Yes",nil),
NSLocalizedString(@"No",nil),
nil) == NSAlertDefaultReturn)
{
// Install it
NSFileManager *fm = [NSFileManager defaultManager];
NSString *cfgPath = [[fm currentDirectoryPath] stringByAppendingPathComponent: CELESTIA_CFG];
NSString *toolPath = [[NSBundle mainBundle] pathForResource: VP_PATCH_SCRIPT ofType: @""];
BOOL patchInstalled = NO;
if ([fm isWritableFileAtPath: cfgPath] && toolPath)
{
NSArray *taskArgs = [NSArray arrayWithObjects:
toolPath, cfgPath, nil];
NSTask *theTask = [NSTask launchedTaskWithLaunchPath: VP_PATCH_SHELL
arguments: taskArgs];
if (theTask)
{
[theTask waitUntilExit];
patchInstalled = ([theTask terminationStatus] == 0);
}
}
if (patchInstalled)
{
NSRunAlertPanel(NSLocalizedString(@"Workaround successfully installed.",nil),
[NSString stringWithFormat: NSLocalizedString(@"Your original %@ has been backed up.",nil), CELESTIA_CFG],
nil, nil, nil);
}
else
{
[[CelestiaController shared] fatalError: NSLocalizedString(@"There was a problem installing the workaround. You may be running from a disk image, which is write-protected. Please try copying the CelestiaResources folder to your home directory as described in the README. You can also attempt to perform the workaround manually by following the instructions in the README.",nil)];
[[CelestiaController shared] fatalError: nil];
}
}
}
}
#endif NO_VP_WORKAROUND
if ((extrasDirsSetting = [prefs stringArrayForKey:@"extrasDirs"]))
{
NSEnumerator *iter = [extrasDirsSetting objectEnumerator];
@ -282,7 +355,7 @@ static NSMutableDictionary* tagDict;
extrasDirs.push_back([extrasDir stdString]);
}
return (BOOL)appCore->initSimulation(confFileSetting ? &confFile : nil,
return (BOOL)appCore->initSimulation(!confFile.empty() ? &confFile : nil,
extrasDirsSetting ? &extrasDirs : nil,
&progressNotifier);
}

View File

@ -12,6 +12,8 @@
#import "RenderPanelController.h"
#import "BrowserWindowController.h"
#define CELESTIA_RESOURCES_FOLDER @"CelestiaResources"
@class SplashWindow;
@class SplashWindowController;

View File

@ -18,8 +18,6 @@
#include <float.h>
#define CELESTIA_RESOURCES_FOLDER @"CelestiaResources"
@implementation CelestiaController
@ -186,6 +184,7 @@ NSString* fatalErrorMessage;
if (fatalErrorMessage == nil) return;
[splashWindowController close];
NSRunAlertPanel(@"Fatal Error", fatalErrorMessage, nil, nil, nil);
fatalErrorMessage = nil; // user could cancel the terminate
[NSApp terminate:self];
return;
}

View File

@ -152,6 +152,7 @@
E5B615070777307F001BB2BF /* celestia.icns in Resources */ = {isa = PBXBuildFile; fileRef = E5B615060777307F001BB2BF /* celestia.icns */; };
E5C9ADE10848FFEF0071B1EE /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5040B0602A47B91014901DC /* Carbon.framework */; };
E5C9B478084909E40071B1EE /* README for Mac OS X.rtf in CopyFiles */ = {isa = PBXBuildFile; fileRef = E5C9B46B084909B90071B1EE /* README for Mac OS X.rtf */; };
E5D3196B096C91A6007FA87F /* vp_patch.sh in Resources */ = {isa = PBXBuildFile; fileRef = E5D3196A096C91A6007FA87F /* vp_patch.sh */; };
E5D446660777291700A1577D /* utf8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E5D446640777291700A1577D /* utf8.cpp */; };
E5D4467607772B6C00A1577D /* CelestiaSettings.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5D4467407772B6C00A1577D /* CelestiaSettings.mm */; };
E5D4467807772BA000A1577D /* CGLInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = F505BFFA02CA9DAE0100020A /* CGLInfo.m */; };
@ -355,6 +356,7 @@
E5B61B2E077737A6001BB2BF /* png.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = png.h; sourceTree = "<group>"; };
E5B61B2F077737A6001BB2BF /* pngconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngconf.h; sourceTree = "<group>"; };
E5C9B46B084909B90071B1EE /* README for Mac OS X.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = "README for Mac OS X.rtf"; sourceTree = "<group>"; };
E5D3196A096C91A6007FA87F /* vp_patch.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = vp_patch.sh; sourceTree = "<group>"; };
E5D446640777291700A1577D /* utf8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = utf8.cpp; path = ../src/celutil/utf8.cpp; sourceTree = SOURCE_ROOT; };
E5D446650777291700A1577D /* utf8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utf8.h; path = ../src/celutil/utf8.h; sourceTree = SOURCE_ROOT; };
E5D4467307772B6C00A1577D /* CelestiaSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CelestiaSettings.h; sourceTree = "<group>"; };
@ -743,6 +745,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
E5D3196A096C91A6007FA87F /* vp_patch.sh */,
E54742CF09631D3600E89E09 /* defaults.plist */,
E5C9B46B084909B90071B1EE /* README for Mac OS X.rtf */,
E53C2FBE079433D300C76766 /* KbdMouseJoyControls.txt */,
@ -1232,6 +1235,7 @@
E56A5AD10848F24D00A21D7E /* caution.tiff in Resources */,
E5E365AF095C123E00B14224 /* splash.png in Resources */,
E54742D009631D3600E89E09 /* defaults.plist in Resources */,
E5D3196B096C91A6007FA87F /* vp_patch.sh in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -0,0 +1,3 @@
#!/bin/zsh
[[ -w $1 ]] && sed -e 's/^#[[:blank:]]*IgnoreGLExtensions/IgnoreGLExtensions/' -i .bak $1