在 OpenGL 中平铺背景
我确信这是一个相对简单的问题,这只是我一直难以理解的一件事。
我有一个 512x512 的背景,我想“无限”平铺。我四处寻找,似乎找不到很多东西,所以我想我应该来这里。无论如何,这里是:
背景 http://dl.dropbox.com/u /5003139/hud/stars_far.png
所以,你已经明白了。我有一个船精灵,可以在 2D 平面上的任何位置移动,这是一个自上而下的游戏。我将如何渲染这个背景,以便它覆盖任意大小的窗口的每个像素?
I'm sure this is a relatively simple question, it's just one thing I've always had trouble wrapping my mind around.
I have a 512x512 background I'd like to tile "infinitely." I've searched around and can't seem to find a whole lot, so I figured I'd come here. Anyway, here it is:
background http://dl.dropbox.com/u/5003139/hud/stars_far.png
So, there you have it. I have a ship sprite that can move anywhere on a 2D plane, and this is a top-down game. How would I render this background so that it covers every pixel of an arbitrarily sized window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 GL_REPEAT 纹理夹紧/环绕模式,范围 [0,1] 之外的纹理坐标将环绕,重复纹理。因此,您可以绘制屏幕填充四边形,但使用更大的纹理坐标。例如,使用纹理坐标 (0,0) 到 (10,10) 将在每个方向上重复纹理 10 次。为当前绑定的 2D 纹理启用重复模式
With GL_REPEAT texture clamping/wrapping mode, texture coordinates outside the range [0,1] will wrap around, repeating the texture. So you can draw a screen filling quad, but use larger texture coordinates. For example using the texture coordinates (0,0) to (10,10) will repeat the texture 10 times in each direction. Repeating mode is enabled for the currently bound 2D texture with