video mode switching optimization
This commit is contained in:
parent
1a11b9cb15
commit
9218f58b1d
|
@ -741,8 +741,8 @@ int game_init(const char *name)
|
|||
if (name)
|
||||
game_err_msg(NULL);
|
||||
|
||||
if (gfx_video_init() || input_init())
|
||||
return -1;
|
||||
// if (gfx_video_init() || input_init())
|
||||
// return -1;
|
||||
|
||||
snd_init(opt_hz);
|
||||
game_change_vol(0, opt_vol);
|
||||
|
@ -846,7 +846,7 @@ void game_done(int err)
|
|||
input_clear();
|
||||
snd_done();
|
||||
instead_done();
|
||||
gfx_video_done();
|
||||
// gfx_video_done();
|
||||
curgame_dir = NULL;
|
||||
game_own_theme = 0;
|
||||
// SDL_Quit();
|
||||
|
|
|
@ -1033,8 +1033,9 @@ void gfx_clear(int x, int y, int w, int h)
|
|||
SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, bgcol.r, bgcol.g, bgcol.b));
|
||||
}
|
||||
|
||||
int gfx_width;
|
||||
int gfx_height;
|
||||
int gfx_width = -1;
|
||||
int gfx_height = -1;
|
||||
int gfx_fs = -1;
|
||||
|
||||
static SDL_Rect** vid_modes = NULL;
|
||||
static SDL_Rect m640x480 = { .w = 640, .h = 480 };
|
||||
|
@ -1157,6 +1158,9 @@ int gfx_get_max_mode(int *w, int *h)
|
|||
|
||||
int gfx_set_mode(int w, int h, int fs)
|
||||
{
|
||||
if (gfx_width == w && gfx_height == h && gfx_fs == fs)
|
||||
return 0; /* already done */
|
||||
gfx_fs = fs;
|
||||
gfx_width = w;
|
||||
gfx_height = h;
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
|
|
@ -288,12 +288,20 @@ int main(int argc, char *argv[])
|
|||
// Initialize SDL
|
||||
if (gfx_init() < 0)
|
||||
return -1;
|
||||
|
||||
if (gfx_video_init() || input_init())
|
||||
return -1;
|
||||
|
||||
if (game_init(opt_game)) {
|
||||
game_error(opt_game);
|
||||
}
|
||||
|
||||
|
||||
game_loop();
|
||||
cfg_save();
|
||||
game_done(0);
|
||||
|
||||
gfx_video_done();
|
||||
#ifndef ANDROID
|
||||
gfx_done();
|
||||
#endif
|
||||
|
|
Reference in a new issue