Per*_*abs 8 android textures opengl-es
我试图在Android for OpenGL 2.0中获得最大的纹理大小限制.但是我发现只有当我在OpenGL上下文中时,下一条指令才有效,换句话说我必须有GL Surface和GL Renderer等,这是我不想要的.
int[] maxTextureSize = new int[1];
GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
Run Code Online (Sandbox Code Playgroud)
所以我选择了下一个算法,它给了我最大的纹理大小,而不必创建任何表面或渲染器.它的工作正常,所以我的问题是,这是否适用于所有Android设备,如果有人能发现任何错误,以防万一.
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;
}
Run Code Online (Sandbox Code Playgroud)
遗憾的是,PBUFFER最大尺寸与最大纹理尺寸无关(但可能相同).
我相信获得最大纹理大小的最佳方法是创建GL上下文(与实际使用此纹理的上下文相同)并请求GL_MAX_TEXTURE_SIZE.
这背后有充分的理由:在创建表面(和上下文)之前,未对当前进程初始化ogl驱动程序.某些驱动程序在初始化时执行基础HW/SKU检测,并根据硬件功能计算最大表面大小.
此外,允许最大纹理大小取决于上下文(并且创建了EGLConfig上下文).
还有一件事:eglGetConfigs将获得所有EGLconfigs,甚至是默认的软件android渲染器,或者来自OpenGL ES 1.1CM HW驱动程序(如果在目标平台上有1.1和2.0的单独驱动程序).驱动程序在图形堆栈中是独立的,可以返回不同的max-es.
| 归档时间: |
|
| 查看次数: |
6762 次 |
| 最近记录: |