滚动的大背景中的OpenGL ES [英] Large scrolling background in OpenGL ES

查看:222
本文介绍了滚动的大背景中的OpenGL ES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个2D卷轴游戏的iPhone。我有一个大的图像背景,说480×6000像素,只有一部分是可见的(只有一个屏幕的价值,480×320像素)。是什么让屏幕在这样的背景下最好的方法是什么?

I am working on a 2D scrolling game for iPhone. I have a large image background, say 480×6000 pixels, of only a part is visible (exactly one screen’s worth, 480×320 pixels). What is the best way to get such a background on the screen?

目前我有后台拆分成几个纹理(来绕过最大纹理尺寸的限制),并绘制每一帧作为纹理的三角形带的整个背景。滚动是通过翻译模型视图矩阵完成。剪刀框设置为窗口大小,480×320像素。这并不意味着要快,我只是想要一个工作code之前,我得到优化。

Currently I have the background split into several textures (to get around the maximum texture size limit) and draw the whole background in each frame as a textured triangle strip. The scrolling is done by translating the modelview matrix. The scissor box is set to the window size, 480×320 pixels. This is not meant to be fast, I just wanted a working code before I get to optimizing.

我想,也许OpenGL实现将足够聪明丢弃背景的无形部分,但据一些测量code我写它看起来像背景需要7毫秒借鉴平均84毫秒最大。 (这是衡量模拟器。)这是对整个的一半渲染循环,即。对我来说相当缓慢。

I thought that maybe the OpenGL implementation would be smart enough to discard the invisible portion of the background, but according to some measuring code I wrote it looks like background takes 7 ms to draw on average and 84 ms at maximum. (This is measured in the simulator.) This is about a half of the whole render loop, ie. quite slow for me.

绘制背景应作为复制来自VRAM的一个部分约480×320像素到另一个,或者,换句话说,速度极快的那样容易。什么是更接近这样的表现的最好方法是什么?

Drawing the background should be as easy as copying some 480×320 pixels from one part of the VRAM to another, or, in other words, blazing fast. What is the best way to get closer to such performance?

推荐答案

这就是做这件事的快速方法。事情可以做,以提高性能:

That's the fast way of doing it. Things you can do to improve performance:

  • 尝试不同的纹理格式。 presumably的SDK文档对preferred格式的详细信息,以及presumably越小越好。
  • 在卡尔出完全离屏砖自己
  • 图象分成更小的纹理

我假设你正在绘制的1:1的放大级;是这样吗?

I'm assuming you're drawing at a 1:1 zoom-level; is that the case?

编辑:糟糕。有更多的仔细阅读你的问题,我所提供的另一个忠告:做在模拟器上的时序是毫无价值

Oops. Having read your question more carefully, I have to offer another piece of advice: Timings made on the simulator are worthless.

这篇关于滚动的大背景中的OpenGL ES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