(OpenGL iOS) 在 X 和 Y 坐标中移动时,原始形状 (2D) 扭曲 (GL_TRIANGLE_STRIP)
当我通过 x 和 y 坐标移动图元时,我得到了这个奇怪的扭曲的图元形状(而不是正方形)。
这是一个快照: http://img535.imageshack.us/img535/9046/screenshot20120126at122.png
我正在使用正交投影,因为我想以 2D 渲染。
这是渲染代码:
//vertex definition
static GLfloat qdt[] = {
30.0f, 60.0f, -0.03f,
30.0f, 30.0f, -0.03f,
60.0f, 60.0f, -0.03f,
60.0f, 30.0f, -0.03f
};
//clear buffers
glClear(GL_COLOR_BUFFER_BIT);// also tried using GL_DEPTH_BUFFER_BIT
//load matrices
glLoadIdentity();
//drawing
glVertexPointer(3, GL_FLOAT, 0, &qdt[0]);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 12);
//swap buffers
[glContext presentRenderbuffer:GL_RENDERBUFFER_OES];
我也禁用了深度缓冲区。 如果有人指出导致这种扭曲的错误,那就太好了。 提前致谢。
I get this strange distorted primitive shape (instead of a square) when i move the primitive through the x and y co-ordinates.
Here is a snapshot:
http://img535.imageshack.us/img535/9046/screenshot20120126at122.png
I'm using orthogonal projection since i want to render in 2D.
Here is the render code:
//vertex definition
static GLfloat qdt[] = {
30.0f, 60.0f, -0.03f,
30.0f, 30.0f, -0.03f,
60.0f, 60.0f, -0.03f,
60.0f, 30.0f, -0.03f
};
//clear buffers
glClear(GL_COLOR_BUFFER_BIT);// also tried using GL_DEPTH_BUFFER_BIT
//load matrices
glLoadIdentity();
//drawing
glVertexPointer(3, GL_FLOAT, 0, &qdt[0]);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 12);
//swap buffers
[glContext presentRenderbuffer:GL_RENDERBUFFER_OES];
I've disabled the depth buffers too.
It would be nice if someone points out the mistakes which is causing this distortion.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 12 替换为 4,因为您绘制了 4 个顶点:
Replace 12 by 4, because you draw 4 vertices: