Mercurial > fife-parpg
comparison engine/core/video/devicecaps.cpp @ 643:edf6dcfe8cd4
* Modified the way we detect valid resolutions because SDL_VideoModeOK() was unreliable on a Mac when passed values returned from SDL_ListModes(). It now uses a pre-canned list of common resolutions to check.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 09 Oct 2010 17:00:33 +0000 |
parents | 6e2151325017 |
children | 07b1cf8e92b5 |
comparison
equal
deleted
inserted
replaced
642:6e2151325017 | 643:edf6dcfe8cd4 |
---|---|
116 char buffer[bufferSize]; | 116 char buffer[bufferSize]; |
117 | 117 |
118 int numBPP = 1; | 118 int numBPP = 1; |
119 int bpps[numBPP]; | 119 int bpps[numBPP]; |
120 | 120 |
121 SDL_Rect **modes; | |
122 | |
123 //clear in case this is called twice | 121 //clear in case this is called twice |
124 reset(); | 122 reset(); |
125 | 123 |
126 //FLAGS | 124 //FLAGS |
127 #ifdef HAVE_OPENGL | 125 #ifdef HAVE_OPENGL |
146 flags[1] = ScreenMode::FULLSCREEN_SDL; | 144 flags[1] = ScreenMode::FULLSCREEN_SDL; |
147 #endif | 145 #endif |
148 //BITS PER PIXEL | 146 //BITS PER PIXEL |
149 | 147 |
150 bpps[0] = 32; | 148 bpps[0] = 32; |
149 | |
150 //COMMON FS RESOLUTIONS | |
151 int resolutions[15][2] = { | |
152 {640, 480}, | |
153 {800, 600}, | |
154 {1024, 768}, | |
155 {1152, 864}, | |
156 {1280, 768}, | |
157 {1280, 800}, | |
158 {1280, 960}, | |
159 {1280, 1024}, | |
160 {1366, 768}, | |
161 {1440, 900}, | |
162 {1600, 900}, | |
163 {1600, 1200}, | |
164 {1680, 1050}, | |
165 {1920, 1080}, | |
166 {1920, 1200} | |
167 }; | |
168 int numRes = 15; | |
169 | |
151 | 170 |
152 for (int i = 0; i < numBPP; ++i){ | 171 for (int i = 0; i < numBPP; ++i){ |
153 for (int j = 0; j < numFlags; ++j) { | 172 for (int j = 0; j < numFlags; ++j) { |
154 modes = SDL_ListModes(NULL, flags[j]); | 173 for ( int k = 0; k < numRes; ++k) { |
155 | 174 int bpp; |
156 if (modes == (SDL_Rect**)0) { | 175 if (flags[j] & SDL_FULLSCREEN) { |
157 //no modes found | 176 bpp = SDL_VideoModeOK(resolutions[k][0],resolutions[k][1], bpps[i], flags[j]); |
158 break; | 177 |
178 if (bpp > 0) { | |
179 ScreenMode mode = ScreenMode(resolutions[k][0],resolutions[k][1], bpps[i], flags[j]); | |
180 m_screenModes.push_back(mode); | |
181 } | |
182 } | |
183 else { //windowed mode | |
184 //check an arbitrary value as we know all resolutions are supported in windowed mode. | |
185 //we are checking to make sure the bpp is supported here. | |
186 bpp = SDL_VideoModeOK(resolutions[k][0],resolutions[k][1], bpps[i], flags[j]); | |
187 if (bpp > 0) { | |
188 ScreenMode mode = ScreenMode(0,0, bpps[i], flags[j]); | |
189 m_screenModes.push_back(mode); | |
190 break; //insert windowed mode once as all resolutions are supported. | |
191 } | |
192 } | |
193 | |
159 } | 194 } |
160 | |
161 if (modes == (SDL_Rect**)-1) { | |
162 //All screen modes are available with the specified flags (a windowed mode most likely) | |
163 ScreenMode mode = ScreenMode(0, 0, bpps[i], flags[j]); | |
164 m_screenModes.push_back(mode); | |
165 continue; | |
166 } | |
167 | |
168 for (int k = 0; modes[k]; ++k) { | |
169 int bpp = SDL_VideoModeOK(modes[k]->w, modes[k]->h, bpps[i], flags[j]); | |
170 if (bpp > 0) { | |
171 ScreenMode mode = ScreenMode(modes[k]->w, modes[k]->h, bpps[i], flags[j]); | |
172 m_screenModes.push_back(mode); | |
173 } | |
174 } | |
175 modes = (SDL_Rect**)0; | |
176 } | 195 } |
177 } | 196 } |
178 | 197 |
179 if(SDL_VideoDriverName(buffer, bufferSize) != NULL) { | 198 if(SDL_VideoDriverName(buffer, bufferSize) != NULL) { |
180 m_driverName = std::string(buffer); | 199 m_driverName = std::string(buffer); |
195 m_swToHwAlphaBlitAccel = vInfo->blit_sw_A; | 214 m_swToHwAlphaBlitAccel = vInfo->blit_sw_A; |
196 m_BlitFillAccel = vInfo->blit_fill; | 215 m_BlitFillAccel = vInfo->blit_fill; |
197 m_videoMem = vInfo->video_mem; | 216 m_videoMem = vInfo->video_mem; |
198 } | 217 } |
199 | 218 |
200 ScreenMode DeviceCaps::getNearestScreenMode(uint32_t width, uint32_t height, uint32_t bpp, const std::string& renderer, bool fs) const { | 219 ScreenMode DeviceCaps::getNearestScreenMode(uint16_t width, uint16_t height, uint16_t bpp, const std::string& renderer, bool fs) const { |
201 ScreenMode mode; | 220 ScreenMode mode; |
202 bool foundMode = false; | 221 bool foundMode = false; |
203 | 222 |
204 bool widthCheck = false; | 223 bool widthCheck = false; |
205 bool heightCheck = false; | 224 bool heightCheck = false; |