Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOShaderMaterial.m File Reference
+ Include dependency graph for OOShaderMaterial.m:

Go to the source code of this file.

Functions

static BOOL GetShaderSource (NSString *fileName, NSString *shaderType, NSString *prefix, NSString **outResult)
 

Function Documentation

◆ GetShaderSource()

static BOOL GetShaderSource ( NSString * fileName,
NSString * shaderType,
NSString * prefix,
NSString ** outResult )
static

Definition at line 860 of file OOShaderMaterial.m.

861{
862 NSString *result = nil;
863 NSArray *extensions = nil;
864 NSEnumerator *extEnum = nil;
865 NSString *extension = nil;
866 NSString *nameWithExtension = nil;
867
868 if (fileName == nil) return YES; // It's OK for one or the other of the shaders to be undefined.
869
870 result = [ResourceManager stringFromFilesNamed:fileName inFolder:@"Shaders"];
871 if (result == nil)
872 {
873 extensions = [NSArray arrayWithObjects:shaderType, [shaderType substringToIndex:4], nil]; // vertex and vert, or fragment and frag
874
875 // Futureproofing -- in future, we may wish to support automatic selection between supported shader languages.
876 if (![fileName pathHasExtensionInArray:extensions])
877 {
878 for (extEnum = [extensions objectEnumerator]; (extension = [extEnum nextObject]); )
879 {
880 nameWithExtension = [fileName stringByAppendingPathExtension:extension];
881 result = [ResourceManager stringFromFilesNamed:nameWithExtension
882 inFolder:@"Shaders"];
883 if (result != nil) break;
884 }
885 }
886 if (result == nil)
887 {
888 OOLog(kOOLogFileNotFound, @"GLSL ERROR: failed to find %@ program %@.", shaderType, fileName);
889 return NO;
890 }
891 }
892
893 if (outResult != NULL) *outResult = result;
894 return YES;
895}
#define OOLog(class, format,...)
Definition OOLogging.h:88
NSString *const kOOLogFileNotFound
Definition OOLogging.m:652
return nil
NSString * stringFromFilesNamed:inFolder:(NSString *fileName,[inFolder] NSString *folderName)

References kOOLogFileNotFound, nil, OOLog, and ResourceManager::stringFromFilesNamed:inFolder:.

+ Here is the call graph for this function: