Generating a grid in OpenGL

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.

Answers


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.


Need Your Help

Google Apps Script Spreadsheets - Assign script to image from a script

google-apps-script google-sheets google-spreadsheet-api

I want to generate images with a script assigned to it using another script. I know you can insert images from a script link here, but I can't find a way to assign a script to that image from a scr...

Publishing WebSite in VS Express Editions

asp.net visual-studio-2010 web publish visual-studio-express

I m trying to publish my website and dlls with vs2010 express edition.