我在使用 glDrawRangeElementsBaseVertex() 时遇到了一些疑问。
以下是源代码:
GLfloat vertices[]=
{
-0.9,-0.9,1.0,1.0,
-0.1,-0.9,1.0,1.0,
-0.1,-0.1,1.0,1.0,
-0.9,-0.1,1.0,1.0,
0.1,0.1,1.0,1.0,
0.9,0.1,1.0,1.0,
0.9,0.9,1.0,1.0,
0.1,0.9,1.0,1.0,
-0.9,0.1,1.0,1.0,
-0.1,0.1,1.0,1.0,
-0.1,0.9,1.0,1.0,
-0.9,0.9,1.0,1.0,
0.1,-0.1,1.0,1.0,
0.1,-0.9,1.0,1.0,
0.9,-0.9,1.0,1.0,
0.9,-0.1,1.0,1.0
};
GLuint indices_uint[]=
{
0,1,2,3,222,//Triangle 0
4,5,6,7,222,//Triangle 1
8,9,10,11,222,//Triangle 2
12,13,14,15,222,//Triangle 3
4,5,6,7,222,//Triangle 1
8,9,10,11,222,//Triangle 2
4,5,6,7,222,//Triangle 1
12,13,14,15,222//Triangle 3
};
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(222);
glEnableVertexAttribArray(position);
glVertexAttribPointer(position, 4, GL_FLOAT, GL_FALSE, 0,vertices);
glDrawRangeElementsBaseVertex(GL_TRIANGLE_STRIP,0,7,10,GL_UNSIGNED_INT,indices_uint,4);
我不确定输出到底应该是什么。代码呈现三角形 1 和三角形 2。当我将 [start,end] 传递为 [0,7] 时,三角形 2 的绘制究竟如何?
规范说:
Index values lying outside the range [start, end] are treated in the same way as glDrawElementsBaseVertex()
这是否意味着即使 {8,9,10,11} 超出 [0,7] 范围,它们仍将用于渲染?如果是这样,那么为什么我们必须使用 glDrawRangeElementsBaseVertex() ?