Is ofGraphics (ex: ofDrawCircle) using OpenGL?

Sorry for the daft question but:

Does calling ofDrawCircle use OpenGL in the background?

If it does, does it also use shaders?

(I may be mixing up some terminology here.)

(I’m trying to understand what’s happening behind the scenes, mainly because I have an odd issue where I’m drawing a thousand circles on the screen, and getting poor performance on my Mac Mini, but then when i compile and run on my PC which has a high-end GeForce graphics card, I still get the exact same slow performance, no improvement, which was surprising - is my code not running on the graphics card?)

Hi, yes and no.
If you are using the default renderer it will use opengl2.
If you use the programablerenderere it will use shaders and opengl3.
otherwise it will depend on the renderer.

ofDrawCircle can be quite inneficient when drawing lots of circles, as on each case it will do most of the maths in the cpu. There are several ways to address this issue, like using instanced rendering,(there is an example for it), billboards or batching all into an ofMesh and then drawing.
if you post your code I can give you some advice on how to improve it´s performance

a thousand circles should run fine with ofDrawCircle, perhaps post the code you are using but also check that you are running on release and not using a debug build

Hi guys, thanks for the help;

If you are using the default renderer it will use opengl2.

ooh i don’t know which renderer i am using; i have not specified. i should look into that.

check that you are running on release and not using a debug build

I am running latest release build 0.11.0

if you post your code

The code is below. I’ve removed tons of extra code to hopefully improve readability.

in summary of what’s happening in the code below: I have a “draw strategy” which is an interface whose implementers decide what shape to draw and how (circle, square, etc.). (for now i am only looking at drawing a circle.) Each shape is drawn inside of a “cell”. (Hence the following draw call found below)

drawManifestoPanel.getDrawStrategy().drawCell(cells[i_th_cell], drawManifestoGlobal, &drawManifestoPanel);

So, given this setup - is this too inefficient to draw up to 20,000 circles? (It’s possible that I am adding unintential bottlenecks elsewhere with all my function calls to pass objects around here and there, 20,000 times per draw call…)


void ofApp::draw(){


    // center everything
    ofTranslate(-Constants::DEFAULT_SCREEN_WIDTH/2, -Constants::DEFAULT_SCREEN_HEIGHT/2);




void Canvas::draw() {
    for (int i_th_cell = 0; i_th_cell < cells.size(); i_th_cell++) {
        // Main draw call (....drawCell(...))
        drawManifestoPanel.getDrawStrategy().drawCell(cells[i_th_cell], drawManifestoGlobal, &drawManifestoPanel);


IVectorShapeBehavior &DrawManifestoPanel::getDrawStrategy() {
    IVectorShapeBehavior * drawStrategy = vectorShapesStrategies[drawStrategyIndex];
    return *drawStrategy;


void VectorShapeCircleClassic::drawCell(Cell & _cell, DrawManifestoGlobal * drawManifestoGlobal, DrawManifestoPanel * _drawManifestoPanel) const {

        // ... float x = ...


        // ... ofTranslate ...


20000 circles is already too much to draw using ofDrawCircle, yes, more even if you use ofTranslate, pushMatrix, popMatrix…

you can try first just using ofDrawCircle in whatever position you want to draw it instead of using ofTranslate, push and pop

with that you can probably already draw much more than now at 60fps but probably not as much as 20000

this is not a problem of ofDrawCircle using the gpu or shaders or the kind of renderer you are using but about the number of draw calls you are doing which take a lot of cpu time.

so in order to optimize things even further your could try to accumulate all the circles in one ofMesh and then draw all of them in one go.