diff --git a/platforms/desktop-shared/application.cpp b/platforms/desktop-shared/application.cpp index 24f054f..133e355 100644 --- a/platforms/desktop-shared/application.cpp +++ b/platforms/desktop-shared/application.cpp @@ -43,6 +43,7 @@ static void sdl_shortcuts_gui(const SDL_Event* event); static void run_emulator(void); static void render(void); static void frame_throttle(void); +static void save_window_size(void); int application_init(const char* arg) { @@ -53,11 +54,10 @@ int application_init(const char* arg) Log ("Loading with argv: %s"); } - int ret = sdl_init(); - config_init(); config_read(); + int ret = sdl_init(); emu_init(); strcpy(emu_savefiles_path, config_emulator.savefiles_path.c_str()); @@ -86,6 +86,7 @@ int application_init(const char* arg) void application_destroy(void) { + save_window_size(); config_write(); config_destroy(); renderer_destroy(); @@ -136,7 +137,8 @@ static int sdl_init(void) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - sdl_window = SDL_CreateWindow(GEARCOLECO_TITLE " " GEARCOLECO_VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 770, 698, window_flags); + + sdl_window = SDL_CreateWindow(GEARCOLECO_TITLE " " GEARCOLECO_VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, config_emulator.window_width, config_emulator.window_height, window_flags); gl_context = SDL_GL_CreateContext(sdl_window); SDL_GL_MakeCurrent(sdl_window, gl_context); SDL_GL_SetSwapInterval(0); @@ -656,3 +658,11 @@ static void frame_throttle(void) SDL_Delay((Uint32)(min - elapsed)); } } + +static void save_window_size(void) +{ + int width, height; + SDL_GetWindowSize(sdl_window, &width, &height); + config_emulator.window_width = width; + config_emulator.window_height = height; +} diff --git a/platforms/desktop-shared/config.cpp b/platforms/desktop-shared/config.cpp index 0c44c35..74fcef3 100644 --- a/platforms/desktop-shared/config.cpp +++ b/platforms/desktop-shared/config.cpp @@ -165,6 +165,8 @@ void config_read(void) config_emulator.savestates_dir_option = read_int("Emulator", "SaveStatesDirOption", 0); config_emulator.savestates_path = read_string("Emulator", "SaveStatesPath"); config_emulator.last_open_path = read_string("Emulator", "LastOpenPath"); + config_emulator.window_width = read_int("Emulator", "WindowWidth", 770); + config_emulator.window_height = read_int("Emulator", "WindowHeight", 600); if (config_emulator.savefiles_path.empty()) { @@ -318,6 +320,8 @@ void config_write(void) write_int("Emulator", "SaveStatesDirOption", config_emulator.savestates_dir_option); write_string("Emulator", "SaveStatesPath", config_emulator.savestates_path); write_string("Emulator", "LastOpenPath", config_emulator.last_open_path); + write_int("Emulator", "WindowWidth", config_emulator.window_width); + write_int("Emulator", "WindowHeight", config_emulator.window_height); for (int i = 0; i < config_max_recent_roms; i++) { diff --git a/platforms/desktop-shared/config.h b/platforms/desktop-shared/config.h index ba1b981..bb27fe1 100644 --- a/platforms/desktop-shared/config.h +++ b/platforms/desktop-shared/config.h @@ -52,6 +52,8 @@ struct config_Emulator int savestates_dir_option = 0; std::string savestates_path; std::string last_open_path; + int window_width = 770; + int window_height = 600; }; struct config_Video