21#include "../../SDL_internal.h"
23#if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL
31#include "../SDL_egl_c.h"
35#include <wrl/client.h>
36using namespace Windows::UI::Core;
39static const int ANGLE_D3D_FEATURE_LEVEL_ANY = 0;
40#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
41#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
42#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204
43#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205
44#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
45#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE 0x3209
46#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE 0x320B
47#define EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE 0x320F
49#define EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER 0x320B
57WINRT_GLES_LoadLibrary(
_THIS,
const char *
path)
66 CreateWinrtEglWindow_Old_Function CreateWinrtEglWindow = (CreateWinrtEglWindow_Old_Function)
SDL_LoadFunction(
_this->egl_data->egl_dll_handle,
"CreateWinrtEglWindow");
67 if (CreateWinrtEglWindow) {
75 CoreWindow ^ native_win = CoreWindow::GetForCurrentThread();
76 Microsoft::WRL::ComPtr<IUnknown> cpp_win =
reinterpret_cast<IUnknown *
>(native_win);
77 HRESULT
result = CreateWinrtEglWindow(cpp_win, ANGLE_D3D_FEATURE_LEVEL_ANY, &(video_data->
winrtEglWindow));
88 Microsoft::WRL::ComPtr<IUnknown> cpp_display = video_data->
winrtEglWindow;
89 _this->egl_data->egl_display = ((eglGetDisplay_Old_Function)
_this->egl_data->eglGetDisplay)(cpp_display);
90 if (!
_this->egl_data->egl_display) {
91 return SDL_EGL_SetError(
"Could not get Windows 8.0 EGL display",
"eglGetDisplay");
95 return SDL_EGL_SetError(
"Could not initialize Windows 8.0 EGL",
"eglInitialize");
101 const EGLint defaultDisplayAttributes[] =
103 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
104 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER,
EGL_TRUE,
105 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,
109 const EGLint fl9_3DisplayAttributes[] =
111 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
112 EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
113 EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,
114 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER,
EGL_TRUE,
115 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,
119 const EGLint warpDisplayAttributes[] =
121 EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
122 EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE,
123 EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER,
EGL_TRUE,
124 EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE,
EGL_TRUE,
134 eglGetPlatformDisplayEXT_Function eglGetPlatformDisplayEXT = (eglGetPlatformDisplayEXT_Function)
_this->egl_data->eglGetProcAddress(
"eglGetPlatformDisplayEXT");
135 if (!eglGetPlatformDisplayEXT) {
136 return SDL_EGL_SetError(
"Could not retrieve ANGLE/WinRT display function(s)",
"eglGetProcAddress");
139#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP)
143 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
EGL_DEFAULT_DISPLAY, defaultDisplayAttributes);
144 if (!
_this->egl_data->egl_display) {
145 return SDL_EGL_SetError(
"Could not get EGL display for Direct3D 10_0+",
"eglGetPlatformDisplayEXT");
155 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes);
156 if (!
_this->egl_data->egl_display) {
157 return SDL_EGL_SetError(
"Could not get EGL display for Direct3D 9_3",
"eglGetPlatformDisplayEXT");
164 _this->egl_data->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,
EGL_DEFAULT_DISPLAY, warpDisplayAttributes);
165 if (!
_this->egl_data->egl_display) {
166 return SDL_EGL_SetError(
"Could not get EGL display for Direct3D WARP",
"eglGetPlatformDisplayEXT");
170 return SDL_EGL_SetError(
"Could not initialize WinRT 8.x+ EGL",
"eglInitialize");
180WINRT_GLES_UnloadLibrary(
_THIS)
191 SDL_EGL_UnloadLibrary(
_this);
195SDL_EGL_CreateContext_impl(WINRT)
196SDL_EGL_SwapWindow_impl(WINRT)
197SDL_EGL_MakeCurrent_impl(WINRT)
void * SDL_LoadFunction(void *handle, const char *name)
GLsizei const GLchar *const * path
static SDL_VideoDevice * _this
#define EGL_DEFAULT_DISPLAY
IUnknown * winrtEglWindow