Android OpenGL ES 2.0 maximum font size

I am trying to get the maximum texture size limit in Android for OpenGL 2.0. But I found that the following instruction only works if I enter the OpenGL context, in other words, I have to have GL Surface and GL Renderer, etc., which I don't want.

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

So, I came up with the following algorithm, which gives me the maximum size of the texture without the need to create any kind of surface or rendering. It works correctly, so my question is that it will work with all Android devices, and if anyone can detect any error, just in case.

 public int getMaximumTextureSize() { EGL10 egl = (EGL10)EGLContext.getEGL(); EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); // Initialise int[] version = new int[2]; egl.eglInitialize(display, version); // Query total number of configurations int[] totalConfigurations = new int[1]; egl.eglGetConfigs(display, null, 0, totalConfigurations); // Query actual list configurations EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]]; egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations); int[] textureSize = new int[1]; int maximumTextureSize = 0; // Iterate through all the configurations to located the maximum texture size for (int i = 0; i < totalConfigurations[0]; i++) { // Only need to check for width since opengl textures are always squared egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize); // Keep track of the maximum texture size if (maximumTextureSize < textureSize[0]) { maximumTextureSize = textureSize[0]; } Log.i("GLHelper", Integer.toString(textureSize[0])); } // Release egl.eglTerminate(display); Log.i("GLHelper", "Maximum GL texture size: " + Integer.toString(maximumTextureSize)); return maximumTextureSize; } 
+8
android opengl-es textures
source share
1 answer

The maximum size of PBUFFER, unfortunately, is not related to the maximum size of the texture (but may be the same).

I believe the best way to get the maximum texture size is to create a GL context (in the same context in which you will actually use these textures) and request GL_MAX_TEXTURE_SIZE.

There is a good reason for this: the ogl driver is not initialized for the current process until the surface (and context) is created. Some drivers perform HW / SKU determination during initialization and calculate maximum surface sizes depending on the capabilities of the HW.

In addition, the maximum texture size is allowed to vary depending on the context (and the EGLConfig context was created).

And one more thing: eglGetConfigs will receive all EGLconfigs, even from the standard android renderer software, or from the OpenGL ES 1.1CM HW driver (if there are separate drivers for 1.1 and 2.0 on the target platform). Drivers are standalone in the graphics stack and can return different maximum values.

+6
source share

All Articles