Android OpenGL 纹理压缩
我需要一些帮助来查找有关如何在 Android 上使用纹理压缩的信息(或示例)。我现在有很多 PNG,我需要减少它们占用的内存量。我正在研究 PVR 压缩,但我不知道如何在 OpenGL 中使用它。
有人可以指出我正确的方向或提供一些例子,因为我找不到任何东西。
I need some help finding information (or an example) of how to use texture compression for Android. I have a lot of PNG's right now and I need to reduce the amount of memory they take up. I was looking at PVR compression but I can't figure out how to use this within OpenGL.
Could some point me in the right direction or offer some examples as I cannot find anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Android 主要支持四种纹理压缩类型:
更详细的信息 此处和此处。
简而言之,如果你的纹理没有 Alpha,你可以使用 ETC1。如果它们确实有 Alpha,并且您想支持所有设备,则必须以其他三种类型压缩纹理并根据设备加载它们。
如何使用:
压缩您的png文件(您可以使用ETC-Pack等工具,< a href="http://www.imgtec.com/powervr/insider/powervr-pvrtextool.asp" rel="noreferrer">PVRTexTool, ATI 压缩器,Nvidia Texure Tools 根据纹理类型)并添加到您的项目资源中。
如果您不使用 ETC1,请确定设备中可用的扩展:
将压缩纹理加载为原始数据。
使用glCompressedTexImage2D代替glTexImage2D:
There are mainly four texture compression types supported on Android:
More detailed information here and here.
In short, if your textures don't have alpha, you can use ETC1. If they do have alpha, and you want to support all devices, you must have your textures compressed in the other three types and load them according to the device.
How to use:
Compress your png files (You can use a tool like ETC-Pack, PVRTexTool, ATI Compressonator, Nvidia Texure Tools according to the type of texture) and add to your project assets.
Determine which extensions are available in the device, if you're not using ETC1:
Load compressed texture as raw data.
Use glCompressedTexImage2D instead of glTexImage2D:
这是一个 ol 线程,所以我想我应该使用 http://devtools.ericsson 上提供的信息来更新它。 com/etc
ETC2 在 Khronos 标准 OpenGL ES 3.0 和 OpenGL 4.3 中是强制性的。
This is an ol thread, so I thought I'd update it with the information available on http://devtools.ericsson.com/etc
ETC2 is mandatory in the Khronos standards OpenGL ES 3.0 and OpenGL 4.3.
您不应该在 Android 上仅使用 PVR 压缩,因为这并不适用于所有型号。为了解决这个问题,您应该只使用 ETC1(在所有 GLES 2.0 设备上强制)或为单独的 GPU 模式使用单独的纹理包。 android 开发指南 有一个辅助类来加载压缩格式。
您可以使用 etcpack 进行压缩。
请注意,您不会使用 ETC1 获得 Alpha 通道 - 您可以通过将 Alpha 通道作为单独的纹理来执行一些奇特的片段着色技巧来解决这个问题。
You should not use just PVR compression on Android, since that will not work with all models. To get around that you should either only use ETC1 (mandated on all GLES 2.0 devices) or have separate texture packs for separate GPU modes. The android dev guide has a helper class to load the compression format.
You can use etcpack to do compression.
Note that you will not get an alpha channel with ETC1 - you can do some fancy fragment shading tricks to get around that by having the alpha channel as a separate texture.
只是想指出并非所有 Android 设备都支持 etc1,这与 gergonzalez 所说的相反
https://developer.android.com/guide/topics/graphics/ opengl.html#textures
Just wanted to point out etc1 isn't supported by all android devices, contrary to what gergonzalez said
https://developer.android.com/guide/topics/graphics/opengl.html#textures