From 598ac1c5cff7c79e52e8daf22e81bcc76e9d2819 Mon Sep 17 00:00:00 2001 From: Shariq Shah Date: Sun, 19 Mar 2017 01:33:35 +0500 Subject: [PATCH] Added window to render settings to editor ui and updated nuklear version --- README | 147 ++++++++++++++++++++------------------ assets/shaders/debug.frag | 4 +- include/nuklear.h | 27 ++++--- orgfile.org | 3 +- src/editor.c | 122 +++++++++++++++++++++++++++---- src/game.c | 2 +- src/gui.c | 5 +- src/linmath.c | 8 +++ src/linmath.h | 1 + src/model.c | 4 +- src/model.h | 2 +- src/renderer.c | 2 +- src/renderer.h | 2 +- 13 files changed, 219 insertions(+), 110 deletions(-) diff --git a/README b/README index c14d5cc..20c9d14 100644 --- a/README +++ b/README @@ -46,38 +46,39 @@ _________________ .. 2.30 DONE Fix problems with texture units .. 2.31 CANCELED Draw light volumes .. 2.32 TODO Fix problems with frustrum culling -.. 2.33 TODO -.. 2.34 TODO -.. 2.35 TODO 2d drawing routines -.. 2.36 DONE Gui -.. 2.37 CANCELED Image based lighting? -.. 2.38 CANCELED Deferred rendering? -.. 2.39 TODO Fix mouse bugs on windows -.. 2.40 DONE Toggleable debug drawing for meshes -.. 2.41 TODO Interleaved vbos for meshes and changes to blender exporter accordingly -.. 2.42 TODO Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? -.. 2.43 TODO Physics/Collision detection in 2d -.. 2.44 TODO Complete gui integration -.. 2.45 TODO Allow passsing base path as commandline argument? -.. 2.46 TODO Sprite sheet animations -.. 2.47 DONE Resizable framebuffers and textures -.. 2.48 DONE Support for multiple color attachments in framebuffers? -.. 2.49 TODO Multisampled textures and framebuffers -.. 2.50 DONE Better way to store and manage textures attached to framebuffers -.. 2.51 TODO Validate necessary assets at game launch -.. 2.52 TODO Variant type -.. 2.53 TODO Log and debug/stats output in gui -.. 2.54 TODO Editor -.. 2.55 TODO Event Subsystem -.. 2.56 TODO Keybindings for gui? -.. 2.57 DONE Compile and test on windows -.. 2.58 TODO Array based string type comptible with cstring(char*) -.. 2.59 DONE Fix mouse bugs -.. 2.60 DONE Fix -.. 2.61 TODO issues with opengl context showing 2.1 only -.. 2.62 TODO Improve this readme -.. 2.63 TODO ??? -.. 2.64 TODO Profit! +.. 2.33 TODO 2d drawing routines +.. 2.34 DONE Gui +.. 2.35 CANCELED Image based lighting? +.. 2.36 CANCELED Deferred rendering? +.. 2.37 TODO Fix mouse bugs on windows +.. 2.38 DONE Fix mousewheel bugs and gui not responding to mousewheel input +.. 2.39 TODO Ability to mark meshes for debug rendering with possibility of different color for each? +.. 2.40 TODO Setup cross compilation with mingw or stick to msvc? +.. 2.41 DONE Toggleable debug drawing for meshes +.. 2.42 TODO Interleaved vbos for meshes and changes to blender exporter accordingly +.. 2.43 TODO Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? +.. 2.44 TODO Physics/Collision detection in 2d +.. 2.45 TODO Complete gui integration +.. 2.46 TODO Allow passsing base path as commandline argument? +.. 2.47 TODO Sprite sheet animations +.. 2.48 DONE Resizable framebuffers and textures +.. 2.49 DONE Support for multiple color attachments in framebuffers? +.. 2.50 TODO Multisampled textures and framebuffers +.. 2.51 DONE Better way to store and manage textures attached to framebuffers +.. 2.52 TODO Validate necessary assets at game launch +.. 2.53 TODO Variant type +.. 2.54 TODO Log and debug/stats output in gui +.. 2.55 TODO Editor +.. 2.56 TODO Event Subsystem +.. 2.57 TODO Keybindings for gui? +.. 2.58 DONE Compile and test on windows +.. 2.59 TODO Array based string type comptible with cstring(char*) +.. 2.60 DONE Fix mouse bugs +.. 2.61 DONE Fix +.. 2.62 TODO issues with opengl context showing 2.1 only +.. 2.63 TODO Improve this readme +.. 2.64 TODO ??? +.. 2.65 TODO Profit! 1 Project Symmetry @@ -294,66 +295,72 @@ _________________ 2.32 TODO Fix problems with frustrum culling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -2.33 TODO -~~~~~~~~~~ - - -2.34 TODO -~~~~~~~~~~ - - Recalculate bounding boxes for rotated meshes? -2.35 TODO 2d drawing routines +2.33 TODO 2d drawing routines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Sprite batching -2.36 DONE Gui +2.34 DONE Gui ~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-03-15 Wed 23:41] -2.37 CANCELED Image based lighting? +2.35 CANCELED Image based lighting? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "CANCELED" from "TODO" [2017-03-14 Tue 00:31] Not a requirement for current project -2.38 CANCELED Deferred rendering? +2.36 CANCELED Deferred rendering? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] Sticking with forward rendering for now and focusing on tools etc. -2.39 TODO Fix mouse bugs on windows +2.37 TODO Fix mouse bugs on windows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.40 DONE Toggleable debug drawing for meshes +2.38 DONE Fix mousewheel bugs and gui not responding to mousewheel input +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + - State "DONE" from "TODO" [2017-03-19 Sun 01:31] + + +2.39 TODO Ability to mark meshes for debug rendering with possibility of different color for each? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +2.40 TODO Setup cross compilation with mingw or stick to msvc? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +2.41 DONE Toggleable debug drawing for meshes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-03-18 Sat 16:18] -2.41 TODO Interleaved vbos for meshes and changes to blender exporter accordingly +2.42 TODO Interleaved vbos for meshes and changes to blender exporter accordingly ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.42 TODO Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? +2.43 TODO Enumerate and save all the uniform and attribute positions in shader when it is added and cache them in shader object? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.43 TODO Physics/Collision detection in 2d +2.44 TODO Physics/Collision detection in 2d ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.44 TODO Complete gui integration +2.45 TODO Complete gui integration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ x Font selection x Font atlas proper cleanup @@ -361,93 +368,93 @@ _________________ - Custom rendering for gui -2.45 TODO Allow passsing base path as commandline argument? +2.46 TODO Allow passsing base path as commandline argument? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.46 TODO Sprite sheet animations +2.47 TODO Sprite sheet animations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.47 DONE Resizable framebuffers and textures +2.48 DONE Resizable framebuffers and textures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-03-16 Thu 22:50] -2.48 DONE Support for multiple color attachments in framebuffers? +2.49 DONE Support for multiple color attachments in framebuffers? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-03-16 Thu 22:51] -2.49 TODO Multisampled textures and framebuffers +2.50 TODO Multisampled textures and framebuffers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.50 DONE Better way to store and manage textures attached to framebuffers +2.51 DONE Better way to store and manage textures attached to framebuffers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-03-16 Thu 22:51] -2.51 TODO Validate necessary assets at game launch +2.52 TODO Validate necessary assets at game launch ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.52 TODO Variant type +2.53 TODO Variant type ~~~~~~~~~~~~~~~~~~~~~~ -2.53 TODO Log and debug/stats output in gui +2.54 TODO Log and debug/stats output in gui ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.54 TODO Editor +2.55 TODO Editor ~~~~~~~~~~~~~~~~ -2.55 TODO Event Subsystem +2.56 TODO Event Subsystem ~~~~~~~~~~~~~~~~~~~~~~~~~ -2.56 TODO Keybindings for gui? +2.57 TODO Keybindings for gui? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.57 DONE Compile and test on windows +2.58 DONE Compile and test on windows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-03-14 Tue 00:32] -2.58 TODO Array based string type comptible with cstring(char*) +2.59 TODO Array based string type comptible with cstring(char*) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.59 DONE Fix mouse bugs +2.60 DONE Fix mouse bugs ~~~~~~~~~~~~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-03-01 Wed 00:45] -2.60 DONE Fix +2.61 DONE Fix ~~~~~~~~~~~~~ -2.61 TODO issues with opengl context showing 2.1 only +2.62 TODO issues with opengl context showing 2.1 only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - State "DONE" from "TODO" [2017-02-26 Sun 15:39] -2.62 TODO Improve this readme +2.63 TODO Improve this readme ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -2.63 TODO ??? +2.64 TODO ??? ~~~~~~~~~~~~~ -2.64 TODO Profit! +2.65 TODO Profit! ~~~~~~~~~~~~~~~~~ diff --git a/assets/shaders/debug.frag b/assets/shaders/debug.frag index bb86af5..69d8138 100644 --- a/assets/shaders/debug.frag +++ b/assets/shaders/debug.frag @@ -1,10 +1,10 @@ //include version.glsl -uniform vec3 debug_color; +uniform vec4 debug_color; out vec4 frag_color; void main() { - frag_color = vec4(debug_color, 1.0); + frag_color = debug_color; } diff --git a/include/nuklear.h b/include/nuklear.h index e1a1f6e..284fb42 100644 --- a/include/nuklear.h +++ b/include/nuklear.h @@ -1,7 +1,7 @@ /* Nuklear - 1.33.0 - public domain no warrenty implied; use at your own risk. - authored from 2015-2016 by Micha Mettke + authored from 2015-2017 by Micha Mettke ABOUT: This is a minimal state graphical user interface single header toolkit @@ -1135,9 +1135,9 @@ NK_API struct nk_vec2 nk_rect_size(struct nk_rect); NK_API int nk_strlen(const char *str); NK_API int nk_stricmp(const char *s1, const char *s2); NK_API int nk_stricmpn(const char *s1, const char *s2, int n); -NK_API int nk_strtoi(const char *str, char **endptr); -NK_API float nk_strtof(const char *str, char **endptr); -NK_API double nk_strtod(const char *str, char **endptr); +NK_API int nk_strtoi(const char *str, const char **endptr); +NK_API float nk_strtof(const char *str, const char **endptr); +NK_API double nk_strtod(const char *str, const char **endptr); NK_API int nk_strfilter(const char *text, const char *regexp); NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score); NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score); @@ -3530,7 +3530,7 @@ nk_strlen(const char *str) } NK_API int -nk_strtoi(const char *str, char **endptr) +nk_strtoi(const char *str, const char **endptr) { int neg = 1; const char *p = str; @@ -3550,12 +3550,12 @@ nk_strtoi(const char *str, char **endptr) p++; } if (endptr) - *endptr = (char*)p; + *endptr = p; return neg*value; } NK_API double -nk_strtod(const char *str, char **endptr) +nk_strtod(const char *str, const char **endptr) { double m; double neg = 1.0; @@ -3608,12 +3608,12 @@ nk_strtod(const char *str, char **endptr) } number = value * neg; if (endptr) - *endptr = (char*)p; + *endptr = p; return number; } NK_API float -nk_strtof(const char *str, char **endptr) +nk_strtof(const char *str, const char **endptr) { float float_value; double double_value; @@ -4091,7 +4091,7 @@ nk_vsnprintf(char *buf, int buf_size, const char *fmt, va_list args) /* width argument */ width = NK_DEFAULT; if (*iter >= '1' && *iter <= '9') { - char *end; + const char *end; width = nk_strtoi(iter, &end); if (end == iter) width = -1; @@ -4109,7 +4109,7 @@ nk_vsnprintf(char *buf, int buf_size, const char *fmt, va_list args) precision = va_arg(args, int); iter++; } else { - char *end; + const char *end; precision = nk_strtoi(iter, &end); if (end == iter) precision = -1; @@ -13454,8 +13454,7 @@ nk_do_selectable_image(nk_flags *state, struct nk_command_buffer *out, NK_INTERN float nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor, struct nk_rect *visual_cursor, struct nk_input *in, - const struct nk_style_slider *style, struct nk_rect bounds, - float slider_min, float slider_max, float slider_value, + struct nk_rect bounds, float slider_min, float slider_max, float slider_value, float slider_step, float slider_steps) { int left_mouse_down; @@ -13637,7 +13636,7 @@ nk_do_slider(nk_flags *state, visual_cursor.x = logical_cursor.x - visual_cursor.w*0.5f; slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor, - in, style, bounds, slider_min, slider_max, slider_value, step, slider_steps); + in, bounds, slider_min, slider_max, slider_value, step, slider_steps); visual_cursor.x = logical_cursor.x - visual_cursor.w*0.5f; /* draw slider */ diff --git a/orgfile.org b/orgfile.org index 4f2d9ef..dc55577 100644 --- a/orgfile.org +++ b/orgfile.org @@ -93,7 +93,8 @@ All the code in this repository is under GPLv3, see LICENSE for more information - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\ Sticking with forward rendering for now and focusing on tools etc. ** TODO Fix mouse bugs on windows -** TODO Fix mousewheel bugs and gui not responding to mousewheel input +** DONE Fix mousewheel bugs and gui not responding to mousewheel input +- State "DONE" from "TODO" [2017-03-19 Sun 01:31] ** TODO Ability to mark meshes for debug rendering with possibility of different color for each? ** TODO Setup cross compilation with mingw or stick to msvc? ** DONE Toggleable debug drawing for meshes diff --git a/src/editor.c b/src/editor.c index 33c4dbe..e553c9e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -18,17 +18,19 @@ struct Editor_State { int enabled; - int debug_window_enabled; + int renderer_settings_window; int top_panel_height; }; static struct Editor_State editor_state; +static void editor_color_combo(struct nk_context* context, vec4* color, int width, int height); + void editor_init(void) { - editor_state.enabled = 1; - editor_state.debug_window_enabled = 0; - editor_state.top_panel_height = 50; + editor_state.enabled = 1; + editor_state.renderer_settings_window = 1; + editor_state.top_panel_height = 30; } void editor_update(float dt) @@ -41,32 +43,88 @@ void editor_update(float dt) struct Render_Settings* render_settings = renderer_settings_get(); int win_width = 0, win_height = 0; window_get_drawable_size(game_state->window, &win_width, &win_height); - static int debug_window = 1; + int half_width = win_width / 2, half_height = win_height / 2; /* Top Panel */ if(nk_begin(context, "Top_Panel", nk_recti(0, 0, win_width, win_height - (win_height - editor_state.top_panel_height)), - NK_WINDOW_NO_SCROLLBAR | NK_WINDOW_BACKGROUND)) + NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) { - nk_layout_row_static(context, 40, 100, 2); - if(nk_button_label(context, "Debug")) editor_state.debug_window_enabled = !editor_state.debug_window_enabled; + float ratios[] = {0.1f, 0.8f, 0.1f}; + static int frames = 0; + static int fps = 0; + static float seconds = 0.f; + seconds += dt; + frames++; + if(seconds >= 1.f) + { + fps = frames; + seconds = 0.f; + frames = 0; + } + nk_layout_row(context, NK_DYNAMIC, 22, 3, ratios); + if(nk_button_label(context, "Render Settings")) + editor_state.renderer_settings_window = !editor_state.renderer_settings_window; + nk_spacing(context, 1); + nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps); } nk_end(context); /* Debug Window */ - if(debug_window) + if(editor_state.renderer_settings_window) { - if(nk_begin_titled(context, "Debug_Window", "Debug", nk_recti(0, 0, 200, 200), + if(nk_begin_titled(context, "Renderer_Settings_Window", "Renderer Settings", nk_rect(half_width, half_height, 400, 300), NK_WINDOW_BORDER | NK_WINDOW_CLOSABLE | NK_WINDOW_MOVABLE | - NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_DYNAMIC)) + NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_SCALABLE | NK_WINDOW_MINIMIZABLE)) { - debug_window = 1; - nk_layout_row_static(context, 40, 50, 1); - nk_checkbox_label(context, "Debug Draw", &render_settings->debug_draw_enabled); + if(nk_tree_push(context, NK_TREE_TAB, "Debug", NK_MINIMIZED)) + { + static const char* draw_modes[] = {"Triangles", "Lines", "Points"}; + nk_layout_row_dynamic(context, 25, 2); + nk_label(context, "Debug Draw", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); + nk_checkbox_label(context, "", &render_settings->debug_draw_enabled); + + nk_layout_row_dynamic(context, 25, 2); + nk_label(context, "Debug Draw Mode", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); + render_settings->debug_draw_mode = nk_combo(context, draw_modes, 3, render_settings->debug_draw_mode, 20, nk_vec2(180, 100)); + + nk_layout_row_dynamic(context, 25, 2); + nk_label(context, "Debug Color", NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_MIDDLE); + editor_color_combo(context, &render_settings->debug_draw_color, 200, 400); + nk_tree_pop(context); + } + + if(nk_tree_push(context, NK_TREE_TAB, "Fog", NK_MINIMIZED)) + { + 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); + + 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)); + + 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, 1); + nk_property_float(context, "Start Distance", 0.f, &render_settings->fog.start_dist, 10000.f, 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_tree_pop(context); + } + } else { - debug_window = 0; + editor_state.renderer_settings_window = 0; } nk_end(context); } @@ -77,3 +135,37 @@ void editor_toggle(void) editor_state.enabled = !editor_state.enabled; } +void editor_color_combo(struct nk_context* context, vec4* color, int width, int height) +{ + struct nk_color temp_color = nk_rgba_f(color->x, color->y, color->z, color->w); + if(nk_combo_begin_color(context, temp_color, nk_vec2(width, height))) + { + enum color_mode {COL_RGB, COL_HSV}; + static int col_mode = COL_RGB; + nk_layout_row_dynamic(context, 25, 2); + col_mode = nk_option_label(context, "RGB", col_mode == COL_RGB) ? COL_RGB : col_mode; + col_mode = nk_option_label(context, "HSV", col_mode == COL_HSV) ? COL_HSV : col_mode; + nk_layout_row_dynamic(context, 120, 1); + temp_color = nk_color_picker(context, temp_color, NK_RGBA); + nk_layout_row_dynamic(context, 25, 1); + if(col_mode == COL_RGB) + { + temp_color.r = (nk_byte)nk_propertyi(context, "#R:", 0, temp_color.r, 255, 1,1); + temp_color.g = (nk_byte)nk_propertyi(context, "#G:", 0, temp_color.g, 255, 1,1); + temp_color.b = (nk_byte)nk_propertyi(context, "#B:", 0, temp_color.b, 255, 1,1); + temp_color.a = (nk_byte)nk_propertyi(context, "#A:", 0, temp_color.a, 255, 1,1); + } + else + { + nk_byte tmp[4]; + nk_color_hsva_bv(tmp, temp_color); + tmp[0] = (nk_byte)nk_propertyi(context, "#H:", 0, tmp[0], 255, 1,1); + tmp[1] = (nk_byte)nk_propertyi(context, "#S:", 0, tmp[1], 255, 1,1); + tmp[2] = (nk_byte)nk_propertyi(context, "#V:", 0, tmp[2], 255, 1,1); + tmp[3] = (nk_byte)nk_propertyi(context, "#A:", 0, tmp[3], 255, 1,1); + temp_color = nk_hsva_bv(tmp); + } + nk_color_f(&color->x, &color->y, &color->z, &color->w, temp_color); + nk_combo_end(context); + } +} diff --git a/src/game.c b/src/game.c index 9b3ff14..7eacbbb 100644 --- a/src/game.c +++ b/src/game.c @@ -389,7 +389,7 @@ void debug_gui(float dt) if (scale_left) window_flags |= NK_WINDOW_SCALE_LEFT; if (minimizable) window_flags |= NK_WINDOW_MINIMIZABLE; - if (nk_begin(ctx, "Overview", nk_rect(10, 10, 400, 600), window_flags)) + if (nk_begin(ctx, "Overview", nk_rect(70, 70, 400, 600), window_flags)) { if (show_menu) { diff --git a/src/gui.c b/src/gui.c index 0194966..2385197 100644 --- a/src/gui.c +++ b/src/gui.c @@ -87,8 +87,9 @@ int gui_init(void) glBindVertexArray(0); platform_textinput_callback_set(&gui_handle_textinput_event); - gui_font_set("roboto.ttf", 18); - gui_theme_set(GT_DEFAULT); + gui_font_set("Ubuntu-R.ttf", 14); + /* gui_font_set("FiraSans-Regular.ttf", 14); */ + gui_theme_set(GT_RED); success = 1; return success; } diff --git a/src/linmath.c b/src/linmath.c index 95779b8..bee1c47 100644 --- a/src/linmath.c +++ b/src/linmath.c @@ -197,6 +197,14 @@ void vec4_fill(vec4* res, float x, float y, float z, float w) res->w = w; } +void vec4_fill_vec3(vec4* res, const vec3* v, float w) +{ + res->x = v->x; + res->y = v->y; + res->z = v->z; + res->w = w; +} + void vec4_add(vec4* res, vec4* v1, vec4* v4) { res->x = v1->x + v4->x; diff --git a/src/linmath.h b/src/linmath.h index e507d14..fe2bfc0 100644 --- a/src/linmath.h +++ b/src/linmath.h @@ -84,6 +84,7 @@ float vec3_dot(vec3* v1, vec3* v2); /* vec4 */ int vec4_equals(vec4* v1, vec4* v2); void vec4_fill(vec4* res, float x, float y, float z, float w); +void vec4_fill_vec3(vec4* res, const vec3* v, float w); void vec4_transform_norm(vec4* res, const vec4* val, const mat4* mat); void vec4_scale(vec4* res, const vec4* val, float s); void vec4_mul_mat4(vec4* res, vec4* val, mat4* mat); diff --git a/src/model.c b/src/model.c index 687b7c8..a3f2a9e 100644 --- a/src/model.c +++ b/src/model.c @@ -367,13 +367,13 @@ struct Model* model_get_all(void) void model_render_all_debug(struct Camera* camera, int debug_shader, enum Geometry_Draw_Mode draw_mode, - const vec3* debug_color) + const vec4* debug_color) { assert(debug_shader > -1); shader_bind(debug_shader); { static mat4 mvp; - shader_set_uniform_vec3(debug_shader, "debug_color", debug_color); + shader_set_uniform_vec4(debug_shader, "debug_color", debug_color); for(int i = 0; i < array_len(model_list); i++) { struct Model* model = &model_list[i]; diff --git a/src/model.h b/src/model.h index ef47b9f..ca2c09e 100644 --- a/src/model.h +++ b/src/model.h @@ -27,6 +27,6 @@ int model_get_material_param(struct Model* model, const char* name, void* v void model_render_all_debug(struct Camera* camera, int debug_shader, enum Geometry_Draw_Mode draw_mode, - const vec3* debug_color); + const vec4* debug_color); #endif diff --git a/src/renderer.c b/src/renderer.c index 60523ac..223ad20 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -46,7 +46,7 @@ void renderer_init(void) settings.max_gui_element_memory = MAX_GUI_ELEMENT_MEMORY; vec3_fill(&settings.fog.color, 60.f/255.f, 60.f/255.f, 75.f/255.f); vec3_fill(&settings.ambient_light, 0.1f, 0.1f, 0.12f); - vec3_fill(&settings.debug_draw_color, 0.f, 1.f, 0.f); + vec4_fill(&settings.debug_draw_color, 0.f, 1.f, 0.f, 1.f); gui_init(); diff --git a/src/renderer.h b/src/renderer.h index 10383f2..59ef0a2 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -29,7 +29,7 @@ struct Render_Settings int max_gui_vertex_memory; int max_gui_element_memory; int debug_draw_enabled; - vec3 debug_draw_color; + vec4 debug_draw_color; enum Geometry_Draw_Mode debug_draw_mode; };