Wednesday, May 8, 2024
HomeGame Developmentopengl es - How to clip or mask entity in android/andengine?

opengl es – How to clip or mask entity in android/andengine?


I want to implement masking with sprite in Andengine. I want same functionality as in ios class called

SKCropNode

which works like an masking node!
Is there any workaround like this in andengine/opengl ?
Thanks.

Edit:
This is something I was trying to mask an entity, got no effect, any suggestion?

public class ClippingEntity extends Entity//BaseSprite
{

protected int mWidth;
protected int mHeight;

public ClippingEntity(float pX, float pY, int pWidth, int pHeight, TextureRegion t)
{
    super(pX, pY);//, pWidth, pHeight, t);
    mWidth = pWidth;
    mHeight = pHeight;
}

@Override
protected void onManagedDraw(GL10 pGL, Camera pCamera)
{

    pGL.glPushMatrix();
    {

        pGL.glEnable(GL10.GL_SCISSOR_TEST);
        pGL.glScissor(0 + (int) mX, 800 - mHeight + (int) mY, mWidth, mHeight);

        super.onManagedDraw(pGL, pCamera);

        pGL.glDisable(GL10.GL_SCISSOR_TEST);

    }
    pGL.glPopMatrix();

}

}

I have also tried Stencil Test but it just clears the color of rectangle. ref: opengl mask tests

Ultimate goal is to disable drawing changes in specific entity where it may aslo have transparent background.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments