openframeworks slow for 3d?

Hello people, i been working before with puredata for making tools for vj using opengl and gem.
i was trying to remake the tools in openframeworks because i was thinking that it is going to be faster, but i got surprised when i discovered that they run slower than pd. Maybe theres something im doing wrong. So my first question is:
Is there any way of seeing which processes are speeding down things? how can i see which are the bootlenecks in my program?

The program i made is pretty simple, it consist in nested iterations of 3d elements.
iterating over 3d elements and opengl commands i can create different 3d forms.
for example:

for(int i=0; i < NBALLS; i++)
{
glRotatef(35, 0, 0, 1);
glTranslatef(56, 15, center * 4);
gluSphere(gluNewQuadric(), 30.f, 6, 6);
}

The thing is that with puredata i can have more iterations than openframeworks until my program begins to speeding down, Do anybody have an idea of why is this?

Many thanks

Oyuky

Hey

I think there might be a problem with the code you have.

Every time you call that line

  
 gluSphere(gluNewQuadric(), 30.f, 6, 6);  

you’re leaking memory.

Every time you call gluNewQuadric() it will allocate some memory for the sphere, but there’s no way to delete it, so every time draw() is called, you’re eating up NBALLS * memory size for a quadric.

So, the program probably slows down until it runs out of memory.

The best way to write this is to create a single quadric in setup, then use it repeatedly in draw().

i.e., put

  
 GLUquadric *sphere;  

in testApp.h, in your class definition.

Then in testApp.cpp, in setup(), put

  
 sphere = gluNewQuadric();  

and then in draw you say
for(int i=0; i < NBALLS; i++)
{
glRotatef(35, 0, 0, 1);
glTranslatef(56, 15, center * 4);
gluSphere(sphere, 30.f, 6, 6);
}

[/code]

No more memory leak!