Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Remove listener on listener method?

$
0
0

@chuckleplant wrote:

Is it safe to remove a listener on the method that listens?

Consider the following:

On key press I want to render the depth buffer onto an FBO and store it. So I need to do something once and it needs to be on the draw call from the main loop. I'm doing something like this:

void ofApp::onKeyPress(...)
{
    if(key == 's')
    {
        ofAddListener(ofEvents().draw, this, &ofApp::drawOnce);
    }
}


void ofApp::drawOnce()
{
    drawAndSave();
    ofRemoveListener(ofEvents().draw, this, &ofApp::drawOnce);
}

I'm getting weird OpenGL crashes every once in a while and I think it might be related. This is on of 0.8.4 btw.

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles