EXC_BAD_ACCESS in ofTessellation

Ported a processing sketch to oF (sooo easy), really happy with the results and performance. Love it!

I do however run into this problem where my sketch crashes at ofTessellator::performTessellation xcode tells me.

The comments suggest that this is related to the transformation of ofPolylines into ofMeshes in order to be displayed more efficently using OpenGL. I don’t use this function directly, all my sketch does is using ofPushMatrix, ofPopMatrix, ofTranslate, ofRotate and ofDrawRectRounded. I have a class that is instantiated many many times and stored in an array, updated and drawn just like the oF examples suggested.

Any idea why this happens and how it can be avoided?

sorry for dragging this unpopular questions back to the top but now it came up again in a different way :confused:

I have a parameter …
ofParameter<bool> rotate;

which I’m added to the GUI …
gui.add(rotate.set("rotate", false));

and used in …
void ofApp::update(){ if(rotate == true) { ... } }

The problem occurs when initialising the parameter with true
gui.add(rotate.set("rotate", true));

Doing so causes the error I reported above. Unlike when it occured randomly earlier, it now happens every time the parameter is initialised with true. Setting it to true during runtime works just fine.

Any help would be much appreciated, really stuck here :slight_smile:

What’s in the ... part? :slight_smile:

The methods I mentioned in the initial question, real basic drawing, transformation and rotation stuff.

I’m updating values and later drawing all objects of my Shape class in an array as describe in the oF tutorials. This works well until it doesn’t

I understand, but you didn’t provide a minimal program that we can try to see if it happens to us too…

Great that you are happy with the performance btw :slight_smile:

an exc_bad_access error happens because of a bad memory access. sometimes the tessellator fails in that way when drawing “impossible” polygons but your second problem is a totally different thing, as @hamoid says is hard to know without an small example that reproduces the error

Well, OK. But I’ve warned you, it’s all really basic boring stuff based on this chapter:
I stripped it down as it’s pretty wild at the moment as I’m learning.

// ofApp.h    
Shape shapes[NSHAPES];

// ofApp.cpp   
void ofApp::setup() {
    for(int i = 0; i < NSHAPES; i++)
        shapes[i].setup(i, ofGetWidth() / 2, ofGetHeight() / 2, SHAPE_SIZE - i * shapeSizeOffset, SHAPE_SIZE - i * shapeSizeOffset);

void ofApp::update() {
        for(int i = 0; i < NSHAPES; i++) {
            shapes[i].bumpSize = 0.25 * lfo1value;
            if(fmod(i, 2) == 0)

void ofApp::draw() {
    for(int i = 0; i < NSHAPES; i++)

// Shape.cpp
void Shape::setup(int id, float x, float y, float w, float h) {
    this->id = id;
    this->x = x;
    this->y = y;
    this->w = w;
    this->h = h;

void Shape::update(float x, float y, float w, float h) {
    this->x = x;
    this->y = y;
    this->w = w;
    this->h = h;

void Shape::update() {
    bumpSize = ofMap(sin(ofGetElapsedTimef()), -1, 1, 0.0, 0.25);

void Shape::draw() {
    ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);

    ofDrawRectRounded(0, 0, w, h, cornerRadius);
    ofDrawTriangle(0, -h/2, -w/2, h/2, w/2, h/2);
    float bumpW = ofMap(bumpSize, 0.0, 1.0, 0.0, w / 2);
    float bumpH = ofMap(bumpSize, 0.0, 1.0, 0.0, h / 2);
    if (show_bump) {
        ofDrawRectRounded(0, 0 - h / 2, bumpW, bumpH, cornerRadiusBumps);
        ofDrawRectRounded(0, h / 2, bumpW, bumpH, cornerRadiusBumps);
        ofDrawRectRounded(0 - w / 2, 0, bumpW, bumpH, cornerRadiusBumps);
        ofDrawRectRounded(w / 2, 0, bumpW, bumpH, cornerRadiusBumps);


This produces the results expected, drawing many of basic shapes on top of one another with slight rotations resulting in one weird shape. Reading that under the hood “…The ofPath class uses tessellation to turn its paths into openGL-ready shapes …” (ofTessellator.h line 11), left me wondering …

Should I clamp things like an LFO or the angle used to apply rotation cause they are causing trouble down the line?

Can I do try-catch or similar to avoid a crash and skip the frame?

Aaany hints how I could solve this are much appreciated :slight_smile: