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

Best way to draw an array of objects

$
0
0

ofMesh is only stored in RAM in the computer's memory while ofVboMesh is also uploaded to the graphics card memory as a vbo, since circleMesh is not going to be drawn it doesn't need a vbo while for the mesh that it's going to be rendered at the end it's more efficient to have a vboMesh so it's directly stored in the graphics card.

You can't draw curves in openGL what you do is just draw lots of small lines so they look like a curve. An easy way to create a circle is to just use an ofPolyline to create one and then put all those points in the ofMesh but since the ofMesh needs triangles to be drawn you'll need to go through the center for every 2 points, something like:

ofPolyline circle;
circle.arc(0,0,radius,radius,0,360);
for(int i=0; i<circle.getVertices().size(); i+=2){
    circleMesh.addVertex(circle[i]);
    circleMesh.addVertex(circle[i+1]);
    circleMesh.addVertex(ofVec3f(0,0));
}

you can also just use an ofPath to get the circle already decomposed in triangles but the resulting mesh might have more triangles than necesary:

ofPath circle;
circle.arc(0,0,radius,radius,0,360);
circleMesh = cricle.getTessellation();

alsot take a look at the code in ofPolyline::arc to see how to draw a circle just using sin and cos


Viewing all articles
Browse latest Browse all 40524

Trending Articles



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