comparison src/video/win32/SDL_win32modes.c @ 1733:0b1070f2f94d SDL-1.3

Implemented gamma correction on Windows. Added general code to restore the video mode and gamma when windows lose focus.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 09 Jul 2006 09:02:26 +0000
parents 98a3207ddde8
children 8dd28c4ef746
comparison
equal deleted inserted replaced
1732:fd65f12b6de6 1733:0b1070f2f94d
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #include "SDL_win32video.h" 24 #include "SDL_win32video.h"
25 25
26
27 typedef struct
28 {
29 TCHAR DeviceName[32];
30 DEVMODE DeviceMode;
31 } SDL_DisplayModeData;
32 26
33 /* FIXME: Each call to EnumDisplaySettings() takes about 6 ms on my laptop. 27 /* FIXME: Each call to EnumDisplaySettings() takes about 6 ms on my laptop.
34 With 500 or so modes, this takes almost 3 seconds to run! 28 With 500 or so modes, this takes almost 3 seconds to run!
35 */ 29 */
36 30
121 115
122 void 116 void
123 WIN_InitModes(_THIS) 117 WIN_InitModes(_THIS)
124 { 118 {
125 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 119 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
126 DWORD i, j, k; 120 DWORD i, j;
127 DISPLAY_DEVICE device; 121 DISPLAY_DEVICE device;
128 122
129 device.cb = sizeof(device); 123 device.cb = sizeof(device);
130 for (i = 0;; ++i) { 124 for (i = 0;; ++i) {
131 TCHAR DeviceName[32]; 125 TCHAR DeviceName[32];
141 printf("Device: %s\n", WIN_StringToUTF8(DeviceName)); 135 printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
142 #endif 136 #endif
143 for (j = 0;; ++j) { 137 for (j = 0;; ++j) {
144 int index; 138 int index;
145 SDL_VideoDisplay display; 139 SDL_VideoDisplay display;
140 SDL_DisplayData *displaydata;
146 SDL_DisplayMode mode; 141 SDL_DisplayMode mode;
147 142
148 if (!EnumDisplayDevices(DeviceName, j, &device, 0)) { 143 if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
149 break; 144 break;
150 } 145 }
155 printf("Monitor: %s\n", WIN_StringToUTF8(device.DeviceName)); 150 printf("Monitor: %s\n", WIN_StringToUTF8(device.DeviceName));
156 #endif 151 #endif
157 if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) { 152 if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
158 break; 153 break;
159 } 154 }
155
156 displaydata =
157 (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
158 if (!displaydata) {
159 continue;
160 }
161 SDL_memcpy(displaydata->DeviceName, DeviceName,
162 sizeof(DeviceName));
163
160 SDL_zero(display); 164 SDL_zero(display);
161 display.desktop_mode = mode; 165 display.desktop_mode = mode;
162 display.current_mode = mode; 166 display.current_mode = mode;
163 index = SDL_AddVideoDisplay(&display); 167 display.driverdata = displaydata;
164 168 SDL_AddVideoDisplay(&display);
165 for (k = 0;; ++k) { 169 }
166 if (!WIN_GetDisplayMode(DeviceName, k, &mode)) { 170 }
167 break; 171 }
168 } 172
169 if (!SDL_AddDisplayMode(index, &mode)) { 173 void
170 SDL_free(mode.driverdata); 174 WIN_GetDisplayModes(_THIS)
171 } 175 {
172 } 176 SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
177 DWORD i;
178 SDL_DisplayMode mode;
179
180 for (i = 0;; ++i) {
181 if (!WIN_GetDisplayMode(data->DeviceName, i, &mode)) {
182 break;
183 }
184 if (!SDL_AddDisplayMode(_this->current_display, &mode)) {
185 SDL_free(mode.driverdata);
173 } 186 }
174 } 187 }
175 } 188 }
176 189
177 int 190 int