From 58b1c59eaac80e5fd3c14f803a00b7dccd3370d7 Mon Sep 17 00:00:00 2001 From: Shariq Shah Date: Sun, 19 Mar 2017 15:10:48 +0500 Subject: [PATCH] Fixed bugs with fog setttings in editor --- orgfile.org | 3 ++- src/editor.c | 45 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/orgfile.org b/orgfile.org index dc55577..1708979 100644 --- a/orgfile.org +++ b/orgfile.org @@ -128,7 +128,8 @@ x Font atlas proper cleanup ** DONE Fix mouse bugs - State "DONE" from "TODO" [2017-03-01 Wed 00:45] ** DONE Fix -** TODO issues with opengl context showing 2.1 only +** DONE issues with opengl context showing 2.1 only +- State "DONE" from "TODO" [2017-03-19 Sun 14:03] - State "DONE" from "TODO" [2017-02-26 Sun 15:39] ** TODO Improve this readme ** TODO ??? diff --git a/src/editor.c b/src/editor.c index e553c9e..86d0e2b 100644 --- a/src/editor.c +++ b/src/editor.c @@ -15,6 +15,8 @@ #include "game.h" #include "gui.h" +#include + struct Editor_State { int enabled; @@ -73,11 +75,11 @@ void editor_update(float dt) /* Debug Window */ if(editor_state.renderer_settings_window) { - if(nk_begin_titled(context, "Renderer_Settings_Window", "Renderer Settings", nk_rect(half_width, half_height, 400, 300), + if(nk_begin_titled(context, "Renderer_Settings_Window", "Renderer Settings", nk_rect(half_width, half_height, 300, 350), NK_WINDOW_BORDER | NK_WINDOW_CLOSABLE | NK_WINDOW_MOVABLE | NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_SCALABLE | NK_WINDOW_MINIMIZABLE)) { - if(nk_tree_push(context, NK_TREE_TAB, "Debug", NK_MINIMIZED)) + if(nk_tree_push(context, NK_TREE_TAB, "Debug", NK_MAXIMIZED)) { static const char* draw_modes[] = {"Triangles", "Lines", "Points"}; nk_layout_row_dynamic(context, 25, 2); @@ -94,29 +96,52 @@ void editor_update(float dt) nk_tree_pop(context); } - if(nk_tree_push(context, NK_TREE_TAB, "Fog", NK_MINIMIZED)) + if(nk_tree_push(context, NK_TREE_TAB, "Fog", NK_MAXIMIZED)) { static const char* fog_modes[] = {"None", "Linear", "Exponential", "Exponential Squared"}; - /* TODO: Fix bugs here before moving on! */ nk_layout_row_dynamic(context, 25, 2); nk_label(context, "Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); static vec4 fog_color; vec4_fill_vec3(&fog_color, &render_settings->fog.color, 1.f); editor_color_combo(context, &fog_color, 200, 400); - vec3_fill(&render_settings->fog.color, fog_color.x, fog_color.y, fog_color.w); + vec3_fill(&render_settings->fog.color, fog_color.x, fog_color.y, fog_color.z); nk_layout_row_dynamic(context, 25, 2); nk_label(context, "Fog Mode", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); - render_settings->fog.mode = nk_combo(context, fog_modes, 4, render_settings->fog.mode, 20, nk_vec2(180, 100)); + render_settings->fog.mode = nk_combo(context, + fog_modes, + 4, + render_settings->fog.mode, + 20, + nk_vec2(180, 100)); - nk_layout_row_dynamic(context, 25, 1); - nk_property_float(context, "Density", 0.f, &render_settings->fog.density, 10.f, 0.05f, 0.1f); + nk_layout_row_dynamic(context, 25, 2); + nk_label(context, "Density", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); + struct nk_rect bounds = nk_widget_bounds(context); + nk_slider_float(context, 0.f, &render_settings->fog.density, 1.f, 0.005); + if(nk_input_is_mouse_hovering_rect(&context->input, bounds)) + { + static char float_str[6]; + snprintf(float_str, 6, "%.4f", render_settings->fog.density); + float_str[5] = '\0'; + nk_tooltip(context, float_str); + } nk_layout_row_dynamic(context, 25, 1); - nk_property_float(context, "Start Distance", 0.f, &render_settings->fog.start_dist, 10000.f, 5.f, 10.f); + nk_property_float(context, + "Start Distance", + 0.f, + &render_settings->fog.start_dist, + render_settings->fog.max_dist, + 5.f, 10.f); nk_layout_row_dynamic(context, 25, 1); - nk_property_float(context, "Max Distance", 0.f, &render_settings->fog.max_dist, 10000.f, 5.f, 10.f); + nk_property_float(context, + "Max Distance", + render_settings->fog.start_dist, + &render_settings->fog.max_dist, + 10000.f, + 5.f, 10.f); nk_tree_pop(context); }