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