Android NDK:OpenGL ES 中的奇怪线条坐标
我正在使用 NDK 在 Android 上使用库 GLESv1_CM 渲染简单的场景。
void render(Rect viewport)
{
glViewport(viewport.left, viewport.top, viewport.Width(), viewport.Height());
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(viewport.left, viewport.right, viewport.top, viewport.bottom, -1, 1);
GLfloat points[] = { 5, 50, 1, 1, 1, 1,
7, 50, 1, 1, 1, 1,
7, 50, 1, 0, 0, 1,
7, 52, 1, 0, 0, 1,
8, 50, 0, 1, 0, 1,
10, 50, 0, 1, 0, 1};
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(2,GL_FLOAT,sizeof(GLfloat)*6,&points);
glColorPointer(4,GL_FLOAT,sizeof(GLfloat)*6,&points[2]);
glDrawArrays(GL_LINES,0,6);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
}
我希望有 3 条交叉线,但是当我在 Android 2.2 或 3.2 的设备上运行它时,我有这个:
甚至更多,在 Android 4 的 Android 模拟器上(更新:与 2.3 的模拟器相同)我有这个:
是否可以在不使用 opengl2 的情况下在所有 Android 版本的所有设备上使其看起来像此图片所示?
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据此类投影的 OpenGL 常见问题解答:
我想这会减少舍入问题的可能性。
According to the OpenGL FAQ for this type of projection:
I imagine this reduces the likelihood of rounding issues.