Tôi đang cố gắng nhận giới hạn kích thước hoạ tiết tối đa trong Android cho OpenGL 2.0. Nhưng tôi đã thấy rằng hướng dẫn tiếp theo chỉ hoạt động nếu tôi hiện đang ở trong ngữ cảnh OpenGL, nói cách khác tôi phải có GL Surface và GL Renderer, vv, mà tôi không muốn.Nhận giới hạn kích thước kết cấu OpenGL ES 2.0 tối đa trong Android
int[] maxTextureSize = new int[1];
GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
Vì vậy, tôi đi kèm với thuật toán tiếp theo, mang lại cho tôi kích thước họa tiết tối đa mà không phải tạo bất kỳ bề mặt hoặc trình kết xuất nào. Nó hoạt động chính xác, do đó, câu hỏi của tôi là nếu điều này sẽ làm việc với tất cả các thiết bị Android, và nếu bất cứ ai có thể phát hiện bất kỳ lỗi, chỉ trong trường hợp.
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;
}
Bạn có chắc kích thước kết cấu GL bị ràng buộc với kích thước bộ đệm bọt EGL không? Đây có phải là thông số kỹ thuật EGL 1.0 ở đâu đó không? –