264 if (!(window->flags & SDL_WINDOW_OPENGL)) { |
264 if (!(window->flags & SDL_WINDOW_OPENGL)) { |
265 /* OpenGL ES 2 wasn't requested. Don't set up an EGL surface. */ |
265 /* OpenGL ES 2 wasn't requested. Don't set up an EGL surface. */ |
266 data->egl_surface = EGL_NO_SURFACE; |
266 data->egl_surface = EGL_NO_SURFACE; |
267 } else { |
267 } else { |
268 /* OpenGL ES 2 was reuqested. Set up an EGL surface. */ |
268 /* OpenGL ES 2 was reuqested. Set up an EGL surface. */ |
269 IUnknown * nativeWindow = reinterpret_cast<IUnknown *>(data->coreWindow.Get()); |
269 |
270 data->egl_surface = SDL_EGL_CreateSurface(_this, nativeWindow); |
270 /* HACK: ANGLE/WinRT currently uses non-pointer, C++ objects to represent |
|
271 native windows. The object only contains a single pointer to a COM |
|
272 interface pointer, which on x86 appears to be castable to the object |
|
273 without apparant problems. On other platforms, notable ARM and x64, |
|
274 doing so will cause a crash. To avoid this crash, we'll bypass |
|
275 SDL's normal call to eglCreateWindowSurface, which is invoked from C |
|
276 code, and call it here, where an appropriate C++ object may be |
|
277 passed in. |
|
278 */ |
|
279 typedef EGLSurface (*eglCreateWindowSurfaceFunction)(EGLDisplay dpy, EGLConfig config, |
|
280 Microsoft::WRL::ComPtr<IUnknown> win, |
|
281 const EGLint *attrib_list); |
|
282 eglCreateWindowSurfaceFunction WINRT_eglCreateWindowSurface = |
|
283 (eglCreateWindowSurfaceFunction) _this->egl_data->eglCreateWindowSurface; |
|
284 |
|
285 Microsoft::WRL::ComPtr<IUnknown> nativeWindow = reinterpret_cast<IUnknown *>(data->coreWindow.Get()); |
|
286 data->egl_surface = WINRT_eglCreateWindowSurface( |
|
287 _this->egl_data->egl_display, |
|
288 _this->egl_data->egl_config, |
|
289 nativeWindow, NULL); |
271 if (data->egl_surface == NULL) { |
290 if (data->egl_surface == NULL) { |
272 // TODO, WinRT: see if SDL_EGL_CreateSurface, or its callee(s), sets an error message. If so, attach it to the SDL error. |
291 // TODO, WinRT: see if SDL_EGL_CreateSurface, or its callee(s), sets an error message. If so, attach it to the SDL error. |
273 return SDL_SetError("SDL_EGL_CreateSurface failed"); |
292 return SDL_SetError("SDL_EGL_CreateSurface failed"); |
274 } |
293 } |
275 } |
294 } |