src/video/winrt/SDL_winrtvideo.cpp
author David Ludwig <dludwig@pobox.com>
Sun, 06 Dec 2015 18:42:30 -0500
changeset 9951 839a45509496
parent 9950 6cc7e0682758
child 9952 54b2eeb48c7d
permissions -rw-r--r--
WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.0 apps
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     1
/*
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     2
  Simple DirectMedia Layer
9619
b94b6d0bff0f Updated the copyright year to 2015
Sam Lantinga <slouken@libsdl.org>
parents: 9557
diff changeset
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     4
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     7
  arising from the use of this software.
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     8
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    12
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    16
     appreciated but is not required.
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    18
     misrepresented as being the original software.
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    20
*/
8600
092802455aed build fixes for most WinRT-related files
David Ludwig <dludwig@pobox.com>
parents: 8582
diff changeset
    21
#include "../../SDL_internal.h"
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    22
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    23
#if SDL_VIDEO_DRIVER_WINRT
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    24
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    25
/* WinRT SDL video driver implementation
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    26
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    27
   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    28
   was based off of SDL's "dummy" video driver.
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    29
 */
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    30
8494
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    31
/* Windows includes */
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    32
#include <agile.h>
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    33
#include <windows.graphics.display.h>
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    34
#include <dxgi.h>
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    35
#include <dxgi1_2.h>
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    36
using namespace Windows::ApplicationModel::Core;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    37
using namespace Windows::Foundation;
9925
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
    38
