src/video/winrt/SDL_winrtvideo.cpp
author David Ludwig
Sat, 22 Mar 2014 20:48:18 -0400
changeset 8663 308e74493106
parent 8621 5252788cb448
child 8664 565698ab1c40
permissions -rw-r--r--
WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.

SDL/WinRT did have support for OpenGL ES 2 via an older version of ANGLE/WinRT,
however its API changed a few months ago, and SDL/WinRT would crash when trying
to use it. It would also occasionally crash when using the older version.

This changeset should make SDL/WinRT work with the latest version, as
available via MS Open Tech's git repository of it at
https://github.com/msopentech/angle

Older versions of ANGLE/WinRT (from either https://github.com/stammen/angleproject
or https://bitbucket.org/DavidLudwig/angleproject) will need to be updated to
MS Open Tech's latest version.
dludwig@8327
     1
/*
dludwig@8327
     2
  Simple DirectMedia Layer
slouken@8615
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
dludwig@8327
     4
dludwig@8327
     5
  This software is provided 'as-is', without any express or implied
dludwig@8327
     6
  warranty.  In no event will the authors be held liable for any damages
dludwig@8327
     7
  arising from the use of this software.
dludwig@8327
     8
dludwig@8327
     9
  Permission is granted to anyone to use this software for any purpose,
dludwig@8327
    10
  including commercial applications, and to alter it and redistribute it
dludwig@8327
    11
  freely, subject to the following restrictions:
dludwig@8327
    12
dludwig@8327
    13
  1. The origin of this software must not be misrepresented; you must not
dludwig@8327
    14
     claim that you wrote the original software. If you use this software
dludwig@8327
    15
     in a product, an acknowledgment in the product documentation would be
dludwig@8327
    16
     appreciated but is not required.
dludwig@8327
    17
  2. Altered source versions must be plainly marked as such, and must not be
dludwig@8327
    18
     misrepresented as being the original software.
dludwig@8327
    19
  3. This notice may not be removed or altered from any source distribution.
dludwig@8327
    20
*/
dludwig@8600
    21
#include "../../SDL_internal.h"
dludwig@8327
    22
dludwig@8327
    23
#if SDL_VIDEO_DRIVER_WINRT
dludwig@8327
    24
dludwig@8327
    25
/* WinRT SDL video driver implementation
dludwig@8327
    26
dludwig@8327
    27
   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
dludwig@8327
    28
   was based off of SDL's "dummy" video driver.
dludwig@8327
    29
 */
dludwig@8327
    30
dludwig@8494
    31
/* Windows includes */
dludwig@8494
    32
#include <agile.h>
dludwig@8663
    33
#include <wrl/client.h>
dludwig@8494
    34
using namespace Windows::UI::Core;
dludwig@8494
    35
dludwig@8494
    36
dludwig@8494
    37
/* SDL includes */
dludwig@8329
    38
extern "C" {
dludwig@8327
    39
#include "SDL_video.h"
dludwig@8327
    40
#include "SDL_mouse.h"
dludwig@8327
    41
#include "../SDL_sysvideo.h"
dludwig@8327
    42
#include "../SDL_pixels_c.h"
dludwig@8327
    43
#include "../../events/SDL_events_c.h"
dludwig@8400
    44
#include "../../render/SDL_sysrender.h"
dludwig@8411
    45
#include "SDL_syswm.h"
dludwig@8541
    46
#include "SDL_winrtopengles.h"
dludwig@8329
    47
}
dludwig@8327
    48
dludwig@8522
    49
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
dludwig@8522
    50
#include "../../core/winrt/SDL_winrtapp_xaml.h"
dludwig@8512
    51
#include "SDL_winrtvideo_cpp.h"
dludwig@8327
    52
#include "SDL_winrtevents_c.h"
dludwig@8516
    53
#include "SDL_winrtmouse_c.h"
dludwig@8505
    54
#include "SDL_main.h"
dludwig@8505
    55
#include "SDL_system.h"
dludwig@8327
    56
dludwig@8327
    57
dludwig@8327
    58
/* Initialization/Query functions */
dludwig@8327
    59
static int WINRT_VideoInit(_THIS);
dludwig@8374
    60
static int WINRT_InitModes(_THIS);
dludwig@8327
    61
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
dludwig@8327
    62
static void WINRT_VideoQuit(_THIS);
dludwig@8327
    63
dludwig@8494
    64
dludwig@8333
    65
/* Window functions */
dludwig@8522
    66
static int WINRT_CreateWindow(_THIS, SDL_Window * window);
dludwig@8333
    67
static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
dludwig@8411
    68
static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
dludwig@8333
    69
dludwig@8494
    70
dludwig@8515
    71
/* SDL-internal globals: */
dludwig@8497
    72
SDL_Window * WINRT_GlobalSDLWindow = NULL;
dludwig@8498
    73
SDL_VideoDevice * WINRT_GlobalSDLVideoDevice = NULL;
dludwig@8498
    74
dludwig@8498
    75
dludwig@8327
    76
/* WinRT driver bootstrap functions */
dludwig@8327
    77
dludwig@8327
    78
static int
dludwig@8327
    79
WINRT_Available(void)
dludwig@8327
    80
{
dludwig@8328
    81
    return (1);
dludwig@8327
    82
}
dludwig@8327
    83
dludwig@8327
    84
static void
dludwig@8327
    85
WINRT_DeleteDevice(SDL_VideoDevice * device)
dludwig@8327
    86
{
dludwig@8498
    87
    if (device == WINRT_GlobalSDLVideoDevice) {
dludwig@8498
    88
        WINRT_GlobalSDLVideoDevice = NULL;
dludwig@8498
    89
    }
dludwig@8663
    90
dludwig@8663
    91
    if (device->driverdata) {
dludwig@8663
    92
        SDL_VideoData * video_data = (SDL_VideoData *)device->driverdata;
dludwig@8663
    93
        if (video_data->winrtEglWindow) {
dludwig@8663
    94
            video_data->winrtEglWindow->Release();
dludwig@8663
    95
        }
dludwig@8663
    96
        SDL_free(video_data);
dludwig@8663
    97
    }
dludwig@8663
    98
dludwig@8327
    99
    SDL_free(device);
dludwig@8327
   100
}
dludwig@8327
   101
dludwig@8327
   102
static SDL_VideoDevice *
dludwig@8327
   103
WINRT_CreateDevice(int devindex)
dludwig@8327
   104
{
dludwig@8327
   105
    SDL_VideoDevice *device;
dludwig@8663
   106
    SDL_VideoData *data;
dludwig@8327
   107
dludwig@8327
   108
    /* Initialize all variables that we clean on shutdown */
dludwig@8327
   109
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
dludwig@8327
   110
    if (!device) {
dludwig@8327
   111
        SDL_OutOfMemory();
dludwig@8327
   112
        if (device) {
dludwig@8327
   113
            SDL_free(device);
dludwig@8327
   114
        }
dludwig@8327
   115
        return (0);
dludwig@8327
   116
    }
dludwig@8327
   117
dludwig@8663
   118
    data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
dludwig@8663
   119
    if (!data) {
dludwig@8663
   120
        SDL_OutOfMemory();
dludwig@8663
   121
        return (0);
dludwig@8663
   122
    }
dludwig@8663
   123
    SDL_zerop(data);
dludwig@8663
   124
    device->driverdata = data;
dludwig@8663
   125
dludwig@8327
   126
    /* Set the function pointers */
dludwig@8327
   127
    device->VideoInit = WINRT_VideoInit;
dludwig@8327
   128
    device->VideoQuit = WINRT_VideoQuit;
dludwig@8333
   129
    device->CreateWindow = WINRT_CreateWindow;
dludwig@8333
   130
    device->DestroyWindow = WINRT_DestroyWindow;
dludwig@8327
   131
    device->SetDisplayMode = WINRT_SetDisplayMode;
dludwig@8327
   132
    device->PumpEvents = WINRT_PumpEvents;
dludwig@8411
   133
    device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
dludwig@8541
   134
#ifdef SDL_VIDEO_OPENGL_EGL
slouken@8582
   135
    device->GL_LoadLibrary = WINRT_GLES_LoadLibrary;
slouken@8582
   136
    device->GL_GetProcAddress = WINRT_GLES_GetProcAddress;
slouken@8582
   137
    device->GL_UnloadLibrary = WINRT_GLES_UnloadLibrary;
slouken@8582
   138
    device->GL_CreateContext = WINRT_GLES_CreateContext;
slouken@8582
   139
    device->GL_MakeCurrent = WINRT_GLES_MakeCurrent;
slouken@8582
   140
    device->GL_SetSwapInterval = WINRT_GLES_SetSwapInterval;
slouken@8582
   141
    device->GL_GetSwapInterval = WINRT_GLES_GetSwapInterval;
slouken@8582
   142
    device->GL_SwapWindow = WINRT_GLES_SwapWindow;
dludwig@8541
   143
    device->GL_DeleteContext = WINRT_GLES_DeleteContext;
dludwig@8541
   144
#endif
dludwig@8433
   145
    device->free = WINRT_DeleteDevice;
dludwig@8501
   146
    WINRT_GlobalSDLVideoDevice = device;
dludwig@8327
   147
dludwig@8327
   148
    return device;
dludwig@8327
   149
}
dludwig@8327
   150
dludwig@8494
   151
#define WINRTVID_DRIVER_NAME "winrt"
dludwig@8327
   152
VideoBootStrap WINRT_bootstrap = {
dludwig@8500
   153
    WINRTVID_DRIVER_NAME, "SDL WinRT video driver",
dludwig@8327
   154
    WINRT_Available, WINRT_CreateDevice
dludwig@8327
   155
};
dludwig@8327
   156
dludwig@8327
   157
int
dludwig@8327
   158
WINRT_VideoInit(_THIS)
dludwig@8327
   159
{
dludwig@8374
   160
    if (WINRT_InitModes(_this) < 0) {
dludwig@8374
   161
        return -1;
dludwig@8374
   162
    }
dludwig@8374
   163
    WINRT_InitMouse(_this);
dludwig@8515
   164
    WINRT_InitTouch(_this);
dludwig@8522
   165
dludwig@8374
   166
    return 0;
dludwig@8374
   167
}
dludwig@8374
   168
dludwig@8578
   169
int
dludwig@8578
   170
WINRT_CalcDisplayModeUsingNativeWindow(SDL_DisplayMode * mode)
dludwig@8522
   171
{
dludwig@8578
   172
    SDL_DisplayModeData * driverdata;
dludwig@8578
   173
dludwig@8522
   174
    using namespace Windows::Graphics::Display;
dludwig@8522
   175
dludwig@8522
   176
    // Go no further if a native window cannot be accessed.  This can happen,
dludwig@8522
   177
    // for example, if this function is called from certain threads, such as
dludwig@8522
   178
    // the SDL/XAML thread.
dludwig@8522
   179
    if (!CoreWindow::GetForCurrentThread()) {
dludwig@8578
   180
        return SDL_SetError("SDL/WinRT display modes cannot be calculated outside of the main thread, such as in SDL's XAML thread");
dludwig@8522
   181
    }
dludwig@8522
   182
dludwig@8579
   183
    // Calculate the display size given the window size, taking into account
dludwig@8579
   184
    // the current display's DPI:
dludwig@8621
   185
#if NTDDI_VERSION > NTDDI_WIN8
dludwig@8621
   186
    const float currentDPI = DisplayInformation::GetForCurrentView()->LogicalDpi;
dludwig@8621
   187
#else
dludwig@8621
   188
    const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
dludwig@8621
   189
#endif
dludwig@8579
   190
    const float dipsPerInch = 96.0f;
dludwig@8579
   191
    const int w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
dludwig@8579
   192
    const int h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
dludwig@8579
   193
    if (w == 0 || w == h) {
dludwig@8579
   194
        return SDL_SetError("Unable to calculate the WinRT window/display's size");
dludwig@8579
   195
    }
dludwig@8579
   196
dludwig@8578
   197
    // Create a driverdata field:
dludwig@8578
   198
    driverdata = (SDL_DisplayModeData *) SDL_malloc(sizeof(*driverdata));
dludwig@8578
   199
    if (!driverdata) {
dludwig@8578
   200
        return SDL_OutOfMemory();
dludwig@8578
   201
    }
dludwig@8578
   202
    SDL_zerop(driverdata);
dludwig@8578
   203
dludwig@8522
   204
    // Fill in most fields:
dludwig@8579
   205
    SDL_zerop(mode);
dludwig@8578
   206
    mode->format = SDL_PIXELFORMAT_RGB888;
dludwig@8578
   207
    mode->refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
dludwig@8579
   208
    mode->w = w;
dludwig@8579
   209
    mode->h = h;
dludwig@8578
   210
    mode->driverdata = driverdata;
dludwig@8621
   211
#if NTDDI_VERSION > NTDDI_WIN8
dludwig@8621
   212
    driverdata->currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
dludwig@8621
   213
#else
dludwig@8578
   214
    driverdata->currentOrientation = DisplayProperties::CurrentOrientation;
dludwig@8621
   215
#endif
dludwig@8522
   216
dludwig@8522
   217
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
dludwig@8522
   218
    // On Windows Phone, the native window's size is always in portrait,
dludwig@8522
   219
    // regardless of the device's orientation.  This is in contrast to
dludwig@8522
   220
    // Windows 8/RT, which will resize the native window as the device's
dludwig@8522
   221
    // orientation changes.  In order to compensate for this behavior,
dludwig@8522
   222
    // on Windows Phone, the mode's width and height will be swapped when
dludwig@8522
   223
    // the device is in a landscape (non-portrait) mode.
dludwig@8522
   224
    switch (DisplayProperties::CurrentOrientation) {
dludwig@8522
   225
        case DisplayOrientations::Landscape:
dludwig@8522
   226
        case DisplayOrientations::LandscapeFlipped:
dludwig@8522
   227
        {
dludwig@8578
   228
            const int tmp = mode->h;
dludwig@8578
   229
            mode->h = mode->w;
dludwig@8578
   230
            mode->w = tmp;
dludwig@8522
   231
            break;
dludwig@8522
   232
        }
dludwig@8522
   233
dludwig@8522
   234
        default:
dludwig@8522
   235
            break;
dludwig@8522
   236
    }
dludwig@8522
   237
#endif
dludwig@8522
   238
dludwig@8578
   239
    return 0;
dludwig@8578
   240
}
dludwig@8578
   241
dludwig@8578
   242
int
dludwig@8578
   243
WINRT_DuplicateDisplayMode(SDL_DisplayMode * dest, const SDL_DisplayMode * src)
dludwig@8578
   244
{
dludwig@8578
   245
    SDL_DisplayModeData * driverdata;
dludwig@8578
   246
    driverdata = (SDL_DisplayModeData *) SDL_malloc(sizeof(*driverdata));
dludwig@8578
   247
    if (!driverdata) {
dludwig@8578
   248
        return SDL_OutOfMemory();
dludwig@8578
   249
    }
dludwig@8578
   250
    SDL_memcpy(driverdata, src->driverdata, sizeof(SDL_DisplayModeData));
dludwig@8578
   251
    SDL_memcpy(dest, src, sizeof(SDL_DisplayMode));
dludwig@8578
   252
    dest->driverdata = driverdata;
dludwig@8578
   253
    return 0;
dludwig@8522
   254
}
dludwig@8503
   255
dludwig@8505
   256
int
dludwig@8374
   257
WINRT_InitModes(_THIS)
dludwig@8374
   258
{
dludwig@8505
   259
    // Retrieve the display mode:
dludwig@8578
   260
    SDL_DisplayMode mode, desktop_mode;
dludwig@8578
   261
    if (WINRT_CalcDisplayModeUsingNativeWindow(&mode) != 0) {
dludwig@8578
   262
        return -1;	// If WINRT_CalcDisplayModeUsingNativeWindow fails, it'll already have set the SDL error
dludwig@8578
   263
    }
dludwig@8522
   264
dludwig@8578
   265
    if (WINRT_DuplicateDisplayMode(&desktop_mode, &mode) != 0) {
dludwig@8578
   266
        return -1;
dludwig@8578
   267
    }
dludwig@8578
   268
    if (SDL_AddBasicVideoDisplay(&desktop_mode) < 0) {
dludwig@8522
   269
        return -1;
dludwig@8374
   270
    }
dludwig@8374
   271
dludwig@8374
   272
    SDL_AddDisplayMode(&_this->displays[0], &mode);
dludwig@8327
   273
    return 0;
dludwig@8327
   274
}
dludwig@8327
   275
dludwig@8327
   276
static int
dludwig@8327
   277
WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
dludwig@8327
   278
{
dludwig@8327
   279
    return 0;
dludwig@8327
   280
}
dludwig@8327
   281
dludwig@8327
   282
void
dludwig@8327
   283
WINRT_VideoQuit(_THIS)
dludwig@8327
   284
{
dludwig@8374
   285
    WINRT_QuitMouse(_this);
dludwig@8327
   286
}
dludwig@8327
   287
dludwig@8522
   288
int
dludwig@8522
   289
WINRT_CreateWindow(_THIS, SDL_Window * window)
dludwig@8522
   290
{
dludwig@8522
   291
    // Make sure that only one window gets created, at least until multimonitor
dludwig@8522
   292
    // support is added.
dludwig@8522
   293
    if (WINRT_GlobalSDLWindow != NULL) {
dludwig@8522
   294
        SDL_SetError("WinRT only supports one window");
dludwig@8522
   295
        return -1;
dludwig@8522
   296
    }
dludwig@8522
   297
dludwig@8522
   298
    SDL_WindowData *data = new SDL_WindowData;
dludwig@8522
   299
    if (!data) {
dludwig@8522
   300
        SDL_OutOfMemory();
dludwig@8522
   301
        return -1;
dludwig@8522
   302
    }
dludwig@8522
   303
    window->driverdata = data;
dludwig@8522
   304
    data->sdlWindow = window;
dludwig@8522
   305
dludwig@8522
   306
    /* To note, when XAML support is enabled, access to the CoreWindow will not
dludwig@8522
   307
       be possible, at least not via the SDL/XAML thread.  Attempts to access it
dludwig@8522
   308
       from there will throw exceptions.  As such, the SDL_WindowData's
dludwig@8522
   309
       'coreWindow' field will only be set (to a non-null value) if XAML isn't
dludwig@8522
   310
       enabled.
dludwig@8522
   311
    */
dludwig@8522
   312
    if (!WINRT_XAMLWasEnabled) {
dludwig@8522
   313
        data->coreWindow = CoreWindow::GetForCurrentThread();
dludwig@8522
   314
    }
dludwig@8522
   315
dludwig@8541
   316
#if SDL_VIDEO_OPENGL_EGL
dludwig@8541
   317
    /* Setup the EGL surface, but only if OpenGL ES 2 was requested. */
dludwig@8541
   318
    if (!(window->flags & SDL_WINDOW_OPENGL)) {
dludwig@8541
   319
        /* OpenGL ES 2 wasn't requested.  Don't set up an EGL surface. */
dludwig@8541
   320
        data->egl_surface = EGL_NO_SURFACE;
dludwig@8541
   321
    } else {
dludwig@8541
   322
        /* OpenGL ES 2 was reuqested.  Set up an EGL surface. */
dludwig@8663
   323
        SDL_VideoData * video_data = (SDL_VideoData *)_this->driverdata;
dludwig@8572
   324
dludwig@8663
   325
        /* Call SDL_EGL_ChooseConfig and eglCreateWindowSurface directly,
dludwig@8663
   326
         * rather than via SDL_EGL_CreateSurface, as ANGLE/WinRT requires
dludwig@8663
   327
         * a C++ object, ComPtr<IUnknown>, to be passed into
dludwig@8663
   328
         * eglCreateWindowSurface.
dludwig@8572
   329
         */
dludwig@8663
   330
        if (SDL_EGL_ChooseConfig(_this) != 0) {
dludwig@8663
   331
            char buf[512];
dludwig@8663
   332
            SDL_snprintf(buf, sizeof(buf), "SDL_EGL_ChooseConfig failed: %s", SDL_GetError());
dludwig@8663
   333
            return SDL_SetError(buf);
dludwig@8663
   334
        }
dludwig@8572
   335
dludwig@8663
   336
        Microsoft::WRL::ComPtr<IUnknown> cpp_winrtEglWindow = video_data->winrtEglWindow;
dludwig@8663
   337
        data->egl_surface = ((eglCreateWindowSurface_Function)_this->egl_data->eglCreateWindowSurface)(
dludwig@8572
   338
            _this->egl_data->egl_display,
dludwig@8572
   339
            _this->egl_data->egl_config,
dludwig@8663
   340
            cpp_winrtEglWindow, NULL);
dludwig@8541
   341
        if (data->egl_surface == NULL) {
dludwig@8574
   342
            return SDL_SetError("eglCreateWindowSurface failed");
dludwig@8541
   343
        }
dludwig@8541
   344
    }
dludwig@8541
   345
#endif
dludwig@8541
   346
dludwig@8522
   347
    /* Make sure the window is considered to be positioned at {0,0},
dludwig@8522
   348
       and is considered fullscreen, shown, and the like.
dludwig@8522
   349
    */
dludwig@8522
   350
    window->x = 0;
dludwig@8522
   351
    window->y = 0;
dludwig@8522
   352
    window->flags =
dludwig@8522
   353
        SDL_WINDOW_FULLSCREEN |
dludwig@8522
   354
        SDL_WINDOW_SHOWN |
dludwig@8522
   355
        SDL_WINDOW_BORDERLESS |
dludwig@8522
   356
        SDL_WINDOW_MAXIMIZED |
dludwig@8522
   357
        SDL_WINDOW_INPUT_GRABBED;
dludwig@8522
   358
dludwig@8541
   359
#if SDL_VIDEO_OPENGL_EGL
dludwig@8541
   360
    if (data->egl_surface) {
dludwig@8541
   361
        window->flags |= SDL_WINDOW_OPENGL;
dludwig@8541
   362
    }
dludwig@8541
   363
#endif
dludwig@8541
   364
dludwig@8522
   365
    /* WinRT does not, as of this writing, appear to support app-adjustable
dludwig@8522
   366
       window sizes.  Set the window size to whatever the native WinRT
dludwig@8522
   367
       CoreWindow is set at.
dludwig@8522
   368
dludwig@8522
   369
       TODO, WinRT: if and when non-fullscreen XAML control support is added to SDL, consider making those resizable via SDL_Window's interfaces.
dludwig@8522
   370
    */
dludwig@8522
   371
    window->w = _this->displays[0].current_mode.w;
dludwig@8522
   372
    window->h = _this->displays[0].current_mode.h;
dludwig@8551
   373
dludwig@8551
   374
    /* For now, treat WinRT apps as if they always have focus.
dludwig@8551
   375
       TODO, WinRT: try tracking keyboard and mouse focus state with respect to snapped apps
dludwig@8551
   376
     */
slouken@8582
   377
    SDL_SetMouseFocus(window);
dludwig@8551
   378
    SDL_SetKeyboardFocus(window);
dludwig@8522
   379
 
dludwig@8522
   380
    /* Make sure the WinRT app's IFramworkView can post events on
dludwig@8522
   381
       behalf of SDL:
dludwig@8522
   382
    */
dludwig@8522
   383
    WINRT_GlobalSDLWindow = window;
dludwig@8522
   384
dludwig@8522
   385
    /* All done! */
dludwig@8522
   386
    return 0;
dludwig@8522
   387
}
dludwig@8522
   388
dludwig@8333
   389
void
dludwig@8333
   390
WINRT_DestroyWindow(_THIS, SDL_Window * window)
dludwig@8333
   391
{
dludwig@8411
   392
    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
dludwig@8411
   393
dludwig@8497
   394
    if (WINRT_GlobalSDLWindow == window) {
dludwig@8497
   395
        WINRT_GlobalSDLWindow = NULL;
dludwig@8424
   396
    }
dludwig@8424
   397
dludwig@8411
   398
    if (data) {
dludwig@8411
   399
        // Delete the internal window data:
dludwig@8411
   400
        delete data;
dludwig@8411
   401
        data = NULL;
dludwig@8411
   402
    }
dludwig@8333
   403
}
dludwig@8333
   404
dludwig@8522
   405
SDL_bool
dludwig@8522
   406
WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
dludwig@8522
   407
{
dludwig@8522
   408
    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
dludwig@8522
   409
dludwig@8522
   410
    if (info->version.major <= SDL_MAJOR_VERSION) {
dludwig@8522
   411
        info->subsystem = SDL_SYSWM_WINRT;
dludwig@8527
   412
        info->info.winrt.window = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
dludwig@8522
   413
        return SDL_TRUE;
dludwig@8522
   414
    } else {
dludwig@8522
   415
        SDL_SetError("Application not compiled with SDL %d.%d\n",
dludwig@8522
   416
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
dludwig@8522
   417
        return SDL_FALSE;
dludwig@8522
   418
    }
dludwig@8522
   419
    return SDL_FALSE;
dludwig@8411
   420
}
dludwig@8333
   421
dludwig@8327
   422
#endif /* SDL_VIDEO_DRIVER_WINRT */
dludwig@8327
   423
dludwig@8327
   424
/* vi: set ts=4 sw=4 expandtab: */