src/video/windows/SDL_windowsvideo.c
author Sam Lantinga
Tue, 08 Feb 2011 16:50:51 -0800
changeset 5229 c015d3e63631
parent 5175 9b2e99ebd099
child 5243 3a8a452b49f0
permissions -rw-r--r--
Fixed setting the texture unit, still doesn't work.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_main.h"
    25 #include "SDL_video.h"
    26 #include "SDL_mouse.h"
    27 #include "../SDL_sysvideo.h"
    28 #include "../SDL_pixels_c.h"
    29 
    30 #include "SDL_windowsvideo.h"
    31 #include "SDL_windowsframebuffer.h"
    32 #include "SDL_windowsshape.h"
    33 
    34 /* Initialization/Query functions */
    35 static int WIN_VideoInit(_THIS);
    36 static void WIN_VideoQuit(_THIS);
    37 
    38 
    39 /* Windows driver bootstrap functions */
    40 
    41 static int
    42 WIN_Available(void)
    43 {
    44     return (1);
    45 }
    46 
    47 static void
    48 WIN_DeleteDevice(SDL_VideoDevice * device)
    49 {
    50     SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
    51 
    52     SDL_UnregisterApp();
    53 #ifdef _WIN32_WCE
    54     if(data->hAygShell) {
    55        SDL_UnloadObject(data->hAygShell);
    56     }
    57 #endif
    58 	if (data->userDLL) {
    59 		SDL_UnloadObject(data->userDLL);
    60 	}
    61 
    62     SDL_free(device->driverdata);
    63     SDL_free(device);
    64 }
    65 
    66 static SDL_VideoDevice *
    67 WIN_CreateDevice(int devindex)
    68 {
    69     SDL_VideoDevice *device;
    70     SDL_VideoData *data;
    71 
    72     SDL_RegisterApp(NULL, 0, NULL);
    73 
    74     /* Initialize all variables that we clean on shutdown */
    75     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    76     if (device) {
    77         data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
    78     } else {
    79         data = NULL;
    80     }
    81     if (!data) {
    82         SDL_OutOfMemory();
    83         if (device) {
    84             SDL_free(device);
    85         }
    86         return NULL;
    87     }
    88     device->driverdata = data;
    89 
    90 #ifdef _WIN32_WCE
    91     data->hAygShell = SDL_LoadObject("\\windows\\aygshell.dll");
    92     if(0 == data->hAygShell)
    93         data->hAygShell = SDL_LoadObject("aygshell.dll");
    94     data->SHFullScreen = (0 != data->hAygShell ?
    95         (PFNSHFullScreen) SDL_LoadFunction(data->hAygShell, "SHFullScreen") : 0);
    96     data->CoordTransform = NULL;
    97 #endif
    98 
    99 	data->userDLL = SDL_LoadObject("USER32.DLL");
   100 	if (data->userDLL) {
   101 		data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
   102 		data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
   103 		data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
   104 	}
   105 
   106     /* Set the function pointers */
   107     device->VideoInit = WIN_VideoInit;
   108     device->VideoQuit = WIN_VideoQuit;
   109     device->GetDisplayBounds = WIN_GetDisplayBounds;
   110     device->GetDisplayModes = WIN_GetDisplayModes;
   111     device->SetDisplayMode = WIN_SetDisplayMode;
   112     device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
   113     device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
   114     device->PumpEvents = WIN_PumpEvents;
   115 
   116 #undef CreateWindow
   117     device->CreateWindow = WIN_CreateWindow;
   118     device->CreateWindowFrom = WIN_CreateWindowFrom;
   119     device->SetWindowTitle = WIN_SetWindowTitle;
   120     device->SetWindowIcon = WIN_SetWindowIcon;
   121     device->SetWindowPosition = WIN_SetWindowPosition;
   122     device->SetWindowSize = WIN_SetWindowSize;
   123     device->ShowWindow = WIN_ShowWindow;
   124     device->HideWindow = WIN_HideWindow;
   125     device->RaiseWindow = WIN_RaiseWindow;
   126     device->MaximizeWindow = WIN_MaximizeWindow;
   127     device->MinimizeWindow = WIN_MinimizeWindow;
   128     device->RestoreWindow = WIN_RestoreWindow;
   129     device->SetWindowGrab = WIN_SetWindowGrab;
   130     device->DestroyWindow = WIN_DestroyWindow;
   131     device->GetWindowWMInfo = WIN_GetWindowWMInfo;
   132     device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer;
   133     device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer;
   134     device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer;
   135     
   136     device->shape_driver.CreateShaper = Win32_CreateShaper;
   137     device->shape_driver.SetWindowShape = Win32_SetWindowShape;
   138     device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape;
   139     
   140 #if SDL_VIDEO_OPENGL_WGL
   141     device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   142     device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   143     device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
   144     device->GL_CreateContext = WIN_GL_CreateContext;
   145     device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   146     device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
   147     device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
   148     device->GL_SwapWindow = WIN_GL_SwapWindow;
   149     device->GL_DeleteContext = WIN_GL_DeleteContext;
   150 #endif
   151     device->StartTextInput = WIN_StartTextInput;
   152     device->StopTextInput = WIN_StopTextInput;
   153     device->SetTextInputRect = WIN_SetTextInputRect;
   154 
   155     device->SetClipboardText = WIN_SetClipboardText;
   156     device->GetClipboardText = WIN_GetClipboardText;
   157     device->HasClipboardText = WIN_HasClipboardText;
   158 
   159     device->free = WIN_DeleteDevice;
   160 
   161     return device;
   162 }
   163 
   164 VideoBootStrap WINDOWS_bootstrap = {
   165     "windows", "SDL Windows video driver", WIN_Available, WIN_CreateDevice
   166 };
   167 
   168 int
   169 WIN_VideoInit(_THIS)
   170 {
   171     if (WIN_InitModes(_this) < 0) {
   172         return -1;
   173     }
   174 
   175     WIN_InitKeyboard(_this);
   176     WIN_InitMouse(_this);
   177 
   178     return 0;
   179 }
   180 
   181 void
   182 WIN_VideoQuit(_THIS)
   183 {
   184     WIN_QuitModes(_this);
   185     WIN_QuitKeyboard(_this);
   186     WIN_QuitMouse(_this);
   187 }
   188 
   189 /* vim: set ts=4 sw=4 expandtab: */