nicolasgramlich/AndEngine — pull request #219 by nazgee (2013-05-02 19:28:03+00:00)
Title: ClipEntity nesting does not work

There is a problem when ClipEntities are being nested- it is caused by not restoring glScissor rect properly (test bit is restored, scissor rect is not).

It can be solved by:
- pushing "ScissorData" to a stack before (so it is available for anyone to be restored)
```java
/* Draw children, etc... */
super.onManagedDraw(pGLState, pCamera);
```
- popping ScissorData out of the stack
- peeking stack and restoring scissors to value that was peeked

I have this stack currently sitting static in my ClipEntity just to prove that it works, but I'm guessing that it should be kept in GLState like this:

```java
public void applyScissors(ScissorData pScissorData) {
mScissorsStack.push(pScissorData);
GLES20.glScissor(pScissorData.minX, pScissorData.minY, pScissorData.width, pScissorData.height);
}

public void restoreScissors() {
mScissorsStack.pop();
if (!mScissorsStack.isEmpty()) {
ScissorData oldScissor = mScissorsStack.peek();
GLES20.glScissor(oldScissor.minX, oldScissor.minY, oldScissor.width, oldScissor.height);
}
}
```

If there is something you're willing to pull- let me know. If that's something you want to fix on your own- please do :)