comparison src/video/win32/SDL_win32modes.c @ 2119:9341a884a4d9

Fixed running on Windows under VMware
author Sam Lantinga <slouken@libsdl.org>
date Thu, 14 Jun 2007 06:32:36 +0000
parents a788656ca29a
children eba4fd03b4f6
comparison
equal deleted inserted replaced
2118:238db749017a 2119:9341a884a4d9
108 } 108 }
109 } 109 }
110 return SDL_TRUE; 110 return SDL_TRUE;
111 } 111 }
112 112
113 static void
114 WIN_AddDisplay(LPTSTR DeviceName)
115 {
116 SDL_VideoDisplay display;
117 SDL_DisplayData *displaydata;
118 SDL_DisplayMode mode;
119
120 #ifdef DEBUG_MODES
121 printf("Display: %s\n", WIN_StringToUTF8(DeviceName));
122 #endif
123 if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
124 return;
125 }
126
127 displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
128 if (!displaydata) {
129 return;
130 }
131 SDL_memcpy(displaydata->DeviceName, DeviceName,
132 sizeof(displaydata->DeviceName));
133
134 SDL_zero(display);
135 display.desktop_mode = mode;
136 display.current_mode = mode;
137 display.driverdata = displaydata;
138 SDL_AddVideoDisplay(&display);
139 }
140
113 void 141 void
114 WIN_InitModes(_THIS) 142 WIN_InitModes(_THIS)
115 { 143 {
116 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 144 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
117 DWORD i, j; 145 DWORD i, j;
130 SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName)); 158 SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName));
131 #ifdef DEBUG_MODES 159 #ifdef DEBUG_MODES
132 printf("Device: %s\n", WIN_StringToUTF8(DeviceName)); 160 printf("Device: %s\n", WIN_StringToUTF8(DeviceName));
133 #endif 161 #endif
134 for (j = 0;; ++j) { 162 for (j = 0;; ++j) {
135 SDL_VideoDisplay display;
136 SDL_DisplayData *displaydata;
137 SDL_DisplayMode mode;
138
139 if (!EnumDisplayDevices(DeviceName, j, &device, 0)) { 163 if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
140 break; 164 break;
141 } 165 }
142 if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) { 166 if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
143 continue; 167 continue;
144 } 168 }
145 #ifdef DEBUG_MODES 169 WIN_AddDisplay(device.DeviceName);
146 printf("Monitor: %s\n", WIN_StringToUTF8(device.DeviceName)); 170 }
147 #endif 171 if (j == 0) {
148 if (!WIN_GetDisplayMode(DeviceName, ENUM_CURRENT_SETTINGS, &mode)) { 172 WIN_AddDisplay(DeviceName);
149 break;
150 }
151
152 displaydata =
153 (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
154 if (!displaydata) {
155 continue;
156 }
157 SDL_memcpy(displaydata->DeviceName, DeviceName,
158 sizeof(DeviceName));
159
160 SDL_zero(display);
161 display.desktop_mode = mode;
162 display.current_mode = mode;
163 display.driverdata = displaydata;
164 SDL_AddVideoDisplay(&display);
165 } 173 }
166 } 174 }
167 } 175 }
168 176
169 void 177 void