Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOOpenGLExtensionManager Class Reference

#include <OOOpenGLExtensionManager.h>

+ Inheritance diagram for OOOpenGLExtensionManager:
+ Collaboration diagram for OOOpenGLExtensionManager:

Instance Methods

(void) - reset
 
(BOOL) - haveExtension:
 
(BOOL) - shadersSupported
 
(BOOL) - shadersForceDisabled
 
(OOGraphicsDetail- defaultDetailLevel
 
(OOGraphicsDetail- maximumDetailLevel
 
(GLint) - textureImageUnitCount
 
(BOOL) - vboSupported
 
(BOOL) - fboSupported
 
(BOOL) - textureCombinersSupported
 
(GLint) - textureUnitCount
 
(NSUInteger) - majorVersionNumber
 
(NSUInteger) - minorVersionNumber
 
(NSUInteger) - releaseVersionNumber
 
(void) - getVersionMajor:minor:release:
 
(BOOL) - versionIsAtLeastMajor:minor:
 
(NSString *) - vendorString
 
(NSString *) - rendererString
 
(BOOL) - usePointSmoothing
 
(BOOL) - useLineSmoothing
 
(BOOL) - useDustShader
 
(id) - init [implementation]
 
(void) - dealloc [implementation]
 
(void) - checkShadersSupported [implementation]
 
(NSDictionary *) - lookUpPerGPUSettingsWithVersionString:extensionsString: [implementation]
 
(NSComparisonResult) - CompareGPUSettingsByPriority [implementation]
 
(id) - copyWithZone: [implementation]
 
(id) - retain [implementation]
 
(NSUInteger) - retainCount [implementation]
 
(id) - autorelease [implementation]
 

Class Methods

(OOOpenGLExtensionManager *) + sharedManager
 
(static BOOL) + CheckRegExps [implementation]
 
(id) + allocWithZone: [implementation]
 

Private Attributes

NSSet * extensions
 
NSString * vendor
 
NSString * renderer
 
unsigned major
 
unsigned minor
 
unsigned release
 
BOOL usePointSmoothing
 
BOOL useLineSmoothing
 
BOOL useDustShader
 
BOOL shadersAvailable
 
BOOL shadersForceDisabled
 
OOShaderSetting defaultShaderSetting
 
OOShaderSetting maximumShaderSetting
 
GLint textureImageUnitCount
 

Detailed Description

Definition at line 115 of file OOOpenGLExtensionManager.h.

Method Documentation

◆ allocWithZone:

+ (id) allocWithZone: (NSZone *) inZone
implementation

Provided by category OOOpenGLExtensionManager(Singleton).

Definition at line 771 of file OOOpenGLExtensionManager.m.

839 :(NSZone *)inZone
840{
841 if (sSingleton == nil)
842 {
843 sSingleton = [super allocWithZone:inZone];
844 return sSingleton;
845 }
846 return nil;
847}
static OODebugMonitor * sSingleton
return nil

◆ autorelease

- (id) autorelease
implementation

Provided by category OOOpenGLExtensionManager(Singleton).

Definition at line 771 of file OOOpenGLExtensionManager.m.

873{
874 return self;
875}

◆ CheckRegExps

+ (static BOOL) CheckRegExps (NSString *) string
(id) regexps 
implementation

Provided by category OOOpenGLExtensionManager(OOPrivate).

Definition at line 741 of file OOOpenGLExtensionManager.m.

742{
743 if (regexps == nil) return YES; // No restriction == match.
744 if ([regexps isKindOfClass:[NSString class]])
745 {
746 return [string oo_matchesRegularExpression:regexps];
747 }
748 if ([regexps isKindOfClass:[NSArray class]])
749 {
750 NSEnumerator *regexpEnum = nil;
751 NSString *regexp = nil;
752
753 for (regexpEnum = [regexps objectEnumerator]; (regexp = [regexpEnum nextObject]); )
754 {
755 if (EXPECT_NOT(![regexp isKindOfClass:[NSString class]]))
756 {
757 // Invalid type -- match fails.
758 return NO;
759 }
760
761 if (![string oo_matchesRegularExpression:regexp]) return NO;
762 }
763 return YES;
764 }
765
766 // Invalid type -- match fails.
767 return NO;
768}
#define EXPECT_NOT(x)

◆ CompareGPUSettingsByPriority

- (NSComparisonResult) CompareGPUSettingsByPriority (id) a
(id) b
(void *) context 
implementation

Provided by category OOOpenGLExtensionManager(OOPrivate).

Definition at line 771 of file OOOpenGLExtensionManager.m.

772{
773 NSString *keyA = a;
774 NSString *keyB = b;
775 NSDictionary *configurations = context;
776 NSDictionary *dictA = [configurations oo_dictionaryForKey:keyA];
777 NSDictionary *dictB = [configurations oo_dictionaryForKey:keyB];
778 double precedenceA = [dictA oo_doubleForKey:@"precedence" defaultValue:1];
779 double precedenceB = [dictB oo_doubleForKey:@"precedence" defaultValue:1];
780
781 if (precedenceA > precedenceB) return NSOrderedAscending;
782 if (precedenceA < precedenceB) return NSOrderedDescending;
783
784 return [keyA caseInsensitiveCompare:keyB];
785}

◆ copyWithZone:

- (id) copyWithZone: (NSZone *) inZone
implementation

Provided by category OOOpenGLExtensionManager(Singleton).

Definition at line 771 of file OOOpenGLExtensionManager.m.

850 :(NSZone *)inZone
851{
852 return self;
853}

◆ dealloc

- (void) dealloc
implementation

Definition at line 529 of file OOOpenGLExtensionManager.m.

322{
323 if (sSingleton == self) sSingleton = nil;
324
325#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
326 [lock release];
327#endif
331
332 [super dealloc];
333}
#define DESTROY(x)
Definition OOCocoa.h:77

◆ defaultDetailLevel

- (OOGraphicsDetail) defaultDetailLevel

Definition at line 529 of file OOOpenGLExtensionManager.m.

382{
383#if OO_SHADERS
385 {
387 }
388 else
389 {
391 }
392#else
394#endif
395}
@ SHADERS_FULL
Definition OOOpenGL.h:40
@ SHADERS_NOT_SUPPORTED
Definition OOOpenGL.h:37
@ DETAIL_LEVEL_MAXIMUM
Definition OOTypes.h:251
@ DETAIL_LEVEL_MINIMUM
Definition OOTypes.h:244

◆ fboSupported

- (BOOL) fboSupported

Definition at line 529 of file OOOpenGLExtensionManager.m.

436{
437#if OO_USE_FBO
438 return fboSupported;
439#else
440 return NO;
441#endif
442}

◆ getVersionMajor:minor:release:

- (void) getVersionMajor: (unsigned *) outMajor
minor: (unsigned *) outMinor
release: (unsigned *) outRelease 

Definition at line 529 of file OOOpenGLExtensionManager.m.

483 :(unsigned *)outMajor minor:(unsigned *)outMinor release:(unsigned *)outRelease
484{
485 if (outMajor != NULL) *outMajor = major;
486 if (outMinor != NULL) *outMinor = minor;
487 if (outRelease != NULL) *outRelease = release;
488}

◆ haveExtension:

- (BOOL) haveExtension: (NSString *) extension

Definition at line 529 of file OOOpenGLExtensionManager.m.

344 :(NSString *)extension
345{
346// NSSet is documented as thread-safe under OS X, but I'm not sure about GNUstep. -- Ahruman
347#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
348 [lock lock];
349#endif
350
351 BOOL result = [extensions containsObject:extension];
352
353#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
354 [lock unlock];
355#endif
356
357 return result;
358}

◆ init

- (id) init
implementation

Definition at line 529 of file OOOpenGLExtensionManager.m.

198{
199 self = [super init];
200 if (self != nil)
201 {
202#if OOOPENGLEXTMGR_LOCK_SET_ACCESS
203 lock = [[NSLock alloc] init];
204 [lock setName:@"OOOpenGLExtensionManager extension set lock"];
205#endif
206
207 [self reset];
208 }
209
210 return self;
211}

◆ lookUpPerGPUSettingsWithVersionString:extensionsString:

- (NSDictionary *) lookUpPerGPUSettingsWithVersionString: (NSString *) version
extensionsString: (NSString *) extensionsStr 
implementation

Provided by category OOOpenGLExtensionManager(OOPrivate).

Definition at line 771 of file OOOpenGLExtensionManager.m.

788 :(NSString *)versionStr extensionsString:(NSString *)extensionsStr
789{
790 NSDictionary *configurations = [ResourceManager dictionaryFromFilesNamed:@"gpu-settings.plist"
791 inFolder:@"Config"
792 andMerge:YES];
793
794 NSArray *keys = [[configurations allKeys] sortedArrayUsingFunction:CompareGPUSettingsByPriority context:configurations];
795
796 NSEnumerator *keyEnum = nil;
797 NSString *key = nil;
798 NSDictionary *config = nil;
799
800 for (keyEnum = [keys objectEnumerator]; (key = [keyEnum nextObject]); )
801 {
802 config = [configurations oo_dictionaryForKey:key];
803 if (EXPECT_NOT(config == nil)) continue;
804
805 NSDictionary *match = [config oo_dictionaryForKey:@"match"];
806 NSString *expr = nil;
807
808 expr = [match objectForKey:@"vendor"];
809 if (!CheckRegExps(vendor, expr)) continue;
810
811 expr = [match oo_stringForKey:@"renderer"];
812 if (!CheckRegExps(renderer, expr)) continue;
813
814 expr = [match oo_stringForKey:@"version"];
815 if (!CheckRegExps(versionStr, expr)) continue;
816
817 expr = [match oo_stringForKey:@"extensions"];
818 if (!CheckRegExps(extensionsStr, expr)) continue;
819
820 OOLog(@"rendering.opengl.gpuSpecific", @"Matched GPU configuration \"%@\".", key);
821 return config;
822 }
823
824 return [NSDictionary dictionary];
825}
#define OOLog(class, format,...)
Definition OOLogging.h:88
static BOOL CheckRegExps(NSString *string, id regexps)
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ majorVersionNumber

- (NSUInteger) majorVersionNumber

Definition at line 529 of file OOOpenGLExtensionManager.m.

466{
467 return major;
468}

◆ maximumDetailLevel

- (OOGraphicsDetail) maximumDetailLevel

Definition at line 529 of file OOOpenGLExtensionManager.m.

399{
400#if OO_SHADERS
402 {
404 }
405 else
406 {
408 }
409#else
411#endif
412}

Referenced by ConsoleGetProperty().

+ Here is the caller graph for this function:

◆ minorVersionNumber

- (NSUInteger) minorVersionNumber

Definition at line 529 of file OOOpenGLExtensionManager.m.

472{
473 return minor;
474}

◆ releaseVersionNumber

- (NSUInteger) releaseVersionNumber

Definition at line 529 of file OOOpenGLExtensionManager.m.

478{
479 return release;
480}

◆ rendererString

- (NSString *) rendererString

Definition at line 529 of file OOOpenGLExtensionManager.m.

504{
505 return renderer;
506}

◆ reset

- (void) reset

Definition at line 529 of file OOOpenGLExtensionManager.m.

215{
216 const GLubyte *versionString = NULL, *curr = NULL;
217
221
222 NSString *extensionsStr = [NSString stringWithUTF8String:(char *)glGetString(GL_EXTENSIONS)];
223 extensions = [[NSSet alloc] initWithArray:ArrayOfExtensions(extensionsStr)];
224
225 vendor = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_VENDOR)];
226 renderer = [[NSString alloc] initWithUTF8String:(const char *)glGetString(GL_RENDERER)];
227
228 versionString = glGetString(GL_VERSION);
229 if (versionString != NULL)
230 {
231 /* String is supposed to be "major.minorFOO" or
232 "major.minor.releaseFOO" where FOO is an empty string or
233 a string beginning with space.
234 */
235 curr = versionString;
236 major = IntegerFromString(&curr);
237 if (*curr == '.')
238 {
239 curr++;
240 minor = IntegerFromString(&curr);
241 }
242 if (*curr == '.')
243 {
244 curr++;
245 release = IntegerFromString(&curr);
246 }
247 }
248
249 /* For aesthetic reasons, cause the ResourceManager to initialize its
250 search paths here. If we don't, the search path dump ends up in
251 the middle of the OpenGL stuff.
252 */
254
255 OOLog(@"rendering.opengl.version", @"OpenGL renderer version: %u.%u.%u (\"%s\"). Vendor: \"%@\". Renderer: \"%@\".", major, minor, release, versionString, vendor, renderer);
256 OOLog(@"rendering.opengl.extensions", @"OpenGL extensions (%lu):\n%@", [extensions count], [[extensions allObjects] componentsJoinedByString:@", "]);
257
258 if (![self versionIsAtLeastMajor:kMinMajorVersion minor:kMinMinorVersion])
259 {
260 OOLog(@"rendering.opengl.version.insufficient", @"***** Oolite requires OpenGL version %u.%u or later.", kMinMajorVersion, kMinMinorVersion);
261 [NSException raise:@"OoliteOpenGLTooOldException"
262 format:@"Oolite requires at least OpenGL %u.%u. You have %u.%u (\"%s\").", kMinMajorVersion, kMinMinorVersion, major, minor, versionString];
263 }
264
265 NSString *versionStr = [[[NSString alloc] initWithUTF8String:(const char *)versionString] autorelease];
266 NSDictionary *gpuConfig = [self lookUpPerGPUSettingsWithVersionString:versionStr extensionsString:extensionsStr];
267
268#if OO_SHADERS
269 [self checkShadersSupported];
270
272 {
273 defaultShaderSetting = OOShaderSettingFromString([gpuConfig oo_stringForKey:@"default_shader_level"
274 defaultValue:@"SHADERS_FULL"]);
275 maximumShaderSetting = OOShaderSettingFromString([gpuConfig oo_stringForKey:@"maximum_shader_level"
276 defaultValue:@"SHADERS_FULL"]);
278 {
279 shadersAvailable = NO;
281 OOLog(kOOLogOpenGLShaderSupport, @"Shaders will not be used (disallowed for GPU type \"%@\").", [gpuConfig oo_stringForKey:@"name" defaultValue:renderer]);
282 }
284 {
286 }
287
289 {
290 OOLog(kOOLogOpenGLShaderSupport, @"%@", @"Shaders are supported.");
291 }
292 }
293 else
294 {
297 }
298
299 GLint texImageUnitOverride = [gpuConfig oo_intForKey:@"texture_image_units" defaultValue:textureImageUnitCount];
300 if (texImageUnitOverride < textureImageUnitCount) textureImageUnitCount = MAX(texImageUnitOverride, 0);
301#endif
302
303#if OO_USE_VBO
304 [self checkVBOSupported];
305#endif
306#if OO_USE_FBO
307 [self checkFBOSupported];
308#endif
309#if OO_MULTITEXTURE
310 [self checkTextureCombinersSupported];
311 GLint texUnitOverride = [gpuConfig oo_intForKey:@"texture_units" defaultValue:textureUnitCount];
312 if (texUnitOverride < textureUnitCount) textureUnitCount = MAX(texUnitOverride, 0);
313#endif
314
315 usePointSmoothing = [gpuConfig oo_boolForKey:@"smooth_points" defaultValue:YES];
316 useLineSmoothing = [gpuConfig oo_boolForKey:@"smooth_lines" defaultValue:YES];
317 useDustShader = [gpuConfig oo_boolForKey:@"use_dust_shader" defaultValue:YES];
318}
OOShaderSetting OOShaderSettingFromString(NSString *string)
#define MAX(A, B)
Definition OOMaths.h:114
static NSString *const kOOLogOpenGLShaderSupport
static unsigned IntegerFromString(const GLubyte **ioString)
@ SHADERS_OFF
Definition OOOpenGL.h:38
unsigned count

◆ retain

- (id) retain
implementation

Provided by category OOOpenGLExtensionManager(Singleton).

Definition at line 771 of file OOOpenGLExtensionManager.m.

857{
858 return self;
859}

◆ retainCount

- (NSUInteger) retainCount
implementation

Provided by category OOOpenGLExtensionManager(Singleton).

Definition at line 771 of file OOOpenGLExtensionManager.m.

863{
864 return UINT_MAX;
865}

◆ shadersForceDisabled

- (BOOL) shadersForceDisabled

◆ shadersSupported

- (BOOL) shadersSupported

Definition at line 529 of file OOOpenGLExtensionManager.m.

362{
363#if OO_SHADERS
364 return shadersAvailable;
365#else
366 return NO;
367#endif
368}

Referenced by OOShadersSupported().

+ Here is the caller graph for this function:

◆ sharedManager

+ (OOOpenGLExtensionManager *) sharedManager

Definition at line 529 of file OOOpenGLExtensionManager.m.

337{
338 // NOTE: assumes single-threaded first access. See header.
339 if (sSingleton == nil) sSingleton = [[self alloc] init];
340 return sSingleton;
341}

Referenced by ConsoleGetProperty(), and OOShadersSupported().

+ Here is the caller graph for this function:

◆ textureCombinersSupported

