Which is the most perfomant way to draw a cube?

Hello, I’m following the OpenGL tutorial http://openframeworks.cc/tutorials/graphics/opengl.html and i was wondering which is the most efficient way to draw a cube. I’ve seen in the forum that there is a post regarding this topic, Tutorial: OpenGL / GLSL flat shading using an indexed ofMesh, but the solution looks hackish and maybe there is a “standard” way to deal with cubes (or other customs 3d solids).
For now, i’ve simply adapted the icosahedron example to a cube.

 #include "ofApp.h"
    // In my header file I've
    // ofMesh mesh;
    // const int side = 200.0f;

    void ofApp::setup(){
        static GLfloat vdata[8][3] = {
            // front square vertices
            {0.0, 0.0, 0.0}, {side, 0.0, 0.0}, {side, side, 0.0}, {0.0, side, 0.0},
            //back square vertices of the cube
            {0.0, 0.0, -side}, {side, 0.0, -side}, {side, side, -side}, {0.0, side, -side},
        };

        // these are the data for the indexes
        // http://poniesandlight.co.uk/img/quad_sketch.jpg
        static GLint indices[12][3] = {
            {0, 1, 2}, {0, 2, 3},
            {1, 5, 6}, {1, 2, 6},
            {5, 4, 7}, {5, 7, 6},
            {4, 0, 3}, {4, 3, 7},
            {0, 1, 5}, {0, 4, 5},
            {3, 2, 6}, {3, 6, 7}
        };

        ofColor color(255, 0, 0);
        float hue = 254.f;

        for(int i = 0; i<8; ++i){
            mesh.addVertex(ofVec3f(vdata[i][0], vdata[i][1], vdata[i][2]));
            mesh.addColor(color);
            color.setHue(hue);
            hue -= 20.f;
        }

        for(int i = 0; i<12; ++i){
            mesh.addIndex(indices[i][0]);
            mesh.addIndex(indices[i][1]);
            mesh.addIndex(indices[i][2]);
        }
        cout << mesh.getNumVertices() << endl;
    }

    //--------------------------------------------------------------
    void ofApp::update(){

    }

    //--------------------------------------------------------------
    void ofApp::draw(){
        ofBackground(122,122,122);
        easyCam.begin();
            ofPushMatrix();
            mesh.drawWireframe();
            ofPopMatrix();
        easyCam.end();
    }

Does it makes any difference the order in which the triangles are connected? Are there any conventions that I’m missing?

ok, so I assume that OpenFrameworks experts are creating 3d solid like this, adding vertices, connecting them through indexes and use as primitive mode the default OF_PRIMITIVE_TRIANGLES.
Am I correct?

Also you can use ofBoxPrimitive.

I’d go with of3dPrimitive which uses ofVboMesh under the hood. VBO’s are probably the fastest way to render meshes.

@Dorald, ofBoxPrimitives it’s good for cube or cuboids, i was looking for 3d solid in general (yes the title of the post is misleading)
@chuckleplant, can you post an example? i’ve simply substituted in my header file

ofMesh mesh;

with:

ofVboMesh mesh;

leaving the rest of the code as it is in my first post, and the example compiles. Is that enough to render meshes through VBO?

Yes that should be enough, take a look at the vboExample in the examples folder.