Skip to content

Commit 3ecb865

Browse files
author
Thayer J Andrews
committed
CCEffectNode - Add initializers with the same parameters as CCRenderTexture
And add convenience constructors too.
1 parent 800bb52 commit 3ecb865

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

cocos2d/CCEffectNode.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,66 @@
4141
*/
4242
-(id)initWithWidth:(int)w height:(int)h;
4343

44+
/**
45+
* Initializes a CCEffectNode object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and no depth-stencil buffer.
46+
*
47+
* @param w Width of render target.
48+
* @param h Height of render target.
49+
* @param format Pixel format of render target.
50+
*
51+
* @return An initialized CCRenderTarget object.
52+
*/
53+
-(id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexturePixelFormat)format;
54+
55+
/**
56+
* Initializes a CCEffectNode object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
57+
*
58+
* @param w Width of render target.
59+
* @param h Height of render target.
60+
* @param format Pixel format of render target.
61+
* @param depthStencilFormat Stencil format of render target.
62+
*
63+
* @return An initialized CCRenderTarget object.
64+
*/
65+
-(id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexturePixelFormat)format depthStencilFormat:(GLuint)depthStencilFormat;
66+
67+
68+
/// -----------------------------------------------------------------------
69+
/// @name Creating a CCEffectNode object
70+
/// -----------------------------------------------------------------------
71+
72+
/**
73+
* Creates a CCEffectNode object with width and height in points, the default color format and no depth-stencil buffer.
74+
*
75+
* @param w Width of render target.
76+
* @param h Height of render target.
77+
*
78+
* @return An initialized CCRenderTarget object.
79+
*/
80+
+(id)effectNodeWithWidth:(int)w height:(int)h;
81+
82+
/**
83+
* Creates a CCEffectNode object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and no depth-stencil buffer.
84+
*
85+
* @param w Width of render target.
86+
* @param h Height of render target.
87+
* @param format Pixel format of render target.
88+
*
89+
* @return An initialized CCRenderTarget object.
90+
*/
91+
+(id)effectNodeWithWidth:(int)w height:(int)h pixelFormat:(CCTexturePixelFormat)format;
92+
93+
/**
94+
* Creates a CCEffectNode object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format
95+
*
96+
* @param w Width of render target.
97+
* @param h Height of render target.
98+
* @param format Pixel format of render target.
99+
* @param depthStencilFormat Stencil format of render target.
100+
*
101+
* @return An initialized CCRenderTarget object.
102+
*/
103+
+(id)effectNodeWithWidth:(int)w height:(int)h pixelFormat:(CCTexturePixelFormat)format depthStencilFormat:(GLuint)depthStencilFormat;
104+
105+
44106
@end

cocos2d/CCEffectNode.m

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,39 @@ -(id)init
4747

4848
-(id)initWithWidth:(int)width height:(int)height
4949
{
50-
if((self = [super initWithWidth:width height:height pixelFormat:CCTexturePixelFormat_Default])) {
50+
return [self initWithWidth:width height:height pixelFormat:CCTexturePixelFormat_Default];
51+
}
52+
53+
-(id)initWithWidth:(int)width height:(int)height pixelFormat:(CCTexturePixelFormat)format
54+
{
55+
return [self initWithWidth:width height:height pixelFormat:format depthStencilFormat:0];
56+
}
57+
58+
-(id)initWithWidth:(int)width height:(int)height pixelFormat:(CCTexturePixelFormat) format depthStencilFormat:(GLuint)depthStencilFormat
59+
{
60+
if((self = [super initWithWidth:width height:height pixelFormat:CCTexturePixelFormat_Default depthStencilFormat:depthStencilFormat]))
61+
{
5162
_effectRenderer = [[CCEffectRenderer alloc] init];
5263
_allocatedSize = CGSizeMake(0.0f, 0.0f);
5364
}
5465
return self;
5566
}
5667

68+
+(id)effectNodeWithWidth:(int)w height:(int)h
69+
{
70+
return [[CCEffectNode alloc] initWithWidth:w height:h];
71+
}
72+
73+
+(id)effectNodeWithWidth:(int)w height:(int)h pixelFormat:(CCTexturePixelFormat)format
74+
{
75+
return [[CCEffectNode alloc] initWithWidth:w height:h pixelFormat:format];
76+
}
77+
78+
+(id)effectNodeWithWidth:(int)w height:(int)h pixelFormat:(CCTexturePixelFormat)format depthStencilFormat:(GLuint)depthStencilFormat
79+
{
80+
return [[CCEffectNode alloc] initWithWidth:w height:h pixelFormat:format depthStencilFormat:depthStencilFormat];
81+
}
82+
5783
-(CCEffect *)effect
5884
{
5985
return _effect;

0 commit comments

Comments
 (0)