using namespace Windows::Graphics::Display;
8494
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    39
using namespace Windows::UI::Core;
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    40
using namespace Windows::UI::ViewManagement;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    41
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    42
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    43
/* [re]declare Windows GUIDs locally, to limit the amount of external lib(s) SDL has to link to */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    44
static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48,{ 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
8494
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    45
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    46
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    47
/* SDL includes */
8329
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8328
diff changeset
    48
extern "C" {
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    49
#include "SDL_video.h"
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    50
#include "SDL_mouse.h"
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    51
#include "../SDL_sysvideo.h"
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    52
#include "../SDL_pixels_c.h"
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    53
#include "../../events/SDL_events_c.h"
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8374
diff changeset
    54
#include "../../render/SDL_sysrender.h"
8411
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
    55
#include "SDL_syswm.h"
8541
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
    56
#include "SDL_winrtopengles.h"
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
    57
#include "../../core/windows/SDL_windows.h"
8329
c3047b88e35b WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
David Ludwig <dludwig@pobox.com>
parents: 8328
diff changeset
    58
}
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    59
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
    60
#include "../../core/winrt/SDL_winrtapp_direct3d.h"
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
    61
#include "../../core/winrt/SDL_winrtapp_xaml.h"
8512
5b345a756965 WinRT: corrected SDL_MOUSE* coordinates in non-Portrait modes
David Ludwig <dludwig@pobox.com>
parents: 8510
diff changeset
    62
#include "SDL_winrtvideo_cpp.h"
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    63
#include "SDL_winrtevents_c.h"
8516
f3e0e381bdcd WinRT: renamed a mouse-related header file for naming-consistency's sake
David Ludwig <dludwig@pobox.com>
parents: 8515
diff changeset
    64
#include "SDL_winrtmouse_c.h"
8505
a76a3842c9eb WinRT: experimental and preliminary support for XAML-based overlays on Windows 8/RT
David Ludwig <dludwig@pobox.com>
parents: 8503
diff changeset
    65
#include "SDL_main.h"
a76a3842c9eb WinRT: experimental and preliminary support for XAML-based overlays on Windows 8/RT
David Ludwig <dludwig@pobox.com>
parents: 8503
diff changeset
    66
#include "SDL_system.h"
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8747
diff changeset
    67
//#include "SDL_log.h"
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    68
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    69
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    70
/* Initialization/Query functions */
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    71
static int WINRT_VideoInit(_THIS);
8374
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
    72
static int WINRT_InitModes(_THIS);
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    73
static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    74
static void WINRT_VideoQuit(_THIS);
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    75
8494
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    76
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
    77
/* Window functions */
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
    78
static int WINRT_CreateWindow(_THIS, SDL_Window * window);
9931
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
    79
static void WINRT_SetWindowSize(_THIS, SDL_Window * window);
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
    80
static void WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
    81
static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
8411
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
    82
static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
    83
8494
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
    84
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents: 8512
diff changeset
    85
/* SDL-internal globals: */
8497
103bb054aa7d WinRT: moved the pointer to the global SDL_Window to a separate variable
David Ludwig <dludwig@pobox.com>
parents: 8496
diff changeset
    86
SDL_Window * WINRT_GlobalSDLWindow = NULL;
8498
333ae9a0f411 WinRT: moved the WinRT SDL_VideoDevice out of SDL_WinRTApp
David Ludwig <dludwig@pobox.com>
parents: 8497
diff changeset
    87
333ae9a0f411 WinRT: moved the WinRT SDL_VideoDevice out of SDL_WinRTApp
David Ludwig <dludwig@pobox.com>
parents: 8497
diff changeset
    88
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    89
/* WinRT driver bootstrap functions */
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    90
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    91
static int
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    92
WINRT_Available(void)
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    93
{
8328
88b08ad81bf7 WinRT: made the WinRT video driver always be initialize-able
David Ludwig <dludwig@pobox.com>
parents: 8327
diff changeset
    94
    return (1);
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    95
}
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    96
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    97
static void
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    98
WINRT_DeleteDevice(SDL_VideoDevice * device)
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    99
{
8663
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   100
    if (device->driverdata) {
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   101
        SDL_VideoData * video_data = (SDL_VideoData *)device->driverdata;
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   102
        if (video_data->winrtEglWindow) {
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   103
            video_data->winrtEglWindow->Release();
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   104
        }
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   105
        SDL_free(video_data);
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   106
    }
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   107
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   108
    SDL_free(device);
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   109
}
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   110
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   111
static SDL_VideoDevice *
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   112
WINRT_CreateDevice(int devindex)
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   113
{
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   114
    SDL_VideoDevice *device;
8663
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   115
    SDL_VideoData *data;
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   116
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   117
    /* Initialize all variables that we clean on shutdown */
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   118
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   119
    if (!device) {
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   120
        SDL_OutOfMemory();
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   121
        if (device) {
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   122
            SDL_free(device);
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   123
        }
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   124
        return (0);
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   125
    }
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   126
8663
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   127
    data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   128
    if (!data) {
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   129
        SDL_OutOfMemory();
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   130
        return (0);
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   131
    }
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   132
    SDL_zerop(data);
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   133
    device->driverdata = data;
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   134
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   135
    /* Set the function pointers */
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   136
    device->VideoInit = WINRT_VideoInit;
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   137
    device->VideoQuit = WINRT_VideoQuit;
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   138
    device->CreateWindow = WINRT_CreateWindow;
9931
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   139
    device->SetWindowSize = WINRT_SetWindowSize;
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   140
    device->SetWindowFullscreen = WINRT_SetWindowFullscreen;
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   141
    device->DestroyWindow = WINRT_DestroyWindow;
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   142
    device->SetDisplayMode = WINRT_SetDisplayMode;
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   143
    device->PumpEvents = WINRT_PumpEvents;
8411
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   144
    device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
8541
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   145
#ifdef SDL_VIDEO_OPENGL_EGL
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   146
    device->GL_LoadLibrary = WINRT_GLES_LoadLibrary;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   147
    device->GL_GetProcAddress = WINRT_GLES_GetProcAddress;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   148
    device->GL_UnloadLibrary = WINRT_GLES_UnloadLibrary;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   149
    device->GL_CreateContext = WINRT_GLES_CreateContext;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   150
    device->GL_MakeCurrent = WINRT_GLES_MakeCurrent;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   151
    device->GL_SetSwapInterval = WINRT_GLES_SetSwapInterval;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   152
    device->GL_GetSwapInterval = WINRT_GLES_GetSwapInterval;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8579
diff changeset
   153
    device->GL_SwapWindow = WINRT_GLES_SwapWindow;
8541
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   154
    device->GL_DeleteContext = WINRT_GLES_DeleteContext;
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   155
#endif
8433
3017f87e4479 WinRT: bug fixes for device orientation + Direct3D 11.1 rendering
David Ludwig <dludwig@pobox.com>
parents: 8424
diff changeset
   156
    device->free = WINRT_DeleteDevice;
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   157
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   158
    return device;
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   159
}
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   160
8494
5d165785918d WinRT: misc code cleanups
David Ludwig <dludwig@pobox.com>
parents: 8492
diff changeset
   161
#define WINRTVID_DRIVER_NAME "winrt"
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   162
VideoBootStrap WINRT_bootstrap = {
8500
f25ef28d61e8 WinRT: more "Windows RT" to "WinRT" renaming
David Ludwig <dludwig@pobox.com>
parents: 8499
diff changeset
   163
    WINRTVID_DRIVER_NAME, "SDL WinRT video driver",
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   164
    WINRT_Available, WINRT_CreateDevice
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   165
};
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   166
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   167
int
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   168
WINRT_VideoInit(_THIS)
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   169
{
8374
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   170
    if (WINRT_InitModes(_this) < 0) {
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   171
        return -1;
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   172
    }
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   173
    WINRT_InitMouse(_this);
8515
bc6cf9201dab WinRT: misc code cleanups regarding touch and mouse events, and also SDL-internal globals
David Ludwig <dludwig@pobox.com>
parents: 8512
diff changeset
   174
    WINRT_InitTouch(_this);
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   175
8374
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   176
    return 0;
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   177
}
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   178
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   179
extern "C"
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   180
Uint32 D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   181
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   182
static void
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   183
WINRT_DXGIModeToSDLDisplayMode(const DXGI_MODE_DESC * dxgiMode, SDL_DisplayMode * sdlMode)
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   184
{
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   185
    SDL_zerop(sdlMode);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   186
    sdlMode->w = dxgiMode->Width;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   187
    sdlMode->h = dxgiMode->Height;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   188
    sdlMode->refresh_rate = dxgiMode->RefreshRate.Numerator / dxgiMode->RefreshRate.Denominator;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   189
    sdlMode->format = D3D11_DXGIFormatToSDLPixelFormat(dxgiMode->Format);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   190
}
8578
6517b6aca713 WinRT: fixed a crash in SDL_Quit
David Ludwig <dludwig@pobox.com>
parents: 8574
diff changeset
   191
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   192
static int
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   193
WINRT_AddDisplaysForOutput (_THIS, IDXGIAdapter1 * dxgiAdapter1, int outputIndex)
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   194
{
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   195
    HRESULT hr;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   196
    IDXGIOutput * dxgiOutput = NULL;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   197
    DXGI_OUTPUT_DESC dxgiOutputDesc;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   198
    SDL_VideoDisplay display;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   199
    char * displayName = NULL;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   200
    UINT numModes;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   201
    DXGI_MODE_DESC * dxgiModes = NULL;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   202
    int functionResult = -1;        /* -1 for failure, 0 for success */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   203
    DXGI_MODE_DESC modeToMatch, closestMatch;
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   204
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   205
    SDL_zero(display);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   206
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   207
    hr = dxgiAdapter1->EnumOutputs(outputIndex, &dxgiOutput);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   208
    if (FAILED(hr)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   209
        if (hr != DXGI_ERROR_NOT_FOUND) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   210
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIAdapter1::EnumOutputs failed", hr);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   211
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   212
        goto done;
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   213
    }
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   214
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   215
    hr = dxgiOutput->GetDesc(&dxgiOutputDesc);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   216
    if (FAILED(hr)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   217
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::GetDesc failed", hr);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   218
        goto done;
8579
ee7126c459d0 WinRT: cleaned up some hard-to-read SDL_DisplayMode management code
David Ludwig <dludwig@pobox.com>
parents: 8578
diff changeset
   219
    }
ee7126c459d0 WinRT: cleaned up some hard-to-read SDL_DisplayMode management code
David Ludwig <dludwig@pobox.com>
parents: 8578
diff changeset
   220
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   221
    SDL_zero(modeToMatch);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   222
    modeToMatch.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   223
    modeToMatch.Width = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   224
    modeToMatch.Height = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   225
    hr = dxgiOutput->FindClosestMatchingMode(&modeToMatch, &closestMatch, NULL);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   226
    if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   227
        /* DXGI_ERROR_NOT_CURRENTLY_AVAILABLE gets returned by IDXGIOutput::FindClosestMatchingMode
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   228
           when running under the Windows Simulator, which uses Remote Desktop (formerly known as Terminal
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   229
           Services) under the hood.  According to the MSDN docs for the similar function,
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   230
           IDXGIOutput::GetDisplayModeList, DXGI_ERROR_NOT_CURRENTLY_AVAILABLE is returned if and
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   231
           when an app is run under a Terminal Services session, hence the assumption.
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   232
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   233
           In this case, just add an SDL display mode, with approximated values.
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   234
        */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   235
        SDL_DisplayMode mode;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   236
        SDL_zero(mode);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   237
        display.name = "Windows Simulator / Terminal Services Display";
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   238
        mode.w = (dxgiOutputDesc.DesktopCoordinates.right - dxgiOutputDesc.DesktopCoordinates.left);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   239
        mode.h = (dxgiOutputDesc.DesktopCoordinates.bottom - dxgiOutputDesc.DesktopCoordinates.top);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   240
        mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   241
        mode.refresh_rate = 0;  /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   242
        display.desktop_mode = mode;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   243
        display.current_mode = mode;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   244
        if ( ! SDL_AddDisplayMode(&display, &mode)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   245
            goto done;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   246
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   247
    } else if (FAILED(hr)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   248
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::FindClosestMatchingMode failed", hr);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   249
        goto done;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   250
    } else {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   251
        displayName = WIN_StringToUTF8(dxgiOutputDesc.DeviceName);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   252
        display.name = displayName;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   253
        WINRT_DXGIModeToSDLDisplayMode(&closestMatch, &display.desktop_mode);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   254
        display.current_mode = display.desktop_mode;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   255
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   256
        hr = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, NULL);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   257
        if (FAILED(hr)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   258
            if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   259
                // TODO, WinRT: make sure display mode(s) are added when using Terminal Services / Windows Simulator
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   260
            }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   261
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::GetDisplayModeList [get mode list size] failed", hr);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   262
            goto done;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   263
        }
8578
6517b6aca713 WinRT: fixed a crash in SDL_Quit
David Ludwig <dludwig@pobox.com>
parents: 8574
diff changeset
   264
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   265
        dxgiModes = (DXGI_MODE_DESC *)SDL_calloc(numModes, sizeof(DXGI_MODE_DESC));
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   266
        if ( ! dxgiModes) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   267
            SDL_OutOfMemory();
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   268
            goto done;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   269
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   270
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   271
        hr = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, dxgiModes);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   272
        if (FAILED(hr)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   273
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::GetDisplayModeList [get mode contents] failed", hr);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   274
            goto done;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   275
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   276
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   277
        for (UINT i = 0; i < numModes; ++i) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   278
            SDL_DisplayMode sdlMode;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   279
            WINRT_DXGIModeToSDLDisplayMode(&dxgiModes[i], &sdlMode);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   280
            SDL_AddDisplayMode(&display, &sdlMode);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   281
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   282
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   283
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   284
    if (SDL_AddVideoDisplay(&display) < 0) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   285
        goto done;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   286
    }
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   287
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   288
    functionResult = 0;     /* 0 for Success! */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   289
