@@ -126,7 +126,7 @@ bool WaylandDisplay::Run() {
126
126
return false ;
127
127
}
128
128
129
- abort () ;
129
+ FLWAY_WIP ;
130
130
131
131
return true ;
132
132
}
@@ -215,8 +215,12 @@ bool WaylandDisplay::SetupEGL() {
215
215
return false ;
216
216
}
217
217
218
- EGLint attributes[] = {
219
- // clang-format off
218
+ EGLConfig egl_config = nullptr ;
219
+
220
+ // Choose an EGL config to use for the surface and context.
221
+ {
222
+ EGLint attribs[] = {
223
+ // clang-format off
220
224
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
221
225
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
222
226
EGL_RED_SIZE, 8 ,
@@ -226,36 +230,53 @@ bool WaylandDisplay::SetupEGL() {
226
230
EGL_DEPTH_SIZE, 0 ,
227
231
EGL_STENCIL_SIZE, 0 ,
228
232
EGL_NONE, // termination sentinel
229
- // clang-format on
230
- };
233
+ // clang-format on
234
+ };
231
235
232
- EGLint config_count = 0 ;
233
- EGLConfig egl_config = nullptr ;
236
+ EGLint config_count = 0 ;
234
237
235
- if (eglChooseConfig (egl_display_, attributes, &egl_config, 1 ,
236
- &config_count) != EGL_TRUE) {
237
- LogLastEGLError ();
238
- FLWAY_ERROR << " Error when attempting to choose an EGL surface config."
239
- << std::endl;
240
- return false ;
238
+ if (eglChooseConfig (egl_display_, attribs, &egl_config, 1 , &config_count) !=
239
+ EGL_TRUE) {
240
+ LogLastEGLError ();
241
+ FLWAY_ERROR << " Error when attempting to choose an EGL surface config."
242
+ << std::endl;
243
+ return false ;
244
+ }
245
+
246
+ if (config_count == 0 || egl_config == nullptr ) {
247
+ LogLastEGLError ();
248
+ FLWAY_ERROR << " No matching configs." << std::endl;
249
+ return false ;
250
+ }
241
251
}
242
252
243
- if (config_count == 0 || egl_config == nullptr ) {
244
- LogLastEGLError ();
245
- FLWAY_ERROR << " No matching configs." << std::endl;
246
- return false ;
253
+ // Create an EGL window surface with the matched config.
254
+ {
255
+ const EGLint attribs[] = {EGL_NONE};
256
+
257
+ egl_surface_ =
258
+ eglCreateWindowSurface (egl_display_, egl_config, window_, attribs);
259
+
260
+ if (surface_ == EGL_NO_SURFACE) {
261
+ LogLastEGLError ();
262
+ FLWAY_ERROR << " EGL surface was null during surface selection."
263
+ << std::endl;
264
+ return false ;
265
+ }
247
266
}
248
267
249
- const EGLint attribs[] = {EGL_NONE};
268
+ // Create an EGL context with the match config.
269
+ {
270
+ const EGLint attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE};
250
271
251
- egl_surface_ =
252
- eglCreateWindowSurface (egl_display_, egl_config, window_ , attribs);
272
+ egl_context_ = eglCreateContext (egl_display_, egl_config,
273
+ nullptr /* share group */ , attribs);
253
274
254
- if (surface_ == EGL_NO_SURFACE ) {
255
- LogLastEGLError ();
256
- FLWAY_ERROR << " EGL surface was null during surface selection. "
257
- << std::endl ;
258
- return false ;
275
+ if (egl_context_ == EGL_NO_CONTEXT ) {
276
+ LogLastEGLError ();
277
+ FLWAY_ERROR << " Could not create an onscreen context. " << std::endl;
278
+ return false ;
279
+ }
259
280
}
260
281
261
282
return true ;
0 commit comments