Created
July 8, 2015 21:24
-
-
Save roymacdonald/265654a165334aa7e498 to your computer and use it in GitHub Desktop.
Max vertices rendering test openFrameworks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofMain.h" | |
class ofApp : public ofBaseApp{ | |
public: | |
ofVboMesh mesh; | |
int resolution; | |
int numVertices; | |
ofEasyCam cam; | |
//-------------------------------------------------------------- | |
void setup(){ | |
ofSetVerticalSync(false); | |
resolution = 64; | |
updateMesh(); | |
} | |
//-------------------------------------------------------------- | |
void updateMesh(){ | |
mesh.clear(); | |
mesh.getVbo().clear(); | |
mesh.setMode(OF_PRIMITIVE_TRIANGLES); | |
mesh.setUsage(GL_STATIC_DRAW); | |
mesh = ofMesh::plane(1024, 1024, resolution, resolution); | |
mesh.disableColors(); | |
numVertices = mesh.getNumVertices(); | |
} | |
//-------------------------------------------------------------- | |
void update(){ | |
ofSetWindowTitle(ofToString(ofGetFrameRate())); | |
} | |
//-------------------------------------------------------------- | |
void draw(){ | |
ofBackground(0); | |
ofSetColor(255); | |
cam.begin(); | |
mesh.drawWireframe(); | |
cam.end(); | |
string s = "Use the UP/DOWN arrow keys to increase/decrease resolution.\n"; | |
s+= "Resolution: " + ofToString(resolution) + "\n"; | |
s += "Num Vertices: " + ofToString(numVertices) + "\n"; | |
ofDrawBitmapStringHighlight(s, 20, 20); | |
} | |
//-------------------------------------------------------------- | |
void keyReleased(int key){ | |
if (key == OF_KEY_UP) { | |
resolution*=2; | |
updateMesh(); | |
}else if (key == OF_KEY_DOWN) { | |
resolution/=2; | |
if (resolution < 2) { | |
resolution = 2; | |
} | |
updateMesh(); | |
} | |
} | |
}; | |
//======================================================================== | |
int main( ){ | |
ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context | |
ofRunApp( new ofApp()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment