Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

ofMesh slow fps v0.9.0

$
0
0

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


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>