Skip to content

Commit 2449289

Browse files
committed
Enable depth testing when binding a CCFrameBufferObject.
1 parent a388c58 commit 2449289

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

CCRendererGLSupport.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,13 @@ -(void)bindWithClear:(GLbitfield)mask color:(GLKVector4)color4 depth:(GLclampf)d
375375
if(mask & GL_COLOR_BUFFER_BIT) glClearColor(color4.r, color4.g, color4.b, color4.a);
376376
if(mask & GL_DEPTH_BUFFER_BIT) glClearDepth(depth);
377377
if(mask & GL_STENCIL_BUFFER_BIT) glClearStencil(stencil);
378+
if(mask) glClear(mask);
378379

379-
glClear(mask);
380+
// Enabled depth testing if there is a depth buffer.
381+
if(_depthStencilFormat){
382+
glEnable(GL_DEPTH_TEST);
383+
glDepthFunc(GL_LEQUAL);
384+
}
380385
}
381386

382387
-(void)syncWithView:(CC_VIEW<CCDirectorView> *)view;

cocos2d/CCDirector.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,6 @@ -(void) setView:(CC_VIEW<CCDirectorView> *)view
396396

397397
[self createStatsLabel];
398398
[self setProjection: _projection];
399-
#warning TODO this should probably migrate somewhere else.
400-
// if([(CCGLView *)view depthFormat]){
401-
// CCRenderDispatch(YES, ^{
402-
// glEnable(GL_DEPTH_TEST);
403-
// glDepthFunc(GL_LEQUAL);
404-
// });
405-
// }
406399
}
407400

408401
// Dump info once OpenGL was initilized

cocos2d/CCRendererBasicTypes.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,14 @@ -(instancetype)initWithTexture:(CCTexture *)texture depthStencilFormat:(GLuint)d
430430

431431
_sizeInPixels = texture.contentSizeInPixels;
432432
_contentScale = texture.contentScale;
433+
434+
_depthStencilFormat = depthStencilFormat;
433435
}
434436

435437
return self;
436438
}
437439

438-
-(void)bind
440+
-(void)bindWithClear:(GLbitfield)mask color:(GLKVector4)color4 depth:(GLclampf)depth stencil:(GLint)stencil
439441
{NSAssert(NO, @"Must be overridden.");}
440442

441443
-(void)syncWithView:(CC_VIEW<CCDirectorView> *)view;

cocos2d/CCRendererBasicTypes_Private.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ CCGraphicsBufferPushElements(CCGraphicsBuffer *buffer, size_t requestedCount)
116116
@end
117117

118118

119-
@interface CCFrameBufferObject : NSObject
119+
@interface CCFrameBufferObject : NSObject {
120+
GLuint _depthStencilFormat;
121+
}
120122

121123
// Setters should be treated as protected.
122124
@property(nonatomic, readonly) CCTexture *texture;

0 commit comments

Comments
 (0)