Added window to render settings to editor ui and updated nuklear version

dev
Shariq Shah 9 years ago
parent 97ac88e7da
commit 598ac1c5cf
  1. 147
      README
  2. 4
      assets/shaders/debug.frag
  3. 27
      include/nuklear.h
  4. 3
      orgfile.org
  5. 120
      src/editor.c
  6. 2
      src/game.c
  7. 5
      src/gui.c
  8. 8
      src/linmath.c
  9. 1
      src/linmath.h
  10. 4
      src/model.c
  11. 2
      src/model.h
  12. 2
      src/renderer.c
  13. 2
      src/renderer.h

147
README

@ -46,38 +46,39 @@ _________________
.. 2.30 DONE Fix problems with texture units .. 2.30 DONE Fix problems with texture units
.. 2.31 CANCELED Draw light volumes .. 2.31 CANCELED Draw light volumes
.. 2.32 TODO Fix problems with frustrum culling .. 2.32 TODO Fix problems with frustrum culling
.. 2.33 TODO .. 2.33 TODO 2d drawing routines
.. 2.34 TODO .. 2.34 DONE Gui
.. 2.35 TODO 2d drawing routines .. 2.35 CANCELED Image based lighting?
.. 2.36 DONE Gui .. 2.36 CANCELED Deferred rendering?
.. 2.37 CANCELED Image based lighting? .. 2.37 TODO Fix mouse bugs on windows
.. 2.38 CANCELED Deferred rendering? .. 2.38 DONE Fix mousewheel bugs and gui not responding to mousewheel input
.. 2.39 TODO Fix mouse bugs on windows .. 2.39 TODO Ability to mark meshes for debug rendering with possibility of different color for each?
.. 2.40 DONE Toggleable debug drawing for meshes .. 2.40 TODO Setup cross compilation with mingw or stick to msvc?
.. 2.41 TODO Interleaved vbos for meshes and changes to blender exporter accordingly .. 2.41 DONE Toggleable debug drawing for meshes
.. 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.42 TODO Interleaved vbos for meshes and changes to blender exporter accordingly
.. 2.43 TODO Physics/Collision detection in 2d .. 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 Complete gui integration .. 2.44 TODO Physics/Collision detection in 2d
.. 2.45 TODO Allow passsing base path as commandline argument? .. 2.45 TODO Complete gui integration
.. 2.46 TODO Sprite sheet animations .. 2.46 TODO Allow passsing base path as commandline argument?
.. 2.47 DONE Resizable framebuffers and textures .. 2.47 TODO Sprite sheet animations
.. 2.48 DONE Support for multiple color attachments in framebuffers? .. 2.48 DONE Resizable framebuffers and textures
.. 2.49 TODO Multisampled textures and framebuffers .. 2.49 DONE Support for multiple color attachments in framebuffers?
.. 2.50 DONE Better way to store and manage textures attached to framebuffers .. 2.50 TODO Multisampled textures and framebuffers
.. 2.51 TODO Validate necessary assets at game launch .. 2.51 DONE Better way to store and manage textures attached to framebuffers
.. 2.52 TODO Variant type .. 2.52 TODO Validate necessary assets at game launch
.. 2.53 TODO Log and debug/stats output in gui .. 2.53 TODO Variant type
.. 2.54 TODO Editor .. 2.54 TODO Log and debug/stats output in gui
.. 2.55 TODO Event Subsystem .. 2.55 TODO Editor
.. 2.56 TODO Keybindings for gui? .. 2.56 TODO Event Subsystem
.. 2.57 DONE Compile and test on windows .. 2.57 TODO Keybindings for gui?
.. 2.58 TODO Array based string type comptible with cstring(char*) .. 2.58 DONE Compile and test on windows
.. 2.59 DONE Fix mouse bugs .. 2.59 TODO Array based string type comptible with cstring(char*)
.. 2.60 DONE Fix .. 2.60 DONE Fix mouse bugs
.. 2.61 TODO issues with opengl context showing 2.1 only .. 2.61 DONE Fix
.. 2.62 TODO Improve this readme .. 2.62 TODO issues with opengl context showing 2.1 only
.. 2.63 TODO ??? .. 2.63 TODO Improve this readme
.. 2.64 TODO Profit! .. 2.64 TODO ???
.. 2.65 TODO Profit!
1 Project Symmetry 1 Project Symmetry
@ -294,66 +295,72 @@ _________________
2.32 TODO Fix problems with frustrum culling 2.32 TODO Fix problems with frustrum culling
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2.33 TODO
~~~~~~~~~~
2.34 TODO
~~~~~~~~~~
- Recalculate bounding boxes for rotated meshes? - Recalculate bounding boxes for rotated meshes?
2.35 TODO 2d drawing routines 2.33 TODO 2d drawing routines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Sprite batching - Sprite batching
2.36 DONE Gui 2.34 DONE Gui
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
- State "DONE" from "TODO" [2017-03-15 Wed 23:41] - 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] - State "CANCELED" from "TODO" [2017-03-14 Tue 00:31]
Not a requirement for current project 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] - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49]
Sticking with forward rendering for now and focusing on tools etc. 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] - 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 x Font selection x Font atlas proper cleanup
@ -361,93 +368,93 @@ _________________
- Custom rendering for gui - 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] - 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] - 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] - 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] - 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] - 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] - 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!
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

