OpenGL 中的 2D 显示看起来很奇怪
目前我正在用 OpenGL 编写一个视频播放器。
我这样调用 gluOrtho2D:
gluOrtho2D(0, w, 0, h);
并输出它:
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0, this->height());
glTexCoord2f(1.0f, 0.0f); glVertex2f(this->width(), this->height());
glTexCoord2f(1.0f, 1.1f); glVertex2f(this->width(), 0);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 0.0f);
glEnd();
正确的输出应该是这样的:
但是我看到的是...(请注意右下角)
似乎渲染不正确。也许你会推荐我使用 sdl_opengl...但我目前在 Qt 中使用 OpenGL,所以我无法打开 SDL 窗口。
那么,我该怎么办?
Currently I am writing a video player in OpenGL.
I call gluOrtho2D like this:
gluOrtho2D(0, w, 0, h);
And output it with:
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(0, this->height());
glTexCoord2f(1.0f, 0.0f); glVertex2f(this->width(), this->height());
glTexCoord2f(1.0f, 1.1f); glVertex2f(this->width(), 0);
glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 0.0f);
glEnd();
The correct output should be like:
But what I see is... (Please pay attention to the bottom right corner)
It seems that it's rendered incorrectly. Maybe you would recommend me to use sdl_opengl... But I'm currently using OpenGL in Qt, so I would not be able to open SDL windows.
So, what should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能是因为您使用
1.1f
作为第三个纹理坐标的y
部分?Is it perhaps because you're using
1.1f
as they
part of the 3rd texture coordinate?