|
28 | 28 | - CCEffectStack
|
29 | 29 | - Experimental as of v3.4: CCEffectDistanceField, CCEffectDFInnerGlow, CCEffectDFOutline
|
30 | 30 | */
|
| 31 | + |
| 32 | +extern NSString * const CCShaderUniformPreviousPassTexture; |
| 33 | +extern NSString * const CCShaderUniformTexCoord1Center; |
| 34 | +extern NSString * const CCShaderUniformTexCoord1Extents; |
| 35 | +extern NSString * const CCShaderUniformTexCoord2Center; |
| 36 | +extern NSString * const CCShaderUniformTexCoord2Extents; |
| 37 | +extern NSString * const CCEffectDefaultInitialInputSnippet; |
| 38 | +extern NSString * const CCEffectDefaultInputSnippet; |
| 39 | + |
| 40 | + |
| 41 | +typedef NS_ENUM(NSUInteger, CCEffectPrepareStatus) |
| 42 | +{ |
| 43 | + CCEffectPrepareFailure = 0, |
| 44 | + CCEffectPrepareSuccess = 1, |
| 45 | +}; |
| 46 | + |
| 47 | +typedef NS_OPTIONS(NSUInteger, CCEffectPrepareWhatChanged) |
| 48 | +{ |
| 49 | + CCEffectPrepareNothingChanged = 0, |
| 50 | + CCEffectPreparePassesChanged = (1 << 0), |
| 51 | + CCEffectPrepareShaderChanged = (1 << 1), |
| 52 | + CCEffectPrepareUniformsChanged = (1 << 2) |
| 53 | +}; |
| 54 | + |
| 55 | +typedef struct CCEffectPrepareResult |
| 56 | +{ |
| 57 | + CCEffectPrepareStatus status; |
| 58 | + CCEffectPrepareWhatChanged changes; |
| 59 | +} CCEffectPrepareResult; |
| 60 | + |
| 61 | +extern const CCEffectPrepareResult CCEffectPrepareNoop; |
| 62 | + |
| 63 | +typedef NS_ENUM(NSUInteger, CCEffectFunctionStitchFlags) |
| 64 | +{ |
| 65 | + CCEffectFunctionStitchBefore = 1 << 0, |
| 66 | + CCEffectFunctionStitchAfter = 1 << 1, |
| 67 | + CCEffectFunctionStitchBoth = (CCEffectFunctionStitchBefore | CCEffectFunctionStitchAfter), |
| 68 | +}; |
| 69 | + |
| 70 | +typedef NS_ENUM(NSUInteger, CCEffectTexCoordMapping) |
| 71 | +{ |
| 72 | + CCEffectTexCoordMapMainTex = 0, |
| 73 | + CCEffectTexCoordMapPreviousPassTex = 1, |
| 74 | + CCEffectTexCoordMapCustomTex = 2, |
| 75 | + CCEffectTexCoordMapCustomTexNoTransform = 3 |
| 76 | +}; |
| 77 | + |
| 78 | +@interface CCEffectFunction : NSObject |
| 79 | + |
| 80 | +@property (nonatomic, readonly) NSString* body; |
| 81 | +@property (nonatomic, readonly) NSString* name; |
| 82 | +@property (nonatomic, readonly) NSArray* inputs; |
| 83 | +@property (nonatomic, readonly) NSString* inputString; |
| 84 | +@property (nonatomic, readonly) NSString* returnType; |
| 85 | +@property (nonatomic, readonly) NSString* function; |
| 86 | + |
| 87 | +-(id)initWithName:(NSString*)name body:(NSString*)body inputs:(NSArray*)inputs returnType:(NSString*)returnType; |
| 88 | ++(instancetype)functionWithName:(NSString*)name body:(NSString*)body inputs:(NSArray*)inputs returnType:(NSString*)returnType; |
| 89 | + |
| 90 | +-(NSString*)callStringWithInputs:(NSArray*)inputs; |
| 91 | + |
| 92 | +@end |
| 93 | + |
| 94 | +@interface CCEffectFunctionInput : NSObject |
| 95 | + |
| 96 | +@property (nonatomic, readonly) NSString* type; |
| 97 | +@property (nonatomic, readonly) NSString* name; |
| 98 | +@property (nonatomic, readonly) NSString* initialSnippet; |
| 99 | +@property (nonatomic, readonly) NSString* snippet; |
| 100 | + |
| 101 | +-(id)initWithType:(NSString*)type name:(NSString*)name initialSnippet:(NSString*)initialSnippet snippet:(NSString*)snippet; |
| 102 | ++(instancetype)inputWithType:(NSString*)type name:(NSString*)name initialSnippet:(NSString*)initialSnippet snippet:(NSString*)snippet; |
| 103 | + |
| 104 | +@end |
| 105 | + |
| 106 | +@interface CCEffectUniform : NSObject |
| 107 | + |
| 108 | +@property (nonatomic, readonly) NSString* name; |
| 109 | +@property (nonatomic, readonly) NSString* type; |
| 110 | +@property (nonatomic, readonly) NSString* declaration; |
| 111 | +@property (nonatomic, readonly) NSValue* value; |
| 112 | + |
| 113 | +-(id)initWithType:(NSString*)type name:(NSString*)name value:(NSValue*)value; |
| 114 | ++(instancetype)uniform:(NSString*)type name:(NSString*)name value:(NSValue*)value; |
| 115 | + |
| 116 | +@end |
| 117 | + |
| 118 | +@interface CCEffectVarying : NSObject |
| 119 | + |
| 120 | +@property (nonatomic, readonly) NSString* name; |
| 121 | +@property (nonatomic, readonly) NSString* type; |
| 122 | +@property (nonatomic, readonly) NSString* declaration; |
| 123 | +@property (nonatomic, readonly) NSInteger count; |
| 124 | + |
| 125 | +-(id)initWithType:(NSString*)type name:(NSString*)name; |
| 126 | +-(id)initWithType:(NSString*)type name:(NSString*)name count:(NSInteger)count; |
| 127 | ++(instancetype)varying:(NSString*)type name:(NSString*)name; |
| 128 | ++(instancetype)varying:(NSString*)type name:(NSString*)name count:(NSInteger)count; |
| 129 | + |
| 130 | +@end |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | +@interface CCEffectRenderPassInputs : NSObject |
| 135 | + |
| 136 | +@property (nonatomic, assign) NSInteger renderPassId; |
| 137 | +@property (nonatomic, strong) CCRenderer* renderer; |
| 138 | +@property (nonatomic, strong) CCSprite *sprite; |
| 139 | +@property (nonatomic, assign) CCSpriteVertexes verts; |
| 140 | +@property (nonatomic, strong) CCTexture *previousPassTexture; |
| 141 | +@property (nonatomic, assign) GLKMatrix4 transform; |
| 142 | +@property (nonatomic, assign) GLKMatrix4 ndcToNodeLocal; |
| 143 | +@property (nonatomic, assign) GLKVector2 texCoord1Center; |
| 144 | +@property (nonatomic, assign) GLKVector2 texCoord1Extents; |
| 145 | +@property (nonatomic, assign) GLKVector2 texCoord2Center; |
| 146 | +@property (nonatomic, assign) GLKVector2 texCoord2Extents; |
| 147 | +@property (nonatomic, strong) NSMutableDictionary* shaderUniforms; |
| 148 | +@property (nonatomic, strong) NSDictionary* uniformTranslationTable; |
| 149 | +@property (nonatomic, assign) BOOL needsClear; |
| 150 | + |
| 151 | +-(void)setVertsWorkAround:(CCSpriteVertexes*)verts; |
| 152 | + |
| 153 | +@end |
| 154 | + |
| 155 | + |
| 156 | +@class CCEffectRenderPass; |
| 157 | + |
| 158 | +typedef void (^CCEffectRenderPassBeginBlock)(CCEffectRenderPass *pass, CCEffectRenderPassInputs *passInputs); |
| 159 | +typedef void (^CCEffectRenderPassUpdateBlock)(CCEffectRenderPass *pass, CCEffectRenderPassInputs *passInputs); |
| 160 | + |
| 161 | + |
| 162 | +@interface CCEffectRenderPassBeginBlockContext : NSObject |
| 163 | + |
| 164 | +@property (nonatomic, copy) CCEffectRenderPassBeginBlock block; |
| 165 | +@property (nonatomic, strong) NSDictionary *uniformTranslationTable; |
| 166 | + |
| 167 | +-(id)initWithBlock:(CCEffectRenderPassBeginBlock)block; |
| 168 | + |
| 169 | +@end |
| 170 | + |
| 171 | + |
| 172 | +@interface CCEffectRenderPass : NSObject |
| 173 | + |
| 174 | +@property (nonatomic, readonly) NSUInteger indexInEffect; |
| 175 | +@property (nonatomic, assign) CCEffectTexCoordMapping texCoord1Mapping; |
| 176 | +@property (nonatomic, assign) CCEffectTexCoordMapping texCoord2Mapping; |
| 177 | +@property (nonatomic, strong) CCBlendMode* blendMode; |
| 178 | +@property (nonatomic, strong) CCShader* shader; |
| 179 | +@property (nonatomic, copy) NSArray* beginBlocks; |
| 180 | +@property (nonatomic, copy) NSArray* updateBlocks; |
| 181 | +@property (nonatomic, copy) NSString *debugLabel; |
| 182 | + |
| 183 | +-(id)initWithIndex:(NSUInteger)indexInEffect; |
| 184 | + |
| 185 | +-(void)begin:(CCEffectRenderPassInputs *)passInputs; |
| 186 | +-(void)update:(CCEffectRenderPassInputs *)passInputs; |
| 187 | +-(void)enqueueTriangles:(CCEffectRenderPassInputs *)passInputs; |
| 188 | + |
| 189 | +@end |
| 190 | + |
| 191 | + |
| 192 | +@interface CCEffectImpl : NSObject |
| 193 | + |
| 194 | +@property (nonatomic, copy) NSString *debugName; |
| 195 | + |
| 196 | +@property (nonatomic, readonly) BOOL supportsDirectRendering; |
| 197 | + |
| 198 | +@property (nonatomic, readonly) CCShader* shader; |
| 199 | +@property (nonatomic, readonly) NSMutableDictionary* shaderUniforms; |
| 200 | +@property (nonatomic, readonly) NSArray* vertexFunctions; |
| 201 | +@property (nonatomic, readonly) NSArray* fragmentFunctions; |
| 202 | +@property (nonatomic, readonly) NSArray* fragmentUniforms; |
| 203 | +@property (nonatomic, readonly) NSArray* vertexUniforms; |
| 204 | +@property (nonatomic, readonly) NSArray* varyingVars; |
| 205 | + |
| 206 | +@property (nonatomic, readonly) NSArray* renderPasses; |
| 207 | +@property (nonatomic, assign) CCEffectFunctionStitchFlags stitchFlags; |
| 208 | + |
| 209 | +@property (nonatomic, readonly) BOOL firstInStack; |
| 210 | + |
| 211 | + |
| 212 | +-(id)initWithRenderPasses:(NSArray *)renderPasses fragmentFunctions:(NSArray*)fragmentFunctions vertexFunctions:(NSArray*)vertexFunctions fragmentUniforms:(NSArray*)fragmentUniforms vertexUniforms:(NSArray*)vertexUniforms varyings:(NSArray*)varyings firstInStack:(BOOL)firstInStack; |
| 213 | +-(id)initWithRenderPasses:(NSArray *)renderPasses fragmentFunctions:(NSArray*)fragmentFunctions vertexFunctions:(NSArray*)vertexFunctions fragmentUniforms:(NSArray*)fragmentUniforms vertexUniforms:(NSArray*)vertexUniforms varyings:(NSArray*)varyings; |
| 214 | + |
| 215 | +-(id)initWithRenderPasses:(NSArray *)renderPasses shaderUniforms:(NSMutableDictionary *)uniforms; |
| 216 | + |
| 217 | +-(CCEffectPrepareResult)prepareForRenderingWithSprite:(CCSprite *)sprite; |
| 218 | +-(CCEffectRenderPass *)renderPassAtIndex:(NSUInteger)passIndex; |
| 219 | + |
| 220 | +-(BOOL)stitchSupported:(CCEffectFunctionStitchFlags)stitch; |
| 221 | + |
| 222 | ++ (NSSet *)defaultEffectFragmentUniformNames; |
| 223 | ++ (NSSet *)defaultEffectVertexUniformNames; |
| 224 | + |
| 225 | +@end |
| 226 | + |
| 227 | + |
31 | 228 | @interface CCEffect : NSObject
|
32 | 229 |
|
33 | 230 | /// -----------------------------------------------------------------------
|
|
47 | 244 | */
|
48 | 245 | @property (nonatomic, assign) CGSize padding;
|
49 | 246 |
|
| 247 | +@property (nonatomic, strong) CCEffectImpl *effectImpl; |
| 248 | + |
| 249 | +@property (nonatomic, readonly) BOOL supportsDirectRendering; |
| 250 | +@property (nonatomic, readonly) NSUInteger renderPassCount; |
| 251 | + |
| 252 | +-(CCEffectPrepareResult)prepareForRenderingWithSprite:(CCSprite *)sprite;; |
| 253 | +-(CCEffectRenderPass *)renderPassAtIndex:(NSUInteger)passIndex; |
50 | 254 | @end
|
0 commit comments