Environment
- Windows (x64) Host
- Android 5.0 USB connected to the Windows machine
- Samsung Galaxy 5
- VisualGDB
- OpenGL (v1.4)
- ADB CmdLine tool => Native C++ (No Java)
Use-case
Implement an ADB commandline tool that extract the main display resolution ( this is part of the tools functionality )
The following code print gibberish data, How can I get the main display resolution using Native C++ code running as an ADB command line tool ?
Code snippet
HRESULT GetMainDisplayResolution(OUT SIZE& sz) {
EGLConfig pConfigs[MAX_CONFIGS] = { 0 };
EGLint iErr = 0;
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (0 == display)
return E_FAIL;
int maj, min;
if (FALSE == eglInitialize(display, &maj, &min)) {
iErr = eglGetError();
return E_FAIL;
}
EGLint iCfgCount = 0;
if (FALSE == eglGetConfigs(display, pConfigs, MAX_CONFIGS, &iCfgCount)) {
iErr = eglGetError();// EGL_NOT_INITIALIZED
return E_FAIL;
}
for (int i = 0; i < iCfgCount; i++) {
eglGetConfigAttrib(display, pConfigs[i], EGL_HORIZONTAL_RESOLUTION, (EGLint*)&sz.cx);
eglGetConfigAttrib(display, pConfigs[i], EGL_VERTICAL_RESOLUTION, (EGLint*)&sz.cy);
printf("Cfg %i, x:%i, y:%i", i, sz.cx, sz.cy);
}
return S_OK;
}