model.cpp
// Draw a model of vertices, triangulate all the neighboring vertices
Draw a model of vertices, triangulate all the neighboring vertices
Draw a model of vertices triangulate all the neighboring vertices
void Model::DrawVertices()
{
    glEnable(GL_DEPTH_TEST);
    struct drawVertex
    {
        glm::vec3 p;
        glm::vec3 n;
    };
    std::cout << "deform vertices:" << vertices.size() << std::endl;
    std::vector<drawVertex> vertexData;
    for(auto v:vertices)
    {
        drawVertex dv = {v.Position, v.Normal};
        vertexData.push_back(dv);
    }
    GLuint VAO, VBO;
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    glBindVertexArray(VAO);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, vertexData.size() * sizeof(drawVertex), glm::value_ptr(vertexData[0].p),
                 GL_STREAM_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(drawVertex), (const GLvoid *) 0);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(drawVertex), (const GLvoid *) (sizeof(glm::vec3)));
    glEnableVertexAttribArray(1);
    glDrawArrays(GL_POINTS, 0, vertexData.size());
    glBindVertexArray(0);
}
void Model :: DrawVertices ( ) { glEnable ( GL_DEPTH_TEST ) ; struct drawVertex { glm :: vec3 p ; glm :: vec3 n ; } ; std :: cout << " " << vertices . size ( ) << std :: endl ; std :: vector < drawVertex > vertexData ; for ( auto v : vertices ) { drawVertex dv = { v . Position , v . Normal } ; vertexData . push_back ( dv ) ; } GLuint VAO , VBO ; glGenVertexArrays ( 1 , & VAO ) ; glGenBuffers ( 1 , & VBO ) ; glBindVertexArray ( VAO ) ; glBindBuffer ( GL_ARRAY_BUFFER , VBO ) ; glBufferData ( GL_ARRAY_BUFFER , vertexData . size ( ) * sizeof ( drawVertex ) , glm :: value_ptr ( vertexData [ 0 ] . p ) , GL_STREAM_DRAW ) ; glVertexAttribPointer ( 0 , 3 , GL_FLOAT , GL_FALSE , sizeof ( drawVertex ) , ( const GLvoid * ) 0 ) ; glEnableVertexAttribArray ( 0 ) ; glVertexAttribPointer ( 1 , 3 , GL_FLOAT , GL_FALSE , sizeof ( drawVertex ) , ( const GLvoid * ) ( sizeof ( glm :: vec3 ) ) ) ; glEnableVertexAttribArray ( 1 ) ; glDrawArrays ( GL_POINTS , 0 , vertexData . size ( ) ) ; glBindVertexArray ( 0 ) ; }
Draw a model of vertices, triangulate all the neighboring vertices
Draw a model of vertices triangulate all the neighboring vertices
// Combine the data of position and normal into the vertex. // Set the model's VAO. // Position attribute. // Normal attribute. // Unbind VAO.