From fee6c2364e8d22c41b53db90ace721cbe945f0af Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Mon, 22 Jun 2020 17:40:30 +0200 Subject: cpu rendering --- src/settings.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/settings.c') diff --git a/src/settings.c b/src/settings.c index 118dca7..79b1a95 100644 --- a/src/settings.c +++ b/src/settings.c @@ -9,11 +9,10 @@ void set_status_text_to_finished_search(); void settings_page_create() { + global_settings_page.use_gpu = global_use_gpu; global_settings_page.active = false; - global_settings_page.font_small = assets_load_font(_binary____data_fonts_mono_ttf_start, - _binary____data_fonts_mono_ttf_end, 16); - global_settings_page.logo_img = assets_load_image(_binary____data_imgs_logo_64_png_start, - _binary____data_imgs_logo_64_png_end, true); + global_settings_page.font_small = load_font(mono_ttf, 15); + global_settings_page.logo_img = load_bitmap(logo_64_bmp); global_settings_page.keyboard = keyboard_input_create(); global_settings_page.mouse = mouse_input_create(); @@ -24,6 +23,7 @@ void settings_page_create() global_settings_page.camera = cam; + global_settings_page.cb_use_gpu = ui_create_checkbox(global_use_gpu); global_settings_page.btn_close = ui_create_button(); global_settings_page.btn_save = ui_create_button(); global_settings_page.dropdown_language = ui_create_dropdown(); @@ -35,11 +35,24 @@ void settings_page_create() static void load_current_settings_into_ui() { - + global_settings_page.use_gpu = global_use_gpu; + global_settings_page.cb_use_gpu.state = global_settings_page.use_gpu; } void settings_page_update_render() { + if (global_settings_page.window.has_focus) + global_settings_page.window.do_draw = true; + + // switch to cpu/gpu + if (global_use_gpu != global_settings_page.use_gpu) + { + global_use_gpu = global_settings_page.use_gpu; + platform_setup_backbuffer(main_window); + platform_setup_renderer(); + assets_switch_render_method(); + } + if (global_settings_page.active) { platform_window_make_current(&global_settings_page.window); @@ -50,7 +63,7 @@ void settings_page_update_render() { global_settings_page.window.do_draw = false; - render_clear(); + render_clear(&global_settings_page.window); camera_apply_transformations(&global_settings_page.window, &global_settings_page.camera); @@ -97,6 +110,14 @@ void settings_page_update_render() } ui_block_end(); + ui_block_begin(LAYOUT_HORIZONTAL); + { + if (ui_push_checkbox(&global_settings_page.cb_use_gpu, localize("use_gpu"))) + { + } + } + ui_block_end(); + ui_block_begin(LAYOUT_HORIZONTAL); { if (ui_push_hypertext_link(localize("copy_config_path"))) @@ -122,6 +143,7 @@ void settings_page_update_render() if (ui_push_button(&global_settings_page.btn_close, localize("save"))) { global_settings_page.active = false; + global_settings_page.use_gpu = global_settings_page.cb_use_gpu.state; settings_page_hide(); return; } @@ -157,7 +179,7 @@ void settings_page_show() load_current_settings_into_ui(); global_settings_page.window = platform_open_window(localize("mo_edit_settings"), - 350, 220, 350, 220, 350, 220); + 350, 240, 350, 240, 350, 240); settings_window = &global_settings_page.window; -- cgit v1.2.3-70-g09d2