Are OpenGL Textures more memory efficient than Android Bitmaps?

梦想的初衷 提交于 2019-12-07 09:33:49

问题


I have a custom map application that deals with many Bitmaps that are 256x256 images (png,jpg). I'm currently using the View 2d canvas and bring in all images as 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). I've been thinking about using opengl but am fairly new to it.

  1. Would opengl Textures be more memory efficient than keeping Bitmaps around? 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?

  3. Do you need to cache Textures or does the GPU handle that for you?

UPDATE: I received a nice detailed answer to this question on GameStack.


回答1:


  1. Load many Bitmap instance in app may cause OOM sometimes.
  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.
  3. you must gen texture and del it explicitly.


来源:https://stackoverflow.com/questions/9475850/are-opengl-textures-more-memory-efficient-than-android-bitmaps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!