Oolite
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 857 of file OOShaderMaterial.m.

858{
859 NSString *result = nil;
860 NSArray *extensions = nil;
861 NSString *extension = nil;
862 NSString *nameWithExtension = nil;
863
864 if (fileName == nil) return YES; // It's OK for one or the other of the shaders to be undefined.
865
866 result = [ResourceManager stringFromFilesNamed:fileName inFolder:@"Shaders"];
867 if (result == nil)
868 {
869 extensions = [NSArray arrayWithObjects:shaderType, [shaderType substringToIndex:4], nil]; // vertex and vert, or fragment and frag
870
871 // Futureproofing -- in future, we may wish to support automatic selection between supported shader languages.
872 if (![fileName pathHasExtensionInArray:extensions])
873 {
874 foreach (extension, extensions)
875 {
876 nameWithExtension = [fileName stringByAppendingPathExtension:extension];
877 result = [ResourceManager stringFromFilesNamed:nameWithExtension
878 inFolder:@"Shaders"];
879 if (result != nil) break;
880 }
881 }
882 if (result == nil)
883 {
884 OOLog(kOOLogFileNotFound, @"GLSL ERROR: failed to find %@ program %@.", shaderType, fileName);
885 return NO;
886 }
887 }
888
889 if (outResult != NULL) *outResult = result;
890 return YES;
891}
#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: