summaryrefslogtreecommitdiff
path: root/src/i_video.c
diff options
context:
space:
mode:
authorSimon Howard2010-11-26 18:56:45 +0000
committerSimon Howard2010-11-26 18:56:45 +0000
commit74c2dc333a383f27ebddf479e3b666a9068d6d36 (patch)
tree09bf37eee59789e6f1d113e99bc9a70967db18db /src/i_video.c
parentca81122db362eb01660598a4f3e980ed5274220d (diff)
downloadchocolate-doom-74c2dc333a383f27ebddf479e3b666a9068d6d36.tar.gz
chocolate-doom-74c2dc333a383f27ebddf479e3b666a9068d6d36.tar.bz2
chocolate-doom-74c2dc333a383f27ebddf479e3b666a9068d6d36.zip
In non-palettized boxed screen modes, don't update the border areas of
the screen. This is more CPU and memory efficient, and also fixes the "flashing border" bug when palette flashes occur. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2170
Diffstat (limited to 'src/i_video.c')
-rw-r--r--src/i_video.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/i_video.c b/src/i_video.c
index dab0e09d..62c74b73 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -926,7 +926,14 @@ void I_FinishUpdate (void)
if (screenbuffer != screen)
{
- SDL_BlitSurface(screenbuffer, NULL, screen, NULL);
+ SDL_Rect dst_rect;
+
+ // Center the buffer within the full screen space.
+
+ dst_rect.x = (screen->w - screenbuffer->w) / 2;
+ dst_rect.y = (screen->h - screenbuffer->h) / 2;
+
+ SDL_BlitSurface(screenbuffer, NULL, screen, &dst_rect);
}
SDL_Flip(screen);
@@ -1625,16 +1632,10 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h)
w, h, screen_bpp, SDL_GetError());
}
- if (screen->format->BitsPerPixel == 8)
- {
- screenbuffer = screen;
- }
- else
- {
- screenbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE,
- screen->w, screen->h, 8,
- 0, 0, 0, 0);
- }
+ // Blank out the full screen area in case there is any junk in
+ // the borders that won't otherwise be overwritten.
+
+ SDL_FillRect(screen, NULL, 0);
// If mode was not set, it must be set now that we know the
// screen size.
@@ -1657,6 +1658,22 @@ static void SetVideoMode(screen_mode_t *mode, int w, int h)
}
}
+ // Create the screenbuffer surface; if we have a real 8-bit palettized
+ // screen, then we can use the screen as the screenbuffer.
+
+ if (screen->format->BitsPerPixel == 8)
+ {
+ screenbuffer = screen;
+ }
+ else
+ {
+ screenbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ mode->width, mode->height, 8,
+ 0, 0, 0, 0);
+
+ SDL_FillRect(screenbuffer, NULL, 0);
+ }
+
// Save screen mode.
screen_mode = mode;
@@ -1782,12 +1799,6 @@ void I_InitGraphics(void)
I_SetPalette(doompal);
SDL_SetColors(screenbuffer, palette, 0, 256);
- if (screen != screenbuffer)
- {
- SDL_BlitSurface(screenbuffer, NULL, screen, NULL);
- SDL_Flip(screen);
- }
-
CreateCursors();
UpdateFocus();