1
\$\begingroup\$

Im making a user interface using libgdx I created a Window class & a Textfield class, that both use clipping. I use the ScissorStack class of libgdx for clipping.

The Textfield is drawn inside the window class.

Window draw method :

ScissorStack.calculateScissors(camera, batch.getTransformMatrix(), clipBounds, scissors);
ScissorStack.pushScissors(scissors);

//Draw textflied

ScissorStack.popScissors();

Textfield draw method:

clipBounds.setPosition(
            700,
            200
            );

//Draw textfield image

ScissorStack.calculateScissors(camera, batch.getTransformMatrix(), clipBounds, scissors);
ScissorStack.pushScissors(scissors);

//Draw text

ScissorStack.popScissors();

The current problem is on the Textfield class with this code :

clipBounds.setPosition(
            700,
            200
            );

If I remove this code I don't get error.

This is the error :

Exception in thread "LWJGL Application" java.lang.IllegalStateException: Array is empty.
at com.badlogic.gdx.utils.Array.pop(Array.java:292)
at com.badlogic.gdx.scenes.scene2d.utils.ScissorStack.popScissors(ScissorStack.java:77)

I noticed that if I change the value of clipBounds, something I got the error, and sometimes, with some values, I dont get the error.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ My guess is that the resulting scissor rectangle has zero area and so is not being pushed on the stack, so there's nothing to pop. You should check the return value of pushScissors. If it returns false you should not call popScissors (and you don't need to draw anything). \$\endgroup\$
    – GuyRT
    Jun 28, 2014 at 9:00

0

You must log in to answer this question.

Browse other questions tagged .