src/video/windowsrt/SDL_winrtvideo.cpp
changeset 8333 49973bfb8d23
parent 8332 ea83d191cc17
child 8334 09b0670fece4
equal deleted inserted replaced
8332:ea83d191cc17 8333:49973bfb8d23
    39 #include "SDL_WinRTApp.h"
    39 #include "SDL_WinRTApp.h"
    40 #include "SDL_winrtvideo.h"
    40 #include "SDL_winrtvideo.h"
    41 #include "SDL_winrtevents_c.h"
    41 #include "SDL_winrtevents_c.h"
    42 #include "SDL_winrtframebuffer_c.h"
    42 #include "SDL_winrtframebuffer_c.h"
    43 
    43 
       
    44 /* On Windows, windows.h defines CreateWindow */
       
    45 #ifdef CreateWindow
       
    46 #undef CreateWindow
       
    47 #endif
       
    48 
    44 extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
    49 extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
    45 
    50 
    46 #define WINRTVID_DRIVER_NAME "dummy"
    51 #define WINRTVID_DRIVER_NAME "dummy"
    47 
    52 
    48 /* Initialization/Query functions */
    53 /* Initialization/Query functions */
    49 static int WINRT_VideoInit(_THIS);
    54 static int WINRT_VideoInit(_THIS);
    50 static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    55 static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
    51 static void WINRT_VideoQuit(_THIS);
    56 static void WINRT_VideoQuit(_THIS);
       
    57 
       
    58 /* Window functions */
       
    59 static int WINRT_CreateWindow(_THIS, SDL_Window * window);
       
    60 static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
    52 
    61 
    53 /* WinRT driver bootstrap functions */
    62 /* WinRT driver bootstrap functions */
    54 
    63 
    55 static int
    64 static int
    56 WINRT_Available(void)
    65 WINRT_Available(void)
    80     }
    89     }
    81 
    90 
    82     /* Set the function pointers */
    91     /* Set the function pointers */
    83     device->VideoInit = WINRT_VideoInit;
    92     device->VideoInit = WINRT_VideoInit;
    84     device->VideoQuit = WINRT_VideoQuit;
    93     device->VideoQuit = WINRT_VideoQuit;
       
    94     device->CreateWindow = WINRT_CreateWindow;
       
    95     device->DestroyWindow = WINRT_DestroyWindow;
    85     device->SetDisplayMode = WINRT_SetDisplayMode;
    96     device->SetDisplayMode = WINRT_SetDisplayMode;
    86     device->PumpEvents = WINRT_PumpEvents;
    97     device->PumpEvents = WINRT_PumpEvents;
    87     device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
    98     device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
    88     device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
    99     device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
    89     device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
   100     device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
   121 void
   132 void
   122 WINRT_VideoQuit(_THIS)
   133 WINRT_VideoQuit(_THIS)
   123 {
   134 {
   124 }
   135 }
   125 
   136 
       
   137 int
       
   138 WINRT_CreateWindow(_THIS, SDL_Window * window)
       
   139 {
       
   140     // TODO, WinRT: modify WINRT_Createwindow to ensure that, for now, only one window gets created
       
   141     // (until multimonitor support is added to the WinRT port).
       
   142 
       
   143     SDL_WindowData *data;
       
   144     data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
       
   145     if (!data) {
       
   146         SDL_OutOfMemory();
       
   147         return -1;
       
   148     }
       
   149     SDL_zerop(data);
       
   150     data->sdlWindow = window;
       
   151 
       
   152     /* Adjust the window data to match the screen */
       
   153     window->x = 0;
       
   154     window->y = 0;
       
   155     window->w = _this->displays->desktop_mode.w;
       
   156     window->h = _this->displays->desktop_mode.h;
       
   157 
       
   158     SDL_WinRTGlobalApp->SetSDLWindowData(data);
       
   159 
       
   160     return 0;
       
   161 }
       
   162 
       
   163 void
       
   164 WINRT_DestroyWindow(_THIS, SDL_Window * window)
       
   165 {
       
   166     SDL_WinRTGlobalApp->SetSDLWindowData(NULL);
       
   167 }
       
   168 
       
   169 
   126 #endif /* SDL_VIDEO_DRIVER_WINRT */
   170 #endif /* SDL_VIDEO_DRIVER_WINRT */
   127 
   171 
   128 /* vi: set ts=4 sw=4 expandtab: */
   172 /* vi: set ts=4 sw=4 expandtab: */