简体   繁体   English

OpenGL Textures的内存效率是否比Android Bitmaps更高?

[英]Are OpenGL Textures more memory efficient than Android Bitmaps?

I have a custom map application that deals with many Bitmaps that are 256x256 images (png,jpg). 我有一个自定义地图应用程序,处理许多256x256图像(png,jpg)的位图。 I'm currently using the View 2d canvas and bring in all images as RGB_565. 我目前正在使用View 2d画布并将所有图像作为RGB_565引入。 Although I'm generally happy with the applications performance, I have features I'd like to add that will require even more map tiles (Bitmaps). 虽然我对应用程序性能感到满意,但我想添加的功能需要更多的地图图块(Bitmaps)。 I've been thinking about using opengl but am fairly new to it. 我一直在考虑使用opengl,但我对它很新。

  1. Would opengl Textures be more memory efficient than keeping Bitmaps around? opengl Textures比保持Bitmaps更有效吗? I assume you can load a Bitmap into a Texture and then dispose of the Bitmap 我假设您可以将位图加载到纹理中,然后处理位图

  2. Is it an acceptable practice in opengl to dynamically load many different Textures at runtime? 在opengl中,在运行时动态加载许多不同的纹理是否是可接受的做法?

  3. Do you need to cache Textures or does the GPU handle that for you? 你需要缓存纹理还是GPU为你处理?

UPDATE: I received a nice detailed answer to this question on GameStack. 更新:我在GameStack上收到了关于这个问题的详细解答

  1. Load many Bitmap instance in app may cause OOM sometimes. 在app中加载许多Bitmap实例有时可能会导致OOM。
  2. Load data to texture can be done in native code. 将数据加载到纹理可以在本机代码中完成。 It is more efficient than do it in app, just call memcpy, no Bitmap instance needed. 它比在应用程序中更有效,只需调用memcpy,不需要Bitmap实例。
  3. you must gen texture and del it explicitly. 你必须明确地生成纹理和del。

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

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