WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
authorDavid Ludwig <dludwig@pobox.com>
Sun, 28 Oct 2012 18:45:33 -0400
changeset 8329c3047b88e35b
parent 8328 88b08ad81bf7
child 8330 d976f30d38e9
WinRT: made the device's screen size be retrieve-able via SDL_GetDisplayMode()
VisualC/SDL/SDL_VS2012_WinRT.vcxproj
src/video/windowsrt/SDL_WinRTApp.cpp
src/video/windowsrt/SDL_WinRTApp.h
src/video/windowsrt/SDL_winrtevents.c
src/video/windowsrt/SDL_winrtevents.cpp
src/video/windowsrt/SDL_winrtframebuffer.c
src/video/windowsrt/SDL_winrtframebuffer.cpp
src/video/windowsrt/SDL_winrtvideo.c
src/video/windowsrt/SDL_winrtvideo.cpp
src/video/windowsrt/SDL_winrtvideo.h
src/video/windowsrt/SDLmain_WinRT_common.h
     1.1 --- a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj	Sat Oct 27 22:57:07 2012 -0400
     1.2 +++ b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj	Sun Oct 28 18:45:33 2012 -0400
     1.3 @@ -125,9 +125,16 @@
     1.4        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
     1.5        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
     1.6      </ClCompile>
     1.7 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.c" />
     1.8 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.c" />
     1.9 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.c" />
    1.10 +    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp" />
    1.11 +    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtframebuffer.cpp" />
    1.12 +    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    1.13 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.14 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.15 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.16 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.17 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    1.18 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    1.19 +    </ClCompile>
    1.20    </ItemGroup>
    1.21    <ItemGroup>
    1.22      <ClInclude Include="..\..\include\begin_code.h" />
     2.1 --- a/src/video/windowsrt/SDL_WinRTApp.cpp	Sat Oct 27 22:57:07 2012 -0400
     2.2 +++ b/src/video/windowsrt/SDL_WinRTApp.cpp	Sun Oct 28 18:45:33 2012 -0400
     2.3 @@ -2,12 +2,27 @@
     2.4  #include "SDL_WinRTApp.h"
     2.5  #include "BasicTimer.h"
     2.6  
     2.7 +extern "C" {
     2.8 +#include "SDL_assert.h"
     2.9 +#include "SDL_stdinc.h"
    2.10 +#include "../SDL_sysvideo.h"
    2.11 +}
    2.12 +
    2.13  // HACK, DLudwig: The C-style main() will get loaded via the app's
    2.14  // WinRT-styled main(), which is part of SDLmain_for_WinRT.cpp.
    2.15  // This seems wrong on some level, but does seem to work.
    2.16  typedef int (*SDL_WinRT_MainFunction)(int, char **);
    2.17  static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
    2.18  
    2.19 +// HACK, DLudwig: record a reference to the global, Windows RT 'app'/view.
    2.20 +// SDL/WinRT will use this throughout its code.
    2.21 +//
    2.22 +// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
    2.23 +// non-global, such as something created inside
    2.24 +// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
    2.25 +// SDL_CreateWindow().
    2.26 +SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
    2.27 +
    2.28  
    2.29  using namespace Windows::ApplicationModel;
    2.30  using namespace Windows::ApplicationModel::Core;
    2.31 @@ -151,9 +166,30 @@
    2.32  	// does not occur if the app was previously terminated.
    2.33  }
    2.34  
    2.35 +SDL_DisplayMode SDL_WinRTApp::GetMainDisplayMode()
    2.36 +{
    2.37 +    SDL_DisplayMode mode;
    2.38 +    SDL_zero(mode);
    2.39 +    mode.format = SDL_PIXELFORMAT_RGB888;
    2.40 +    mode.w = (int) CoreWindow::GetForCurrentThread()->Bounds.Width;
    2.41 +    mode.h = (int) CoreWindow::GetForCurrentThread()->Bounds.Height;
    2.42 +    mode.refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
    2.43 +    mode.driverdata = NULL;
    2.44 +    return mode;
    2.45 +}
    2.46 +
    2.47  IFrameworkView^ Direct3DApplicationSource::CreateView()
    2.48  {
    2.49 -    return ref new SDL_WinRTApp();
    2.50 +    // TODO, WinRT: see if this function (CreateView) can ever get called
    2.51 +    // more than once.  For now, just prevent it from ever assigning
    2.52 +    // SDL_WinRTGlobalApp more than once.
    2.53 +    SDL_assert(!SDL_WinRTGlobalApp);
    2.54 +    SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
    2.55 +    if (!SDL_WinRTGlobalApp)
    2.56 +    {
    2.57 +        SDL_WinRTGlobalApp = app;
    2.58 +    }
    2.59 +    return app;
    2.60  }
    2.61  
    2.62  __declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
     3.1 --- a/src/video/windowsrt/SDL_WinRTApp.h	Sat Oct 27 22:57:07 2012 -0400
     3.2 +++ b/src/video/windowsrt/SDL_WinRTApp.h	Sun Oct 28 18:45:33 2012 -0400
     3.3 @@ -2,6 +2,9 @@
     3.4  
     3.5  #include "SDLmain_WinRT_common.h"
     3.6  #include "CubeRenderer.h"
     3.7 +#include <vector>
     3.8 +
     3.9 +using namespace Windows::UI::Core;
    3.10  
    3.11  ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
    3.12  {
    3.13 @@ -15,6 +18,10 @@
    3.14  	virtual void Run();
    3.15  	virtual void Uninitialize();
    3.16  
    3.17 +internal:
    3.18 +    // SDL-specific methods
    3.19 +    SDL_DisplayMode GetMainDisplayMode();
    3.20 +
    3.21  protected:
    3.22  	// Event Handlers.
    3.23  	void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
     4.1 --- a/src/video/windowsrt/SDL_winrtevents.c	Sat Oct 27 22:57:07 2012 -0400
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,41 +0,0 @@
     4.4 -/*
     4.5 -  Simple DirectMedia Layer
     4.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     4.7 -
     4.8 -  This software is provided 'as-is', without any express or implied
     4.9 -  warranty.  In no event will the authors be held liable for any damages
    4.10 -  arising from the use of this software.
    4.11 -
    4.12 -  Permission is granted to anyone to use this software for any purpose,
    4.13 -  including commercial applications, and to alter it and redistribute it
    4.14 -  freely, subject to the following restrictions:
    4.15 -
    4.16 -  1. The origin of this software must not be misrepresented; you must not
    4.17 -     claim that you wrote the original software. If you use this software
    4.18 -     in a product, an acknowledgment in the product documentation would be
    4.19 -     appreciated but is not required.
    4.20 -  2. Altered source versions must be plainly marked as such, and must not be
    4.21 -     misrepresented as being the original software.
    4.22 -  3. This notice may not be removed or altered from any source distribution.
    4.23 -*/
    4.24 -#include "SDL_config.h"
    4.25 -
    4.26 -#if SDL_VIDEO_DRIVER_WINRT
    4.27 -
    4.28 -/* Being a null driver, there's no event stream. We just define stubs for
    4.29 -   most of the API. */
    4.30 -
    4.31 -#include "../../events/SDL_events_c.h"
    4.32 -
    4.33 -#include "SDL_winrtvideo.h"
    4.34 -#include "SDL_winrtevents_c.h"
    4.35 -
    4.36 -void
    4.37 -WINRT_PumpEvents(_THIS)
    4.38 -{
    4.39 -    /* do nothing. */
    4.40 -}
    4.41 -
    4.42 -#endif /* SDL_VIDEO_DRIVER_WINRT */
    4.43 -
    4.44 -/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/windowsrt/SDL_winrtevents.cpp	Sun Oct 28 18:45:33 2012 -0400
     5.3 @@ -0,0 +1,41 @@
     5.4 +/*
     5.5 +  Simple DirectMedia Layer
     5.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     5.7 +
     5.8 +  This software is provided 'as-is', without any express or implied
     5.9 +  warranty.  In no event will the authors be held liable for any damages
    5.10 +  arising from the use of this software.
    5.11 +
    5.12 +  Permission is granted to anyone to use this software for any purpose,
    5.13 +  including commercial applications, and to alter it and redistribute it
    5.14 +  freely, subject to the following restrictions:
    5.15 +
    5.16 +  1. The origin of this software must not be misrepresented; you must not
    5.17 +     claim that you wrote the original software. If you use this software
    5.18 +     in a product, an acknowledgment in the product documentation would be
    5.19 +     appreciated but is not required.
    5.20 +  2. Altered source versions must be plainly marked as such, and must not be
    5.21 +     misrepresented as being the original software.
    5.22 +  3. This notice may not be removed or altered from any source distribution.
    5.23 +*/
    5.24 +#include "SDL_config.h"
    5.25 +
    5.26 +#if SDL_VIDEO_DRIVER_WINRT
    5.27 +
    5.28 +/* Being a null driver, there's no event stream. We just define stubs for
    5.29 +   most of the API. */
    5.30 +
    5.31 +#include "../../events/SDL_events_c.h"
    5.32 +
    5.33 +#include "SDL_winrtvideo.h"
    5.34 +#include "SDL_winrtevents_c.h"
    5.35 +
    5.36 +void
    5.37 +WINRT_PumpEvents(_THIS)
    5.38 +{
    5.39 +    /* do nothing. */
    5.40 +}
    5.41 +
    5.42 +#endif /* SDL_VIDEO_DRIVER_WINRT */
    5.43 +
    5.44 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/windowsrt/SDL_winrtframebuffer.c	Sat Oct 27 22:57:07 2012 -0400
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,94 +0,0 @@
     6.4 -/*
     6.5 -  Simple DirectMedia Layer
     6.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     6.7 -
     6.8 -  This software is provided 'as-is', without any express or implied
     6.9 -  warranty.  In no event will the authors be held liable for any damages
    6.10 -  arising from the use of this software.
    6.11 -
    6.12 -  Permission is granted to anyone to use this software for any purpose,
    6.13 -  including commercial applications, and to alter it and redistribute it
    6.14 -  freely, subject to the following restrictions:
    6.15 -
    6.16 -  1. The origin of this software must not be misrepresented; you must not
    6.17 -     claim that you wrote the original software. If you use this software
    6.18 -     in a product, an acknowledgment in the product documentation would be
    6.19 -     appreciated but is not required.
    6.20 -  2. Altered source versions must be plainly marked as such, and must not be
    6.21 -     misrepresented as being the original software.
    6.22 -  3. This notice may not be removed or altered from any source distribution.
    6.23 -*/
    6.24 -#include "SDL_config.h"
    6.25 -
    6.26 -#if SDL_VIDEO_DRIVER_WINRT
    6.27 -
    6.28 -#include "../SDL_sysvideo.h"
    6.29 -#include "SDL_winrtframebuffer_c.h"
    6.30 -
    6.31 -
    6.32 -#define WINRT_SURFACE   "_SDL_WinRTSurface"
    6.33 -
    6.34 -int SDL_WINRT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
    6.35 -{
    6.36 -    SDL_Surface *surface;
    6.37 -    const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
    6.38 -    int w, h;
    6.39 -    int bpp;
    6.40 -    Uint32 Rmask, Gmask, Bmask, Amask;
    6.41 -
    6.42 -    /* Free the old framebuffer surface */
    6.43 -    surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
    6.44 -    if (surface) {
    6.45 -        SDL_FreeSurface(surface);
    6.46 -    }
    6.47 -
    6.48 -    /* Create a new one */
    6.49 -    SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
    6.50 -    SDL_GetWindowSize(window, &w, &h);
    6.51 -    surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
    6.52 -    if (!surface) {
    6.53 -        return -1;
    6.54 -    }
    6.55 -
    6.56 -    /* Save the info and return! */
    6.57 -    SDL_SetWindowData(window, WINRT_SURFACE, surface);
    6.58 -    *format = surface_format;
    6.59 -    *pixels = surface->pixels;
    6.60 -    *pitch = surface->pitch;
    6.61 -    return 0;
    6.62 -}
    6.63 -
    6.64 -int SDL_WINRT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects)
    6.65 -{
    6.66 -    static int frame_number;
    6.67 -    SDL_Surface *surface;
    6.68 -
    6.69 -    surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
    6.70 -    if (!surface) {
    6.71 -        SDL_SetError("Couldn't find WinRT surface for window");
    6.72 -        return -1;
    6.73 -    }
    6.74 -
    6.75 -    /* Send the data to the display */
    6.76 -    if (SDL_getenv("SDL_VIDEO_WINRT_SAVE_FRAMES")) {
    6.77 -        char file[128];
    6.78 -        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
    6.79 -                     SDL_GetWindowID(window), ++frame_number);
    6.80 -        SDL_SaveBMP(surface, file);
    6.81 -    }
    6.82 -    return 0;
    6.83 -}
    6.84 -
    6.85 -void SDL_WINRT_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
    6.86 -{
    6.87 -    SDL_Surface *surface;
    6.88 -
    6.89 -    surface = (SDL_Surface *) SDL_SetWindowData(window, WINRT_SURFACE, NULL);
    6.90 -    if (surface) {
    6.91 -        SDL_FreeSurface(surface);
    6.92 -    }
    6.93 -}
    6.94 -
    6.95 -#endif /* SDL_VIDEO_DRIVER_WINRT */
    6.96 -
    6.97 -/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/video/windowsrt/SDL_winrtframebuffer.cpp	Sun Oct 28 18:45:33 2012 -0400
     7.3 @@ -0,0 +1,94 @@
     7.4 +/*
     7.5 +  Simple DirectMedia Layer
     7.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     7.7 +
     7.8 +  This software is provided 'as-is', without any express or implied
     7.9 +  warranty.  In no event will the authors be held liable for any damages
    7.10 +  arising from the use of this software.
    7.11 +
    7.12 +  Permission is granted to anyone to use this software for any purpose,
    7.13 +  including commercial applications, and to alter it and redistribute it
    7.14 +  freely, subject to the following restrictions:
    7.15 +
    7.16 +  1. The origin of this software must not be misrepresented; you must not
    7.17 +     claim that you wrote the original software. If you use this software
    7.18 +     in a product, an acknowledgment in the product documentation would be
    7.19 +     appreciated but is not required.
    7.20 +  2. Altered source versions must be plainly marked as such, and must not be
    7.21 +     misrepresented as being the original software.
    7.22 +  3. This notice may not be removed or altered from any source distribution.
    7.23 +*/
    7.24 +#include "SDL_config.h"
    7.25 +
    7.26 +#if SDL_VIDEO_DRIVER_WINRT
    7.27 +
    7.28 +#include "../SDL_sysvideo.h"
    7.29 +#include "SDL_winrtframebuffer_c.h"
    7.30 +
    7.31 +
    7.32 +#define WINRT_SURFACE   "_SDL_WinRTSurface"
    7.33 +
    7.34 +int SDL_WINRT_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
    7.35 +{
    7.36 +    SDL_Surface *surface;
    7.37 +    const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
    7.38 +    int w, h;
    7.39 +    int bpp;
    7.40 +    Uint32 Rmask, Gmask, Bmask, Amask;
    7.41 +
    7.42 +    /* Free the old framebuffer surface */
    7.43 +    surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
    7.44 +    if (surface) {
    7.45 +        SDL_FreeSurface(surface);
    7.46 +    }
    7.47 +
    7.48 +    /* Create a new one */
    7.49 +    SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
    7.50 +    SDL_GetWindowSize(window, &w, &h);
    7.51 +    surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
    7.52 +    if (!surface) {
    7.53 +        return -1;
    7.54 +    }
    7.55 +
    7.56 +    /* Save the info and return! */
    7.57 +    SDL_SetWindowData(window, WINRT_SURFACE, surface);
    7.58 +    *format = surface_format;
    7.59 +    *pixels = surface->pixels;
    7.60 +    *pitch = surface->pitch;
    7.61 +    return 0;
    7.62 +}
    7.63 +
    7.64 +int SDL_WINRT_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects)
    7.65 +{
    7.66 +    static int frame_number;
    7.67 +    SDL_Surface *surface;
    7.68 +
    7.69 +    surface = (SDL_Surface *) SDL_GetWindowData(window, WINRT_SURFACE);
    7.70 +    if (!surface) {
    7.71 +        SDL_SetError("Couldn't find WinRT surface for window");
    7.72 +        return -1;
    7.73 +    }
    7.74 +
    7.75 +    /* Send the data to the display */
    7.76 +    if (SDL_getenv("SDL_VIDEO_WINRT_SAVE_FRAMES")) {
    7.77 +        char file[128];
    7.78 +        SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
    7.79 +                     SDL_GetWindowID(window), ++frame_number);
    7.80 +        SDL_SaveBMP(surface, file);
    7.81 +    }
    7.82 +    return 0;
    7.83 +}
    7.84 +
    7.85 +void SDL_WINRT_DestroyWindowFramebuffer(_THIS, SDL_Window * window)
    7.86 +{
    7.87 +    SDL_Surface *surface;
    7.88 +
    7.89 +    surface = (SDL_Surface *) SDL_SetWindowData(window, WINRT_SURFACE, NULL);
    7.90 +    if (surface) {
    7.91 +        SDL_FreeSurface(surface);
    7.92 +    }
    7.93 +}
    7.94 +
    7.95 +#endif /* SDL_VIDEO_DRIVER_WINRT */
    7.96 +
    7.97 +/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/windowsrt/SDL_winrtvideo.c	Sat Oct 27 22:57:07 2012 -0400
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,132 +0,0 @@
     8.4 -/*
     8.5 -  Simple DirectMedia Layer
     8.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     8.7 -
     8.8 -  This software is provided 'as-is', without any express or implied
     8.9 -  warranty.  In no event will the authors be held liable for any damages
    8.10 -  arising from the use of this software.
    8.11 -
    8.12 -  Permission is granted to anyone to use this software for any purpose,
    8.13 -  including commercial applications, and to alter it and redistribute it
    8.14 -  freely, subject to the following restrictions:
    8.15 -
    8.16 -  1. The origin of this software must not be misrepresented; you must not
    8.17 -     claim that you wrote the original software. If you use this software
    8.18 -     in a product, an acknowledgment in the product documentation would be
    8.19 -     appreciated but is not required.
    8.20 -  2. Altered source versions must be plainly marked as such, and must not be
    8.21 -     misrepresented as being the original software.
    8.22 -  3. This notice may not be removed or altered from any source distribution.
    8.23 -*/
    8.24 -#include "SDL_config.h"
    8.25 -
    8.26 -#if SDL_VIDEO_DRIVER_WINRT
    8.27 -
    8.28 -/* WinRT SDL video driver implementation
    8.29 -
    8.30 -   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
    8.31 -   was based off of SDL's "dummy" video driver.
    8.32 - */
    8.33 -
    8.34 -#include "SDL_video.h"
    8.35 -#include "SDL_mouse.h"
    8.36 -#include "../SDL_sysvideo.h"
    8.37 -#include "../SDL_pixels_c.h"
    8.38 -#include "../../events/SDL_events_c.h"
    8.39 -
    8.40 -#include "SDL_winrtvideo.h"
    8.41 -#include "SDL_winrtevents_c.h"
    8.42 -#include "SDL_winrtframebuffer_c.h"
    8.43 -
    8.44 -#define WINRTVID_DRIVER_NAME "dummy"
    8.45 -
    8.46 -/* Initialization/Query functions */
    8.47 -static int WINRT_VideoInit(_THIS);
    8.48 -static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    8.49 -static void WINRT_VideoQuit(_THIS);
    8.50 -
    8.51 -/* WinRT driver bootstrap functions */
    8.52 -
    8.53 -static int
    8.54 -WINRT_Available(void)
    8.55 -{
    8.56 -    return (1);
    8.57 -}
    8.58 -
    8.59 -static void
    8.60 -WINRT_DeleteDevice(SDL_VideoDevice * device)
    8.61 -{
    8.62 -    SDL_free(device);
    8.63 -}
    8.64 -
    8.65 -static SDL_VideoDevice *
    8.66 -WINRT_CreateDevice(int devindex)
    8.67 -{
    8.68 -    SDL_VideoDevice *device;
    8.69 -
    8.70 -    /* Initialize all variables that we clean on shutdown */
    8.71 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    8.72 -    if (!device) {
    8.73 -        SDL_OutOfMemory();
    8.74 -        if (device) {
    8.75 -            SDL_free(device);
    8.76 -        }
    8.77 -        return (0);
    8.78 -    }
    8.79 -
    8.80 -    /* Set the function pointers */
    8.81 -    device->VideoInit = WINRT_VideoInit;
    8.82 -    device->VideoQuit = WINRT_VideoQuit;
    8.83 -    device->SetDisplayMode = WINRT_SetDisplayMode;
    8.84 -    device->PumpEvents = WINRT_PumpEvents;
    8.85 -    device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
    8.86 -    device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
    8.87 -    device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
    8.88 -
    8.89 -    device->free = WINRT_DeleteDevice;
    8.90 -
    8.91 -    return device;
    8.92 -}
    8.93 -
    8.94 -VideoBootStrap WINRT_bootstrap = {
    8.95 -    WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
    8.96 -    WINRT_Available, WINRT_CreateDevice
    8.97 -};
    8.98 -
    8.99 -
   8.100 -int
   8.101 -WINRT_VideoInit(_THIS)
   8.102 -{
   8.103 -    SDL_DisplayMode mode;
   8.104 -
   8.105 -    /* Use a fake 32-bpp desktop mode */
   8.106 -    mode.format = SDL_PIXELFORMAT_RGB888;
   8.107 -    mode.w = 1024;
   8.108 -    mode.h = 768;
   8.109 -    mode.refresh_rate = 0;
   8.110 -    mode.driverdata = NULL;
   8.111 -    if (SDL_AddBasicVideoDisplay(&mode) < 0) {
   8.112 -        return -1;
   8.113 -    }
   8.114 -
   8.115 -    SDL_zero(mode);
   8.116 -    SDL_AddDisplayMode(&_this->displays[0], &mode);
   8.117 -
   8.118 -    /* We're done! */
   8.119 -    return 0;
   8.120 -}
   8.121 -
   8.122 -static int
   8.123 -WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   8.124 -{
   8.125 -    return 0;
   8.126 -}
   8.127 -
   8.128 -void
   8.129 -WINRT_VideoQuit(_THIS)
   8.130 -{
   8.131 -}
   8.132 -
   8.133 -#endif /* SDL_VIDEO_DRIVER_WINRT */
   8.134 -
   8.135 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/video/windowsrt/SDL_winrtvideo.cpp	Sun Oct 28 18:45:33 2012 -0400
     9.3 @@ -0,0 +1,128 @@
     9.4 +/*
     9.5 +  Simple DirectMedia Layer
     9.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     9.7 +
     9.8 +  This software is provided 'as-is', without any express or implied
     9.9 +  warranty.  In no event will the authors be held liable for any damages
    9.10 +  arising from the use of this software.
    9.11 +
    9.12 +  Permission is granted to anyone to use this software for any purpose,
    9.13 +  including commercial applications, and to alter it and redistribute it
    9.14 +  freely, subject to the following restrictions:
    9.15 +
    9.16 +  1. The origin of this software must not be misrepresented; you must not
    9.17 +     claim that you wrote the original software. If you use this software
    9.18 +     in a product, an acknowledgment in the product documentation would be
    9.19 +     appreciated but is not required.
    9.20 +  2. Altered source versions must be plainly marked as such, and must not be
    9.21 +     misrepresented as being the original software.
    9.22 +  3. This notice may not be removed or altered from any source distribution.
    9.23 +*/
    9.24 +#include "SDL_config.h"
    9.25 +
    9.26 +#if SDL_VIDEO_DRIVER_WINRT
    9.27 +
    9.28 +/* WinRT SDL video driver implementation
    9.29 +
    9.30 +   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
    9.31 +   was based off of SDL's "dummy" video driver.
    9.32 + */
    9.33 +
    9.34 +extern "C" {
    9.35 +#include "SDL_video.h"
    9.36 +#include "SDL_mouse.h"
    9.37 +#include "../SDL_sysvideo.h"
    9.38 +#include "../SDL_pixels_c.h"
    9.39 +#include "../../events/SDL_events_c.h"
    9.40 +}
    9.41 +
    9.42 +#include "SDL_WinRTApp.h"
    9.43 +#include "SDL_winrtvideo.h"
    9.44 +#include "SDL_winrtevents_c.h"
    9.45 +#include "SDL_winrtframebuffer_c.h"
    9.46 +
    9.47 +#define WINRTVID_DRIVER_NAME "dummy"
    9.48 +
    9.49 +/* Initialization/Query functions */
    9.50 +static int WINRT_VideoInit(_THIS);
    9.51 +static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    9.52 +static void WINRT_VideoQuit(_THIS);
    9.53 +
    9.54 +/* WinRT driver bootstrap functions */
    9.55 +
    9.56 +static int
    9.57 +WINRT_Available(void)
    9.58 +{
    9.59 +    return (1);
    9.60 +}
    9.61 +
    9.62 +static void
    9.63 +WINRT_DeleteDevice(SDL_VideoDevice * device)
    9.64 +{
    9.65 +    SDL_free(device);
    9.66 +}
    9.67 +
    9.68 +static SDL_VideoDevice *
    9.69 +WINRT_CreateDevice(int devindex)
    9.70 +{
    9.71 +    SDL_VideoDevice *device;
    9.72 +
    9.73 +    /* Initialize all variables that we clean on shutdown */
    9.74 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    9.75 +    if (!device) {
    9.76 +        SDL_OutOfMemory();
    9.77 +        if (device) {
    9.78 +            SDL_free(device);
    9.79 +        }
    9.80 +        return (0);
    9.81 +    }
    9.82 +
    9.83 +    /* Set the function pointers */
    9.84 +    device->VideoInit = WINRT_VideoInit;
    9.85 +    device->VideoQuit = WINRT_VideoQuit;
    9.86 +    device->SetDisplayMode = WINRT_SetDisplayMode;
    9.87 +    device->PumpEvents = WINRT_PumpEvents;
    9.88 +    device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
    9.89 +    device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
    9.90 +    device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
    9.91 +
    9.92 +    device->free = WINRT_DeleteDevice;
    9.93 +
    9.94 +    return device;
    9.95 +}
    9.96 +
    9.97 +VideoBootStrap WINRT_bootstrap = {
    9.98 +    WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
    9.99 +    WINRT_Available, WINRT_CreateDevice
   9.100 +};
   9.101 +
   9.102 +extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
   9.103 +
   9.104 +int
   9.105 +WINRT_VideoInit(_THIS)
   9.106 +{
   9.107 +    SDL_DisplayMode mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
   9.108 +    if (SDL_AddBasicVideoDisplay(&mode) < 0) {
   9.109 +        return -1;
   9.110 +    }
   9.111 +
   9.112 +    SDL_AddDisplayMode(&_this->displays[0], &mode);
   9.113 +
   9.114 +    /* We're done! */
   9.115 +    return 0;
   9.116 +}
   9.117 +
   9.118 +static int
   9.119 +WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   9.120 +{
   9.121 +    return 0;
   9.122 +}
   9.123 +
   9.124 +void
   9.125 +WINRT_VideoQuit(_THIS)
   9.126 +{
   9.127 +}
   9.128 +
   9.129 +#endif /* SDL_VIDEO_DRIVER_WINRT */
   9.130 +
   9.131 +/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/video/windowsrt/SDL_winrtvideo.h	Sat Oct 27 22:57:07 2012 -0400
    10.2 +++ b/src/video/windowsrt/SDL_winrtvideo.h	Sun Oct 28 18:45:33 2012 -0400
    10.3 @@ -23,8 +23,16 @@
    10.4  #ifndef _SDL_winrtvideo_h
    10.5  #define _SDL_winrtvideo_h
    10.6  
    10.7 +#ifdef __cplusplus
    10.8 +extern "C" {
    10.9 +#endif
   10.10 +
   10.11  #include "../SDL_sysvideo.h"
   10.12  
   10.13 +#ifdef __cplusplus
   10.14 +}
   10.15 +#endif
   10.16 +
   10.17  #endif /* _SDL_winrtvideo_h */
   10.18  
   10.19  /* vi: set ts=4 sw=4 expandtab: */
    11.1 --- a/src/video/windowsrt/SDLmain_WinRT_common.h	Sat Oct 27 22:57:07 2012 -0400
    11.2 +++ b/src/video/windowsrt/SDLmain_WinRT_common.h	Sun Oct 28 18:45:33 2012 -0400
    11.3 @@ -4,4 +4,9 @@
    11.4  #include <d3d11_1.h>
    11.5  #include <DirectXMath.h>
    11.6  #include <memory>
    11.7 -#include <agile.h>
    11.8 \ No newline at end of file
    11.9 +#include <agile.h>
   11.10 +#include <vector>
   11.11 +
   11.12 +extern "C" {
   11.13 +#include "../SDL_sysvideo.h"
   11.14 +}