Updated Mac OpenGL context handling to be slightly more similar to recommended best practice. Doesn't actually _follow_ best practice because best practice only works in Snow Leopard. Also, avoid unnecessary graphics reset during startup.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3611 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
7613a150bf
commit
c54fe64bbf
@ -1282,4 +1282,8 @@
|
|||||||
"espeak-default-voice" = "default";
|
"espeak-default-voice" = "default";
|
||||||
|
|
||||||
"speech-synthesis-incoming-message" = "Incoming message.";
|
"speech-synthesis-incoming-message" = "Incoming message.";
|
||||||
|
|
||||||
|
// Mac multi-screen handling
|
||||||
|
"oolite-mac-bad-display" = "The display configuration has changed in a way that may impact Oolite’s performance.";
|
||||||
|
"oolite-mac-bad-display-2" = "Oolite’s main window is now on a screen which is not connected to a graphics processor compatible with Oolite. Oolite should continue to work, but performance may be degraded.";
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,10 @@ extern int debug;
|
|||||||
GLfloat display_z;
|
GLfloat display_z;
|
||||||
GLfloat x_offset, y_offset;
|
GLfloat x_offset, y_offset;
|
||||||
|
|
||||||
JoystickHandler *stickHandler;
|
int _virtualScreen;
|
||||||
|
NSData *_pixelFormatAttributes;
|
||||||
|
|
||||||
|
JoystickHandler *stickHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,6 +132,8 @@ extern int debug;
|
|||||||
|
|
||||||
- (void) initialiseGLWithSize:(NSSize) v_size;
|
- (void) initialiseGLWithSize:(NSSize) v_size;
|
||||||
|
|
||||||
|
- (NSData *)pixelFormatAttributes;
|
||||||
|
|
||||||
- (void) drawRect:(NSRect)rect;
|
- (void) drawRect:(NSRect)rect;
|
||||||
- (void) updateScreen;
|
- (void) updateScreen;
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ MA 02110-1301, USA.
|
|||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
#import "JoystickHandler.h"
|
#import "JoystickHandler.h"
|
||||||
#import "NSFileManagerOOExtensions.h"
|
#import "NSFileManagerOOExtensions.h"
|
||||||
|
#import "OOGraphicsResetManager.h"
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#import <Foundation/NSDebug.h>
|
#import <Foundation/NSDebug.h>
|
||||||
@ -66,7 +67,8 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
|
// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
|
||||||
NSOpenGLPixelFormatAttribute attrs[] =
|
NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
{
|
{
|
||||||
// // Specify that we want a windowed OpenGL context.
|
// Specify that we want a windowed OpenGL context.
|
||||||
|
// Must be first or we'll hit an assert in -[GameController goFullscreen:].
|
||||||
NSOpenGLPFAWindow,
|
NSOpenGLPFAWindow,
|
||||||
|
|
||||||
// We may be on a multi-display system (and each screen may be driven by a different renderer), so we need to specify which screen we want to take over.
|
// We may be on a multi-display system (and each screen may be driven by a different renderer), so we need to specify which screen we want to take over.
|
||||||
@ -94,6 +96,8 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_pixelFormatAttributes = [[NSData alloc] initWithBytes:attrs length:sizeof attrs];
|
||||||
|
|
||||||
// Create our non-FullScreen pixel format.
|
// Create our non-FullScreen pixel format.
|
||||||
NSOpenGLPixelFormat* pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
|
NSOpenGLPixelFormat* pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
|
||||||
|
|
||||||
@ -107,14 +111,17 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
|
|
||||||
timeIntervalAtLastClick = [NSDate timeIntervalSinceReferenceDate];
|
timeIntervalAtLastClick = [NSDate timeIntervalSinceReferenceDate];
|
||||||
|
|
||||||
|
_virtualScreen = [[self openGLContext] currentVirtualScreen];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
if (typedString)
|
DESTROY(typedString);
|
||||||
[typedString release];
|
DESTROY(_pixelFormatAttributes);
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +229,48 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) noteMovedToBadDisplay
|
||||||
|
{
|
||||||
|
NSRunInformationalAlertPanel(DESC(@"oolite-mac-bad-display"), @"%@", nil, nil, nil, DESC(@"oolite-mac-bad-display-2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) update
|
||||||
|
{
|
||||||
|
NSOpenGLContext *context = [self openGLContext];
|
||||||
|
|
||||||
|
[context update];
|
||||||
|
int virtualScreen = [context currentVirtualScreen];
|
||||||
|
if (virtualScreen != _virtualScreen)
|
||||||
|
{
|
||||||
|
@try
|
||||||
|
{
|
||||||
|
[[OOGraphicsResetManager sharedManager] resetGraphicsState];
|
||||||
|
_virtualScreen = virtualScreen;
|
||||||
|
}
|
||||||
|
@catch (NSException *exception)
|
||||||
|
{
|
||||||
|
/* Graphics reset failed, most likely because of OpenGL context
|
||||||
|
incompatibility. Reset to previous "virtual screen" (i.e.,
|
||||||
|
renderer). OS X's OpenGL implementation will take care of
|
||||||
|
copying
|
||||||
|
*/
|
||||||
|
[context setCurrentVirtualScreen:_virtualScreen];
|
||||||
|
[[OOGraphicsResetManager sharedManager] resetGraphicsState]; // If this throws, we're screwed.
|
||||||
|
|
||||||
|
if ([[self gameController] inFullScreenMode])
|
||||||
|
{
|
||||||
|
[[self gameController] pauseFullScreenModeToPerform:@selector(noteMovedToBadDisplay) onTarget:self];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self noteMovedToBadDisplay];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) initialiseGLWithSize:(NSSize) v_size
|
- (void) initialiseGLWithSize:(NSSize) v_size
|
||||||
{
|
{
|
||||||
viewSize = v_size;
|
viewSize = v_size;
|
||||||
@ -243,6 +292,12 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (NSData *)pixelFormatAttributes
|
||||||
|
{
|
||||||
|
return _pixelFormatAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) snapShot
|
- (void) snapShot
|
||||||
{
|
{
|
||||||
int w = viewSize.width;
|
int w = viewSize.width;
|
||||||
|
@ -575,40 +575,13 @@ static NSComparisonResult CompareDisplayModes(id arg1, id arg2, void *context)
|
|||||||
|
|
||||||
originalDisplayMode = (NSDictionary *)CGDisplayCurrentMode(kCGDirectMainDisplay);
|
originalDisplayMode = (NSDictionary *)CGDisplayCurrentMode(kCGDirectMainDisplay);
|
||||||
|
|
||||||
// Pixel Format Attributes for the FullScreen NSOpenGLContext
|
NSMutableData *attrData = [[gameView pixelFormatAttributes] mutableCopy];
|
||||||
NSOpenGLPixelFormatAttribute attrs[] = {
|
NSOpenGLPixelFormatAttribute *attrs = [attrData mutableBytes];
|
||||||
|
NSAssert(attrs[0] == NSOpenGLPFAWindow, @"Pixel format does not meet my strenuous expectations!");
|
||||||
// Specify that we want a full-screen OpenGL context.
|
attrs[0] = NSOpenGLPFAFullScreen;
|
||||||
NSOpenGLPFAFullScreen,
|
|
||||||
// // and that we want a windowed OpenGL context.
|
|
||||||
// NSOpenGLPFAWindow,
|
|
||||||
|
|
||||||
// We may be on a multi-display system (and each screen may be driven by a different renderer), so we need to specify which screen we want to take over.
|
|
||||||
// For this demo, we'll specify the main screen.
|
|
||||||
NSOpenGLPFAScreenMask, CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
|
|
||||||
|
|
||||||
// Specifying "NoRecovery" gives us a context that cannot fall back to the software renderer.
|
|
||||||
// This makes the View-based context compatible with the fullscreen context, enabling us to use the "shareContext"
|
|
||||||
// feature to share textures, display lists, and other OpenGL objects between the two.
|
|
||||||
NSOpenGLPFANoRecovery,
|
|
||||||
|
|
||||||
// Attributes Common to FullScreen and non-FullScreen
|
|
||||||
NSOpenGLPFACompliant,
|
|
||||||
|
|
||||||
NSOpenGLPFAColorSize, 32,
|
|
||||||
NSOpenGLPFADepthSize, 32,
|
|
||||||
NSOpenGLPFADoubleBuffer,
|
|
||||||
NSOpenGLPFAAccelerated,
|
|
||||||
#if FSAA
|
|
||||||
// Need a preference or other sane way to activate this
|
|
||||||
NSOpenGLPFAMultisample,
|
|
||||||
NSOpenGLPFASampleBuffers, 1,
|
|
||||||
NSOpenGLPFASamples,4,
|
|
||||||
#endif
|
|
||||||
0
|
|
||||||
};
|
|
||||||
GLint rendererID;
|
GLint rendererID;
|
||||||
|
|
||||||
// Create the FullScreen NSOpenGLContext with the attributes listed above.
|
// Create the FullScreen NSOpenGLContext with the attributes listed above.
|
||||||
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
|
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#import "OOGraphicsResetManager.h"
|
#import "OOGraphicsResetManager.h"
|
||||||
#import "OOTexture.h"
|
#import "OOTexture.h"
|
||||||
|
#import "OOOpenGLExtensionManager.h"
|
||||||
|
|
||||||
|
|
||||||
static OOGraphicsResetManager *sSingleton = nil;
|
static OOGraphicsResetManager *sSingleton = nil;
|
||||||
@ -76,6 +77,7 @@ static OOGraphicsResetManager *sSingleton = nil;
|
|||||||
OOLog(@"rendering.reset.start", @"Resetting graphics state.");
|
OOLog(@"rendering.reset.start", @"Resetting graphics state.");
|
||||||
OOLogIndentIf(@"rendering.reset.start");
|
OOLogIndentIf(@"rendering.reset.start");
|
||||||
|
|
||||||
|
[[OOOpenGLExtensionManager sharedManager] reset];
|
||||||
[OOTexture rebindAllTextures];
|
[OOTexture rebindAllTextures];
|
||||||
|
|
||||||
for (clientEnum = [clients objectEnumerator]; (client = [[clientEnum nextObject] pointerValue]); )
|
for (clientEnum = [clients objectEnumerator]; (client = [[clientEnum nextObject] pointerValue]); )
|
||||||
|
@ -149,6 +149,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
+ (id)sharedManager;
|
+ (id)sharedManager;
|
||||||
|
|
||||||
|
- (void) reset;
|
||||||
|
|
||||||
- (BOOL)haveExtension:(NSString *)extension;
|
- (BOOL)haveExtension:(NSString *)extension;
|
||||||
|
|
||||||
- (BOOL)shadersSupported;
|
- (BOOL)shadersSupported;
|
||||||
|
@ -161,8 +161,6 @@ static NSArray *ArrayOfExtensions(NSString *extensionString)
|
|||||||
|
|
||||||
- (id)init
|
- (id)init
|
||||||
{
|
{
|
||||||
const GLubyte *versionString = NULL, *curr = NULL;
|
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
@ -171,108 +169,120 @@ static NSArray *ArrayOfExtensions(NSString *extensionString)
|
|||||||
[lock ooSetName:@"OOOpenGLExtensionManager extension set lock"];
|
[lock ooSetName:@"OOOpenGLExtensionManager extension set lock"];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NSString *extensionsStr = [NSString stringWithUTF8String:(char *)glGetString(GL_EXTENSIONS)];
|
[self reset];
|
||||||
extensions = [[NSSet alloc] initWithArray:ArrayOfExtensions(extensionsStr)];
|
|
||||||
|
|
||||||
vendor = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_VENDOR)];
|
|
||||||
renderer = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_RENDERER)];
|
|
||||||
|
|
||||||
versionString = glGetString(GL_VERSION);
|
|
||||||
if (versionString != NULL)
|
|
||||||
{
|
|
||||||
/* String is supposed to be "major.minorFOO" or
|
|
||||||
"major.minor.releaseFOO" where FOO is an empty string or
|
|
||||||
a string beginning with space.
|
|
||||||
*/
|
|
||||||
curr = versionString;
|
|
||||||
major = IntegerFromString(&curr);
|
|
||||||
if (*curr == '.')
|
|
||||||
{
|
|
||||||
curr++;
|
|
||||||
minor = IntegerFromString(&curr);
|
|
||||||
}
|
|
||||||
if (*curr == '.')
|
|
||||||
{
|
|
||||||
curr++;
|
|
||||||
release = IntegerFromString(&curr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For aesthetic reasons, cause the ResourceManager to initialize its
|
|
||||||
search paths here. If we don't, the search path dump ends up in
|
|
||||||
the middle of the OpenGL stuff.
|
|
||||||
*/
|
|
||||||
[ResourceManager paths];
|
|
||||||
|
|
||||||
OOLog(@"rendering.opengl.version", @"OpenGL renderer version: %u.%u.%u (\"%s\")\nVendor: %@\nRenderer: %@", major, minor, release, versionString, vendor, renderer);
|
|
||||||
OOLog(@"rendering.opengl.extensions", @"OpenGL extensions (%u):\n%@", [extensions count], [[extensions allObjects] componentsJoinedByString:@", "]);
|
|
||||||
|
|
||||||
if (![self versionIsAtLeastMajor:kMinMajorVersion minor:kMinMinorVersion])
|
|
||||||
{
|
|
||||||
OOLog(@"rendering.opengl.version.insufficient", @"***** Oolite requires OpenGL version %u.%u or later.", kMinMajorVersion, kMinMinorVersion);
|
|
||||||
[NSException raise:@"OoliteOpenGLTooOldException"
|
|
||||||
format:@"Oolite requires at least OpenGL %u.1%u. You have %u.%u (\"%s\").", kMinMajorVersion, kMinMinorVersion, major, minor, versionString];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString *versionStr = [[[NSString alloc] initWithUTF8String:(const char *)versionString] autorelease];
|
|
||||||
NSDictionary *gpuConfig = [self lookUpPerGPUSettingsWithVersionString:versionStr extensionsString:extensionsStr];
|
|
||||||
|
|
||||||
#if OO_SHADERS
|
|
||||||
[self checkShadersSupported];
|
|
||||||
|
|
||||||
if (shadersAvailable)
|
|
||||||
{
|
|
||||||
defaultShaderSetting = StringToShaderSetting([gpuConfig oo_stringForKey:@"default_shader_level"
|
|
||||||
defaultValue:@"SHADERS_FULL"]);
|
|
||||||
maximumShaderSetting = StringToShaderSetting([gpuConfig oo_stringForKey:@"maximum_shader_level"
|
|
||||||
defaultValue:@"SHADERS_FULL"]);
|
|
||||||
if (maximumShaderSetting <= SHADERS_OFF)
|
|
||||||
{
|
|
||||||
shadersAvailable = NO;
|
|
||||||
maximumShaderSetting = SHADERS_NOT_SUPPORTED;
|
|
||||||
OOLog(kOOLogOpenGLShaderSupport, @"Shaders will not be used (disallowed for GPU type \"%@\").", [gpuConfig oo_stringForKey:@"name" defaultValue:renderer]);
|
|
||||||
}
|
|
||||||
if (maximumShaderSetting < defaultShaderSetting)
|
|
||||||
{
|
|
||||||
defaultShaderSetting = maximumShaderSetting;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shadersAvailable)
|
|
||||||
{
|
|
||||||
OOLog(kOOLogOpenGLShaderSupport, @"Shaders are supported.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
defaultShaderSetting = SHADERS_NOT_SUPPORTED;
|
|
||||||
maximumShaderSetting = SHADERS_NOT_SUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLint texImageUnitOverride = [gpuConfig oo_unsignedIntegerForKey:@"texture_image_units" defaultValue:textureImageUnitCount];
|
|
||||||
if (texImageUnitOverride < textureImageUnitCount) textureImageUnitCount = texImageUnitOverride;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if OO_USE_VBO
|
|
||||||
[self checkVBOSupported];
|
|
||||||
#endif
|
|
||||||
#if OO_USE_FBO
|
|
||||||
[self checkFBOSupported];
|
|
||||||
#endif
|
|
||||||
#if OO_MULTITEXTURE
|
|
||||||
[self checkTextureCombinersSupported];
|
|
||||||
GLint texUnitOverride = [gpuConfig oo_unsignedIntegerForKey:@"texture_units" defaultValue:textureUnitCount];
|
|
||||||
if (texUnitOverride < textureUnitCount) textureUnitCount = texUnitOverride;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
usePointSmoothing = [gpuConfig oo_boolForKey:@"smooth_points" defaultValue:YES];
|
|
||||||
useLineSmoothing = [gpuConfig oo_boolForKey:@"smooth_lines" defaultValue:YES];
|
|
||||||
useDustShader = [gpuConfig oo_boolForKey:@"use_dust_shader" defaultValue:YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void) reset
|
||||||
|
{
|
||||||
|
const GLubyte *versionString = NULL, *curr = NULL;
|
||||||
|
|
||||||
|
DESTROY(extensions);
|
||||||
|
DESTROY(vendor);
|
||||||
|
DESTROY(renderer);
|
||||||
|
|
||||||
|
NSString *extensionsStr = [NSString stringWithUTF8String:(char *)glGetString(GL_EXTENSIONS)];
|
||||||
|
extensions = [[NSSet alloc] initWithArray:ArrayOfExtensions(extensionsStr)];
|
||||||
|
|
||||||
|
vendor = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_VENDOR)];
|
||||||
|
renderer = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_RENDERER)];
|
||||||
|
|
||||||
|
versionString = glGetString(GL_VERSION);
|
||||||
|
if (versionString != NULL)
|
||||||
|
{
|
||||||
|
/* String is supposed to be "major.minorFOO" or
|
||||||
|
"major.minor.releaseFOO" where FOO is an empty string or
|
||||||
|
a string beginning with space.
|
||||||
|
*/
|
||||||
|
curr = versionString;
|
||||||
|
major = IntegerFromString(&curr);
|
||||||
|
if (*curr == '.')
|
||||||
|
{
|
||||||
|
curr++;
|
||||||
|
minor = IntegerFromString(&curr);
|
||||||
|
}
|
||||||
|
if (*curr == '.')
|
||||||
|
{
|
||||||
|
curr++;
|
||||||
|
release = IntegerFromString(&curr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For aesthetic reasons, cause the ResourceManager to initialize its
|
||||||
|
search paths here. If we don't, the search path dump ends up in
|
||||||
|
the middle of the OpenGL stuff.
|
||||||
|
*/
|
||||||
|
[ResourceManager paths];
|
||||||
|
|
||||||
|
OOLog(@"rendering.opengl.version", @"OpenGL renderer version: %u.%u.%u (\"%s\"). Vendor: \"%@\". Renderer: \"%@\".", major, minor, release, versionString, vendor, renderer);
|
||||||
|
OOLog(@"rendering.opengl.extensions", @"OpenGL extensions (%u):\n%@", [extensions count], [[extensions allObjects] componentsJoinedByString:@", "]);
|
||||||
|
|
||||||
|
if (![self versionIsAtLeastMajor:kMinMajorVersion minor:kMinMinorVersion])
|
||||||
|
{
|
||||||
|
OOLog(@"rendering.opengl.version.insufficient", @"***** Oolite requires OpenGL version %u.%u or later.", kMinMajorVersion, kMinMinorVersion);
|
||||||
|
[NSException raise:@"OoliteOpenGLTooOldException"
|
||||||
|
format:@"Oolite requires at least OpenGL %u.1%u. You have %u.%u (\"%s\").", kMinMajorVersion, kMinMinorVersion, major, minor, versionString];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString *versionStr = [[[NSString alloc] initWithUTF8String:(const char *)versionString] autorelease];
|
||||||
|
NSDictionary *gpuConfig = [self lookUpPerGPUSettingsWithVersionString:versionStr extensionsString:extensionsStr];
|
||||||
|
|
||||||
|
#if OO_SHADERS
|
||||||
|
[self checkShadersSupported];
|
||||||
|
|
||||||
|
if (shadersAvailable)
|
||||||
|
{
|
||||||
|
defaultShaderSetting = StringToShaderSetting([gpuConfig oo_stringForKey:@"default_shader_level"
|
||||||
|
defaultValue:@"SHADERS_FULL"]);
|
||||||
|
maximumShaderSetting = StringToShaderSetting([gpuConfig oo_stringForKey:@"maximum_shader_level"
|
||||||
|
defaultValue:@"SHADERS_FULL"]);
|
||||||
|
if (maximumShaderSetting <= SHADERS_OFF)
|
||||||
|
{
|
||||||
|
shadersAvailable = NO;
|
||||||
|
maximumShaderSetting = SHADERS_NOT_SUPPORTED;
|
||||||
|
OOLog(kOOLogOpenGLShaderSupport, @"Shaders will not be used (disallowed for GPU type \"%@\").", [gpuConfig oo_stringForKey:@"name" defaultValue:renderer]);
|
||||||
|
}
|
||||||
|
if (maximumShaderSetting < defaultShaderSetting)
|
||||||
|
{
|
||||||
|
defaultShaderSetting = maximumShaderSetting;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shadersAvailable)
|
||||||
|
{
|
||||||
|
OOLog(kOOLogOpenGLShaderSupport, @"Shaders are supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defaultShaderSetting = SHADERS_NOT_SUPPORTED;
|
||||||
|
maximumShaderSetting = SHADERS_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLint texImageUnitOverride = [gpuConfig oo_unsignedIntegerForKey:@"texture_image_units" defaultValue:textureImageUnitCount];
|
||||||
|
if (texImageUnitOverride < textureImageUnitCount) textureImageUnitCount = texImageUnitOverride;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if OO_USE_VBO
|
||||||
|
[self checkVBOSupported];
|
||||||
|
#endif
|
||||||
|
#if OO_USE_FBO
|
||||||
|
[self checkFBOSupported];
|
||||||
|
#endif
|
||||||
|
#if OO_MULTITEXTURE
|
||||||
|
[self checkTextureCombinersSupported];
|
||||||
|
GLint texUnitOverride = [gpuConfig oo_unsignedIntegerForKey:@"texture_units" defaultValue:textureUnitCount];
|
||||||
|
if (texUnitOverride < textureUnitCount) textureUnitCount = texUnitOverride;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
usePointSmoothing = [gpuConfig oo_boolForKey:@"smooth_points" defaultValue:YES];
|
||||||
|
useLineSmoothing = [gpuConfig oo_boolForKey:@"smooth_lines" defaultValue:YES];
|
||||||
|
useDustShader = [gpuConfig oo_boolForKey:@"use_dust_shader" defaultValue:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
if (sSingleton == self) sSingleton = nil;
|
if (sSingleton == self) sSingleton = nil;
|
||||||
@ -280,9 +290,9 @@ static NSArray *ArrayOfExtensions(NSString *extensionString)
|
|||||||
#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
|
#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
|
||||||
[lock release];
|
[lock release];
|
||||||
#endif
|
#endif
|
||||||
[extensions release];
|
DESTROY(extensions);
|
||||||
[vendor release];
|
DESTROY(vendor);
|
||||||
[renderer release];
|
DESTROY(renderer);
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,9 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
|
|||||||
- (void) filterOutNonStrictEquipment;
|
- (void) filterOutNonStrictEquipment;
|
||||||
- (void) reinitAndShowDemo:(BOOL) showDemo strictChanged:(BOOL) strictChanged;
|
- (void) reinitAndShowDemo:(BOOL) showDemo strictChanged:(BOOL) strictChanged;
|
||||||
|
|
||||||
|
// Set shader effects level without logging or triggering a reset -- should only be used directly during startup.
|
||||||
|
- (void) setShaderEffectsLevelDirectly:(OOShaderSetting)value;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@ -208,6 +211,10 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
|
|||||||
}
|
}
|
||||||
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
if (self == nil) return nil;
|
||||||
|
|
||||||
|
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
[self setGameView:inGameView];
|
[self setGameView:inGameView];
|
||||||
gSharedUniverse = self;
|
gSharedUniverse = self;
|
||||||
|
|
||||||
@ -217,13 +224,14 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
|
|||||||
|
|
||||||
// init OpenGL extension manager (must be done before any other threads might use it)
|
// init OpenGL extension manager (must be done before any other threads might use it)
|
||||||
[OOOpenGLExtensionManager sharedManager];
|
[OOOpenGLExtensionManager sharedManager];
|
||||||
|
[self setShaderEffectsLevelDirectly:[prefs oo_intForKey:@"shader-mode"
|
||||||
|
defaultValue:[[OOOpenGLExtensionManager sharedManager] defaultShaderSetting]]];
|
||||||
|
|
||||||
[OOMaterial setUp];
|
[OOMaterial setUp];
|
||||||
|
|
||||||
// Preload cache
|
// Preload cache
|
||||||
[OOCacheManager sharedCache];
|
[OOCacheManager sharedCache];
|
||||||
|
|
||||||
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
|
||||||
strict = [prefs oo_boolForKey:@"strict-gameplay" defaultValue:NO];
|
strict = [prefs oo_boolForKey:@"strict-gameplay" defaultValue:NO];
|
||||||
|
|
||||||
// init the Resource Manager
|
// init the Resource Manager
|
||||||
@ -242,11 +250,6 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
|
|||||||
doProcedurallyTexturedPlanets = [prefs oo_boolForKey:@"procedurally-textured-planets" defaultValue:YES];
|
doProcedurallyTexturedPlanets = [prefs oo_boolForKey:@"procedurally-textured-planets" defaultValue:YES];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOL logResets = OOLogWillDisplayMessagesInClass(@"rendering.reset.start");
|
|
||||||
OOLogSetDisplayMessagesInClass(@"rendering.reset.start", NO);
|
|
||||||
[self setShaderEffectsLevel:[prefs oo_intForKey:@"shader-mode" defaultValue:[[OOOpenGLExtensionManager sharedManager] defaultShaderSetting]]];
|
|
||||||
OOLogSetDisplayMessagesInClass(@"rendering.reset.start", logResets);
|
|
||||||
|
|
||||||
#if OOLITE_SPEECH_SYNTH
|
#if OOLITE_SPEECH_SYNTH
|
||||||
#if OOLITE_MAC_OS_X
|
#if OOLITE_MAC_OS_X
|
||||||
//// speech stuff
|
//// speech stuff
|
||||||
@ -8386,16 +8389,15 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
|||||||
|
|
||||||
- (void) setShaderEffectsLevel:(OOShaderSetting)value transiently:(BOOL)transiently
|
- (void) setShaderEffectsLevel:(OOShaderSetting)value transiently:(BOOL)transiently
|
||||||
{
|
{
|
||||||
OOShaderSetting max = [[OOOpenGLExtensionManager sharedManager] maximumShaderSetting];
|
OOShaderSetting old = [self shaderEffectsLevel];
|
||||||
|
[self setShaderEffectsLevelDirectly:value];
|
||||||
|
OOShaderSetting new = [self shaderEffectsLevel];
|
||||||
|
|
||||||
if (value < SHADERS_MIN) value = SHADERS_MIN;
|
if (old != new)
|
||||||
if (max < value) value = max;
|
|
||||||
|
|
||||||
if (value != shaderEffectsLevel)
|
|
||||||
{
|
{
|
||||||
OOLog(@"rendering.opengl.shader.mode", @"Shader mode set to %@.", ShaderSettingToString(value));
|
OOLog(@"rendering.opengl.shader.mode", @"Shader mode set to %@.", ShaderSettingToString(value));
|
||||||
shaderEffectsLevel = value;
|
|
||||||
if (!transiently) [[NSUserDefaults standardUserDefaults] setInteger:shaderEffectsLevel forKey:@"shader-mode"];
|
if (!transiently) [[NSUserDefaults standardUserDefaults] setInteger:shaderEffectsLevel forKey:@"shader-mode"];
|
||||||
|
|
||||||
[[OOGraphicsResetManager sharedManager] resetGraphicsState];
|
[[OOGraphicsResetManager sharedManager] resetGraphicsState];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9205,7 +9207,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
|||||||
unsigned i = [_preloadingPlanetMaterials count];
|
unsigned i = [_preloadingPlanetMaterials count];
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
if (![_preloadingPlanetMaterials objectAtIndex:i] || [[_preloadingPlanetMaterials objectAtIndex:i] isFinishedLoading])
|
if ([[_preloadingPlanetMaterials objectAtIndex:i] isFinishedLoading])
|
||||||
{
|
{
|
||||||
[_preloadingPlanetMaterials removeObjectAtIndex:i];
|
[_preloadingPlanetMaterials removeObjectAtIndex:i];
|
||||||
}
|
}
|
||||||
@ -9213,6 +9215,17 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
- (void) setShaderEffectsLevelDirectly:(OOShaderSetting)value
|
||||||
|
{
|
||||||
|
OOShaderSetting max = [[OOOpenGLExtensionManager sharedManager] maximumShaderSetting];
|
||||||
|
|
||||||
|
if (value < SHADERS_MIN) value = SHADERS_MIN;
|
||||||
|
if (max < value) value = max;
|
||||||
|
|
||||||
|
shaderEffectsLevel = value;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user