summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2008-02-06 23:55:33 +0000
committerSimon Howard2008-02-06 23:55:33 +0000
commit57eeaf1d3a8a0fd090e2ccfc37d05131222ec37c (patch)
tree44a170c7a45524ea465d38a2af78704da659aa3f /src
parent631baaaa1a91181ed96030ad4d965133228df535 (diff)
downloadchocolate-doom-57eeaf1d3a8a0fd090e2ccfc37d05131222ec37c.tar.gz
chocolate-doom-57eeaf1d3a8a0fd090e2ccfc37d05131222ec37c.tar.bz2
chocolate-doom-57eeaf1d3a8a0fd090e2ccfc37d05131222ec37c.zip
Use geometric distance to find the nearest mode when autoadjusting,
rather than number of pixels. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1057
Diffstat (limited to 'src')
-rw-r--r--src/i_video.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/i_video.c b/src/i_video.c
index 98eb41ac..8e595c62 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -948,7 +948,7 @@ static void I_AutoAdjustSettings(void)
SDL_Rect **modes;
SDL_Rect *best_mode;
screen_mode_t *screen_mode;
- int target_pixels, num_pixels, best_num_pixels;
+ int target_pixels, diff, best_diff;
int i;
modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
@@ -957,7 +957,7 @@ static void I_AutoAdjustSettings(void)
// configuration file
best_mode = NULL;
- best_num_pixels = INT_MAX;
+ best_diff = INT_MAX;
target_pixels = screen_width * screen_height;
for (i=0; modes[i] != NULL; ++i)
@@ -988,14 +988,16 @@ static void I_AutoAdjustSettings(void)
// Is this mode better than the current mode?
- num_pixels = modes[i]->w * modes[i]->h;
+ diff = (screen_width - modes[i]->w)
+ * (screen_width - modes[i]->w)
+ + (screen_height - modes[i]->h)
+ * (screen_height - modes[i]->h);
- if (abs(num_pixels - target_pixels)
- < abs(best_num_pixels - target_pixels))
+ if (diff < best_diff)
{
// printf("\tA valid mode\n");
- best_num_pixels = num_pixels;
best_mode = modes[i];
+ best_diff = diff;
}
}