@Jikid wrote:
Hi everyone,
I'm trying to draw 200,000 lines/points with a real-time generated ofVboMesh.
However, the drawing is much slower (more than 50%) with OF_PRIMITIVE_LINES mode to OF_PRIMITIVE_POINTS mode.Here is my code for reference
ofVboMesh mesh; void ofApp::setup() { ofDisableDepthTest(); genMesh(); } void ofApp::genMesh() { mesh.clear(); mesh.setMode(OF_PRIMITIVE_LINES); ofVec3f pos; for(int i = 0; i < 200000; i++) { pos.set(ofRandom(-200, 200), ofRandom(-200, 200), ofRandom(-200, 200)); mesh.addVertex(pos); mesh.addColor(ofColor(255, 50)); pos.set(ofRandom(-200, 200), ofRandom(-200, 200), ofRandom(-200, 200)); mesh.addVertex(pos); mesh.addColor(ofColor(255, 50)); mesh.addIndex(i * 2); mesh.addIndex(i * 2 + 1); } } void ofApp::updateMesh() { ofVec3f pos; for(int i = 0; i < mesh.getNumVertices(); i++) { pos.set(ofRandom(-200, 200), ofRandom(-200, 200), ofRandom(-200, 200)); mesh.setVertex(i, pos); } } //-------------------------------------------------------------- void ofApp::update() { updateMesh(); } //-------------------------------------------------------------- void ofApp::draw() { ofBackground(ofColor::black); ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); mesh.draw(); }
I had 60fps with mesh.setMode(OF_PRIMITIVE_POINTS);
but got only 30fps with mesh.setMode(OF_PRIMITIVE_LINES);Those vertex positions in mesh should have some other real-time generated values, but that's not relevant here, so I just put some random positions instead.
So, is there any way to improve the performance when dealing with OF_PRIMITIVE_LINES mode?
Thank you in advance!
Posts: 3
Participants: 2