in PlayAssetDelivery/NativeSample/common/ndk_helper/GLContext.cpp [87:144]
bool GLContext::InitEGLSurface() {
display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display_, 0, 0);
/*
* Here specify the attributes of the desired configuration.
* Below, we select an EGLConfig with at least 8 bits per color
* component compatible with on-screen windows
*/
const EGLint attribs[] = {EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT, // Request opengl ES2.0
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_BLUE_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_RED_SIZE,
8,
EGL_DEPTH_SIZE,
24,
EGL_NONE};
color_size_ = 8;
depth_size_ = 24;
EGLint num_configs;
eglChooseConfig(display_, attribs, &config_, 1, &num_configs);
if (!num_configs) {
// Fall back to 16bit depth buffer
const EGLint attribs[] = {EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT, // Request opengl ES2.0
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_BLUE_SIZE,
8,
EGL_GREEN_SIZE,
8,
EGL_RED_SIZE,
8,
EGL_DEPTH_SIZE,
16,
EGL_NONE};
eglChooseConfig(display_, attribs, &config_, 1, &num_configs);
depth_size_ = 16;
}
if (!num_configs) {
LOGW("Unable to retrieve EGL config");
return false;
}
surface_ = eglCreateWindowSurface(display_, config_, window_, NULL);
eglQuerySurface(display_, surface_, EGL_WIDTH, &screen_width_);
eglQuerySurface(display_, surface_, EGL_HEIGHT, &screen_height_);
return true;
}