liulover5 发表于 2015-03-30 21:52

opengl ES 2.0 顶点数组 如何设置?

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

renxiao2003 发表于 2015-04-13 17:12

现在没做游戏,还是做标准的应用 。这个基本用不上。
页: [1]
查看完整版本: opengl ES 2.0 顶点数组 如何设置?