opengl ES 2.0 顶点数组 如何设置?
为什么顶点数组只能设置成 { -1, -1, 1, -1, 1, 1, -1, 1},设置成{ 1, 1, 1920, 1, 1920, 1080, 1, 1080} 就跑到了屏幕外了?
注:屏幕分辨率是1920×1080,点的范围为什么是区间【-1到1】,而不能是1到1920/1080,为何?
部分代码,请看顶点数组triangleVertices:
// const GLfloat triangleVertices[] = { -1, -1, 1, -1, 1, 1, -1, 1};
const GLfloat triangleVertices[] = { 1, 1, 1920, 1, 1920, 1080, 1, 1080};
const GLfloat triangleColor[] = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1};
glVertexAttribPointer(vPositionHandle, 2, GL_FLOAT, GL_TRUE, 0, triangleVertices);
glEnableVertexAttribArray(vPositionHandle);
glVertexAttribPointer(vColorHandle, 4, GL_FLOAT, GL_TRUE, 0, triangleColor);
glEnableVertexAttribArray(vColorHandle);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);//GL_TRIANGLES |