Here’s the situation: I have a two images that are over 1024 in width and end up scaling up to 2048 as a power-of-2. This works fine on almost all tested Android devices, except for the HTC Eris and HTC Hero which fail and render just an empty white rectangle.
What I’d like to do is add a check to disable a feature that uses the large textures. So basically I just need a way to determine if the device can support the high-res images, with a simple boolean result.
I’ve found several similar questions online but none that answer with a way to do this.
The Solution (as per Tim’s answer):
I was able to capture this info inside the onSurfaceCreated() method of my GLSurfaceView.Renderer class, then test against it:
public void onSurfaceCreated(GL10 gl, EGLConfig config)
{
IntBuffer textureLimit = IntBuffer.allocate(1);
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, textureLimit);
this.mTextureLimit = textureLimit.get(0);
}
Have you explored the glGet* family of functions? You can query all kinds of parameters about the current gles implementation.
Maybe something like
glGetIntegerv(GL_MAX_TEXTURE_SIZE, size);would work.http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml
Also you might be able to use
glGetErrorfor error checking. If you try to create a texture that is too large for the implementation, it should returnGL_INVALID_VALUEafter callingglTexImage2d. You could catch this error after creating the texture and fallback to a smaller size if for some reason the large texture didn’t create successfully.