@ -1,10 +1,10 @@
//include version.glsl //include version.glsl
uniform vec3 debug_color; uniform vec4 debug_color;
out vec4 frag_color; out vec4 frag_color;
void main() void main()
{ {
frag_color = vec4(debug_color, 1.0); frag_color = debug_color;
} }

@ -1,7 +1,7 @@
/* /*
Nuklear - 1.33.0 - public domain Nuklear - 1.33.0 - public domain
no warrenty implied; use at your own risk. no warrenty implied; use at your own risk.
authored from 2015-2016 by Micha Mettke authored from 2015-2017 by Micha Mettke
ABOUT: ABOUT:
This is a minimal state graphical user interface single header toolkit 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_strlen(const char *str);
NK_API int nk_stricmp(const char *s1, const char *s2); 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_stricmpn(const char *s1, const char *s2, int n);
NK_API int nk_strtoi(const char *str, char **endptr); NK_API int nk_strtoi(const char *str, const char **endptr);
NK_API float nk_strtof(const char *str, char **endptr); NK_API float nk_strtof(const char *str, const char **endptr);
NK_API double nk_strtod(const char *str, 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_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_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); 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_API int
nk_strtoi(const char *str, char **endptr) nk_strtoi(const char *str, const char **endptr)
{ {
int neg = 1; int neg = 1;
const char *p = str; const char *p = str;
@ -3550,12 +3550,12 @@ nk_strtoi(const char *str, char **endptr)
p++; p++;
} }
if (endptr) if (endptr)
*endptr = (char*)p; *endptr = p;
return neg*value; return neg*value;
} }
NK_API double NK_API double
nk_strtod(const char *str, char **endptr) nk_strtod(const char *str, const char **endptr)
{ {
double m; double m;
double neg = 1.0; double neg = 1.0;
@ -3608,12 +3608,12 @@ nk_strtod(const char *str, char **endptr)
} }
number = value * neg; number = value * neg;
if (endptr) if (endptr)
*endptr = (char*)p; *endptr = p;
return number; return number;
} }
NK_API float NK_API float
nk_strtof(const char *str, char **endptr) nk_strtof(const char *str, const char **endptr)
{ {
float float_value; float float_value;
double double_value; double double_value;
@ -4091,7 +4091,7 @@ nk_vsnprintf(char *buf, int buf_size, const char *fmt, va_list args)
/* width argument */ /* width argument */
width = NK_DEFAULT; width = NK_DEFAULT;
if (*iter >= '1' && *iter <= '9') { if (*iter >= '1' && *iter <= '9') {
char *end; const char *end;
width = nk_strtoi(iter, &end); width = nk_strtoi(iter, &end);
if (end == iter) if (end == iter)
width = -1; width = -1;
@ -4109,7 +4109,7 @@ nk_vsnprintf(char *buf, int buf_size, const char *fmt, va_list args)
precision = va_arg(args, int); precision = va_arg(args, int);
iter++; iter++;
} else { } else {
char *end; const char *end;
precision = nk_strtoi(iter, &end); precision = nk_strtoi(iter, &end);
if (end == iter) if (end == iter)
precision = -1; precision = -1;
@ -13454,8 +13454,7 @@ nk_do_selectable_image(nk_flags *state, struct nk_command_buffer *out,
NK_INTERN float NK_INTERN float
nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor, nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor,
struct nk_rect *visual_cursor, struct nk_input *in, struct nk_rect *visual_cursor, struct nk_input *in,
const struct nk_style_slider *style, struct nk_rect bounds, struct nk_rect bounds, float slider_min, float slider_max, float slider_value,
float slider_min, float slider_max, float slider_value,
float slider_step, float slider_steps) float slider_step, float slider_steps)
{ {
int left_mouse_down; 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; visual_cursor.x = logical_cursor.x - visual_cursor.w*0.5f;
slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor, 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; visual_cursor.x = logical_cursor.x - visual_cursor.w*0.5f;
/* draw slider */ /* draw slider */

@ -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] \\ - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\
Sticking with forward rendering for now and focusing on tools etc. Sticking with forward rendering for now and focusing on tools etc.
** TODO Fix mouse bugs on windows ** 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 Ability to mark meshes for debug rendering with possibility of different color for each?
** TODO Setup cross compilation with mingw or stick to msvc? ** TODO Setup cross compilation with mingw or stick to msvc?
** DONE Toggleable debug drawing for meshes ** DONE Toggleable debug drawing for meshes

@ -18,17 +18,19 @@
struct Editor_State struct Editor_State
{ {
int enabled; int enabled;
int debug_window_enabled; int renderer_settings_window;
int top_panel_height; int top_panel_height;
}; };
static struct Editor_State editor_state; 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) void editor_init(void)
{ {
editor_state.enabled = 1; editor_state.enabled = 1;
editor_state.debug_window_enabled = 0; editor_state.renderer_settings_window = 1;
editor_state.top_panel_height = 50; editor_state.top_panel_height = 30;
} }
void editor_update(float dt) void editor_update(float dt)
@ -41,32 +43,88 @@ void editor_update(float dt)
struct Render_Settings* render_settings = renderer_settings_get(); struct Render_Settings* render_settings = renderer_settings_get();
int win_width = 0, win_height = 0; int win_width = 0, win_height = 0;
window_get_drawable_size(game_state->window, &win_width, &win_height); 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 */ /* Top Panel */
if(nk_begin(context, "Top_Panel", nk_recti(0, 0, win_width, win_height - (win_height - editor_state.top_panel_height)), 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))
{
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)
{ {
nk_layout_row_static(context, 40, 100, 2); fps = frames;
if(nk_button_label(context, "Debug")) editor_state.debug_window_enabled = !editor_state.debug_window_enabled; 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); nk_end(context);
/* Debug Window */ /* 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_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))
{
if(nk_tree_push(context, NK_TREE_TAB, "Debug", NK_MINIMIZED))
{ {
debug_window = 1; static const char* draw_modes[] = {"Triangles", "Lines", "Points"};
nk_layout_row_static(context, 40, 50, 1); nk_layout_row_dynamic(context, 25, 2);
nk_checkbox_label(context, "Debug Draw", &render_settings->debug_draw_enabled); 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 else
{ {
debug_window = 0; editor_state.renderer_settings_window = 0;
} }
nk_end(context); nk_end(context);
} }
@ -77,3 +135,37 @@ void editor_toggle(void)
editor_state.enabled = !editor_state.enabled; 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);
}
}

@ -389,7 +389,7 @@ void debug_gui(float dt)
if (scale_left) window_flags |= NK_WINDOW_SCALE_LEFT; if (scale_left) window_flags |= NK_WINDOW_SCALE_LEFT;
if (minimizable) window_flags |= NK_WINDOW_MINIMIZABLE; 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) if (show_menu)
{ {

@ -87,8 +87,9 @@ int gui_init(void)
glBindVertexArray(0); glBindVertexArray(0);
platform_textinput_callback_set(&gui_handle_textinput_event); platform_textinput_callback_set(&gui_handle_textinput_event);
gui_font_set("roboto.ttf", 18); gui_font_set("Ubuntu-R.ttf", 14);
gui_theme_set(GT_DEFAULT); /* gui_font_set("FiraSans-Regular.ttf", 14); */
gui_theme_set(GT_RED);
success = 1; success = 1;
return success; return success;
} }

