ofMesh slow fps v0.9.0

Hello,
I just updated my computer to osx 10.11, xcode 7.1, openFrameworks 0.9.0 release. I just built a project from the previous release and I’m seeing half the framerate in 0.9.0. I’m wondering if anyone else has seen this issue when running a project from a previous version when specifically using ofMesh?

Thanks for any help.

Hi, sorry to hear that.
Can you provide some minimal sample code that clearly replicates the issue?

Are you building in Release in both versions? ( 0.9.0 new projects are set to build in Debug by default )

Thanks!
Theo

(also one thing to note is that at some point we enabled vertical sync for osx – which used to be off by default). This means that your app will be pegged to your monitor frame rate (ie, 60hz). You can alter this with ofSetVerticalSync(false), ofSetVerticalSync(true)…)

Thank you so much for the quick response. After some deeper investigation I’ve found the following:

OSX 10.11, Xcode 7.1, openFrameworks 0.9.0 release

Building in Release/Debug. Vertical Sync True/False. 30Fps

OSX 10.10, Xcode 6.4, openFrameworks 8.4 release

Building in Release/Debug. Vertical Sync True 60Fps, Vertical Sync False 300Fps.

#pragma once

#include “ofMain.h”

class ofApp : public ofBaseApp{

public:
	void setup();
	void update();
	void draw();

	void keyPressed(int key);
	void keyReleased(int key);
	void mouseMoved(int x, int y );
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);
	void mouseEntered(int x, int y);
	void mouseExited(int x, int y);
	void windowResized(int w, int h);
	void dragEvent(ofDragInfo dragInfo);
	void gotMessage(ofMessage msg);

ofMesh mesh;
ofVec3f coords;
ofColor color;
float time, noise, alpha;
int size;

};

#include "ofApp.h"

void ofApp::setup(){

ofSetVerticalSync(true);
ofSetBackgroundColor(0);
mesh.setMode(OF_PRIMITIVE_LINE_LOOP);
alpha = 0.05;

}

//--------------------------------------------------------------
void ofApp::draw(){

mesh.clear();
mesh.clearColors();


for (float u = 0.0; u < 2 * PI; u += PI / 75) {
    for (float v = 0.0; v < 2 * PI; v += 2 * PI / 75) {
        
        
        time = ofGetElapsedTimef() * 1.0f;
        noise = cos(v) + ofNoise(time) * 5.0f;
        size = 100;
        coords.x = sin(v) * size;
        coords.y = cos(u) * size;
        coords.z = sin(u + time) * cos(noise) * size;
        color = ofFloatColor(.85,0.9,0.90, u * alpha);
        
        
        //Create
        mesh.addColor(color);
        ofVec3f vec = ofVec3f(coords);
        mesh.addVertex(vec);
    }
}

float r = ofGetElapsedTimef() * 5.0;
ofPushStyle();
ofPushMatrix();
ofTranslate(ofGetWidth() * .5, ofGetHeight() * .5);
ofRotateX(r);
ofRotateY(r);
ofRotateZ(r);
mesh.draw();
ofPopMatrix();
ofPopStyle();

ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), ofGetWidth() * .10, ofGetHeight() * .10);

}

thanks for the sample code.
it actually looks like the offending call is ofGetElapsedTimef();

if you move it out of the inner loop and cache the value for the frame above I get 600fps on 0.9.0 and about 500fps on 0.8.4 ( with vertical sync disabled ).

  #include "ofApp.h"


ofMesh mesh;
ofVec3f coords;
ofColor color;
float timeF, noise, alpha;
int size;

//--------------------------------------------------------------
void ofApp::setup(){
    ofSetVerticalSync(false);
    ofSetBackgroundColor(0);
    mesh.setMode(OF_PRIMITIVE_LINE_LOOP);
    alpha = 0.05;
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){
    mesh.clear();
    mesh.clearColors();

    timeF = ofGetElapsedTimef();
    for (float u = 0.0; u < 2 * PI; u += PI / 75) {
        for (float v = 0.0; v < 2 * PI; v += 2 * PI / 75) {


            noise = cos(v) + ofNoise(timeF) * 5.0f;
            size = 100;
            coords.x = sin(v) * size;
            coords.y = cos(u) * size;
            coords.z = sin(u + timeF) * cos(noise) * size;
            color = ofFloatColor(.85,0.9,0.90, u * alpha);


            //Create
            mesh.addColor(color);
            ofVec3f vec = ofVec3f(coords);
            mesh.addVertex(vec);
        }
    }

    float r = ofGetElapsedTimef() * 5.0;
    ofPushStyle();
    ofPushMatrix();
    ofTranslate(ofGetWidth() * .5, ofGetHeight() * .5);
    ofRotateX(r);
    ofRotateY(r);
    ofRotateZ(r);
    mesh.draw();
    ofPopMatrix();
    ofPopStyle();

    ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate()), ofGetWidth() * .10, ofGetHeight() * .10);
    
}

I’ll file an issue for the ofGetElapsedTimef slow down.
Let me know if that fixes it for you.

All the best!
Theo

Nice! That did the trick. Thanks for the quick response.

–Mike

I have added an issue for it here:
https://github.com/openframeworks/openFrameworks/issues/4595

Thanks for posting this - I don’t think it would have been noticed otherwise!
Theo

1 Like