Fixed bugs with fog setttings in editor

dev
Shariq Shah 9 years ago
parent 598ac1c5cf
commit 58b1c59eaa
  1. 3
      orgfile.org
  2. 45
      src/editor.c

@ -128,7 +128,8 @@ x Font atlas proper cleanup
** DONE Fix mouse bugs ** DONE Fix mouse bugs
- State "DONE" from "TODO" [2017-03-01 Wed 00:45] - State "DONE" from "TODO" [2017-03-01 Wed 00:45]
** DONE Fix ** 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] - State "DONE" from "TODO" [2017-02-26 Sun 15:39]
** TODO Improve this readme ** TODO Improve this readme
** TODO ??? ** TODO ???

@ -15,6 +15,8 @@
#include "game.h" #include "game.h"
#include "gui.h" #include "gui.h"
#include <stdio.h>
struct Editor_State struct Editor_State
{ {
int enabled; int enabled;
@ -73,11 +75,11 @@ void editor_update(float dt)
/* Debug Window */ /* Debug Window */
if(editor_state.renderer_settings_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_BORDER | NK_WINDOW_CLOSABLE | NK_WINDOW_MOVABLE |
NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_SCALABLE | NK_WINDOW_MINIMIZABLE)) 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"}; static const char* draw_modes[] = {"Triangles", "Lines", "Points"};
nk_layout_row_dynamic(context, 25, 2); nk_layout_row_dynamic(context, 25, 2);
@ -94,29 +96,52 @@ void editor_update(float dt)
nk_tree_pop(context); 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"}; 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_layout_row_dynamic(context, 25, 2);
nk_label(context, "Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); nk_label(context, "Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE);
static vec4 fog_color; static vec4 fog_color;
vec4_fill_vec3(&fog_color, &render_settings->fog.color, 1.f); vec4_fill_vec3(&fog_color, &render_settings->fog.color, 1.f);
editor_color_combo(context, &fog_color, 200, 400); 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_layout_row_dynamic(context, 25, 2);
nk_label(context, "Fog Mode", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); 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_layout_row_dynamic(context, 25, 2);
nk_property_float(context, "Density", 0.f, &render_settings->fog.density, 10.f, 0.05f, 0.1f); 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_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_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); nk_tree_pop(context);
} }

Loading…
Cancel
Save