@ -197,6 +197,14 @@ void vec4_fill(vec4* res, float x, float y, float z, float w)
res->w = 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) void vec4_add(vec4* res, vec4* v1, vec4* v4)
{ {
res->x = v1->x + v4->x; res->x = v1->x + v4->x;

@ -84,6 +84,7 @@ float vec3_dot(vec3* v1, vec3* v2);
/* vec4 */ /* vec4 */
int vec4_equals(vec4* v1, vec4* v2); int vec4_equals(vec4* v1, vec4* v2);
void vec4_fill(vec4* res, float x, float y, float z, float w); 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_transform_norm(vec4* res, const vec4* val, const mat4* mat);
void vec4_scale(vec4* res, const vec4* val, float s); void vec4_scale(vec4* res, const vec4* val, float s);
void vec4_mul_mat4(vec4* res, vec4* val, mat4* mat); void vec4_mul_mat4(vec4* res, vec4* val, mat4* mat);

@ -367,13 +367,13 @@ struct Model* model_get_all(void)
void model_render_all_debug(struct Camera* camera, void model_render_all_debug(struct Camera* camera,
int debug_shader, int debug_shader,
enum Geometry_Draw_Mode draw_mode, enum Geometry_Draw_Mode draw_mode,
const vec3* debug_color) const vec4* debug_color)
{ {
assert(debug_shader > -1); assert(debug_shader > -1);
shader_bind(debug_shader); shader_bind(debug_shader);
{ {
static mat4 mvp; 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++) for(int i = 0; i < array_len(model_list); i++)
{ {
struct Model* model = &model_list[i]; struct Model* model = &model_list[i];

@ -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, void model_render_all_debug(struct Camera* camera,
int debug_shader, int debug_shader,
enum Geometry_Draw_Mode draw_mode, enum Geometry_Draw_Mode draw_mode,
const vec3* debug_color); const vec4* debug_color);
#endif #endif

@ -46,7 +46,7 @@ void renderer_init(void)
settings.max_gui_element_memory = MAX_GUI_ELEMENT_MEMORY; 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.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.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(); gui_init();

@ -29,7 +29,7 @@ struct Render_Settings
int max_gui_vertex_memory; int max_gui_vertex_memory;
int max_gui_element_memory; int max_gui_element_memory;
int debug_draw_enabled; int debug_draw_enabled;
vec3 debug_draw_color; vec4 debug_draw_color;
enum Geometry_Draw_Mode debug_draw_mode; enum Geometry_Draw_Mode debug_draw_mode;
}; };

Loading…
Cancel
Save