vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
ISFGLScene.h
1 #import <Cocoa/Cocoa.h>
2 //#import "VVBuffer.h"
3 //#import "GLShaderScene.h"
4 #import <VVBufferPool/VVBufferPool.h>
5 #import "ISFAttrib.h"
6 #import <VVBasics/VVBasics.h>
7 #import "ISFTargetBuffer.h"
8 #import "ISFRenderPass.h"
9 
10 
11 
12 
13 // key is path to the file, object is VVBuffer instance. the userInfo of this VVBuffer instance has an NSNumber, which serves as its "retain count": it's incremented when the buffer is loaded/created, and decremented when it's deleted- when it hits 0, the file is removed from the dict entirely.
14 extern MutLockDict *_ISFImportedImages;
15 extern NSString *_ISFVertPassthru;
16 extern NSString *_ISFVertVarDec;
17 extern NSString *_ISFVertInitFunc;
18 extern NSString *_ISFMacro2DString;
19 extern NSString *_ISFMacro2DBiasString;
20 extern NSString *_ISFMacro2DRectString;
21 extern NSString *_ISFMacro2DRectBiasString;
22 
23 
24 
25 
27 
30 @interface ISFGLScene : GLShaderScene {
31  BOOL throwExceptions; // NO by default
32  NSString *filePath; // full path to the loaded file
33  NSString *fileName; // just the file name (including its extension)
34  NSString *fileDescription; // description of whatever the file does
35  NSString *fileCredits; // credits
36  NSMutableArray *categoryNames; // array of NSStrings of the category names this filter should be listed under
37  MutLockArray *inputs; // array of ISFAttrib instances for the various inputs
38  MutLockArray *imageInputs; // array of ISFAttrib instances for the image inputs (the image inputs are stored in two arrays).
39  MutLockArray *imageImports; // array of ISFAttrib instances that describe imported images. 'attribName' is the name of the sampler, 'attribDescription' is the path to the file.
40 
41  NSSize renderSize; // the last size at which i was requested to render a buffer (used to produce vals from normalized point inputs that need a render size to be used)
42  VVStopwatch *swatch; // used to pass time to shaders
43  double renderTime;
44  BOOL bufferRequiresEval; // NO by default, set to YES during file open if any of the buffers require evaluation (faster than checking every single buffer every pass)
45  MutLockArray *persistentBufferArray; // array of ISFTargetBuffer instances describing the various persistent buffers. these buffers are retained until a different file is loaded.
46  MutLockArray *tempBufferArray; // array of ISFTargetBuffer instances- temp buffers are available while rendering, but are returned to the pool when rendering's complete
47  MutLockArray *passes; // array of ISFRenderPass instances. right now, passes basically just describe a (ISFTargetBuffer)
48 
49  int passIndex; // only has a valid value while rendering
50 
51  NSString *jsonString; // the raw JSON string copied from the source
52  NSString *vertShaderSource; // the raw vert shader source before being find-and-replaced
53  NSString *fragShaderSource; // the raw frag shader source before being find-and-replaced
54  NSString *compiledInputTypeString; // a sequence of characters, either "2" or "R", one character for each input image. describes whether the shader was compiled to work with 2D textures or RECT textures.
55  long renderSizeUniformLoc;
56  long passIndexUniformLoc;
57  long timeUniformLoc;
58 }
59 
60 - (id) initWithSharedContext:(NSOpenGLContext *)c;
61 - (id) initWithSharedContext:(NSOpenGLContext *)c pixelFormat:(NSOpenGLPixelFormat *)p sized:(NSSize)s;
62 
64 - (void) useFile:(NSString *)p;
65 - (void) useFile:(NSString *)p resetTimer:(BOOL)r;
66 
68 
72 - (void) setBuffer:(VVBuffer *)b forInputImageKey:(NSString *)k;
74 - (void) setFilterInputImageBuffer:(VVBuffer *)b;
76 - (VVBuffer *) bufferForInputImageKey:(NSString *)k;
77 - (void) purgeInputGLTextures;
79 
83 - (void) setValue:(ISFAttribVal)n forInputKey:(NSString *)k;
85 
89 - (void) setNSObjectVal:(id)n forInputKey:(NSString *)k;
91 
94 - (NSMutableArray *) inputsOfType:(ISFAttribValType)t;
96 - (ISFAttrib *) attribForInputWithKey:(NSString *)k;
97 
98 - (ISFTargetBuffer *) findPersistentBufferNamed:(NSString *)n;
99 - (ISFTargetBuffer *) findTempBufferNamed:(NSString *)n;
100 
102 - (VVBuffer *) allocAndRenderToBufferSized:(NSSize)s;
103 - (VVBuffer *) allocAndRenderToBufferSized:(NSSize)s prefer2DTex:(BOOL)wants2D;
104 - (VVBuffer *) allocAndRenderToBufferSized:(NSSize)s prefer2DTex:(BOOL)wants2D passDict:(NSMutableDictionary *)d;
105 - (VVBuffer *) allocAndRenderToBufferSized:(NSSize)s prefer2DTex:(BOOL)wants2D renderTime:(double)t;
106 - (VVBuffer *) allocAndRenderToBufferSized:(NSSize)s prefer2DTex:(BOOL)wants2D renderTime:(double)t passDict:(NSMutableDictionary *)d;
107 - (void) renderToBuffer:(VVBuffer *)b sized:(NSSize)s;
109 
115 - (void) renderToBuffer:(VVBuffer *)b sized:(NSSize)s renderTime:(double)t passDict:(NSMutableDictionary *)d;
116 
117 - (void) _assembleShaderSource;
118 - (NSMutableString *) _assembleShaderSource_VarDeclarations;
119 - (NSMutableDictionary *) _assembleSubstitutionDict;
120 - (void) _clearImageImports;
121 
122 @property (assign,readwrite) BOOL throwExceptions;
124 @property (readonly) NSString *filePath;
126 @property (readonly) NSString *fileName;
128 @property (readonly) NSString *fileDescription;
130 @property (readonly) NSString *fileCredits;
132 @property (readonly) NSMutableArray *categoryNames;
134 @property (readonly) MutLockArray *inputs;
136 @property (readonly) MutLockArray *imageInputs;
137 @property (readonly) NSSize renderSize;
138 @property (readonly) int passCount;
139 @property (readonly) int imageInputsCount;
140 @property (readonly) NSString *jsonString;
141 
142 - (void) _renderLock;
143 - (void) _renderUnlock;
144 
145 @end
NSString * fileName
returns the name of the currently-loaded ISF file
Definition: ISFGLScene.h:33
internally, an ISFGLScene creates an ISFAttrib for each of the declared inputs in an ISF file...
Definition: ISFAttrib.h:43
VVBuffer represents a buffer- almost always in VRAM as a GL texture or renderbuffer- created and mana...
Definition: VVBuffer.h:134
MutLockArray * inputs
returns a MutLockArray (from VVBasics) of ISFAttrib instances, one for each of the inputs ...
Definition: ISFGLScene.h:37
This class is used to measure how long it takes to do things; much easier to work with than NSDate...
Definition: VVStopwatch.h:16
NSString * fileCredits
returns a string with the credits (pulled from the JSON blob) of the ISF file
Definition: ISFGLScene.h:35
NSString * fileDescription
returns a string with the description (pulled from the JSON blob) of the ISF file ...
Definition: ISFGLScene.h:34
Subclass of GLScene for working with vertex & frag shaders- just give it some shader strings and watc...
Definition: GLShaderScene.h:14
NSString * filePath
returns the path of the currently-loaded ISF file
Definition: ISFGLScene.h:32
Subclass of GLShaderScene- loads and renders ISF files.
Definition: ISFGLScene.h:30
union describing a value for one of the listed attribute types
Definition: ISFAttrib.h:26
ISFAttribValType
enum describing the different types of attributes listed in the ISF spec
Definition: ISFAttrib.h:13
MutLockDict is a thread-safe version of NSMutableDictionary.
Definition: MutLockDict.h:17
NSMutableArray * categoryNames
returns an array with the category names (as NSStrings) of this ISF file. pulled from the JSON blob...
Definition: ISFGLScene.h:36
Similar to NSMutableArray, but thread-safe. Internally, uses an NSMutableArray and a rwlock...
Definition: MutLockArray.h:20
MutLockArray * imageInputs
returns a MutLockArray (from VVBasics) of all the image-type (ISFAT_Image) ISFAttrib instances...
Definition: ISFGLScene.h:38