免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 947 | 回复: 0
打印 上一主题 下一主题

[C] opengl ES 2.0 顶点数组 如何设置? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-03-30 21:58 |只看该作者 |倒序浏览
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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP