Skip to content

Commit 2df048a

Browse files
author
Thayer J Andrews
committed
CCEffects - buildFragmentFunctions and buildVertexFunctions reallocate their arrays
1 parent 42a37d3 commit 2df048a

File tree

8 files changed

+22
-6
lines changed

8 files changed

+22
-6
lines changed

cocos2d/CCEffect.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ - (void)buildEffectWithFragmentFunction:(NSMutableArray*) fragmentFunctions vert
328328
}
329329
else
330330
{
331-
_fragmentFunctions = [[NSMutableArray alloc] init];
332331
[self buildFragmentFunctions];
333332
}
334333

@@ -338,7 +337,6 @@ - (void)buildEffectWithFragmentFunction:(NSMutableArray*) fragmentFunctions vert
338337
}
339338
else
340339
{
341-
_vertexFunctions = [[NSMutableArray alloc] init];
342340
[self buildVertexFunctions];
343341
}
344342

@@ -495,14 +493,14 @@ -(void)buildEffectShader
495493

496494
-(void)buildFragmentFunctions
497495
{
498-
CCEffectFunction* fragmentFunction = [[CCEffectFunction alloc] initWithName:@"defaultEffect" body:@"return cc_FragColor;" inputs:nil returnType:@"vec4"];
499-
[_fragmentFunctions addObject:fragmentFunction];
496+
_fragmentFunctions = [[NSMutableArray alloc] init];
497+
[_fragmentFunctions addObject:[[CCEffectFunction alloc] initWithName:@"defaultEffect" body:@"return cc_FragColor;" inputs:nil returnType:@"vec4"]];
500498
}
501499

502500
-(void)buildVertexFunctions
503501
{
504-
CCEffectFunction* vertexFunction = [[CCEffectFunction alloc] initWithName:@"defaultEffect" body:@"return cc_Position;" inputs:nil returnType:@"vec4"];
505-
[_vertexFunctions addObject:vertexFunction];
502+
_vertexFunctions = [[NSMutableArray alloc] init];
503+
[_vertexFunctions addObject:[[CCEffectFunction alloc] initWithName:@"defaultEffect" body:@"return cc_Position;" inputs:nil returnType:@"vec4"]];
506504
}
507505

508506
-(void)buildRenderPasses

cocos2d/CCEffectBloom.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ +(id)effectWithPixelBlurRadius:(NSUInteger)blurRadius intensity:(float)intensity
122122

123123
-(void)buildFragmentFunctions
124124
{
125+
self.fragmentFunctions = [[NSMutableArray alloc] init];
126+
125127
GLfloat *standardGaussianWeights = calloc(_blurRadius + 1, sizeof(GLfloat));
126128
GLfloat sumOfWeights = 0.0;
127129
for (NSUInteger currentGaussianWeightIndex = 0; currentGaussianWeightIndex < _blurRadius + 1; currentGaussianWeightIndex++)
@@ -218,6 +220,8 @@ -(void)buildFragmentFunctions
218220

219221
-(void)buildVertexFunctions
220222
{
223+
self.vertexFunctions = [[NSMutableArray alloc] init];
224+
221225
GLfloat* standardGaussianWeights = calloc(_blurRadius + 1, sizeof(GLfloat));
222226
GLfloat sumOfWeights = 0.0;
223227
for (NSUInteger currentGaussianWeightIndex = 0; currentGaussianWeightIndex < _blurRadius + 1; currentGaussianWeightIndex++)

cocos2d/CCEffectBrightness.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ +(id)effectWithBrightness:(float)brightness
5252

5353
-(void)buildFragmentFunctions
5454
{
55+
self.fragmentFunctions = [[NSMutableArray alloc] init];
56+
5557
CCEffectFunctionInput *input = [[CCEffectFunctionInput alloc] initWithType:@"vec4" name:@"inputValue" snippet:@"texture2D(cc_PreviousPassTexture, cc_FragTexCoord1)"];
5658

5759
NSString* effectBody = CC_GLSL(

cocos2d/CCEffectContrast.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ +(id)effectWithContrast:(float)contrast
5353

5454
-(void)buildFragmentFunctions
5555
{
56+
self.fragmentFunctions = [[NSMutableArray alloc] init];
57+
5658
CCEffectFunctionInput *input = [[CCEffectFunctionInput alloc] initWithType:@"vec4" name:@"inputValue" snippet:@"texture2D(cc_PreviousPassTexture, cc_FragTexCoord1)"];
5759

5860
NSString* effectBody = CC_GLSL(

cocos2d/CCEffectGaussianBlur.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ +(id)effectWithPixelBlurRadius:(NSUInteger)blurRadius
9999

100100
-(void)buildFragmentFunctions
101101
{
102+
self.fragmentFunctions = [[NSMutableArray alloc] init];
103+
102104
GLfloat *standardGaussianWeights = calloc(_blurRadius + 1, sizeof(GLfloat));
103105
GLfloat sumOfWeights = 0.0;
104106
for (NSUInteger currentGaussianWeightIndex = 0; currentGaussianWeightIndex < _blurRadius + 1; currentGaussianWeightIndex++)
@@ -175,6 +177,8 @@ -(void)buildFragmentFunctions
175177

176178
-(void)buildVertexFunctions
177179
{
180+
self.vertexFunctions = [[NSMutableArray alloc] init];
181+
178182
GLfloat* standardGaussianWeights = calloc(_blurRadius + 1, sizeof(GLfloat));
179183
GLfloat sumOfWeights = 0.0;
180184
for (NSUInteger currentGaussianWeightIndex = 0; currentGaussianWeightIndex < _blurRadius + 1; currentGaussianWeightIndex++)

cocos2d/CCEffectPixellate.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ +(id)effectWithBlockSize:(float)blockSize;
8888

8989
-(void)buildFragmentFunctions
9090
{
91+
self.fragmentFunctions = [[NSMutableArray alloc] init];
92+
9193
// Image pixellation shader based on pixellation filter in GPUImage - https://github.com/BradLarson/GPUImage
9294
NSString* effectBody = CC_GLSL(
9395
vec2 samplePos = cc_FragTexCoord1 - mod(cc_FragTexCoord1, vec2(u_uStep, u_vStep)) + 0.5 * vec2(u_uStep, u_vStep);

cocos2d/CCEffectRefraction.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ +(id)effectWithRefraction:(float)refraction environment:(CCSprite *)environment
5757

5858
-(void)buildFragmentFunctions
5959
{
60+
self.fragmentFunctions = [[NSMutableArray alloc] init];
61+
6062
CCEffectFunctionInput *input = [[CCEffectFunctionInput alloc] initWithType:@"vec4" name:@"inputValue" snippet:@"texture2D(cc_PreviousPassTexture, cc_FragTexCoord1)"];
6163

6264
NSString* effectBody = CC_GLSL(

cocos2d/CCEffectSaturation.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ +(id)effectWithSaturation:(float)saturation
8787

8888
-(void)buildFragmentFunctions
8989
{
90+
self.fragmentFunctions = [[NSMutableArray alloc] init];
91+
9092
CCEffectFunctionInput *input = [[CCEffectFunctionInput alloc] initWithType:@"vec4" name:@"inputValue" snippet:@"texture2D(cc_PreviousPassTexture, cc_FragTexCoord1)"];
9193

9294
// Image saturation shader based on saturation filter in GPUImage - https://github.com/BradLarson/GPUImage

0 commit comments

Comments
 (0)