Huge frame rate loss when using many ofDrawRectangle

Hi Team,

First time making an iOS app. Long story short i have a physics simulation that i am trying to visualise. I can run everything just fine at 50-60 fps but as soon as i add the visualisation function my framerate drops to around 4fps! (i did some testing and it is specifically the ofDrawRectangle line). The 2D array i am trying to visualise is around 150*200, so around 30,000 points of data. I guess that is quite a lot, or is it? i was very surprised to see such a huge drop in frames, does anyone know of a more efficient way to draw lots of little rectangles or dots or similar?

full disclosure i am running a very old ipad mini from 2013, though it was only marginally quicker on my iphone 5s.

Thanks in advance!

the visualisation function:

void ofApp::drawField(){
for (int x = 0; x <= fieldWidth; x++ ) {
for (int y = 0; y <= fieldHeight; y++ ) {
d=dens[IX(x,y,gridSizeH)]; //2d array is actually 1d array
ofDrawRectangle((x-1) * pixelSize+1, (y-1) * pixelSize+1, pixelSize, pixelSize);

You can use ofMesh, ofVboMesh or ofVbo to draw dots. Is much faster than ofDrawRectangle.
Also look this post.

Cheers mate that is very helpful