全屏 OpenGL 框
我想使用 OpenGL 全屏绘制盒子的内部(即它应该完全填充视口)。 盒子应该有透视效果。
我想我必须根据视口大小更改盒子的尺寸,但我不知道该怎么做。
我正在尝试实现类似于 这张图片 中的房间的效果
我的问题是:我怎样才能实现这一目标?
I'd like to draw the inside of a box fullscreen (i.e. it should completely fill the viewport) using OpenGL. The box should have perspective.
I presume I'll have to change the dimensions of the box depending on the viewport size but I'm not sure how to go about this.
I'm trying to achieve something like the room in this image
My question is: how can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您传递到 glFrustum 时,对四个“墙”四边形的正面使用相同的坐标。通常的视口代码无需修改即可正常工作(它基本上只是告诉 OpenGL 在哪里显示其输出,您(几乎)总是希望将其作为给定窗口的完整大小)。请注意,由于您被告知要填充视图,因此当/如果显示区域的形状发生变化(即方形窗口 -> 方形框,长方形窗口 -> 长方形框)时,您将获得线性失真。
Use the same coords for the fronts of the four "wall" quads as you passed to glFrustum. The usual viewport code will work just fine without modification (it's basically just telling OpenGL where to display its output, which you (nearly) always want as the full size of the window you're given). Just be aware that since you're told it to fill the view, you'll get linear distortion when/if the shape of the display area changes (i.e., square window->square box, oblong window->oblong box).
差不多一年后有点晚了,但看到没有完整的答案,或者至少我无法解决这里的问题,我会向您指出这个问题,这肯定会有所帮助
如何确保平面完美填充 OpenGL 中的视口ES
it's a bit late after almost one year but seen that there is not a complete answear or at least i couldn't solve the problem with what is here i'll point you to this question wich can help for sure
How to ensure that a plane perfectly fills the viewport in OpenGL ES