68 LINFO(
"Initialized EGL v" << major <<
'.' << minor);
71 EGLenum
const api = eglQueryAPI();
74 case EGL_OPENGL_API:
LFATAL(
"EGL API is unsupported EGL_OPENGL_API");
break;
75 case EGL_OPENGL_ES_API:
LINFO(
"EGL API is EGL_OPENGL_ES_API");
break;
76 case EGL_OPENVG_API:
LFATAL(
"EGL API is unsupported EGL_OPENVG_API");
break;
77 case EGL_NONE:
LFATAL(
"EGL API is unsupported EGL_NONE");
break;
78 default:
LFATAL(
"EGL API is unknown");
82 static EGLint
const cfg_attr[] =
84 EGL_SAMPLES, EGL_DONT_CARE,
91 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
92 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
94 EGL_CONFORMANT, EGL_OPENGL_ES2_BIT,
99 GL_CHECK_BOOL(eglChooseConfig(itsDisplay, cfg_attr,
nullptr, 0, &num_config));
100 LINFO(
"OpenGL configs available: " << num_config);
101 if (num_config < 1)
LFATAL(
"Could not find a suitable OpenGL config");
103 EGLConfig * configs =
new EGLConfig[num_config];
104 GL_CHECK_BOOL(eglChooseConfig(itsDisplay, cfg_attr, configs, num_config, &num_config));
106 for (
int i = 0; i < num_config; ++i)
111#define JEVOIS_EGL_INFO(x) GL_CHECK(eglGetConfigAttrib(itsDisplay, configs[i], x, &val)); \
112 info += std::string(#x) + '=' + std::to_string(val) + ", ";
140 LINFO(
"EGL config " << i <<
": " << info);
142#undef JEVOIS_EGL_INFO
144 GL_CHECK(eglGetConfigAttrib(itsDisplay, configs[i], EGL_RED_SIZE, &val));
145 if (val != 8)
continue;
146 GL_CHECK(eglGetConfigAttrib(itsDisplay, configs[i], EGL_GREEN_SIZE, &val));
147 if (val != 8)
continue;
148 GL_CHECK(eglGetConfigAttrib(itsDisplay, configs[i], EGL_BLUE_SIZE, &val));
149 if (val != 8)
continue;
152 LINFO(
"Using config " << i <<
" with 8-bit R,G,B.");
153 itsConfig = configs[i];
160 if (gotit ==
false)
LFATAL(
"Could not find a suitable OpenGL config");
163 static EGLint
const win_attr[] =
168 GL_CHECK(itsSurface = eglCreateWindowSurface(itsDisplay, itsConfig, win, win_attr));
169 LINFO(
"OpenGL surface created ok.");
174 LINFO(
"OpenGL-ES API bound ok.");
177 static EGLint
const ctx_attr[] =
179 EGL_CONTEXT_CLIENT_VERSION, 3,
180 EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
181 EGL_CONTEXT_MINOR_VERSION_KHR, 2,
185 GL_CHECK(itsContext = eglCreateContext(itsDisplay, itsConfig, EGL_NO_CONTEXT, ctx_attr));
186 if (itsContext == EGL_NO_CONTEXT)
LFATAL(
"Failed to create OpenGL context");
187 LINFO(
"OpenGL context ok");
190 GL_CHECK(eglMakeCurrent(itsDisplay, itsSurface, itsSurface, itsContext));
193 glGetIntegerv(GL_MAJOR_VERSION, &major);
194 glGetIntegerv(GL_MINOR_VERSION, &minor);
195 LINFO(glGetString(GL_VERSION) <<
' '<< glGetString(GL_VENDOR) <<
" (" << glGetString(GL_RENDERER) <<
196 ") GL_VER=" << major <<
'.' << minor);
197 LINFO(
"OpenGL extensions: " << glGetString(GL_EXTENSIONS));
204 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);