- (BOOL) textureCombinersSupported

Definition at line 529 of file OOOpenGLExtensionManager.m.

446{
447#if OO_MULTITEXTURE
449#else
450 return NO;
451#endif
452}

◆ textureImageUnitCount

- (GLint) textureImageUnitCount

◆ textureUnitCount

- (GLint) textureUnitCount

Definition at line 529 of file OOOpenGLExtensionManager.m.

456{
457#if OO_MULTITEXTURE
458 return textureUnitCount;
459#else
460 return 0;
461#endif
462}

◆ useDustShader

- (BOOL) useDustShader

◆ useLineSmoothing

- (BOOL) useLineSmoothing

◆ usePointSmoothing

- (BOOL) usePointSmoothing

◆ vboSupported

- (BOOL) vboSupported

Definition at line 529 of file OOOpenGLExtensionManager.m.

426{
427#if OO_USE_VBO
428 return vboSupported;
429#else
430 return NO;
431#endif
432}

◆ vendorString

- (NSString *) vendorString

Definition at line 529 of file OOOpenGLExtensionManager.m.

498{
499 return vendor;
500}

◆ versionIsAtLeastMajor:minor:

- (BOOL) versionIsAtLeastMajor: (unsigned) maj
minor: (unsigned) min 

Definition at line 529 of file OOOpenGLExtensionManager.m.