done:
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   290
    if (dxgiModes) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   291
        SDL_free(dxgiModes);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   292
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   293
    if (dxgiOutput) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   294
        dxgiOutput->Release();
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   295
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   296
    if (displayName) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   297
        SDL_free(displayName);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   298
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   299
    return functionResult;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   300
}
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   301
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   302
static int
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   303
WINRT_AddDisplaysForAdapter (_THIS, IDXGIFactory2 * dxgiFactory2, int adapterIndex)
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   304
{
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   305
    HRESULT hr;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   306
    IDXGIAdapter1 * dxgiAdapter1;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   307
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   308
    hr = dxgiFactory2->EnumAdapters1(adapterIndex, &dxgiAdapter1);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   309
    if (FAILED(hr)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   310
        if (hr != DXGI_ERROR_NOT_FOUND) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   311
            WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory1::EnumAdapters1() failed", hr);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   312
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   313
        return -1;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   314
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   315
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   316
    for (int outputIndex = 0; ; ++outputIndex) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   317
        if (WINRT_AddDisplaysForOutput(_this, dxgiAdapter1, outputIndex) < 0) {
9947
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   318
            /* HACK: The Windows App Certification Kit 10.0 can fail, when
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   319
               running the Store Apps' test, "Direct3D Feature Test".  The
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   320
               certification kit's error is:
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   321
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   322
               "Application App was not running at the end of the test. It likely crashed or was terminated for having become unresponsive."
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   323
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   324
               This was caused by SDL/WinRT's DXGI failing to report any
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   325
               outputs.  Attempts to get the 1st display-output from the
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   326
               1st display-adapter can fail, with IDXGIAdapter::EnumOutputs
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   327
               returning DXGI_ERROR_NOT_FOUND.  This could be a bug in Windows,
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   328
               the Windows App Certification Kit, or possibly in SDL/WinRT's
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   329
               display detection code.  Either way, try to detect when this
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   330
               happens, and use a hackish means to create a reasonable-as-possible
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   331
               'display mode'.  -- DavidL
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   332
            */
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   333
            if (adapterIndex == 0 && outputIndex == 0) {
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   334
                SDL_VideoDisplay display;
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   335
                SDL_DisplayMode mode;
9951
839a45509496 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.0 apps
David Ludwig <dludwig@pobox.com>
parents: 9950
diff changeset
   336
#if (NTDDI_VERSION >= NTDDI_WIN10) || (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
9947
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   337
                ApplicationView ^ appView = ApplicationView::GetForCurrentView();
9951
839a45509496 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.0 apps
David Ludwig <dludwig@pobox.com>
parents: 9950
diff changeset
   338
#else
9950
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   339
                CoreWindow ^ coreWin = CoreWindow::GetForCurrentThread();
9951
839a45509496 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.0 apps
David Ludwig <dludwig@pobox.com>
parents: 9950
diff changeset
   340
#endif
9947
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   341
                SDL_zero(display);
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   342
                SDL_zero(mode);
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   343
                display.name = "DXGI Display-detection Workaround";
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   344
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   345
                /* HACK: ApplicationView's VisibleBounds property, appeared, via testing, to
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   346
                   give a better approximation of display-size, than did CoreWindow's
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   347
                   Bounds property, insofar that ApplicationView::VisibleBounds seems like
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   348
                   it will, at least some of the time, give the full display size (during the
9950
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   349
                   failing test), whereas CoreWindow might not.  -- DavidL
9947
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   350
                */
9950
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   351
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   352
#if (NTDDI_VERSION >= NTDDI_WIN10) || (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
9947
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   353
                mode.w = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Width);
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   354
                mode.h = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Height);
9950
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   355
#else
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   356
                /* On platform(s) that do not support VisibleBounds, such as Windows 8.1,
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   357
                   fall back to CoreWindow's Bounds property.
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   358
                */
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   359
                mode.w = WINRT_DIPS_TO_PHYSICAL_PIXELS(coreWin->Bounds.Width);
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   360
                mode.h = WINRT_DIPS_TO_PHYSICAL_PIXELS(coreWin->Bounds.Height);
6cc7e0682758 WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
David Ludwig <dludwig@pobox.com>
parents: 9949
diff changeset
   361
#endif
9947
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   362
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   363
                mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   364
                mode.refresh_rate = 0;  /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   365
                display.desktop_mode = mode;
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   366
                display.current_mode = mode;
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   367
                if ((SDL_AddDisplayMode(&display, &mode) < 0) ||
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   368
                    (SDL_AddVideoDisplay(&display) < 0))
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   369
                {
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   370
                    return SDL_SetError("Failed to apply DXGI Display-detection workaround");
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   371
                }
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   372
            }
3b68fd2503df WinRT: workaround for a possible bug in the Win10 Store's Certification Kit
David Ludwig <dludwig@pobox.com>
parents: 9931
diff changeset
   373
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   374
            break;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   375
        }
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   376
    }
8578
6517b6aca713 WinRT: fixed a crash in SDL_Quit
David Ludwig <dludwig@pobox.com>
parents: 8574
diff changeset
   377
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   378
    dxgiAdapter1->Release();
8578
6517b6aca713 WinRT: fixed a crash in SDL_Quit
David Ludwig <dludwig@pobox.com>
parents: 8574
diff changeset
   379
    return 0;
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   380
}
8503
90b33b6c6ab9 WinRT: code cleanup wrt. display mode(s)
David Ludwig <dludwig@pobox.com>
parents: 8501
diff changeset
   381
8505
a76a3842c9eb WinRT: experimental and preliminary support for XAML-based overlays on Windows 8/RT
David Ludwig <dludwig@pobox.com>
parents: 8503
diff changeset
   382
int
8374
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   383
WINRT_InitModes(_THIS)
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   384
{
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   385
    /* HACK: Initialize a single display, for whatever screen the app's
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   386
         CoreApplicationView is on.
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   387
       TODO, WinRT: Try initializing multiple displays, one for each monitor.
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   388
         Appropriate WinRT APIs for this seem elusive, though.  -- DavidL
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   389
    */
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   390
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   391
    HRESULT hr;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   392
    IDXGIFactory2 * dxgiFactory2 = NULL;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   393
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   394
    hr = CreateDXGIFactory1(IID_IDXGIFactory2, (void **)&dxgiFactory2);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   395
    if (FAILED(hr)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   396
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr);
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   397
        return -1;
8374
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   398
    }
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   399
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   400
    for (int adapterIndex = 0; ; ++adapterIndex) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   401
        if (WINRT_AddDisplaysForAdapter(_this, dxgiFactory2, adapterIndex) < 0) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   402
            break;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   403
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   404
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   405
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   406
    return 0;
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   407
}
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   408
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   409
static int
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   410
WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   411
{
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   412
    return 0;
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   413
}
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   414
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   415
void
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   416
WINRT_VideoQuit(_THIS)
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   417
{
8374
0294dc45d39d WinRT: added cursor visibility toggling, and system cursor creation
David Ludwig <dludwig@pobox.com>
parents: 8368
diff changeset
   418
    WINRT_QuitMouse(_this);
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   419
}
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   420
9926
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   421
static const Uint32 WINRT_DetectableFlags =
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   422
    SDL_WINDOW_MAXIMIZED |
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   423
    SDL_WINDOW_FULLSCREEN_DESKTOP |
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   424
    SDL_WINDOW_SHOWN |
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   425
    SDL_WINDOW_HIDDEN |
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   426
    SDL_WINDOW_MOUSE_FOCUS;
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   427
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   428
extern "C" Uint32
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   429
WINRT_DetectWindowFlags(SDL_Window * window)
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   430
{
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   431
    Uint32 latestFlags = 0;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   432
    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   433
    bool is_fullscreen = false;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   434
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   435
#if SDL_WINRT_USE_APPLICATIONVIEW
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   436
    if (data->appView) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   437
        is_fullscreen = data->appView->IsFullScreen;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   438
    }
9927
16d2f1997733 WinRT: bug-fix, fullscreen mode wasn't getting reported in Windows 8.0 apps
David Ludwig <dludwig@pobox.com>
parents: 9926
diff changeset
   439
#elif (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION == NTDDI_WIN8)
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   440
    is_fullscreen = true;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   441
#endif
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   442
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   443
    if (data->coreWindow.Get()) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   444
        if (is_fullscreen) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   445
            SDL_VideoDisplay * display = SDL_GetDisplayForWindow(window);
9925
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   446
            int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width);
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   447
            int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height);
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   448
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   449
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   450
            // On all WinRT platforms, except for WinPhone 8.0, rotate the
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   451
            // window size.  This is needed to properly calculate
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   452
            // fullscreen vs. maximized.
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   453
            const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   454
            switch (currentOrientation) {
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   455
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   456
                case DisplayOrientations::Landscape:
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   457
                case DisplayOrientations::LandscapeFlipped:
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   458
#else
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   459
                case DisplayOrientations::Portrait:
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   460
                case DisplayOrientations::PortraitFlipped:
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   461
#endif
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   462
                {
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   463
                    int tmp = w;
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   464
                    w = h;
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   465
                    h = tmp;
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   466
                } break;
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   467
            }
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   468
#endif
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   469
2be74843315c WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
David Ludwig <dludwig@pobox.com>
parents: 9924
diff changeset
   470
            if (display->desktop_mode.w != w || display->desktop_mode.h != h) {
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   471
                latestFlags |= SDL_WINDOW_MAXIMIZED;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   472
            } else {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   473
                latestFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   474
            }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   475
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   476
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   477
        if (data->coreWindow->Visible) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   478
            latestFlags |= SDL_WINDOW_SHOWN;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   479
        } else {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   480
            latestFlags |= SDL_WINDOW_HIDDEN;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   481
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   482
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   483
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION < NTDDI_WINBLUE)
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   484
        // data->coreWindow->PointerPosition is not supported on WinPhone 8.0
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   485
        latestFlags |= SDL_WINDOW_MOUSE_FOCUS;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   486
#else
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   487
        if (data->coreWindow->Bounds.Contains(data->coreWindow->PointerPosition)) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   488
            latestFlags |= SDL_WINDOW_MOUSE_FOCUS;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   489
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   490
#endif
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   491
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   492
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   493
    return latestFlags;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   494
}
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   495
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   496
void
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   497
WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask)
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   498
{
9926
277db103ed10 WinRT: bug-fix, OpenGLES2 was failing to init, after recent windowing fixes
David Ludwig <dludwig@pobox.com>
parents: 9925
diff changeset
   499
    mask &= WINRT_DetectableFlags;
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   500
    if (window) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   501
        Uint32 apply = WINRT_DetectWindowFlags(window);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   502
        if ((apply & mask) & SDL_WINDOW_FULLSCREEN) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   503
            window->last_fullscreen_flags = window->flags;  // seems necessary to programmatically un-fullscreen, via SDL APIs
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   504
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   505
        window->flags = (window->flags & ~mask) | (apply & mask);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   506
    }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   507
}
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   508
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   509
int
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   510
WINRT_CreateWindow(_THIS, SDL_Window * window)
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   511
{
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   512
    // Make sure that only one window gets created, at least until multimonitor
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   513
    // support is added.
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   514
    if (WINRT_GlobalSDLWindow != NULL) {
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   515
        SDL_SetError("WinRT only supports one window");
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   516
        return -1;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   517
    }
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   518
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   519
    SDL_WindowData *data = new SDL_WindowData;  /* use 'new' here as SDL_WindowData may use WinRT/C++ types */
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   520
    if (!data) {
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   521
        SDL_OutOfMemory();
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   522
        return -1;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   523
    }
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   524
    window->driverdata = data;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   525
    data->sdlWindow = window;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   526
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   527
    /* To note, when XAML support is enabled, access to the CoreWindow will not
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   528
       be possible, at least not via the SDL/XAML thread.  Attempts to access it
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   529
       from there will throw exceptions.  As such, the SDL_WindowData's
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   530
       'coreWindow' field will only be set (to a non-null value) if XAML isn't
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   531
       enabled.
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   532
    */
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   533
    if (!WINRT_XAMLWasEnabled) {
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   534
        data->coreWindow = CoreWindow::GetForCurrentThread();
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   535
#if SDL_WINRT_USE_APPLICATIONVIEW
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   536
        data->appView = ApplicationView::GetForCurrentView();
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   537
#endif
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   538
    }
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   539
9931
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   540
    /* Make note of the requested window flags, before they start getting changed. */
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   541
    const Uint32 requestedFlags = window->flags;
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   542
8541
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   543
#if SDL_VIDEO_OPENGL_EGL
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   544
    /* Setup the EGL surface, but only if OpenGL ES 2 was requested. */
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   545
    if (!(window->flags & SDL_WINDOW_OPENGL)) {
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   546
        /* OpenGL ES 2 wasn't requested.  Don't set up an EGL surface. */
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   547
        data->egl_surface = EGL_NO_SURFACE;
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   548
    } else {
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   549
        /* OpenGL ES 2 was reuqested.  Set up an EGL surface. */
8663
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   550
        SDL_VideoData * video_data = (SDL_VideoData *)_this->driverdata;
8572
f8a89aa53309 WinRT: fixed crash on ARM and x64 during OpenGL window init
David Ludwig <dludwig@pobox.com>
parents: 8551
diff changeset
   551
8663
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   552
        /* Call SDL_EGL_ChooseConfig and eglCreateWindowSurface directly,
9212
6b9794bae8ed WinRT: updated an OpenGL-related code-comment
David Ludwig <dludwig@pobox.com>
parents: 9211
diff changeset
   553
         * rather than via SDL_EGL_CreateSurface, as older versions of
6b9794bae8ed WinRT: updated an OpenGL-related code-comment
David Ludwig <dludwig@pobox.com>
parents: 9211
diff changeset
   554
         * ANGLE/WinRT may require that a C++ object, ComPtr<IUnknown>,
6b9794bae8ed WinRT: updated an OpenGL-related code-comment
David Ludwig <dludwig@pobox.com>
parents: 9211
diff changeset
   555
         * be passed into eglCreateWindowSurface.
8572
f8a89aa53309 WinRT: fixed crash on ARM and x64 during OpenGL window init
David Ludwig <dludwig@pobox.com>
parents: 8551
diff changeset
   556
         */
8663
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   557
        if (SDL_EGL_ChooseConfig(_this) != 0) {
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   558
            char buf[512];
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   559
            SDL_snprintf(buf, sizeof(buf), "SDL_EGL_ChooseConfig failed: %s", SDL_GetError());
9557
e05c7ad6ec57 WinRT: Fixed format string for error message.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9214
diff changeset
   560
            return SDL_SetError("%s", buf);
8663
308e74493106 WinRT: Got OpenGL ES 2 working with the latest version of ANGLE/WinRT.
David Ludwig <dludwig@pobox.com>
parents: 8621
diff changeset
   561
        }
8572
f8a89aa53309 WinRT: fixed crash on ARM and x64 during OpenGL window init
David Ludwig <dludwig@pobox.com>
parents: 8551
diff changeset
   562
9211
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   563
        if (video_data->winrtEglWindow) {   /* ... is the 'old' version of ANGLE/WinRT being used? */
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   564
            /* Attempt to create a window surface using older versions of
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   565
             * ANGLE/WinRT:
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   566
             */
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   567
            Microsoft::WRL::ComPtr<IUnknown> cpp_winrtEglWindow = video_data->winrtEglWindow;
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   568
            data->egl_surface = ((eglCreateWindowSurface_Old_Function)_this->egl_data->eglCreateWindowSurface)(
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   569
                _this->egl_data->egl_display,
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   570
                _this->egl_data->egl_config,
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   571
                cpp_winrtEglWindow, NULL);
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   572
            if (data->egl_surface == NULL) {
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   573
                return SDL_SetError("eglCreateWindowSurface failed");
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   574
            }
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   575
        } else if (data->coreWindow.Get() != nullptr) {
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   576
            /* Attempt to create a window surface using newer versions of
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   577
             * ANGLE/WinRT:
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   578
             */
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   579
            IInspectable * coreWindowAsIInspectable = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   580
            data->egl_surface = _this->egl_data->eglCreateWindowSurface(
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   581
                _this->egl_data->egl_display,
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   582
                _this->egl_data->egl_config,
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   583
                coreWindowAsIInspectable,
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   584
                NULL);
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   585
            if (data->egl_surface == NULL) {
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   586
                return SDL_SetError("eglCreateWindowSurface failed");
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   587
            }
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   588
        } else {
04c7e1220a65 WinRT: expanded OpenGL ES 2 support to enable recent updates to ANGLE/WinRT
David Ludwig <dludwig@pobox.com>
parents: 8757
diff changeset
   589
            return SDL_SetError("No supported means to create an EGL window surface are available");
8541
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   590
        }
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   591
    }
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   592
#endif
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   593
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   594
    /* Determine as many flags dynamically, as possible. */
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   595
    window->flags =
9928
639be75bbc84 WinRT: native windows are inherently resizable (in WinRT 8.x)
David Ludwig <dludwig@pobox.com>
parents: 9927
diff changeset
   596
        SDL_WINDOW_BORDERLESS |
639be75bbc84 WinRT: native windows are inherently resizable (in WinRT 8.x)
David Ludwig <dludwig@pobox.com>
parents: 9927
diff changeset
   597
        SDL_WINDOW_RESIZABLE;
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   598
8541
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   599
#if SDL_VIDEO_OPENGL_EGL
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   600
    if (data->egl_surface) {
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   601
        window->flags |= SDL_WINDOW_OPENGL;
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   602
    }
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   603
#endif
0041edb891f3 WinRT: added experimental OpenGL ES 2.0 support
David Ludwig <dludwig@pobox.com>
parents: 8527
diff changeset
   604
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   605
    if (WINRT_XAMLWasEnabled) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   606
        /* TODO, WinRT: set SDL_Window size, maybe position too, from XAML control */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   607
        window->x = 0;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   608
        window->y = 0;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   609
        window->flags |= SDL_WINDOW_SHOWN;
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   610
        SDL_SetMouseFocus(NULL);        // TODO: detect this
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   611
        SDL_SetKeyboardFocus(NULL);     // TODO: detect this
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   612
    } else {
9931
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   613
        /* WinRT 8.x apps seem to live in an environment where the OS controls the
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   614
           app's window size, with some apps being fullscreen, depending on
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   615
           user choice of various things.  For now, just adapt the SDL_Window to
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   616
           whatever Windows set-up as the native-window's geometry.
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   617
        */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   618
        window->x = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Left);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   619
        window->y = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Top);
9931
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   620
#if NTDDI_VERSION < NTDDI_WIN10
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   621
        /* On WinRT 8.x / pre-Win10, just use the size we were given. */
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   622
        window->w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   623
        window->h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height);
9931
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   624
#else
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   625
        /* On Windows 10, we occasionally get control over window size.  For windowed
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   626
           mode apps, try this.
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   627
        */
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   628
        bool didSetSize = false;
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   629
        if (!(requestedFlags & SDL_WINDOW_FULLSCREEN)) {
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   630
            const Windows::Foundation::Size size(WINRT_PHYSICAL_PIXELS_TO_DIPS(window->w),
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   631
                                                 WINRT_PHYSICAL_PIXELS_TO_DIPS(window->h));
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   632
            didSetSize = data->appView->TryResizeView(size);
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   633
        }
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   634
        if (!didSetSize) {
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   635
            /* We either weren't able to set the window size, or a request for
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   636
               fullscreen was made.  Get window-size info from the OS.
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   637
            */
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   638
            window->w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width);
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   639
            window->h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height);
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   640
        }
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   641
#endif
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   642
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   643
        WINRT_UpdateWindowFlags(
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   644
            window,
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   645
            0xffffffff      /* Update any window flag(s) that WINRT_UpdateWindow can handle */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   646
        );
8551
666f05b079ea WinRT: bug fix: game-controller/joystick button-down events weren't getting sent
David Ludwig <dludwig@pobox.com>
parents: 8541
diff changeset
   647
9924
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   648
        /* Try detecting if the window is active */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   649
        bool isWindowActive = true;     /* Presume the window is active, unless we've been told otherwise */
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   650
        if (data->coreWindow->CustomProperties->HasKey("SDLHelperWindowActivationState")) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   651
            CoreWindowActivationState activationState = \
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   652
                safe_cast<CoreWindowActivationState>(data->coreWindow->CustomProperties->Lookup("SDLHelperWindowActivationState"));
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   653
            isWindowActive = (activationState != CoreWindowActivationState::Deactivated);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   654
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   655
        if (isWindowActive) {
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   656
            SDL_SetKeyboardFocus(window);
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   657
        }
355cccccc7dc WinRT: lots of display and windowing related fixes
David Ludwig <dludwig@pobox.com>
parents: 9619
diff changeset
   658
    }
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   659
 
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   660
    /* Make sure the WinRT app's IFramworkView can post events on
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   661
       behalf of SDL:
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   662
    */
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   663
    WINRT_GlobalSDLWindow = window;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   664
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   665
    /* All done! */
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   666
    return 0;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   667
}
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   668
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   669
void
9931
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   670
WINRT_SetWindowSize(_THIS, SDL_Window * window)
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   671
{
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   672
#if NTDDI_VERSION >= NTDDI_WIN10
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   673
    SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   674
    const Windows::Foundation::Size size(WINRT_PHYSICAL_PIXELS_TO_DIPS(window->w),
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   675
                                         WINRT_PHYSICAL_PIXELS_TO_DIPS(window->h));
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   676
    data->appView->TryResizeView(size); // TODO, WinRT: return failure (to caller?) from TryResizeView()
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   677
#endif
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   678
}
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   679
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   680
void
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   681
WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   682
{
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   683
#if NTDDI_VERSION >= NTDDI_WIN10
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   684
    SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   685
    if (fullscreen) {
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   686
        if (!data->appView->IsFullScreenMode) {
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   687
            data->appView->TryEnterFullScreenMode();    // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   688
        }
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   689
    } else {
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   690
        if (data->appView->IsFullScreenMode) {
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   691
            data->appView->ExitFullScreenMode();
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   692
        }
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   693
    }
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   694
#endif
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   695
}
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   696
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   697
0bb3dd1c95f2 WinRT: added Win10/UWP (Universal Windows Platform) support
David Ludwig <dludwig@pobox.com>
parents: 9929
diff changeset
   698
void
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   699
WINRT_DestroyWindow(_THIS, SDL_Window * window)
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   700
{
8411
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   701
    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   702
8497
103bb054aa7d WinRT: moved the pointer to the global SDL_Window to a separate variable
David Ludwig <dludwig@pobox.com>
parents: 8496
diff changeset
   703
    if (WINRT_GlobalSDLWindow == window) {
103bb054aa7d WinRT: moved the pointer to the global SDL_Window to a separate variable
David Ludwig <dludwig@pobox.com>
parents: 8496
diff changeset
   704
        WINRT_GlobalSDLWindow = NULL;
8424
3cf9501008f1 WinRT: fixed bug: SDL_CreateWindow wouldn't work after an initial window was created + destroyed
David Ludwig <dludwig@pobox.com>
parents: 8417
diff changeset
   705
    }
3cf9501008f1 WinRT: fixed bug: SDL_CreateWindow wouldn't work after an initial window was created + destroyed
David Ludwig <dludwig@pobox.com>
parents: 8417
diff changeset
   706
8411
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   707
    if (data) {
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   708
        // Delete the internal window data:
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   709
        delete data;
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   710
        data = NULL;
9214
dad92c567585 WinRT: fixed crash when trying, and failing, to load the opengles2 renderer
David Ludwig <dludwig@pobox.com>
parents: 9212
diff changeset
   711
        window->driverdata = NULL;
8411
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   712
    }
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   713
}
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   714
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   715
SDL_bool
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   716
WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   717
{
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   718
    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   719
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   720
    if (info->version.major <= SDL_MAJOR_VERSION) {
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   721
        info->subsystem = SDL_SYSWM_WINRT;
8527
e3807733fad5 WinRT: made SDL_GetWindowWMInfo return window data in a slightly easier-to-use format
David Ludwig <dludwig@pobox.com>
parents: 8522
diff changeset
   722
        info->info.winrt.window = reinterpret_cast<IInspectable *>(data->coreWindow.Get());
8522
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   723
        return SDL_TRUE;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   724
    } else {
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   725
        SDL_SetError("Application not compiled with SDL %d.%d\n",
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   726
                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   727
        return SDL_FALSE;
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   728
    }
3ae9dc9c439f WinRT: code cleanup: attempted to make it more clear what code is specific to what app type (plain Direct3D or XAML)
David Ludwig <dludwig@pobox.com>
parents: 8516
diff changeset
   729
    return SDL_FALSE;
8411
aca0591bc58f WinRT: provided access, via SDL_GetWindowWMInfo, to SDL's WinRT CoreWindow
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   730
}
8333
49973bfb8d23 WinRT: SDL_GetWindowSize and SDL_MOUSEMOTION works, and cursor position data is now attached to mouse button events
David Ludwig <dludwig@pobox.com>
parents: 8332
diff changeset
   731
8327
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   732
#endif /* SDL_VIDEO_DRIVER_WINRT */
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   733
bc51589f33dc WinRT: created a skeleton for a video driver, using a copy of the dummy driver for a base
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   734
/* vi: set ts=4 sw=4 expandtab: */