src/video/win32/SDL_win32video.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 30 Jun 2006 05:42:49 +0000
branchSDL-1.3
changeset 1720 a1ebb17f9c52
parent 1718 ed4d4f1ea201
child 1724 6c63fc2bd986
permissions -rw-r--r--
Cleaned up a bunch of warnings, started adding Win32 event support
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
    Copyright (C) 1997-2006 Sam Lantinga
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
    24
#include "SDL_main.h"
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_video.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#include "SDL_mouse.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "../SDL_sysvideo.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include "../SDL_pixels_c.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#include "SDL_win32video.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#include "SDL_win32events.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#include "SDL_win32window.h"
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
/* Initialization/Query functions */
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    35
static int WIN_VideoInit(_THIS);
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    36
static int WIN_SetDisplayMode(_THIS, const SDL_DisplayMode * mode);
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    37
static void WIN_VideoQuit(_THIS);
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
/* WIN32 driver bootstrap functions */
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
static int
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    42
WIN_Available(void)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
{
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
    return (1);
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
}
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
static void
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    48
WIN_DeleteDevice(SDL_VideoDevice * device)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
{
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    50
    SDL_UnregisterApp();
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
    51
    SDL_free(device->driverdata);
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
    SDL_free(device);
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
}
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
static SDL_VideoDevice *
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    56
WIN_CreateDevice(int devindex)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
{
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    SDL_VideoDevice *device;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    60
    SDL_RegisterApp(NULL, 0, NULL);
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    61
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
    /* Initialize all variables that we clean on shutdown */
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
    63
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    if (device) {
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
    65
        device->driverdata =
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
    66
            (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    }
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
    68
    if (!device || !device->driverdata) {
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
        SDL_OutOfMemory();
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
        if (device) {
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
            SDL_free(device);
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
        }
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    73
        return NULL;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
    }
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
    /* Set the function pointers */
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    77
    device->VideoInit = WIN_VideoInit;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    78
    device->SetDisplayMode = WIN_SetDisplayMode;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    79
    device->VideoQuit = WIN_VideoQuit;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    80
    device->PumpEvents = WIN_PumpEvents;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
#undef CreateWindow
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    83
    device->CreateWindow = WIN_CreateWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    84
    device->CreateWindowFrom = WIN_CreateWindowFrom;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    85
    device->SetWindowTitle = WIN_SetWindowTitle;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    86
    device->SetWindowPosition = WIN_SetWindowPosition;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    87
    device->SetWindowSize = WIN_SetWindowSize;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    88
    device->ShowWindow = WIN_ShowWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    89
    device->HideWindow = WIN_HideWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    90
    device->RaiseWindow = WIN_RaiseWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    91
    device->MaximizeWindow = WIN_MaximizeWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    92
    device->MinimizeWindow = WIN_MinimizeWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    93
    device->RestoreWindow = WIN_RestoreWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    94
    device->SetWindowGrab = WIN_SetWindowGrab;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    95
    device->DestroyWindow = WIN_DestroyWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    96
    device->GetWindowWMInfo = WIN_GetWindowWMInfo;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
    98
    device->free = WIN_DeleteDevice;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
    return device;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
}
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
VideoBootStrap WIN32_bootstrap = {
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
    "win32", "SDL Win32/64 video driver",
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
   105
    WIN_Available, WIN_CreateDevice
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
};
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
int
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
   110
WIN_VideoInit(_THIS)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
{
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
    SDL_DisplayMode mode;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
    SDL_AddBasicVideoDisplay(NULL);
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
   115
    //SDL_AddRenderDriver(0, &SDL_WIN_RenderDriver);
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
    SDL_zero(mode);
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
    SDL_AddDisplayMode(0, &mode);
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
   120
    WIN_AddKeyboard(_this);
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
   121
    WIN_AddMouse(_this);
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
   122
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
    /* We're done! */
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    return 0;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
}
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
static int
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
   128
WIN_SetDisplayMode(_THIS, const SDL_DisplayMode * mode)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
{
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
    SDL_CurrentDisplay.current_mode = *mode;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
    return 0;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
}
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
void
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
   135
WIN_VideoQuit(_THIS)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
{
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
}
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
/* vim: set ts=4 sw=4 expandtab: */