Get OpenGL max texture size

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

I'm developing an Android app that's going to work with bitmaps extensively and I'm looking for a reliable way to get the maximum texture size for OpenGL on different devices.
I know the minimum size = 2048x2048, but that's not good enough since there are already tablets out there with much higher resolutions (2560x1600 for example)
So is there a reliable way to get this information?

So far I've tried:

  • Canvas.getMaximumBitmapWidth() (Returns 32766, instead of 2048)
  • GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE ...) (Returns 0)

I'm working with minimum-sdk = 15 (ICS) and I'm testing it on a Asus Transformer TF700t Infinity

Does anyone know another way to get it? Or will I have to compile a list of known GPUs with their max canvas size?

回答1:

try use this code

int[] maxTextureSize = new int[1]; GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0); 

maxTextureSize stores the size limit for decoded image such as 4096x4096, 8192x8192 . Remember to run this piece of code in the MainThread or you will get Zero.



回答2:

This will give you the maximum height allowed.

Canvas canvas = new Canvas(); canvas.getMaximumBitmapHeight() / 8 


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