DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

GLScissor enable / disable for CCNodes or may be CCLayer #1032

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I stared writing a CCWindow which is no rocket-science:

@interface CCWindow : CCLayer 
{
    CCLayer * backgroundLayer_;
    CCLayer * contentLayer_;
    CCLayer * titleLayer_;
    CCLayer * overlayLayer_;
}
@property (nonatomic, retain) CCLayer * backgroundLayer;
@property (nonatomic, retain) CCLayer * contentLayer;
@property (nonatomic, retain) CCLayer * titleLayer;
@property (nonatomic, retain) CCLayer * overlayLayer;
@end

but then I recocnized that CCLayers do not support clipping. Why ?

I attached my CCScissorLayer class which I enhanced like the guy in this post : 
http://www.cocos2d-iphone.org/forum/topic/3993?replies=8#post-62639

Well, yes - glScissor does not support matrix operations - so rotation will not 
be recocnized. If you want that, may be you could use CCRenderToTexture stuff 
to optain this - but under big performance issues.

But may be you could lock the rotation if clipping is enabled - or NSAssert if 
rotation is beeing set while clipping is enabled and vice versa ( if rotation 
!= 0 and setting clipping to YES ).

May be its a good starting point to support clipping for nodes. Later on it 
could be that some one will implement a rotation support via render to texture 
- like

 use "glScissor" if rotation == 0 else "Render to texture"

Original issue reported on code.google.com by hamm.h...@googlemail.com on 10 Nov 2010 at 10:24

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ricardoq...@gmail.com on 11 Nov 2010 at 11:02