testbed/common/ConcaveMesh.cpp
void ConcaveMesh::createVBOAndVAO() {

    // Create the VBO for the vertices data
    mVBOVertices.create();
    mVBOVertices.bind();
    size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
    mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
    mVBOVertices.unbind();

    // Create the VBO for the normals data
    mVBONormals.create();
    mVBONormals.bind();
    size_t sizeNormals = mNormals.size() * sizeof(openglframework::Vector3);
    mVBONormals.copyDataIntoVBO(sizeNormals, getNormalsPointer(), GL_STATIC_DRAW);
    mVBONormals.unbind();

    if (hasTexture()) {
        // Create the VBO for the texture co data
        mVBOTextureCoords.create();
        mVBOTextureCoords.bind();
        size_t sizeTextureCoords = mUVs.size() * sizeof(openglframework::Vector2);
        mVBOTextureCoords.copyDataIntoVBO(sizeTextureCoords, getUVTextureCoordinatesPointer(), GL_STATIC_DRAW);
        mVBOTextureCoords.unbind();
    }

    // Create th VBO for the indices data
    mVBOIndices.create();
    mVBOIndices.bind();
    size_t sizeIndices = mIndices[0].size() * sizeof(unsigned int);
    mVBOIndices.copyDataIntoVBO(sizeIndices, getIndicesPointer(), GL_STATIC_DRAW);
    mVBOIndices.unbind();

    // Create the VAO for both VBOs
    mVAO.create();
    mVAO.bind();

    // Bind the VBO of vertices
    mVBOVertices.bind();

    // Bind the VBO of normals
    mVBONormals.bind();

    if (hasTexture()) {
        // Bind the VBO of texture coords
        mVBOTextureCoords.bind();
    }

    // Bind the VBO of indices
    mVBOIndices.bind();

    // Unbind the VAO
    mVAO.unbind();
}
// Create the Vertex Buffer Objects used to render with OpenGL.
/// We create two VBOs (one for vertices and one for indices)
Create the Vertex Buffer Objects used to render with OpenGL.
We create two VBOs (one for vertices and one for indices)
Create the Vertex Buffer Objects used to render with OpenGL . We create two VBOs ( one for vertices and one for indices )
void ConcaveMesh::createVBOAndVAO() {
    mVBOVertices.create();
    mVBOVertices.bind();
    size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3);
    mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW);
    mVBOVertices.unbind();
    mVBONormals.create();
    mVBONormals.bind();
    size_t sizeNormals = mNormals.size() * sizeof(openglframework::Vector3);
    mVBONormals.copyDataIntoVBO(sizeNormals, getNormalsPointer(), GL_STATIC_DRAW);
    mVBONormals.unbind();
    if (hasTexture()) {
        mVBOTextureCoords.create();
        mVBOTextureCoords.bind();
        size_t sizeTextureCoords = mUVs.size() * sizeof(openglframework::Vector2);
        mVBOTextureCoords.copyDataIntoVBO(sizeTextureCoords, getUVTextureCoordinatesPointer(), GL_STATIC_DRAW);
        mVBOTextureCoords.unbind();
    }
    mVBOIndices.create();
    mVBOIndices.bind();
    size_t sizeIndices = mIndices[0].size() * sizeof(unsigned int);
    mVBOIndices.copyDataIntoVBO(sizeIndices, getIndicesPointer(), GL_STATIC_DRAW);
    mVBOIndices.unbind();
    mVAO.create();
    mVAO.bind();
    mVBOVertices.bind();
    mVBONormals.bind();
    if (hasTexture()) {
        mVBOTextureCoords.bind();
    }
    mVBOIndices.bind();
    mVAO.unbind();
}
void ConcaveMesh :: createVBOAndVAO ( ) { mVBOVertices . create ( ) ; mVBOVertices . bind ( ) ; size_t sizeVertices = mVertices . size ( ) * sizeof ( openglframework :: Vector3 ) ; mVBOVertices . copyDataIntoVBO ( sizeVertices , getVerticesPointer ( ) , GL_STATIC_DRAW ) ; mVBOVertices . unbind ( ) ; mVBONormals . create ( ) ; mVBONormals . bind ( ) ; size_t sizeNormals = mNormals . size ( ) * sizeof ( openglframework :: Vector3 ) ; mVBONormals . copyDataIntoVBO ( sizeNormals , getNormalsPointer ( ) , GL_STATIC_DRAW ) ; mVBONormals . unbind ( ) ; if ( hasTexture ( ) ) { mVBOTextureCoords . create ( ) ; mVBOTextureCoords . bind ( ) ; size_t sizeTextureCoords = mUVs . size ( ) * sizeof ( openglframework :: Vector2 ) ; mVBOTextureCoords . copyDataIntoVBO ( sizeTextureCoords , getUVTextureCoordinatesPointer ( ) , GL_STATIC_DRAW ) ; mVBOTextureCoords . unbind ( ) ; } mVBOIndices . create ( ) ; mVBOIndices . bind ( ) ; size_t sizeIndices = mIndices [ 0 ] . size ( ) * sizeof ( unsigned int ) ; mVBOIndices . copyDataIntoVBO ( sizeIndices , getIndicesPointer ( ) , GL_STATIC_DRAW ) ; mVBOIndices . unbind ( ) ; mVAO . create ( ) ; mVAO . bind ( ) ; mVBOVertices . bind ( ) ; mVBONormals . bind ( ) ; if ( hasTexture ( ) ) { mVBOTextureCoords . bind ( ) ; } mVBOIndices . bind ( ) ; mVAO . unbind ( ) ; }
Create the Vertex Buffer Objects used to render with OpenGL.
Create the Vertex Buffer Objects used to render with OpenGL .
// Create the VBO for the vertices data // Create the VBO for the normals data // Create the VBO for the texture co data // Create th VBO for the indices data // Create the VAO for both VBOs // Bind the VBO of vertices // Bind the VBO of normals // Bind the VBO of texture coords // Bind the VBO of indices // Unbind the VAO