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

ofMesh slow fps v0.9.0

$
0
0

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);

}


Viewing all articles
Browse latest Browse all 40524

Trending Articles