On every single android device {emulators} from ldpi to xxhdpi, both DisplayMetrics and native JNI EGL return width:320 and height:526. Even on actual HTC ONE mobile it returns something like 320x526. This is annoying. I need to know the exact pixel dimensions of the GL rendering surface {framebuffer/renderbuffer etc}. How can I do that ?
From Java activity class I am doing:
DisplayMetrics metrics = getResources().getDisplayMetrics();
int widthPixels = metrics.widthPixels;
int heightPixels = metrics.heightPixels;
From the JNI C++ code I am going following with NO luck (again output: Size = 320 x 526):
int W, H;
EGLDisplay display = eglGetCurrentDisplay();
EGLSurface surface = eglGetCurrentSurface(EGL_READ);
eglQuerySurface(display, surface, EGL_WIDTH, &W);
eglQuerySurface(display, surface, EGL_HEIGHT, &H);
LOGI("JNIGlue.cpp:Init:EGL-Width : %d", W);
LOGI("JNIGlue.cpp:Init:EGL-Height: %d", H);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &W);
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &H);
LOGI("JNIGlue.cpp:Init:RB-Width : %d", W);
LOGI("JNIGlue.cpp:Init:RB-Height: %d", H);
So how do I get the exact OpenGL rendering surface/buffer size ?