From f7b2accd52c289cd302c939bbf40ff6689b203f8 Mon Sep 17 00:00:00 2001 From: Jakob Fries Date: Sun, 22 Jul 2007 13:42:28 +0000 Subject: [PATCH] --- src/engine/client/gfx.cpp | 10 ++++++++++ src/engine/config_variables.h | 1 + src/engine/interface.h | 1 + src/game/client/menu.cpp | 25 ++++++++++--------------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp index db020cef8..1e5aa19ec 100644 --- a/src/engine/client/gfx.cpp +++ b/src/engine/client/gfx.cpp @@ -111,6 +111,8 @@ bool gfx_init() dbg_msg("game", "failed to create gl context"); return false; } + + // Init vertices if (g_pVertices) mem_free(g_pVertices); @@ -160,6 +162,9 @@ bool gfx_init() // create null texture, will get id=0 gfx_load_texture_raw(4,4,IMG_RGBA,null_texture_data); + // set vsync as needed + gfx_set_vsync(config.vsync); + return true; } @@ -168,6 +173,11 @@ int gfx_get_video_modes(video_mode *list, int maxcount) return context.getvideomodes((opengl::videomode *)list, maxcount); } +void gfx_set_vsync(int val) +{ + context.set_vsync(val); +} + int gfx_unload_texture(int index) { textures[index].tex.clear(); diff --git a/src/engine/config_variables.h b/src/engine/config_variables.h index a5c4ef5d7..23cb30a41 100644 --- a/src/engine/config_variables.h +++ b/src/engine/config_variables.h @@ -4,6 +4,7 @@ MACRO_CONFIG_INT(screen_width, 800, 0, 0) MACRO_CONFIG_INT(screen_height, 600, 0, 0) MACRO_CONFIG_INT(fullscreen, 1, 0, 1) MACRO_CONFIG_INT(color_depth, 24, 16, 24) +MACRO_CONFIG_INT(vsync, 1, 0, 1) MACRO_CONFIG_INT(volume, 200, 0, 255) MACRO_CONFIG_STR(player_name, 32, "nameless tee") MACRO_CONFIG_STR(clan_name, 32, "") diff --git a/src/engine/interface.h b/src/engine/interface.h index 05c1b9618..3a420c7c8 100644 --- a/src/engine/interface.h +++ b/src/engine/interface.h @@ -62,6 +62,7 @@ void gfx_shutdown(); // NOT EXPOSED void gfx_swap(); // NOT EXPOSED int gfx_get_video_modes(video_mode *list, int maxcount); +void gfx_set_vsync(int val); // textures /* diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp index 64aca4d12..004441464 100644 --- a/src/game/client/menu.cpp +++ b/src/game/client/menu.cpp @@ -311,7 +311,6 @@ struct server_list int selected_index; }; - int ui_do_key_reader(void *id, float x, float y, float w, float h, int key) { // process @@ -704,13 +703,6 @@ static int main_render() if (!inited) { - /* - list.info_count = 256; - - list.scroll_index = 0; - list.selected_index = -1; - */ - inited = true; client_serverbrowse_refresh(); @@ -737,11 +729,11 @@ static int main_render() if (ui_do_button(&refresh_button, "Refresh", 0, 20, 420, 170, 48, draw_teewars_button)) client_serverbrowse_refresh(); - if (selected_index == -1) + /*if (selected_index == -1) { ui_do_button(&join_button, "Join", 0, 620, 420, 128, 48, draw_teewars_button, (void *)1); } - else if (ui_do_button(&join_button, "Join", 0, 620, 420, 128, 48, draw_teewars_button)) + else */if (ui_do_button(&join_button, "Join", 0, 620, 420, 128, 48, draw_teewars_button)) { client_connect(address); @@ -758,9 +750,9 @@ static int main_render() screen = SCREEN_SETTINGS_GENERAL; } - //static int editor_button; - //if (ui_do_button(&editor_button, "Kerning Editor", 0, 20, 470, 170, 48, draw_teewars_button)) - // screen = SCREEN_KERNING; + /*static int editor_button; + if (ui_do_button(&editor_button, "Kerning Editor", 0, 20, 470, 170, 48, draw_teewars_button)) + screen = SCREEN_KERNING;*/ return 0; } @@ -840,7 +832,7 @@ static int settings_video_render() { for (int i = 0; i < resolution_count[depth_index]; i++) { - if (config_copy.screen_width == resolutions[depth_index][i][0]) + if (config_copy.screen_width == resolutions[depth_index][i][0] && config_copy.screen_height == resolutions[depth_index][i][1]) { selected_index = i; break; @@ -858,7 +850,10 @@ static int settings_video_render() }; // we need to draw these bottom up, to make overlapping work correctly - ui_do_label(column1_x, row3_y + 50, "(A restart of the game is required for these settings to take effect.)", 20); + ui_do_label(column1_x, row4_y + 50, "(A restart of the game is required for these settings to take effect.)", 20); + + ui_do_label(column1_x, row4_y, "V-sync:", 36); + config_set_vsync(&config_copy, ui_do_check_box(&config_copy.vsync, column2_x, row4_y + 5, 32, 32, config_copy.vsync)); ui_do_label(column1_x, row3_y, "Fullscreen:", 36); config_set_fullscreen(&config_copy, ui_do_check_box(&config_copy.fullscreen, column2_x, row3_y + 5, 32, 32, config_copy.fullscreen));