We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › "pushMatrix() cannot use push more than 32 times"
Page Index Toggle Pages: 1
"pushMatrix() cannot use push more than 32 times" (Read 792 times)
"pushMatrix() cannot use push more than 32 times"
Aug 2nd, 2009, 3:33pm
 
Resolved it myself, keeping this for reference to others

I'm trying to use some funky matrix manipulation in a for loop to rotate a bunch of objects around a center point:

Code:

// Angle of rotation around sun and planets
float theta = 0;

int maxElements = 20;
int numElements = 0;

int rad[] = new int[maxElements];
color colors[] = new color[maxElements];
float rotCo[] = new float[maxElements];
float distance[] = new float[maxElements];

void setup() {
 size(500,500);
 smooth();
 background(0);
 
 for (int i = 0; i < 5; i++)
 {
   rad[i] = int(random(10)) + 1;
   distance[i] = random(100);
   colors[i] = color(random(255), random(255), random(255));
   rotCo[i] = random(50)/10;
   numElements++;
 }
}

void draw() {
 background(0);
 noStroke();
 
 // Translate to center of window
 translate(width/2,height/2);
 pushMatrix();
 
 for (int i = 0; i < numElements; i++)
 {
   pushMatrix();
   rotate(theta*rotCo[i]);
   translate(distance[i],0);
   fill(colors[i]);
   ellipse(0,0,rad[i],rad[i]);
   popMatrix();
 }
 
 theta += 0.01;
}


On runtime it gives me this bizarre thing:
"pushMatrix() cannot use push more than 32 times"

What did I do wrong, this code looks fine to me.
Re: "pushMatrix() cannot use push more than 32 times"
Reply #1 - Aug 2nd, 2009, 3:35pm
 
Speak of the devil! Found it, I didn't close my first pushMatrix(). Compiler didn't catch it.
Re: "pushMatrix() cannot use push more than 32 times"
Reply #2 - Aug 3rd, 2009, 2:24am
 
deebs wrote on Aug 2nd, 2009, 3:35pm:
Compiler didn't catch it.

It cannot be caught by the compiler, since that's not a language feature, only a runtime one. So you got the message at run time...
Hey, at least, that's a nicer message than a heap error, out of memory or out of bounds exception, or such crash!
Page Index Toggle Pages: 1