I'm trying to draw a grid made of triangles with the inmediate mode of OpenGL but I'm struggling with it. Particularly the number of vertices has to be (N + 1) x (N + 1)
and "linked" between 2 x N x N
Index-vectors. What I've got at this point is the following code:
void generate_grid(
std::uint32_t N,
std::vector<glm::vec3>* vertices, //vector which contains all the vertices
std::vector<glm::uvec3>* indices) // vector which contains all the indices
{
/*cg_assert(N >= 1);
cg_assert(vertices);
cg_assert(indices);
vertices->clear();
indices->clear();*/
std::uint32_t size = 2*N*N;
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, vertices->data());
glDrawElements(GL_TRIANGLES, size, GL_UNSIGNED_INT, indices->data());
glDisableClientState(GL_VERTEX_ARRAY);
}
All your advices about it will be well-recibed (I'm in process of learn OpenGL, be kind ;)). Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire