src/video/windowsrt/SDL_winrtvideo.c
changeset 8327 bc51589f33dc
child 8328 88b08ad81bf7
equal deleted inserted replaced
8326:22db28fb8099 8327:bc51589f33dc
       
     1 /*
       
     2   Simple DirectMedia Layer
       
     3   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
       
     4 
       
     5   This software is provided 'as-is', without any express or implied
       
     6   warranty.  In no event will the authors be held liable for any damages
       
     7   arising from the use of this software.
       
     8 
       
     9   Permission is granted to anyone to use this software for any purpose,
       
    10   including commercial applications, and to alter it and redistribute it
       
    11   freely, subject to the following restrictions:
       
    12 
       
    13   1. The origin of this software must not be misrepresented; you must not
       
    14      claim that you wrote the original software. If you use this software
       
    15      in a product, an acknowledgment in the product documentation would be
       
    16      appreciated but is not required.
       
    17   2. Altered source versions must be plainly marked as such, and must not be
       
    18      misrepresented as being the original software.
       
    19   3. This notice may not be removed or altered from any source distribution.
       
    20 */
       
    21 #include "SDL_config.h"
       
    22 
       
    23 #if SDL_VIDEO_DRIVER_WINRT
       
    24 
       
    25 /* WinRT SDL video driver implementation
       
    26 
       
    27    Initial work on this was done by David Ludwig (dludwig@pobox.com), and
       
    28    was based off of SDL's "dummy" video driver.
       
    29  */
       
    30 
       
    31 #include "SDL_video.h"
       
    32 #include "SDL_mouse.h"
       
    33 #include "../SDL_sysvideo.h"
       
    34 #include "../SDL_pixels_c.h"
       
    35 #include "../../events/SDL_events_c.h"
       
    36 
       
    37 #include "SDL_winrtvideo.h"
       
    38 #include "SDL_winrtevents_c.h"
       
    39 #include "SDL_winrtframebuffer_c.h"
       
    40 
       
    41 #define WINRTVID_DRIVER_NAME "dummy"
       
    42 
       
    43 /* Initialization/Query functions */
       
    44 static int WINRT_VideoInit(_THIS);
       
    45 static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
       
    46 static void WINRT_VideoQuit(_THIS);
       
    47 
       
    48 /* WinRT driver bootstrap functions */
       
    49 
       
    50 static int
       
    51 WINRT_Available(void)
       
    52 {
       
    53     const char *envr = SDL_getenv("SDL_VIDEODRIVER");
       
    54     if ((envr) && (SDL_strcmp(envr, WINRTVID_DRIVER_NAME) == 0)) {
       
    55         return (1);
       
    56     }
       
    57 
       
    58     return (0);
       
    59 }
       
    60 
       
    61 static void
       
    62 WINRT_DeleteDevice(SDL_VideoDevice * device)
       
    63 {
       
    64     SDL_free(device);
       
    65 }
       
    66 
       
    67 static SDL_VideoDevice *
       
    68 WINRT_CreateDevice(int devindex)
       
    69 {
       
    70     SDL_VideoDevice *device;
       
    71 
       
    72     /* Initialize all variables that we clean on shutdown */
       
    73     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
       
    74     if (!device) {
       
    75         SDL_OutOfMemory();
       
    76         if (device) {
       
    77             SDL_free(device);
       
    78         }
       
    79         return (0);
       
    80     }
       
    81 
       
    82     /* Set the function pointers */
       
    83     device->VideoInit = WINRT_VideoInit;
       
    84     device->VideoQuit = WINRT_VideoQuit;
       
    85     device->SetDisplayMode = WINRT_SetDisplayMode;
       
    86     device->PumpEvents = WINRT_PumpEvents;
       
    87     device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
       
    88     device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
       
    89     device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
       
    90 
       
    91     device->free = WINRT_DeleteDevice;
       
    92 
       
    93     return device;
       
    94 }
       
    95 
       
    96 VideoBootStrap WINRT_bootstrap = {
       
    97     WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
       
    98     WINRT_Available, WINRT_CreateDevice
       
    99 };
       
   100 
       
   101 
       
   102 int
       
   103 WINRT_VideoInit(_THIS)
       
   104 {
       
   105     SDL_DisplayMode mode;
       
   106 
       
   107     /* Use a fake 32-bpp desktop mode */
       
   108     mode.format = SDL_PIXELFORMAT_RGB888;
       
   109     mode.w = 1024;
       
   110     mode.h = 768;
       
   111     mode.refresh_rate = 0;
       
   112     mode.driverdata = NULL;
       
   113     if (SDL_AddBasicVideoDisplay(&mode) < 0) {
       
   114         return -1;
       
   115     }
       
   116 
       
   117     SDL_zero(mode);
       
   118     SDL_AddDisplayMode(&_this->displays[0], &mode);
       
   119 
       
   120     /* We're done! */
       
   121     return 0;
       
   122 }
       
   123 
       
   124 static int
       
   125 WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
       
   126 {
       
   127     return 0;
       
   128 }
       
   129 
       
   130 void
       
   131 WINRT_VideoQuit(_THIS)
       
   132 {
       
   133 }
       
   134 
       
   135 #endif /* SDL_VIDEO_DRIVER_WINRT */
       
   136 
       
   137 /* vi: set ts=4 sw=4 expandtab: */