我正在尝试使用OpenGL 3+绘制网格。但是,我在生成它时遇到了问题。我的代码是:
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;
}
}
我将几何图形绘制为GL_TRIANGLES并且看不到任何内容。
答案 0 :(得分:0)
最后,我发现了问题 - 虽然网格生成例程运行良好,但GL缓冲区大小设置为不正确的值,因此没有渲染。