Skip to content

Commit a9bd61f

Browse files
committed
Minor CCClippingNode and transition fixes.
1 parent 06b3598 commit a9bd61f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

cocos2d/CCClippingNode.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ - (void)visit
278278
CCGLProgram *program = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionTextureColorAlphaTest];
279279
GLint alphaValueLocation = glGetUniformLocation(program.program, kCCUniformAlphaTestValue_s);
280280
// set our alphaThreshold
281+
[program use];
281282
[program setUniformLocation:alphaValueLocation withF1:_alphaThreshold];
282283
// we need to recursively apply this shader to all the nodes in the stencil node
283284
// XXX: we should have a way to apply shader to all nodes without having to do this

cocos2d/CCTransition.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ typedef NS_ENUM(NSInteger, CCTransitionDirection)
9494
*/
9595
@property (nonatomic, assign) CCTexturePixelFormat transitionPixelFormat;
9696

97+
/**
98+
* Depth/stencil format used for transition.
99+
* Default GL_DEPTH24_STENCIL8_OES.
100+
*/
101+
@property (nonatomic, assign) GLuint transitionDepthStencilFormat;
102+
97103
/**
98104
* Defines whether outgoing scene will be animated during transition.
99105
* Default NO.

cocos2d/CCTransition.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ - (id)initWithDuration:(NSTimeInterval)duration
164164
_runTime = 0.0f;
165165
_progress = 0.0f;
166166

167-
_transitionPixelFormat = CCTexturePixelFormat_RGB565;
167+
_transitionPixelFormat = CCTexturePixelFormat_RGBA8888;
168+
_transitionDepthStencilFormat = GL_DEPTH24_STENCIL8_OES;
168169

169170
// disable touch during transition
170171
self.userInteractionEnabled = NO;
@@ -197,15 +198,15 @@ - (void)startTransition:(CCScene *)scene
197198
// create texture for outgoing scene
198199
_outgoingTexture = [CCRenderTexture renderTextureWithWidth:rect.size.width / _outgoingDownScale
199200
height:rect.size.height / _outgoingDownScale
200-
pixelFormat:_transitionPixelFormat];
201+
pixelFormat:_transitionPixelFormat depthStencilFormat:_transitionDepthStencilFormat];
201202
_outgoingTexture.position = CGPointMake(rect.size.width * 0.5f + rect.origin.x, rect.size.height * 0.5f + rect.origin.y);
202203
_outgoingTexture.scale = _outgoingDownScale;
203204
[self addChild:_outgoingTexture z:_outgoingOverIncoming];
204205

205206
// create texture for incoming scene
206207
_incomingTexture = [CCRenderTexture renderTextureWithWidth:rect.size.width / _incomingDownScale
207208
height:rect.size.height / _incomingDownScale
208-
pixelFormat:_transitionPixelFormat];
209+
pixelFormat:_transitionPixelFormat depthStencilFormat:_transitionDepthStencilFormat];
209210
_incomingTexture.position = CGPointMake(rect.size.width * 0.5f + rect.origin.x, rect.size.height * 0.5f + rect.origin.y);
210211
_incomingTexture.scale = _incomingDownScale;
211212
[self addChild:_incomingTexture];
@@ -277,7 +278,7 @@ - (void)renderOutgoing:(float)progress
277278
_outgoingScene.scale = oldScale / _outgoingDownScale;
278279

279280
glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
280-
[_outgoingTexture beginWithClear:clearColor[0] g:clearColor[1] b:clearColor[2] a:clearColor[3]];
281+
[_outgoingTexture beginWithClear:clearColor[0] g:clearColor[1] b:clearColor[2] a:clearColor[3] depth:1.0 stencil:0];
281282
[_outgoingScene visit];
282283
[_outgoingTexture end];
283284

@@ -294,7 +295,7 @@ - (void)renderIncoming:(float)progress
294295
_incomingScene.scale = oldScale / _incomingDownScale;
295296

296297
glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
297-
[_incomingTexture beginWithClear:clearColor[0] g:clearColor[1] b:clearColor[2] a:clearColor[3]];
298+
[_incomingTexture beginWithClear:clearColor[0] g:clearColor[1] b:clearColor[2] a:clearColor[3] depth:1.0 stencil:0];
298299
[_incomingScene visit];
299300
[_incomingTexture end];
300301

0 commit comments

Comments
 (0)