什么是OpenGL ES的绘制背景的适当的方式? [英] What is the appropriate way of drawing background in opengl es?

查看:132
本文介绍了什么是OpenGL ES的绘制背景的适当的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个平铺的背景2400x480 pixels.Also多了一个远层为绘制背景,一个循环逻辑?

视差effect.Is

 的for(int i = 0; I< 100;我++){
    //绘制code如0 + 2400 *我...
}


解决方案

我希望这可以让你开始了,但我真的不知道......

我假设在纹理显示一下子以下。由于纹理的大小 - 2400 * 480 =(3 * 800)* 480 - 我想这可能是不正确的,但无论如何,

有关的每一层,有两个四边形固定纹理坐标。最初,一个第一四元是可见的;在动画的过程中,在第一被移出屏幕,并在第二次的。纹理边界必须匹配,否则一个裂缝将可见。


  + ------------- ------------- + +
| || |
| || |
+ ------------- ------------- + +
^^
   可见......随着时间的推移...
+ ------------- ------------- + +
| || |
| || |
+ ------------- ------------- + +
      ^^
         可见


可以用于底层和下一层做到这一点。用于不同距离的层次不同的速度。将需要混合时,有一个以上的层

如果第一个假设被证明是不正确,则需要修改动画中的纹理坐标。有一个全屏幕的四,和纹理坐标被设置为供纹理的三分之一。然后,直线在相同的方向,直到表面被击中翻译所有四个坐标。此时你会莫名其妙地需要开始再次显示前三分之一 - 使用第二四例如:

I have a tile background with 2400x480 pixels.Also one more far layer for parallax effect.Is that drawing background with a for loop logical?

for(int i=0;i<100;i++) {
    //Drawing code like 0+2400*i ...
}

解决方案

I hope this gets you started, but I really don't know...

I assume in the following that the texture is displayed all at once. Due to the size of the texture -- 2400*480 = (3*800)*480 -- I think this may not be correct, but anyway.

For each layer, you have two quads with fixed texture coordinates. Initially, one the first quad is visible; in the course of the animation, the first is moved out of the screen and the second in. The texture border must match, otherwise a crack will be visible.

+-------------++-------------+
|             ||             |
|             ||             |
+-------------++-------------+
^             ^
   visible

... as time progresses ...
+-------------++-------------+
|             ||             |
|             ||             |
+-------------++-------------+
      ^             ^
         visible

You can do this for the bottom layer and the next layer. Use different velocities for layers of different distance. You will need blending when there is more than one layer.

If the first assumption proves to be incorrect, you need to modify texture coordinates during the animation. There is one full-screen quad, and the texture coordinates are setup for one third of the texture. Then, linearly translate all four coordinates in the same direction until the top is hit. At this point you somehow need to begin to show the first third again -- using a second quad for example.

这篇关于什么是OpenGL ES的绘制背景的适当的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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