I’m trying to make a circle shape clipping on a CCSprite in cocos2d, after searching a lot, i tried the open gl glScissor method, i achieve an squared clipping over my sprite. But, i need to make it a circle, and it seems to be impossible to do with the glScissor.
I kept trying and I found something about gl stencil, but I haven’t found a how to on this and I’m not familiar with opengl.
Also I heard something about calling multiple times to the glScissor wo you can achieve a custom shape but i haven’t found anything.
Thanks in advance, any answer is welcome.
this is my actual visit method:
-(void) visit
{
glPushMatrix();
glEnable(GL_SCISSOR_TEST);
glScissor(clippingRegion.origin.x , clippingRegion.origin.y ,
clippingRegion.size.width, clippingRegion.size.height);
[super visit];
glDisable(GL_SCISSOR_TEST);
glPopMatrix();
}
glScissor won’t do what you want. Here is part of some code I wrote a while ago. It draws
a rectangle with a grating texture and uses the stencil buffer to only have a disk visible.
Here is the link I used back then:
http://www.swiftless.com/tutorials/opengl/basic_reflection.html