491 :(unsigned)maj minor:(unsigned)min
492{
493 return major > maj || (major == maj && minor >= min);
494}

Member Data Documentation

◆ defaultShaderSetting

- (OOShaderSetting) defaultShaderSetting
private

Definition at line 135 of file OOOpenGLExtensionManager.h.

◆ extensions

- (NSSet*) extensions
private

Definition at line 121 of file OOOpenGLExtensionManager.h.

◆ major

- (unsigned) major
private

Definition at line 126 of file OOOpenGLExtensionManager.h.

◆ maximumShaderSetting

- (OOShaderSetting) maximumShaderSetting
private

Definition at line 136 of file OOOpenGLExtensionManager.h.

◆ minor

- (unsigned) minor
private

Definition at line 126 of file OOOpenGLExtensionManager.h.

◆ release

- (unsigned) release
private

Provided by category OOOpenGLExtensionManager(Singleton).

Definition at line 126 of file OOOpenGLExtensionManager.h.

◆ renderer

- (NSString*) renderer
private

Definition at line 124 of file OOOpenGLExtensionManager.h.

◆ shadersAvailable

- (BOOL) shadersAvailable
private

Definition at line 133 of file OOOpenGLExtensionManager.h.

◆ shadersForceDisabled

- (BOOL) shadersForceDisabled
private

Definition at line 134 of file OOOpenGLExtensionManager.h.

◆ textureImageUnitCount

- (GLint) textureImageUnitCount
private

Definition at line 137 of file OOOpenGLExtensionManager.h.

◆ useDustShader

- (BOOL) useDustShader
private

Definition at line 130 of file OOOpenGLExtensionManager.h.

◆ useLineSmoothing

- (BOOL) useLineSmoothing
private

Definition at line 129 of file OOOpenGLExtensionManager.h.

◆ usePointSmoothing

- (BOOL) usePointSmoothing
private

Definition at line 128 of file OOOpenGLExtensionManager.h.

◆ vendor

- (NSString*) vendor
private

Definition at line 123 of file OOOpenGLExtensionManager.h.


The documentation for this class was generated from the following files: