java.lang.RuntimeException: Too many calls to pushMatrix() !!
Hello All,
I am using NApplet library in my processing sketch.But when I copied my another application into a NApplet following exception occured:
java.lang.RuntimeException: Too many calls to pushMatrix().
at processing.core.PGraphics2D.pushMatrix(Unknown Source)
at processing.core.PApplet.pushMatrix(Unknown Source)
at napplet.NAppletManager.draw(Unknown Source)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Now to adjust the depth of pushmatrix I copied folllowing code from http://wiki.processing.org/w/Matrix_stack site :
// adjust this value to whatever depth is actually necessary
public final int STACK_DEPTH = 10000;
public float[][] matrixStack = new float[STACK_DEPTH][6];
// this version will override the built-in version pushMatrix function
public void pushMatrix() {
println("hello");
if (matrixStackDepth == 10000) {
println("exception");
throw new RuntimeException("too many calls to pushMatrix()");
}
this.g.getMatrix().get(matrixStack[matrixStackDepth]);
matrixStackDepth++;
}
// this version will override the built-in version popMatrix function
public void popMatrix() {
if (matrixStackDepth == 0) {
throw new RuntimeException("too many calls to popMatrix()" +
"(or too few to pushMatrix)");
}
matrixStackDepth--;
PMatrix2D m = new PMatrix2D();
m.set(matrixStack[matrixStackDepth]);
this.g.setMatrix(m);
}
again following exception is thrown :
java.lang.NullPointerException
at sketch_may28a.pushMatrix(sketch_may28a.java:275)
at napplet.NAppletManager.draw(Unknown Source)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
at processing.core.PApplet$RegisteredMethods.handle(Unknown Source)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:619)
Can anyone there please help solve this issue??
Thanks in advance