简体   繁体   English

使用OpenGL ES绘制纹理的最简单方法是什么?

[英]What is the easiest way to draw texture with OpenGL ES?

I saw this Google IO session: http://code.google.com/intl/iw/events/io/2009/sessions/WritingRealTimeGamesAndroid.html 我看到了这个Google IO会话: http//code.google.com/intl/iw/events/io/2009/sessions/WritingRealTimeGamesAndroid.html
He says that the draw_texture function is the fastest and VBO is 2nd faster. 他说draw_texture函数是最快的,VBO是第二快的。
But I don't understand how to use it(the draw_texture method or the VBO way). 但我不明白如何使用它(draw_texture方法或VBO方式)。

Any suggestion? 有什么建议吗?

The source code for the sprite method test mentioned in the video is available here: 视频中提到的精灵方法测试的源代码可在此处获得:
http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/SpriteMethodTest http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/SpriteMethodTest

Here is an example from that where a VBO is used: 以下是使用VBO的示例:
http://code.google.com/p/apps-for-android/source/browse/SpriteMethodTest/src/com/android/spritemethodtest/Grid.java#237 http://code.google.com/p/apps-for-android/source/browse/SpriteMethodTest/src/com/android/spritemethodtest/Grid.java#237

Here is an example from that where the draw texture extension is used: 以下是使用绘制纹理扩展的示例:
http://code.google.com/p/apps-for-android/source/browse/SpriteMethodTest/src/com/android/spritemethodtest/GLSprite.java http://code.google.com/p/apps-for-android/source/browse/SpriteMethodTest/src/com/android/spritemethodtest/GLSprite.java

One thing to watch out for, however, is that the draw texture extension is actually not the fastest for all games using sprites. 但是要注意的一点是,绘制纹理扩展实际上并不是所有使用精灵的游戏中最快的。 Many games have groups of sprites that all share the same render state, for example. 例如,许多游戏具有共享相同渲染状态的精灵组。 In that case it is much faster to put all sprites with the same render state in the same buffer and draw them with the same draw command. 在这种情况下,将具有相同渲染状态的所有精灵放在同一缓冲区中并使用相同的绘制命令绘制它们要快得多。 The draw texture command doesn't allow this. draw texture命令不允许这样做。 With the draw texture command you have to call it once per sprite. 使用draw texture命令,你必须为每个sprite调用一次。

This is the reason that atlas textures are often used. 这就是经常使用地图集纹理的原因。 An atlas texture is a single bound texture object that has many different images in it. 地图集纹理是单个绑定纹理对象,其中包含许多不同的图像。 You can draw sprites with different images that way without having to bind to a different texture object. 您可以使用不同的图像绘制精灵,而无需绑定到不同的纹理对象。 All you do is have them use different texture coordinates into the atlas texture. 你所做的就是让他们在地图集纹理中使用不同的纹理坐标。 If the other render state is the same as well, such as the blending function needed, then you can draw the sprites together for better performance. 如果另一个渲染状态也是相同的,例如所需的混合功能,那么您可以将精灵绘制在一起以获得更好的性能。

Here are some great Android OpenGL ES working examples. 这里有一些很棒的Android OpenGL ES工作示例。

http://code.google.com/p/android-gl/ http://code.google.com/p/android-gl/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM