src/video/winrt/SDL_winrtvideo_cpp.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 03 Jan 2018 10:03:25 -0800
changeset 11811 5d94cb6b24d3
parent 10737 3406a0f8b041
child 12503 806492103856
permissions -rw-r--r--
Updated copyright for 2018
dludwig@8512
     1
/*
dludwig@8512
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
dludwig@8512
     4
dludwig@8512
     5
  This software is provided 'as-is', without any express or implied
dludwig@8512
     6
  warranty.  In no event will the authors be held liable for any damages
dludwig@8512
     7
  arising from the use of this software.
dludwig@8512
     8
dludwig@8512
     9
  Permission is granted to anyone to use this software for any purpose,
dludwig@8512
    10
  including commercial applications, and to alter it and redistribute it
dludwig@8512
    11
  freely, subject to the following restrictions:
dludwig@8512
    12
dludwig@8512
    13
  1. The origin of this software must not be misrepresented; you must not
dludwig@8512
    14
     claim that you wrote the original software. If you use this software
dludwig@8512
    15
     in a product, an acknowledgment in the product documentation would be
dludwig@8512
    16
     appreciated but is not required.
dludwig@8512
    17
  2. Altered source versions must be plainly marked as such, and must not be
dludwig@8512
    18
     misrepresented as being the original software.
dludwig@8512
    19
  3. This notice may not be removed or altered from any source distribution.
dludwig@8512
    20
*/
dludwig@8512
    21
dludwig@8512
    22
/* Windows includes: */
dludwig@8512
    23
#include <windows.h>
dludwig@8512
    24
#ifdef __cplusplus_winrt
dludwig@8512
    25
#include <agile.h>
dludwig@8512
    26
#endif
dludwig@8512
    27
dludwig@8512
    28
/* SDL includes: */
dludwig@8541
    29
#include "SDL_video.h"
dludwig@8512
    30
#include "SDL_events.h"
dludwig@8512
    31
dludwig@9924
    32
#if NTDDI_VERSION >= NTDDI_WINBLUE  /* ApplicationView's functionality only becomes
dludwig@9924
    33
                                       useful for SDL in Win[Phone] 8.1 and up.
dludwig@9924
    34
                                       Plus, it is not available at all in WinPhone 8.0. */
dludwig@9924
    35
#define SDL_WINRT_USE_APPLICATIONVIEW 1
dludwig@9924
    36
#endif
dludwig@9924
    37
dludwig@8541
    38
extern "C" {
dludwig@8541
    39
#include "../SDL_sysvideo.h"
dludwig@8545
    40
#include "../SDL_egl_c.h"
dludwig@8541
    41
}
dludwig@8541
    42
dludwig@8663
    43
/* Private display data */
dludwig@8663
    44
typedef struct SDL_VideoData {
dludwig@8663
    45
    /* An object created by ANGLE/WinRT (OpenGL ES 2 for WinRT) that gets
dludwig@8663
    46
     * passed to eglGetDisplay and eglCreateWindowSurface:
dludwig@8663
    47
     */
dludwig@8663
    48
    IUnknown *winrtEglWindow;
dludwig@10222
    49
dludwig@10222
    50
    /* Event token(s), for unregistering WinRT event handler(s).
dludwig@10222
    51
       These are just a struct with a 64-bit integer inside them
dludwig@10222
    52
    */
dludwig@10222
    53
    Windows::Foundation::EventRegistrationToken gameBarIsInputRedirectedToken;
dludwig@10293
    54
dludwig@10293
    55
    /* A WinRT DisplayRequest, used for implementing SDL_*ScreenSaver() functions.
dludwig@10293
    56
     * This is really a pointer to a 'ABI::Windows::System::Display::IDisplayRequest *',
dludwig@10293
    57
     * It's casted to 'IUnknown *', to help with building SDL.
dludwig@10293
    58
    */
dludwig@10293
    59
    IUnknown *displayRequest;
dludwig@8663
    60
} SDL_VideoData;
dludwig@8512
    61
dludwig@8515
    62
/* The global, WinRT, SDL Window.
dludwig@8515
    63
   For now, SDL/WinRT only supports one window (due to platform limitations of
dludwig@8515
    64
   WinRT.
dludwig@8515
    65
*/
dludwig@8515
    66
extern SDL_Window * WINRT_GlobalSDLWindow;
dludwig@8515
    67
dludwig@9924
    68
/* Updates one or more SDL_Window flags, by querying the OS' native windowing APIs.
dludwig@9924
    69
   SDL_Window flags that can be updated should be specified in 'mask'.
slouken@8582
    70
*/
dludwig@9924
    71
extern void WINRT_UpdateWindowFlags(SDL_Window * window, Uint32 mask);
dludwig@9924
    72
extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window * window);  /* detects flags w/o applying them */
slouken@8582
    73
slouken@8582
    74
/* Display mode internals */
dludwig@9924
    75
//typedef struct
dludwig@9924
    76
//{
dludwig@9924
    77
//    Windows::Graphics::Display::DisplayOrientations currentOrientation;
dludwig@9924
    78
//} SDL_DisplayModeData;
dludwig@8515
    79
dludwig@8512
    80
#ifdef __cplusplus_winrt
dludwig@8512
    81
dludwig@8755
    82
/* A convenience macro to get a WinRT display property */
dludwig@8755
    83
#if NTDDI_VERSION > NTDDI_WIN8
dludwig@8755
    84
#define WINRT_DISPLAY_PROPERTY(NAME) (Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->NAME)
dludwig@8755
    85
#else
dludwig@8755
    86
#define WINRT_DISPLAY_PROPERTY(NAME) (Windows::Graphics::Display::DisplayProperties::NAME)
dludwig@8755
    87
#endif
dludwig@8755
    88
dludwig@9931
    89
/* Converts DIPS to/from physical pixels */
dludwig@9931
    90
#define WINRT_DIPS_TO_PHYSICAL_PIXELS(DIPS)     ((int)(0.5f + (((float)(DIPS) * (float)WINRT_DISPLAY_PROPERTY(LogicalDpi)) / 96.f)))
dludwig@9931
    91
#define WINRT_PHYSICAL_PIXELS_TO_DIPS(PHYSPIX)  (((float)(PHYSPIX) * 96.f)/WINRT_DISPLAY_PROPERTY(LogicalDpi))
dludwig@9924
    92
dludwig@8512
    93
/* Internal window data */
slouken@8582
    94
struct SDL_WindowData
slouken@8582
    95
{
slouken@8582
    96
    SDL_Window *sdlWindow;
slouken@8582
    97
    Platform::Agile<Windows::UI::Core::CoreWindow> coreWindow;
slouken@8582
    98
#ifdef SDL_VIDEO_OPENGL_EGL
slouken@8582
    99
    EGLSurface egl_surface;
slouken@8582
   100
#endif
dludwig@9924
   101
#if SDL_WINRT_USE_APPLICATIONVIEW
dludwig@9924
   102
    Windows::UI::ViewManagement::ApplicationView ^ appView;
dludwig@9924
   103
#endif
dludwig@8512
   104
};
dludwig@8512
   105
dludwig@8512
   106
#endif // ifdef __cplusplus_winrt