21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL 34 #include <wrl/client.h> 38 static const int ANGLE_D3D_FEATURE_LEVEL_ANY = 0;
39 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 40 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 41 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 42 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 43 #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 44 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209 45 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B 46 #define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F 48 #define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B 56 WINRT_GLES_LoadLibrary(
_THIS,
const char *
path)
60 if (SDL_EGL_LoadLibrary(
_this, path, EGL_DEFAULT_DISPLAY) != 0) {
65 CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function)
SDL_LoadFunction(
_this->egl_data->egl_dll_handle,
"CreateWinrtEglWindow");
66 if (CreateWinrtEglWindow) {
74 CoreWindow ^ native_win = CoreWindow::GetForCurrentThread();
75 Microsoft::WRL::ComPtr<IUnknown> cpp_win =
reinterpret_cast<IUnknown *
>(native_win);
87 Microsoft::WRL::ComPtr<IUnknown> cpp_display = video_data->
winrtEglWindow;
88 _this->egl_data->egl_display = ((eglGetDisplay_Old_Function)
_this->egl_data->eglGetDisplay)(cpp_display);
89 if (!
_this->egl_data->egl_display) {
90 return SDL_SetError(
"Could not get Windows 8.0 EGL display");
93 if (
_this->egl_data->eglInitialize(
_this->egl_data->egl_display,
NULL,
NULL) != EGL_TRUE) {
94 return SDL_SetError(
"Could not initialize Windows 8.0 EGL");
100 const EGLint defaultDisplayAttributes[] =
102 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
103 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
104 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
108 const EGLint fl9_3DisplayAttributes[] =
110 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
111 EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
112 EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,
113 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
114 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
118 const EGLint warpDisplayAttributes[] =
120 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
121 EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE,
122 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
123 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
133 eglGetPlatformDisplayEXT_Function eglGetPlatformDisplayEXT = (eglGetPlatformDisplayEXT_Function)
_this->egl_data->eglGetProcAddress(
"eglGetPlatformDisplayEXT");
134 if (!eglGetPlatformDisplayEXT) {
135 return SDL_SetError(
"Could not retrieve ANGLE/WinRT display function(s)");
138 #if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) 142 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes);
143 if (!
_this->egl_data->egl_display) {
147 if (
_this->egl_data->eglInitialize(
_this->egl_data->egl_display,
NULL,
NULL) != EGL_TRUE)
154 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes);
155 if (!
_this->egl_data->egl_display) {
159 if (
_this->egl_data->eglInitialize(
_this->egl_data->egl_display,
NULL,
NULL) != EGL_TRUE) {
163 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes);
164 if (!
_this->egl_data->egl_display) {
168 if (
_this->egl_data->eglInitialize(
_this->egl_data->egl_display,
NULL,
NULL) != EGL_TRUE) {
169 return SDL_SetError(
"Could not initialize WinRT 8.x+ EGL");
179 WINRT_GLES_UnloadLibrary(
_THIS)
190 SDL_EGL_UnloadLibrary(
_this);
194 SDL_EGL_CreateContext_impl(WINRT)
195 SDL_EGL_SwapWindow_impl(WINRT)
196 SDL_EGL_MakeCurrent_impl(WINRT)
static SDL_VideoDevice * _this
HRESULT(WINAPI *GetDpiForMonitor)(HMONITOR hmonitor
IUnknown * winrtEglWindow
GLsizei const GLchar *const * path
void * SDL_LoadFunction(void *handle, const char *name)