src/video/windowsrt/SDL_winrtvideo.c
changeset 8327 bc51589f33dc
child 8328 88b08ad81bf7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/windowsrt/SDL_winrtvideo.c	Sat Oct 27 22:48:04 2012 -0400
     1.3 @@ -0,0 +1,137 @@
     1.4 +/*
     1.5 +  Simple DirectMedia Layer
     1.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     1.7 +
     1.8 +  This software is provided 'as-is', without any express or implied
     1.9 +  warranty.  In no event will the authors be held liable for any damages
    1.10 +  arising from the use of this software.
    1.11 +
    1.12 +  Permission is granted to anyone to use this software for any purpose,
    1.13 +  including commercial applications, and to alter it and redistribute it
    1.14 +  freely, subject to the following restrictions:
    1.15 +
    1.16 +  1. The origin of this software must not be misrepresented; you must not
    1.17 +     claim that you wrote the original software. If you use this software
    1.18 +     in a product, an acknowledgment in the product documentation would be
    1.19 +     appreciated but is not required.
    1.20 +  2. Altered source versions must be plainly marked as such, and must not be
    1.21 +     misrepresented as being the original software.
    1.22 +  3. This notice may not be removed or altered from any source distribution.
    1.23 +*/
    1.24 +#include "SDL_config.h"
    1.25 +
    1.26 +#if SDL_VIDEO_DRIVER_WINRT
    1.27 +
    1.28 +/* WinRT SDL video driver implementation
    1.29 +
    1.30 +   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
    1.31 +   was based off of SDL's "dummy" video driver.
    1.32 + */
    1.33 +
    1.34 +#include "SDL_video.h"
    1.35 +#include "SDL_mouse.h"
    1.36 +#include "../SDL_sysvideo.h"
    1.37 +#include "../SDL_pixels_c.h"
    1.38 +#include "../../events/SDL_events_c.h"
    1.39 +
    1.40 +#include "SDL_winrtvideo.h"
    1.41 +#include "SDL_winrtevents_c.h"
    1.42 +#include "SDL_winrtframebuffer_c.h"
    1.43 +
    1.44 +#define WINRTVID_DRIVER_NAME "dummy"
    1.45 +
    1.46 +/* Initialization/Query functions */
    1.47 +static int WINRT_VideoInit(_THIS);
    1.48 +static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    1.49 +static void WINRT_VideoQuit(_THIS);
    1.50 +
    1.51 +/* WinRT driver bootstrap functions */
    1.52 +
    1.53 +static int
    1.54 +WINRT_Available(void)
    1.55 +{
    1.56 +    const char *envr = SDL_getenv("SDL_VIDEODRIVER");
    1.57 +    if ((envr) && (SDL_strcmp(envr, WINRTVID_DRIVER_NAME) == 0)) {
    1.58 +        return (1);
    1.59 +    }
    1.60 +
    1.61 +    return (0);
    1.62 +}
    1.63 +
    1.64 +static void
    1.65 +WINRT_DeleteDevice(SDL_VideoDevice * device)
    1.66 +{
    1.67 +    SDL_free(device);
    1.68 +}
    1.69 +
    1.70 +static SDL_VideoDevice *
    1.71 +WINRT_CreateDevice(int devindex)
    1.72 +{
    1.73 +    SDL_VideoDevice *device;
    1.74 +
    1.75 +    /* Initialize all variables that we clean on shutdown */
    1.76 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    1.77 +    if (!device) {
    1.78 +        SDL_OutOfMemory();
    1.79 +        if (device) {
    1.80 +            SDL_free(device);
    1.81 +        }
    1.82 +        return (0);
    1.83 +    }
    1.84 +
    1.85 +    /* Set the function pointers */
    1.86 +    device->VideoInit = WINRT_VideoInit;
    1.87 +    device->VideoQuit = WINRT_VideoQuit;
    1.88 +    device->SetDisplayMode = WINRT_SetDisplayMode;
    1.89 +    device->PumpEvents = WINRT_PumpEvents;
    1.90 +    device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
    1.91 +    device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
    1.92 +    device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
    1.93 +
    1.94 +    device->free = WINRT_DeleteDevice;
    1.95 +
    1.96 +    return device;
    1.97 +}
    1.98 +
    1.99 +VideoBootStrap WINRT_bootstrap = {
   1.100 +    WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
   1.101 +    WINRT_Available, WINRT_CreateDevice
   1.102 +};
   1.103 +
   1.104 +
   1.105 +int
   1.106 +WINRT_VideoInit(_THIS)
   1.107 +{
   1.108 +    SDL_DisplayMode mode;
   1.109 +
   1.110 +    /* Use a fake 32-bpp desktop mode */
   1.111 +    mode.format = SDL_PIXELFORMAT_RGB888;
   1.112 +    mode.w = 1024;
   1.113 +    mode.h = 768;
   1.114 +    mode.refresh_rate = 0;
   1.115 +    mode.driverdata = NULL;
   1.116 +    if (SDL_AddBasicVideoDisplay(&mode) < 0) {
   1.117 +        return -1;
   1.118 +    }
   1.119 +
   1.120 +    SDL_zero(mode);
   1.121 +    SDL_AddDisplayMode(&_this->displays[0], &mode);
   1.122 +
   1.123 +    /* We're done! */
   1.124 +    return 0;
   1.125 +}
   1.126 +
   1.127 +static int
   1.128 +WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
   1.129 +{
   1.130 +    return 0;
   1.131 +}
   1.132 +
   1.133 +void
   1.134 +WINRT_VideoQuit(_THIS)
   1.135 +{
   1.136 +}
   1.137 +
   1.138 +#endif /* SDL_VIDEO_DRIVER_WINRT */
   1.139 +
   1.140 +/* vi: set ts=4 sw=4 expandtab: */