annotate src/video/win32/SDL_win32video.c @ 1725:98a3207ddde8 SDL-1.3

Implemented Win32 video mode support
author Sam Lantinga <slouken@libsdl.org>
date Fri, 07 Jul 2006 08:05:39 +0000
parents 6c63fc2bd986
children e70477157db9
rev   line source
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"
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
31 #include "SDL_dibrender.h"
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 /* Initialization/Query functions */
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
34 static int WIN_VideoInit(_THIS);
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
35 static void WIN_VideoQuit(_THIS);
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 /* WIN32 driver bootstrap functions */
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 static int
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
40 WIN_Available(void)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 {
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 return (1);
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
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 static void
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
46 WIN_DeleteDevice(SDL_VideoDevice * device)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 {
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
48 SDL_UnregisterApp();
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
49 SDL_free(device->driverdata);
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 SDL_free(device);
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 }
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 static SDL_VideoDevice *
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
54 WIN_CreateDevice(int devindex)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 {
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 SDL_VideoDevice *device;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
58 SDL_RegisterApp(NULL, 0, NULL);
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
59
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 /* 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
61 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
62 if (device) {
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
63 device->driverdata =
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
64 (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
65 }
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
66 if (!device || !device->driverdata) {
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 SDL_OutOfMemory();
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 if (device) {
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 SDL_free(device);
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 }
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
71 return NULL;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 }
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 /* Set the function pointers */
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
75 device->VideoInit = WIN_VideoInit;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
76 device->SetDisplayMode = WIN_SetDisplayMode;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
77 device->VideoQuit = WIN_VideoQuit;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
78 device->PumpEvents = WIN_PumpEvents;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 #undef CreateWindow
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
81 device->CreateWindow = WIN_CreateWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
82 device->CreateWindowFrom = WIN_CreateWindowFrom;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
83 device->SetWindowTitle = WIN_SetWindowTitle;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
84 device->SetWindowPosition = WIN_SetWindowPosition;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
85 device->SetWindowSize = WIN_SetWindowSize;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
86 device->ShowWindow = WIN_ShowWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
87 device->HideWindow = WIN_HideWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
88 device->RaiseWindow = WIN_RaiseWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
89 device->MaximizeWindow = WIN_MaximizeWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
90 device->MinimizeWindow = WIN_MinimizeWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
91 device->RestoreWindow = WIN_RestoreWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
92 device->SetWindowGrab = WIN_SetWindowGrab;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
93 device->DestroyWindow = WIN_DestroyWindow;
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
94 device->GetWindowWMInfo = WIN_GetWindowWMInfo;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
96 device->free = WIN_DeleteDevice;
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 return device;
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
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 VideoBootStrap WIN32_bootstrap = {
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 "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
103 WIN_Available, WIN_CreateDevice
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 };
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105
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 int
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
108 WIN_VideoInit(_THIS)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 {
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
110 WIN_InitModes(_this);
1724
6c63fc2bd986 Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents: 1720
diff changeset
111 SDL_AddRenderDriver(0, &SDL_DIB_RenderDriver);
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
113 WIN_InitKeyboard(_this);
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
114 WIN_InitMouse(_this);
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1718
diff changeset
115
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 return 0;
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 }
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 void
1718
ed4d4f1ea201 Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents: 1712
diff changeset
120 WIN_VideoQuit(_THIS)
1712
931d111e737a Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 {
1725
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
122 WIN_QuitModes(_this);
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
123 WIN_QuitKeyboard(_this);
98a3207ddde8 Implemented Win32 video mode support
Sam Lantinga <slouken@libsdl.org>
parents: 1724
diff changeset
124 WIN_QuitMouse(_this);
1712
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 /* vim: set ts=4 sw=4 expandtab: */