I am trying to draw a grid with OpenGL 3+. However, I have a problem generating it. My code is:
vec3 *verts = new vec3[(resolution)*(resolution)];
int count = 0;
for(int i = 0;i<resolution;i++)
for(int j = 0;j<resolution;j++)
{
verts[count++] = vec3(i,0,j);
}
GLuint *indices = new GLuint[(resolution-1)*(resolution-1)*6];
count = 0;
for(int i = 0;i<resolution-1;i++)
{
for(int j = 0;j<resolution-1;j++)
{
indices[count++] = i*resolution+j;
indices[count++] = i*resolution+j+1;
indices[count++] = (i+1)*resolution+j;
indices[count++] = (i+1)*resolution+j;
indices[count++] = i*resolution+j+1;
indices[count++] = (i+1)*resolution+j+1;
}
}
I draw the geometry as GL_TRIANGLES and do not see anything.
At last, I found the problem - the GL buffers sizes were set to incorrect values, and so not rendered, although grid generation routine works well.