changeset 1474:c5c022c7aa54 nuklear_ui

Initial work on Nuklear-based UI
author Michael Pavone <pavone@retrodev.com>
date Tue, 21 Nov 2017 19:07:43 -0800
parents 152a60c6787e
children afa3fbb76bff
files Makefile blastem.c nuklear_ui/blastem_nuklear.c nuklear_ui/blastem_nuklear.h nuklear_ui/font.c nuklear_ui/font.h nuklear_ui/nuklear.h nuklear_ui/nuklear_sdl_gles2.h render_sdl.c render_sdl.h
diffstat 10 files changed, 24400 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Nov 21 18:55:33 2017 -0800
+++ b/Makefile	Tue Nov 21 19:07:43 2017 -0800
@@ -126,8 +126,11 @@
 Z80OBJS=z80inst.o z80_to_x86.o
 AUDIOOBJS=ym2612.o psg.o wave.o
 CONFIGOBJS=config.o tern.o util.o
+NUKLEAROBJS=nuklear_ui/font.o nuklear_ui/blastem_nuklear.o
 
-MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o render_sdl.o ppm.o io.o romdb.o hash.o menu.o xband.o realtec.o i2c.o nor.o sega_mapper.o multi_game.o serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS)
+MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o render_sdl.o ppm.o io.o romdb.o hash.o menu.o xband.o \
+	realtec.o i2c.o nor.o sega_mapper.o multi_game.o serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o $(M68KOBJS) \
+	$(TRANSOBJS) $(AUDIOOBJS) $(NUKLEAROBJS) paths.o
 
 ifeq ($(CPU),x86_64)
 CFLAGS+=-DX86_64 -m64
--- a/blastem.c	Tue Nov 21 18:55:33 2017 -0800
+++ b/blastem.c	Tue Nov 21 19:07:43 2017 -0800
@@ -24,6 +24,7 @@
 #include "arena.h"
 #include "config.h"
 #include "menu.h"
+#include "nuklear_ui/blastem_nuklear.h"
 
 #define BLASTEM_VERSION "0.5.2-pre"
 
@@ -462,6 +463,8 @@
 	} else {
 		game_system = current_system;
 	}
+	
+	blastem_nuklear_init(game_system == current_system);
 
 	current_system->debugger_type = dtype;
 	current_system->enter_debugger = start_in_debugger && menu == debug_target;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuklear_ui/blastem_nuklear.c	Tue Nov 21 19:07:43 2017 -0800
@@ -0,0 +1,158 @@
+#define NK_IMPLEMENTATION
+#define NK_SDL_GLES2_IMPLEMENTATION
+
+#include <stdlib.h>
+#include "blastem_nuklear.h"
+#include "font.h"
+#include "../render.h"
+#include "../render_sdl.h"
+#include "../util.h"
+#include "../paths.h"
+#include "../blastem.h"
+
+static struct nk_context *context;
+
+typedef void (*view_fun)(struct nk_context *);
+static view_fun current_view;
+
+void view_play(struct nk_context *context)
+{
+	
+}
+
+void view_load(struct nk_context *context)
+{
+	static char *current_path;
+	static dir_entry *entries;
+	static size_t num_entries;
+	static uint32_t selected_entry;
+	get_initial_browse_path(&current_path);
+	if (!entries) {
+		entries = get_dir_list(current_path, &num_entries);
+	}
+	uint32_t width = render_width();
+	uint32_t height = render_height();
+	if (nk_begin(context, "Load ROM", nk_rect(0, 0, width, height), 0)) {
+		nk_layout_row_static(context, height - 100, width - 60, 1);
+		if (nk_group_begin(context, "Select ROM", NK_WINDOW_BORDER | NK_WINDOW_TITLE)) {
+			nk_layout_row_static(context, 28, width-100, 1);
+			for (uint32_t i = 0; i < num_entries; i++)
+			{
+				int selected = i == selected_entry;
+				nk_selectable_label(context, entries[i].name, NK_TEXT_ALIGN_LEFT, &selected);
+				if (selected) {
+					selected_entry = i;
+				}
+			}
+			nk_group_end(context);
+		}
+		nk_layout_row_static(context, 52, 300, 1);
+		if (nk_button_label(context, "Open")) {
+			if (entries[selected_entry].is_dir) {
+				char *old = current_path;
+				char const *pieces[] = {old, PATH_SEP, entries[selected_entry].name};
+				current_path = alloc_concat_m(3, pieces);
+				free(old);
+				free_dir_list(entries, num_entries);
+				entries = NULL;
+			} else {
+				//TODO: load ROM
+				current_view = view_play;
+			}
+		}
+		nk_end(context);
+	}
+}
+
+void view_about(struct nk_context *context)
+{
+}
+
+typedef struct {
+	const char *title;
+	view_fun   next_view;
+} menu_item;
+
+static void menu(struct nk_context *context, uint32_t num_entries, const menu_item *items)
+{
+	const uint32_t button_height = 52;
+	const uint32_t ideal_button_width = 300;
+	const uint32_t button_space = 6;
+	
+	uint32_t width = render_width();
+	uint32_t height = render_height();
+	uint32_t top = height/2 - (button_height * num_entries)/2;
+	uint32_t button_width = width > ideal_button_width ? ideal_button_width : width;
+	uint32_t left = width/2 - button_width/2;
+	
+	nk_layout_space_begin(context, NK_STATIC, top + button_height * num_entries, num_entries);
+	for (uint32_t i = 0; i < num_entries; i++)
+	{
+		nk_layout_space_push(context, nk_rect(left, top + i * button_height, button_width, button_height-button_space));
+		if (nk_button_label(context, items[i].title)) {
+			current_view = items[i].next_view;
+			if (!current_view) {
+				exit(0);
+			}
+		}
+	}
+	nk_layout_space_end(context);
+}
+
+void view_menu(struct nk_context *context)
+{
+	static menu_item items[] = {
+		{"Load ROM", view_load},
+		{"About", view_about},
+		{"Exit", NULL}
+	};
+	
+	const uint32_t num_buttons = 3;
+	if (nk_begin(context, "Main Menu", nk_rect(0, 0, render_width(), render_height()), 0)) {
+		menu(context, sizeof(items)/sizeof(*items), items);
+		nk_end(context);
+	}
+}
+
+void blastem_nuklear_render(void)
+{
+	nk_input_end(context);
+	current_view(context);
+	glViewport(0, 0, render_width(), render_height());
+/*	glClear(GL_COLOR_BUFFER_BIT);
+	glClearColor(0, 0, 0, 0);*/
+	nk_sdl_render(NK_ANTI_ALIASING_ON, 512 * 1024, 128 * 1024);
+	//SDL_GL_SwapWindow(render_get_window());
+	nk_input_begin(context);
+}
+
+void idle_loop(void)
+{
+	while (current_view != view_play)
+	{
+		render_update_display();
+	}
+}
+static void handle_event(SDL_Event *event)
+{
+	nk_sdl_handle_event(event);
+}
+
+void blastem_nuklear_init(uint8_t file_loaded)
+{
+	context = nk_sdl_init(render_get_window());
+	
+	struct nk_font_atlas *atlas;
+	nk_sdl_font_stash_begin(&atlas);
+	char *font = default_font_path();
+	if (!font) {
+		fatal_error("Failed to find default font path\n");
+	}
+	struct nk_font *def_font = nk_font_atlas_add_from_file(atlas, font, 30, NULL);
+	nk_sdl_font_stash_end();
+	nk_style_set_font(context, &def_font->handle);
+	current_view = file_loaded ? view_play : view_menu;
+	render_set_ui_render_fun(blastem_nuklear_render);
+	render_set_event_handler(handle_event);
+	idle_loop();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuklear_ui/blastem_nuklear.h	Tue Nov 21 19:07:43 2017 -0800
@@ -0,0 +1,16 @@
+#ifndef BLASTEM_NUKLEAR_H_
+#define BLASTEM_NUKLEAR_H_
+
+#define NK_INCLUDE_FIXED_TYPES
+#define NK_INCLUDE_STANDARD_IO
+#define NK_INCLUDE_STANDARD_VARARGS
+#define NK_INCLUDE_DEFAULT_ALLOCATOR
+#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+#define NK_INCLUDE_FONT_BAKING
+#include <SDL_opengl.h>
+#include "nuklear.h"
+#include "nuklear_sdl_gles2.h"
+
+void blastem_nuklear_init(uint8_t file_loaded);
+
+#endif //BLASTEM_NUKLEAR_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuklear_ui/font.c	Tue Nov 21 19:07:43 2017 -0800
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+char *default_font_path(void)
+{
+	FILE *fc_pipe = popen("fc-match -f '%{file}'", "r");
+	if (!fc_pipe) {
+		return NULL;
+	}
+	size_t buf_size = 128;
+	char *buffer = NULL;
+	size_t total = 0, read = 0;
+	do {
+		total += read;
+		buf_size *= 2;
+		buffer = realloc(buffer, buf_size);
+		if (!buffer) {
+			return NULL;
+		}
+		read = fread(buffer, 1, buf_size - total, fc_pipe);
+	} while (read == (buf_size - total));
+	total += read;
+	buffer[total] = 0;
+	
+	return buffer;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuklear_ui/font.h	Tue Nov 21 19:07:43 2017 -0800
@@ -0,0 +1,6 @@
+#ifndef FONT_H_
+#define FONT_H_
+
+char *default_font_path(void);
+
+#endif //FONT_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nuklear_ui/nuklear.h	Tue Nov 21 19:07:43 2017 -0800
@@ -0,0 +1,23652 @@
+/*
+ Nuklear - 2.00.0 - public domain
+ no warranty implied; use at your own risk.
+ authored from 2015-2017 by Micha Mettke
+
+ABOUT:
+    This is a minimal state graphical user interface single header toolkit
+    written in ANSI C and licensed under public domain.
+    It was designed as a simple embeddable user interface for application and does
+    not have any dependencies, a default renderbackend or OS window and input handling
+    but instead provides a very modular library approach by using simple input state
+    for input and draw commands describing primitive shapes as output.
+    So instead of providing a layered library that tries to abstract over a number
+    of platform and render backends it only focuses on the actual UI.
+
+VALUES:
+    - Graphical user interface toolkit
+    - Single header library
+    - Written in C89 (a.k.a. ANSI C or ISO C90)
+    - Small codebase (~18kLOC)
+    - Focus on portability, efficiency and simplicity
+    - No dependencies (not even the standard library if not wanted)
+    - Fully skinnable and customizable
+    - Low memory footprint with total memory control if needed or wanted
+    - UTF-8 support
+    - No global or hidden state
+    - Customizable library modules (you can compile and use only what you need)
+    - Optional font baker and vertex buffer output
+
+USAGE:
+    This library is self contained in one single header file and can be used either
+    in header only mode or in implementation mode. The header only mode is used
+    by default when included and allows including this header in other headers
+    and does not contain the actual implementation.
+
+    The implementation mode requires to define  the preprocessor macro
+    NK_IMPLEMENTATION in *one* .c/.cpp file before #includeing this file, e.g.:
+
+        #define NK_IMPLEMENTATION
+        #include "nuklear.h"
+
+    Also optionally define the symbols listed in the section "OPTIONAL DEFINES"
+    below in header and implementation mode if you want to use additional functionality
+    or need more control over the library.
+    IMPORTANT:  Every time you include "nuklear.h" you have to define the same flags.
+                This is very important not doing it either leads to compiler errors
+                or even worse stack corruptions.
+
+FEATURES:
+    - Absolutely no platform dependent code
+    - Memory management control ranging from/to
+        - Ease of use by allocating everything from standard library
+        - Control every byte of memory inside the library
+    - Font handling control ranging from/to
+        - Use your own font implementation for everything
+        - Use this libraries internal font baking and handling API
+    - Drawing output control ranging from/to
+        - Simple shapes for more high level APIs which already have drawing capabilities
+        - Hardware accessible anti-aliased vertex buffer output
+    - Customizable colors and properties ranging from/to
+        - Simple changes to color by filling a simple color table
+        - Complete control with ability to use skinning to decorate widgets
+    - Bendable UI library with widget ranging from/to
+        - Basic widgets like buttons, checkboxes, slider, ...
+        - Advanced widget like abstract comboboxes, contextual menus,...
+    - Compile time configuration to only compile what you need
+        - Subset which can be used if you do not want to link or use the standard library
+    - Can be easily modified to only update on user input instead of frame updates
+
+OPTIONAL DEFINES:
+    NK_PRIVATE
+        If defined declares all functions as static, so they can only be accessed
+        inside the file that contains the implementation
+
+    NK_INCLUDE_FIXED_TYPES
+        If defined it will include header <stdint.h> for fixed sized types
+        otherwise nuklear tries to select the correct type. If that fails it will
+        throw a compiler error and you have to select the correct types yourself.
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INCLUDE_DEFAULT_ALLOCATOR
+        if defined it will include header <stdlib.h> and provide additional functions
+        to use this library without caring for memory allocation control and therefore
+        ease memory management.
+        <!> Adds the standard library with malloc and free so don't define if you
+            don't want to link to the standard library <!>
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INCLUDE_STANDARD_IO
+        if defined it will include header <stdio.h> and provide
+        additional functions depending on file loading.
+        <!> Adds the standard library with fopen, fclose,... so don't define this
+            if you don't want to link to the standard library <!>
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INCLUDE_STANDARD_VARARGS
+        if defined it will include header <stdarg.h> and provide
+        additional functions depending on variable arguments
+        <!> Adds the standard library with va_list and  so don't define this if
+            you don't want to link to the standard library<!>
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+        Defining this adds a vertex draw command list backend to this
+        library, which allows you to convert queue commands into vertex draw commands.
+        This is mainly if you need a hardware accessible format for OpenGL, DirectX,
+        Vulkan, Metal,...
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INCLUDE_FONT_BAKING
+        Defining this adds `stb_truetype` and `stb_rect_pack` implementation
+        to this library and provides font baking and rendering.
+        If you already have font handling or do not want to use this font handler
+        you don't have to define it.
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INCLUDE_DEFAULT_FONT
+        Defining this adds the default font: ProggyClean.ttf into this library
+        which can be loaded into a font atlas and allows using this library without
+        having a truetype font
+        <!> Enabling this adds ~12kb to global stack memory <!>
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INCLUDE_COMMAND_USERDATA
+        Defining this adds a userdata pointer into each command. Can be useful for
+        example if you want to provide custom shaders depending on the used widget.
+        Can be combined with the style structures.
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_BUTTON_TRIGGER_ON_RELEASE
+        Different platforms require button clicks occurring either on buttons being
+        pressed (up to down) or released (down to up).
+        By default this library will react on buttons being pressed, but if you
+        define this it will only trigger if a button is released.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_ZERO_COMMAND_MEMORY
+        Defining this will zero out memory for each drawing command added to a
+        drawing queue (inside nk_command_buffer_push). Zeroing command memory
+        is very useful for fast checking (using memcmp) if command buffers are
+        equal and avoid drawing frames when nothing on screen has changed since
+        previous frame.
+
+    NK_ASSERT
+        If you don't define this, nuklear will use <assert.h> with assert().
+        <!> Adds the standard library so define to nothing of not wanted <!>
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_BUFFER_DEFAULT_INITIAL_SIZE
+        Initial buffer size allocated by all buffers while using the default allocator
+        functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't
+        want to allocate the default 4k memory then redefine it.
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_MAX_NUMBER_BUFFER
+        Maximum buffer size for the conversion buffer between float and string
+        Under normal circumstances this should be more than sufficient.
+        <!> If used needs to be defined for implementation and header <!>
+
+    NK_INPUT_MAX
+        Defines the max number of bytes which can be added as text input in one frame.
+        Under normal circumstances this should be more than sufficient.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_MEMSET
+        You can define this to 'memset' or your own memset implementation
+        replacement. If not nuklear will use its own version.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_MEMCPY
+        You can define this to 'memcpy' or your own memcpy implementation
+        replacement. If not nuklear will use its own version.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_SQRT
+        You can define this to 'sqrt' or your own sqrt implementation
+        replacement. If not nuklear will use its own slow and not highly
+        accurate version.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_SIN
+        You can define this to 'sinf' or your own sine implementation
+        replacement. If not nuklear will use its own approximation implementation.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_COS
+        You can define this to 'cosf' or your own cosine implementation
+        replacement. If not nuklear will use its own approximation implementation.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_STRTOD
+        You can define this to `strtod` or your own string to double conversion
+        implementation replacement. If not defined nuklear will use its own
+        imprecise and possibly unsafe version (does not handle nan or infinity!).
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_DTOA
+        You can define this to `dtoa` or your own double to string conversion
+        implementation replacement. If not defined nuklear will use its own
+        imprecise and possibly unsafe version (does not handle nan or infinity!).
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_VSNPRINTF
+        If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO`
+        and want to be safe define this to `vsnprintf` on compilers supporting
+        later versions of C or C++. By default nuklear will check for your stdlib version
+        in C as well as compiler version in C++. if `vsnprintf` is available
+        it will define it to `vsnprintf` directly. If not defined and if you have
+        older versions of C or C++ it will be defined to `vsprintf` which is unsafe.
+        <!> If used it is only required to be defined for the implementation part <!>
+
+    NK_BYTE
+    NK_INT16
+    NK_UINT16
+    NK_INT32
+    NK_UINT32
+    NK_SIZE_TYPE
+    NK_POINTER_TYPE
+        If you compile without NK_USE_FIXED_TYPE then a number of standard types
+        will be selected and compile time validated. If they are incorrect you can
+        define the correct types by overloading these type defines.
+
+CREDITS:
+    Developed by Micha Mettke and every direct or indirect contributor.
+
+    Embeds stb_texedit, stb_truetype and stb_rectpack by Sean Barret (public domain)
+    Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license).
+
+    Big thank you to Omar Cornut (ocornut@github) for his imgui library and
+    giving me the inspiration for this library, Casey Muratori for handmade hero
+    and his original immediate mode graphical user interface idea and Sean
+    Barret for his amazing single header libraries which restored my faith
+    in libraries and brought me to create some of my own.
+
+LICENSE:
+    This software is dual-licensed to the public domain and under the following
+    license: you are granted a perpetual, irrevocable license to copy, modify,
+    publish and distribute this file as you see fit.
+*/
+#ifndef NK_NUKLEAR_H_
+#define NK_NUKLEAR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * ==============================================================
+ *
+ *                          CONSTANTS
+ *
+ * ===============================================================
+ */
+#define NK_UNDEFINED (-1.0f)
+#define NK_UTF_INVALID 0xFFFD /* internal invalid utf8 rune */
+#define NK_UTF_SIZE 4 /* describes the number of bytes a glyph consists of*/
+#ifndef NK_INPUT_MAX
+#define NK_INPUT_MAX 16
+#endif
+#ifndef NK_MAX_NUMBER_BUFFER
+#define NK_MAX_NUMBER_BUFFER 64
+#endif
+#ifndef NK_SCROLLBAR_HIDING_TIMEOUT
+#define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
+#endif
+/*
+ * ==============================================================
+ *
+ *                          HELPER
+ *
+ * ===============================================================
+ */
+#ifndef NK_API
+  #ifdef NK_PRIVATE
+    #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
+      #define NK_API static inline
+    #elif defined(__cplusplus)
+      #define NK_API static inline
+    #else
+      #define NK_API static
+    #endif
+  #else
+    #define NK_API extern
+  #endif
+#endif
+
+#define NK_INTERN static
+#define NK_STORAGE static
+#define NK_GLOBAL static
+
+#define NK_FLAG(x) (1 << (x))
+#define NK_STRINGIFY(x) #x
+#define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
+#define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
+#define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
+#define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
+
+#ifdef _MSC_VER
+#define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
+#else
+#define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
+#endif
+
+#ifndef NK_STATIC_ASSERT
+#define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
+#endif
+
+#ifndef NK_FILE_LINE
+#ifdef _MSC_VER
+#define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
+#else
+#define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
+#endif
+#endif
+
+#define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
+#define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
+#define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
+/*
+ * ===============================================================
+ *
+ *                          BASIC
+ *
+ * ===============================================================
+ */
+#ifdef NK_INCLUDE_FIXED_TYPES
+ #include <stdint.h>
+ #define NK_INT8 int8_t
+ #define NK_UINT8 uint8_t
+ #define NK_INT16 int16_t
+ #define NK_UINT16 uint16_t
+ #define NK_INT32 int32_t
+ #define NK_UINT32 uint32_t
+ #define NK_SIZE_TYPE uintptr_t
+ #define NK_POINTER_TYPE uintptr_t
+#else
+  #ifndef NK_INT8
+    #define NK_INT8 char
+  #endif
+  #ifndef NK_UINT8
+    #define NK_UINT8 unsigned char
+  #endif
+  #ifndef NK_INT16
+    #define NK_INT16 signed short
+  #endif
+  #ifndef NK_UINT16
+    #define NK_UINT16 unsigned short
+  #endif
+  #ifndef NK_INT32
+    #if defined(_MSC_VER)
+      #define NK_INT32 __int32
+    #else
+      #define NK_INT32 signed int
+    #endif
+  #endif
+  #ifndef NK_UINT32
+    #if defined(_MSC_VER)
+      #define NK_UINT32 unsigned __int32
+    #else
+      #define NK_UINT32 unsigned int
+    #endif
+  #endif
+  #ifndef NK_SIZE_TYPE
+    #if defined(_WIN64) && defined(_MSC_VER)
+      #define NK_SIZE_TYPE unsigned __int64
+    #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
+      #define NK_SIZE_TYPE unsigned __int32
+    #elif defined(__GNUC__) || defined(__clang__)
+      #if defined(__x86_64__) || defined(__ppc64__)
+        #define NK_SIZE_TYPE unsigned long
+      #else
+        #define NK_SIZE_TYPE unsigned int
+      #endif
+    #else
+      #define NK_SIZE_TYPE unsigned long
+    #endif
+  #endif
+  #ifndef NK_POINTER_TYPE
+    #if defined(_WIN64) && defined(_MSC_VER)
+      #define NK_POINTER_TYPE unsigned __int64
+    #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
+      #define NK_POINTER_TYPE unsigned __int32
+    #elif defined(__GNUC__) || defined(__clang__)
+      #if defined(__x86_64__) || defined(__ppc64__)
+        #define NK_POINTER_TYPE unsigned long
+      #else
+        #define NK_POINTER_TYPE unsigned int
+      #endif
+    #else
+      #define NK_POINTER_TYPE unsigned long
+    #endif
+  #endif
+#endif
+
+typedef NK_INT8 nk_char;
+typedef NK_UINT8 nk_uchar;
+typedef NK_UINT8 nk_byte;
+typedef NK_INT16 nk_short;
+typedef NK_UINT16 nk_ushort;
+typedef NK_INT32 nk_int;
+typedef NK_UINT32 nk_uint;
+typedef NK_SIZE_TYPE nk_size;
+typedef NK_POINTER_TYPE nk_ptr;
+
+typedef nk_uint nk_hash;
+typedef nk_uint nk_flags;
+typedef nk_uint nk_rune;
+
+/* Make sure correct type size:
+ * This will fire with a negative subscript error if the type sizes
+ * are set incorrectly by the compiler, and compile out if not */
+NK_STATIC_ASSERT(sizeof(nk_short) == 2);
+NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
+NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
+NK_STATIC_ASSERT(sizeof(nk_int) == 4);
+NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
+NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
+NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
+NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
+NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*));
+
+/* ============================================================================
+ *
+ *                                  API
+ *
+ * =========================================================================== */
+struct nk_buffer;
+struct nk_allocator;
+struct nk_command_buffer;
+struct nk_draw_command;
+struct nk_convert_config;
+struct nk_style_item;
+struct nk_text_edit;
+struct nk_draw_list;
+struct nk_user_font;
+struct nk_panel;
+struct nk_context;
+struct nk_draw_vertex_layout_element;
+struct nk_style_button;
+struct nk_style_toggle;
+struct nk_style_selectable;
+struct nk_style_slide;
+struct nk_style_progress;
+struct nk_style_scrollbar;
+struct nk_style_edit;
+struct nk_style_property;
+struct nk_style_chart;
+struct nk_style_combo;
+struct nk_style_tab;
+struct nk_style_window_header;
+struct nk_style_window;
+
+enum {nk_false, nk_true};
+struct nk_color {nk_byte r,g,b,a;};
+struct nk_colorf {float r,g,b,a;};
+struct nk_vec2 {float x,y;};
+struct nk_vec2i {short x, y;};
+struct nk_rect {float x,y,w,h;};
+struct nk_recti {short x,y,w,h;};
+typedef char nk_glyph[NK_UTF_SIZE];
+typedef union {void *ptr; int id;} nk_handle;
+struct nk_image {nk_handle handle;unsigned short w,h;unsigned short region[4];};
+struct nk_cursor {struct nk_image img; struct nk_vec2 size, offset;};
+struct nk_scroll {nk_uint x, y;};
+
+enum nk_heading         {NK_UP, NK_RIGHT, NK_DOWN, NK_LEFT};
+enum nk_button_behavior {NK_BUTTON_DEFAULT, NK_BUTTON_REPEATER};
+enum nk_modify          {NK_FIXED = nk_false, NK_MODIFIABLE = nk_true};
+enum nk_orientation     {NK_VERTICAL, NK_HORIZONTAL};
+enum nk_collapse_states {NK_MINIMIZED = nk_false, NK_MAXIMIZED = nk_true};
+enum nk_show_states     {NK_HIDDEN = nk_false, NK_SHOWN = nk_true};
+enum nk_chart_type      {NK_CHART_LINES, NK_CHART_COLUMN, NK_CHART_MAX};
+enum nk_chart_event     {NK_CHART_HOVERING = 0x01, NK_CHART_CLICKED = 0x02};
+enum nk_color_format    {NK_RGB, NK_RGBA};
+enum nk_popup_type      {NK_POPUP_STATIC, NK_POPUP_DYNAMIC};
+enum nk_layout_format   {NK_DYNAMIC, NK_STATIC};
+enum nk_tree_type       {NK_TREE_NODE, NK_TREE_TAB};
+
+typedef void*(*nk_plugin_alloc)(nk_handle, void *old, nk_size);
+typedef void (*nk_plugin_free)(nk_handle, void *old);
+typedef int(*nk_plugin_filter)(const struct nk_text_edit*, nk_rune unicode);
+typedef void(*nk_plugin_paste)(nk_handle, struct nk_text_edit*);
+typedef void(*nk_plugin_copy)(nk_handle, const char*, int len);
+
+struct nk_allocator {
+    nk_handle userdata;
+    nk_plugin_alloc alloc;
+    nk_plugin_free free;
+};
+enum nk_symbol_type {
+    NK_SYMBOL_NONE,
+    NK_SYMBOL_X,
+    NK_SYMBOL_UNDERSCORE,
+    NK_SYMBOL_CIRCLE_SOLID,
+    NK_SYMBOL_CIRCLE_OUTLINE,
+    NK_SYMBOL_RECT_SOLID,
+    NK_SYMBOL_RECT_OUTLINE,
+    NK_SYMBOL_TRIANGLE_UP,
+    NK_SYMBOL_TRIANGLE_DOWN,
+    NK_SYMBOL_TRIANGLE_LEFT,
+    NK_SYMBOL_TRIANGLE_RIGHT,
+    NK_SYMBOL_PLUS,
+    NK_SYMBOL_MINUS,
+    NK_SYMBOL_MAX
+};
+/* =============================================================================
+ *
+ *                                  CONTEXT
+ *
+ * =============================================================================*/
+/*  Contexts are the main entry point and the majestro of nuklear and contain all required state.
+ *  They are used for window, memory, input, style, stack, commands and time management and need
+ *  to be passed into all nuklear GUI specific functions.
+ *
+ *  Usage
+ *  -------------------
+ *  To use a context it first has to be initialized which can be achieved by calling
+ *  one of either `nk_init_default`, `nk_init_fixed`, `nk_init`, `nk_init_custom`.
+ *  Each takes in a font handle and a specific way of handling memory. Memory control
+ *  hereby ranges from standard library to just specifying a fixed sized block of memory
+ *  which nuklear has to manage itself from.
+ *
+ *      struct nk_context ctx;
+ *      nk_init_xxx(&ctx, ...);
+ *      while (1) {
+ *          [...]
+ *          nk_clear(&ctx);
+ *      }
+ *      nk_free(&ctx);
+ *
+ *  Reference
+ *  -------------------
+ *  nk_init_default     - Initializes context with standard library memory allocation (malloc,free)
+ *  nk_init_fixed       - Initializes context from single fixed size memory block
+ *  nk_init             - Initializes context with memory allocator callbacks for alloc and free
+ *  nk_init_custom      - Initializes context from two buffers. One for draw commands the other for window/panel/table allocations
+ *  nk_clear            - Called at the end of the frame to reset and prepare the context for the next frame
+ *  nk_free             - Shutdown and free all memory allocated inside the context
+ *  nk_set_user_data    - Utility function to pass user data to draw command
+ */
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+/*  nk_init_default - Initializes a `nk_context` struct with a default standard library allocator.
+ *  Should be used if you don't want to be bothered with memory management in nuklear.
+ *  Parameters:
+ *      @ctx must point to an either stack or heap allocated `nk_context` struct
+ *      @font must point to a previously initialized font handle for more info look at font documentation
+ *  Return values:
+ *      true(1) on success
+ *      false(0) on failure */
+NK_API int nk_init_default(struct nk_context*, const struct nk_user_font*);
+#endif
+/*  nk_init_fixed - Initializes a `nk_context` struct from a single fixed size memory block
+ *  Should be used if you want complete control over nuklear's memory management.
+ *  Especially recommended for system with little memory or systems with virtual memory.
+ *  For the later case you can just allocate for example 16MB of virtual memory
+ *  and only the required amount of memory will actually be committed.
+ *  IMPORTANT: make sure the passed memory block is aligned correctly for `nk_draw_commands`
+ *  Parameters:
+ *      @ctx must point to an either stack or heap allocated `nk_context` struct
+ *      @memory must point to a previously allocated memory block
+ *      @size must contain the total size of @memory
+ *      @font must point to a previously initialized font handle for more info look at font documentation
+ *  Return values:
+ *      true(1) on success
+ *      false(0) on failure */
+NK_API int nk_init_fixed(struct nk_context*, void *memory, nk_size size, const struct nk_user_font*);
+/*  nk_init - Initializes a `nk_context` struct with memory allocation callbacks for nuklear to allocate
+ *  memory from. Used internally for `nk_init_default` and provides a kitchen sink allocation
+ *  interface to nuklear. Can be useful for cases like monitoring memory consumption.
+ *  Parameters:
+ *      @ctx must point to an either stack or heap allocated `nk_context` struct
+ *      @alloc must point to a previously allocated memory allocator
+ *      @font must point to a previously initialized font handle for more info look at font documentation
+ *  Return values:
+ *      true(1) on success
+ *      false(0) on failure */
+NK_API int nk_init(struct nk_context*, struct nk_allocator*, const struct nk_user_font*);
+/*  nk_init_custom - Initializes a `nk_context` struct from two different either fixed or growing
+ *  buffers. The first buffer is for allocating draw commands while the second buffer is
+ *  used for allocating windows, panels and state tables.
+ *  Parameters:
+ *      @ctx must point to an either stack or heap allocated `nk_context` struct
+ *      @cmds must point to a previously initialized memory buffer either fixed or dynamic to store draw commands into
+ *      @pool must point to a previously initialized memory buffer either fixed or dynamic to store windows, panels and tables
+ *      @font must point to a previously initialized font handle for more info look at font documentation
+ *  Return values:
+ *      true(1) on success
+ *      false(0) on failure */
+NK_API int nk_init_custom(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font*);
+/*  nk_clear - Resets the context state at the end of the frame. This includes mostly
+ *  garbage collector tasks like removing windows or table not called and therefore
+ *  used anymore.
+ *  Parameters:
+ *      @ctx must point to a previously initialized `nk_context` struct */
+NK_API void nk_clear(struct nk_context*);
+/*  nk_free - Frees all memory allocated by nuklear. Not needed if context was
+ *  initialized with `nk_init_fixed`.
+ *  Parameters:
+ *      @ctx must point to a previously initialized `nk_context` struct */
+NK_API void nk_free(struct nk_context*);
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+/*  nk_set_user_data - Sets the currently passed userdata passed down into each draw command.
+ *  Parameters:
+ *      @ctx must point to a previously initialized `nk_context` struct
+ *      @data handle with either pointer or index to be passed into every draw commands */
+NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
+#endif
+/* =============================================================================
+ *
+ *                                  INPUT
+ *
+ * =============================================================================*/
+/*  The input API is responsible for holding the current input state composed of
+ *  mouse, key and text input states.
+ *  It is worth noting that no direct os or window handling is done in nuklear.
+ *  Instead all input state has to be provided by platform specific code. This in one hand
+ *  expects more work from the user and complicates usage but on the other hand
+ *  provides simple abstraction over a big number of platforms, libraries and other
+ *  already provided functionality.
+ *
+ *  Usage
+ *  -------------------
+ *  Input state needs to be provided to nuklear by first calling `nk_input_begin`
+ *  which resets internal state like delta mouse position and button transistions.
+ *  After `nk_input_begin` all current input state needs to be provided. This includes
+ *  mouse motion, button and key pressed and released, text input and scrolling.
+ *  Both event- or state-based input handling are supported by this API
+ *  and should work without problems. Finally after all input state has been
+ *  mirrored `nk_input_end` needs to be called to finish input process.
+ *
+ *      struct nk_context ctx;
+ *      nk_init_xxx(&ctx, ...);
+ *      while (1) {
+ *          Event evt;
+ *          nk_input_begin(&ctx);
+ *          while (GetEvent(&evt)) {
+ *              if (evt.type == MOUSE_MOVE)
+ *                  nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
+ *              else if (evt.type == ...) {
+ *                  ...
+ *              }
+ *          }
+ *          nk_input_end(&ctx);
+ *          [...]
+ *          nk_clear(&ctx);
+ *      }
+ *      nk_free(&ctx);
+ *
+ *  Reference
+ *  -------------------
+ *  nk_input_begin      - Begins the input mirroring process. Needs to be called before all other `nk_input_xxx` calls
+ *  nk_input_motion     - Mirrors mouse cursor position
+ *  nk_input_key        - Mirrors key state with either pressed or released
+ *  nk_input_button     - Mirrors mouse button state with either pressed or released
+ *  nk_input_scroll     - Mirrors mouse scroll values
+ *  nk_input_char       - Adds a single ASCII text character into an internal text buffer
+ *  nk_input_glyph      - Adds a single multi-byte UTF-8 character into an internal text buffer
+ *  nk_input_unicode    - Adds a single unicode rune into an internal text buffer
+ *  nk_input_end        - Ends the input mirroring process by calculating state changes. Don't call any `nk_input_xxx` function referenced above after this call
+ */
+enum nk_keys {
+    NK_KEY_NONE,
+    NK_KEY_SHIFT,
+    NK_KEY_CTRL,
+    NK_KEY_DEL,
+    NK_KEY_ENTER,
+    NK_KEY_TAB,
+    NK_KEY_BACKSPACE,
+    NK_KEY_COPY,
+    NK_KEY_CUT,
+    NK_KEY_PASTE,
+    NK_KEY_UP,
+    NK_KEY_DOWN,
+    NK_KEY_LEFT,
+    NK_KEY_RIGHT,
+    /* Shortcuts: text field */
+    NK_KEY_TEXT_INSERT_MODE,
+    NK_KEY_TEXT_REPLACE_MODE,
+    NK_KEY_TEXT_RESET_MODE,
+    NK_KEY_TEXT_LINE_START,
+    NK_KEY_TEXT_LINE_END,
+    NK_KEY_TEXT_START,
+    NK_KEY_TEXT_END,
+    NK_KEY_TEXT_UNDO,
+    NK_KEY_TEXT_REDO,
+    NK_KEY_TEXT_SELECT_ALL,
+    NK_KEY_TEXT_WORD_LEFT,
+    NK_KEY_TEXT_WORD_RIGHT,
+    /* Shortcuts: scrollbar */
+    NK_KEY_SCROLL_START,
+    NK_KEY_SCROLL_END,
+    NK_KEY_SCROLL_DOWN,
+    NK_KEY_SCROLL_UP,
+    NK_KEY_MAX
+};
+enum nk_buttons {
+    NK_BUTTON_LEFT,
+    NK_BUTTON_MIDDLE,
+    NK_BUTTON_RIGHT,
+    NK_BUTTON_DOUBLE,
+    NK_BUTTON_MAX
+};
+/*  nk_input_begin - Begins the input mirroring process by resetting text, scroll
+ *  mouse previous mouse position and movement as well as key state transitions,
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct */
+NK_API void nk_input_begin(struct nk_context*);
+/*  nk_input_motion - Mirrors current mouse position to nuklear
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @x must contain an integer describing the current mouse cursor x-position
+ *      @y must contain an integer describing the current mouse cursor y-position */
+NK_API void nk_input_motion(struct nk_context*, int x, int y);
+/*  nk_input_key - Mirrors state of a specific key to nuklear
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @key must be any value specified in enum `nk_keys` that needs to be mirrored
+ *      @down must be 0 for key is up and 1 for key is down */
+NK_API void nk_input_key(struct nk_context*, enum nk_keys, int down);
+/*  nk_input_button - Mirrors the state of a specific mouse button to nuklear
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @nk_buttons must be any value specified in enum `nk_buttons` that needs to be mirrored
+ *      @x must contain an integer describing mouse cursor x-position on click up/down
+ *      @y must contain an integer describing mouse cursor y-position on click up/down
+ *      @down must be 0 for key is up and 1 for key is down */
+NK_API void nk_input_button(struct nk_context*, enum nk_buttons, int x, int y, int down);
+/*  nk_input_scroll - Copies the last mouse scroll value to nuklear. Is generally
+ *  a  scroll value. So does not have to come from mouse and could also originate
+ *  from touch for example.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @val vector with both X- as well as Y-scroll value */
+NK_API void nk_input_scroll(struct nk_context*, struct nk_vec2 val);
+/*  nk_input_char - Copies a single ASCII character into an internal text buffer
+ *  This is basically a helper function to quickly push ASCII characters into
+ *  nuklear. Note that you can only push up to NK_INPUT_MAX bytes into
+ *  struct `nk_input` between `nk_input_begin` and `nk_input_end`.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @c must be a single ASCII character preferable one that can be printed */
+NK_API void nk_input_char(struct nk_context*, char);
+/*  nk_input_unicode - Converts a encoded unicode rune into UTF-8 and copies the result
+ *  into an internal text buffer.
+ *  Note that you can only push up to NK_INPUT_MAX bytes into
+ *  struct `nk_input` between `nk_input_begin` and `nk_input_end`.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @glyph UTF-32 unicode codepoint */
+NK_API void nk_input_glyph(struct nk_context*, const nk_glyph);
+/*  nk_input_unicode - Converts a unicode rune into UTF-8 and copies the result
+ *  into an internal text buffer.
+ *  Note that you can only push up to NK_INPUT_MAX bytes into
+ *  struct `nk_input` between `nk_input_begin` and `nk_input_end`.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @glyph UTF-32 unicode codepoint */
+NK_API void nk_input_unicode(struct nk_context*, nk_rune);
+/*  nk_input_end - End the input mirroring process by resetting mouse grabbing
+ *  state to ensure the mouse cursor is not grabbed indefinitely.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct */
+NK_API void nk_input_end(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  DRAWING
+ *
+ * =============================================================================*/
+/*  This library was designed to be render backend agnostic so it does
+ *  not draw anything to screen directly. Instead all drawn shapes, widgets
+ *  are made of, are buffered into memory and make up a command queue.
+ *  Each frame therefore fills the command buffer with draw commands
+ *  that then need to be executed by the user and his own render backend.
+ *  After that the command buffer needs to be cleared and a new frame can be
+ *  started. It is probably important to note that the command buffer is the main
+ *  drawing API and the optional vertex buffer API only takes this format and
+ *  converts it into a hardware accessible format.
+ *
+ *  Usage
+ *  -------------------
+ *  To draw all draw commands accumulated over a frame you need your own render
+ *  backend able to draw a number of 2D primitives. This includes at least
+ *  filled and stroked rectangles, circles, text, lines, triangles and scissors.
+ *  As soon as this criterion is met you can iterate over each draw command
+ *  and execute each draw command in a interpreter like fashion:
+ *
+ *      const struct nk_command *cmd = 0;
+ *      nk_foreach(cmd, &ctx) {
+ *      switch (cmd->type) {
+ *      case NK_COMMAND_LINE:
+ *          your_draw_line_function(...)
+ *          break;
+ *      case NK_COMMAND_RECT
+ *          your_draw_rect_function(...)
+ *          break;
+ *      case ...:
+ *          [...]
+ *      }
+ *
+ *  In program flow context draw commands need to be executed after input has been
+ *  gathered and the complete UI with windows and their contained widgets have
+ *  been executed and before calling `nk_clear` which frees all previously
+ *  allocated draw commands.
+ *
+ *      struct nk_context ctx;
+ *      nk_init_xxx(&ctx, ...);
+ *      while (1) {
+ *          Event evt;
+ *          nk_input_begin(&ctx);
+ *          while (GetEvent(&evt)) {
+ *              if (evt.type == MOUSE_MOVE)
+ *                  nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
+ *              else if (evt.type == [...]) {
+ *                  [...]
+ *              }
+ *          }
+ *          nk_input_end(&ctx);
+ *
+ *          [...]
+ *
+ *          const struct nk_command *cmd = 0;
+ *          nk_foreach(cmd, &ctx) {
+ *          switch (cmd->type) {
+ *          case NK_COMMAND_LINE:
+ *              your_draw_line_function(...)
+ *              break;
+ *          case NK_COMMAND_RECT
+ *              your_draw_rect_function(...)
+ *              break;
+ *          case ...:
+ *              [...]
+ *          }
+ *          nk_clear(&ctx);
+ *      }
+ *      nk_free(&ctx);
+ *
+ *  You probably noticed that you have to draw all of the UI each frame which is
+ *  quite wasteful. While the actual UI updating loop is quite fast rendering
+ *  without actually needing it is not. So there are multiple things you could do.
+ *
+ *  First is only update on input. This of course is only an option if your
+ *  application only depends on the UI and does not require any outside calculations.
+ *  If you actually only update on input make sure to update the UI two times each
+ *  frame and call `nk_clear` directly after the first pass and only draw in
+ *  the second pass. In addition it is recommended to also add additional timers
+ *  to make sure the UI is not drawn more than a fixed number of frames per second.
+ *
+ *      struct nk_context ctx;
+ *      nk_init_xxx(&ctx, ...);
+ *      while (1) {
+ *          [...wait for input ]
+ *
+ *          [...do two UI passes ...]
+ *          do_ui(...)
+ *          nk_clear(&ctx);
+ *          do_ui(...)
+ *
+ *          const struct nk_command *cmd = 0;
+ *          nk_foreach(cmd, &ctx) {
+ *          switch (cmd->type) {
+ *          case NK_COMMAND_LINE:
+ *              your_draw_line_function(...)
+ *              break;
+ *          case NK_COMMAND_RECT
+ *              your_draw_rect_function(...)
+ *              break;
+ *          case ...:
+ *              [...]
+ *          }
+ *          nk_clear(&ctx);
+ *      }
+ *      nk_free(&ctx);
+ *
+ *  The second probably more applicable trick is to only draw if anything changed.
+ *  It is not really useful for applications with continuous draw loop but
+ *  quite useful for desktop applications. To actually get nuklear to only
+ *  draw on changes you first have to define `NK_ZERO_COMMAND_MEMORY` and
+ *  allocate a memory buffer that will store each unique drawing output.
+ *  After each frame you compare the draw command memory inside the library
+ *  with your allocated buffer by memcmp. If memcmp detects differences
+ *  you have to copy the command buffer into the allocated buffer
+ *  and then draw like usual (this example uses fixed memory but you could
+ *  use dynamically allocated memory).
+ *
+ *      [... other defines ...]
+ *      #define NK_ZERO_COMMAND_MEMORY
+ *      #include "nuklear.h"
+ *
+ *      struct nk_context ctx;
+ *      void *last = calloc(1,64*1024);
+ *      void *buf = calloc(1,64*1024);
+ *      nk_init_fixed(&ctx, buf, 64*1024);
+ *      while (1) {
+ *          [...input...]
+ *          [...ui...]
+ *
+ *          void *cmds = nk_buffer_memory(&ctx.memory);
+ *          if (memcmp(cmds, last, ctx.memory.allocated)) {
+ *              memcpy(last,cmds,ctx.memory.allocated);
+ *              const struct nk_command *cmd = 0;
+ *              nk_foreach(cmd, &ctx) {
+ *                  switch (cmd->type) {
+ *                  case NK_COMMAND_LINE:
+ *                      your_draw_line_function(...)
+ *                      break;
+ *                  case NK_COMMAND_RECT
+ *                      your_draw_rect_function(...)
+ *                      break;
+ *                  case ...:
+ *                      [...]
+ *                  }
+ *              }
+ *          }
+ *          nk_clear(&ctx);
+ *      }
+ *      nk_free(&ctx);
+ *
+ *  Finally while using draw commands makes sense for higher abstracted platforms like
+ *  X11 and Win32 or drawing libraries it is often desirable to use graphics
+ *  hardware directly. Therefore it is possible to just define
+ *  `NK_INCLUDE_VERTEX_BUFFER_OUTPUT` which includes optional vertex output.
+ *  To access the vertex output you first have to convert all draw commands into
+ *  vertexes by calling `nk_convert` which takes in your preferred vertex format.
+ *  After successfully converting all draw commands just iterate over and execute all
+ *  vertex draw commands:
+ *
+ *      struct nk_convert_config cfg = {};
+ *      static const struct nk_draw_vertex_layout_element vertex_layout[] = {
+ *          {NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, pos)},
+ *          {NK_VERTEX_TEXCOORD, NK_FORMAT_FLOAT, NK_OFFSETOF(struct your_vertex, uv)},
+ *          {NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct your_vertex, col)},
+ *          {NK_VERTEX_LAYOUT_END}
+ *      };
+ *      cfg.shape_AA = NK_ANTI_ALIASING_ON;
+ *      cfg.line_AA = NK_ANTI_ALIASING_ON;
+ *      cfg.vertex_layout = vertex_layout;
+ *      cfg.vertex_size = sizeof(struct your_vertex);
+ *      cfg.vertex_alignment = NK_ALIGNOF(struct your_vertex);
+ *      cfg.circle_segment_count = 22;
+ *      cfg.curve_segment_count = 22;
+ *      cfg.arc_segment_count = 22;
+ *      cfg.global_alpha = 1.0f;
+ *      cfg.null = dev->null;
+ *
+ *      struct nk_buffer cmds, verts, idx;
+ *      nk_buffer_init_default(&cmds);
+ *      nk_buffer_init_default(&verts);
+ *      nk_buffer_init_default(&idx);
+ *      nk_convert(&ctx, &cmds, &verts, &idx, &cfg);
+ *      nk_draw_foreach(cmd, &ctx, &cmds) {
+ *          if (!cmd->elem_count) continue;
+ *          [...]
+ *      }
+ *      nk_buffer_free(&cms);
+ *      nk_buffer_free(&verts);
+ *      nk_buffer_free(&idx);
+ *
+ *  Reference
+ *  -------------------
+ *  nk__begin           - Returns the first draw command in the context draw command list to be drawn
+ *  nk__next            - Increments the draw command iterator to the next command inside the context draw command list
+ *  nk_foreach          - Iterates over each draw command inside the context draw command list
+ *
+ *  nk_convert          - Converts from the abstract draw commands list into a hardware accessible vertex format
+ *  nk__draw_begin      - Returns the first vertex command in the context vertex draw list to be executed
+ *  nk__draw_next       - Increments the vertex command iterator to the next command inside the context vertex command list
+ *  nk__draw_end        - Returns the end of the vertex draw list
+ *  nk_draw_foreach     - Iterates over each vertex draw command inside the vertex draw list
+ */
+enum nk_anti_aliasing {NK_ANTI_ALIASING_OFF, NK_ANTI_ALIASING_ON};
+enum nk_convert_result {
+    NK_CONVERT_SUCCESS = 0,
+    NK_CONVERT_INVALID_PARAM = 1,
+    NK_CONVERT_COMMAND_BUFFER_FULL = NK_FLAG(1),
+    NK_CONVERT_VERTEX_BUFFER_FULL = NK_FLAG(2),
+    NK_CONVERT_ELEMENT_BUFFER_FULL = NK_FLAG(3)
+};
+struct nk_draw_null_texture {
+    nk_handle texture; /* texture handle to a texture with a white pixel */
+    struct nk_vec2 uv; /* coordinates to a white pixel in the texture  */
+};
+struct nk_convert_config {
+    float global_alpha; /* global alpha value */
+    enum nk_anti_aliasing line_AA; /* line anti-aliasing flag can be turned off if you are tight on memory */
+    enum nk_anti_aliasing shape_AA; /* shape anti-aliasing flag can be turned off if you are tight on memory */
+    unsigned circle_segment_count; /* number of segments used for circles: default to 22 */
+    unsigned arc_segment_count; /* number of segments used for arcs: default to 22 */
+    unsigned curve_segment_count; /* number of segments used for curves: default to 22 */
+    struct nk_draw_null_texture null; /* handle to texture with a white pixel for shape drawing */
+    const struct nk_draw_vertex_layout_element *vertex_layout; /* describes the vertex output format and packing */
+    nk_size vertex_size; /* sizeof one vertex for vertex packing */
+    nk_size vertex_alignment; /* vertex alignment: Can be obtained by NK_ALIGNOF */
+};
+/*  nk__begin - Returns a draw command list iterator to iterate all draw
+ *  commands accumulated over one frame.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame
+ *  Return values:
+ *      draw command pointer pointing to the first command inside the draw command list  */
+NK_API const struct nk_command* nk__begin(struct nk_context*);
+/*  nk__next - Returns a draw command list iterator to iterate all draw
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame
+ *      @cmd must point to an previously a draw command either returned by `nk__begin` or `nk__next`
+ *  Return values:
+ *      draw command pointer pointing to the next command inside the draw command list  */
+NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_command*);
+/*  nk_foreach - Iterates over each draw command inside the context draw command list
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame
+ *      @cmd pointer initialized to NULL */
+#define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
+#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+/*  nk_convert - converts all internal draw command into vertex draw commands and fills
+ *  three buffers with vertexes, vertex draw commands and vertex indices. The vertex format
+ *  as well as some other configuration values have to be configured by filling out a
+ *  `nk_convert_config` struct.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame
+ *      @cmds must point to a previously initialized buffer to hold converted vertex draw commands
+ *      @vertices must point to a previously initialized buffer to hold all produced vertices
+ *      @elements must point to a previously initialized buffer to hold all produced vertex indices
+ *      @config must point to a filled out `nk_config` struct to configure the conversion process
+ *  Returns:
+ *      returns NK_CONVERT_SUCCESS on success and a enum nk_convert_result error values if not */
+NK_API nk_flags nk_convert(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
+/*  nk__draw_begin - Returns a draw vertex command buffer iterator to iterate each the vertex draw command buffer
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame
+ *      @buf must point to an previously by `nk_convert` filled out vertex draw command buffer
+ *  Return values:
+ *      vertex draw command pointer pointing to the first command inside the vertex draw command buffer  */
+NK_API const struct nk_draw_command* nk__draw_begin(const struct nk_context*, const struct nk_buffer*);
+/*  nk__draw_end - Returns the vertex draw command  at the end of the vertex draw command buffer
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame
+ *      @buf must point to an previously by `nk_convert` filled out vertex draw command buffer
+ *  Return values:
+ *      vertex draw command pointer pointing to the end of the last vertex draw command inside the vertex draw command buffer  */
+NK_API const struct nk_draw_command* nk__draw_end(const struct nk_context*, const struct nk_buffer*);
+/*  nk__draw_next - Increments the vertex draw command buffer iterator
+ *  Parameters:
+ *      @cmd must point to an previously either by `nk__draw_begin` or `nk__draw_next` returned vertex draw command
+ *      @buf must point to an previously by `nk_convert` filled out vertex draw command buffer
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame
+ *  Return values:
+ *      vertex draw command pointer pointing to the end of the last vertex draw command inside the vertex draw command buffer  */
+NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_context*);
+/*  nk_draw_foreach - Iterates over each vertex draw command inside a vertex draw command buffer
+ *  Parameters:
+ *      @cmd nk_draw_command pointer set to NULL
+ *      @buf must point to an previously by `nk_convert` filled out vertex draw command buffer
+ *      @ctx must point to an previously initialized `nk_context` struct at the end of a frame */
+#define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
+#endif
+/* =============================================================================
+ *
+ *                                  WINDOW
+ *
+ * =============================================================================
+ * Windows are the main persistent state used inside nuklear and are life time
+ * controlled by simply "retouching" (i.e. calling) each window each frame.
+ * All widgets inside nuklear can only be added inside function pair `nk_begin_xxx`
+ * and `nk_end`. Calling any widgets outside these two functions will result in an
+ * assert in debug or no state change in release mode.
+ *
+ * Each window holds frame persistent state like position, size, flags, state tables,
+ * and some garbage collected internal persistent widget state. Each window
+ * is linked into a window stack list which determines the drawing and overlapping
+ * order. The topmost window thereby is the currently active window.
+ *
+ * To change window position inside the stack occurs either automatically by
+ * user input by being clicked on or programmatically by calling `nk_window_focus`.
+ * Windows by default are visible unless explicitly being defined with flag
+ * `NK_WINDOW_HIDDEN`, the user clicked the close button on windows with flag
+ * `NK_WINDOW_CLOSABLE` or if a window was explicitly hidden by calling
+ * `nk_window_show`. To explicitly close and destroy a window call `nk_window_close`.
+ *
+ * Usage
+ * -------------------
+ * To create and keep a window you have to call one of the two `nk_begin_xxx`
+ * functions to start window declarations and `nk_end` at the end. Furthermore it
+ * is recommended to check the return value of `nk_begin_xxx` and only process
+ * widgets inside the window if the value is not 0. Either way you have to call
+ * `nk_end` at the end of window declarations. Furthermore, do not attempt to
+ * nest `nk_begin_xxx` calls which will hopefully result in an assert or if not
+ * in a segmentation fault.
+ *
+ *      if (nk_begin_xxx(...) {
+ *          [... widgets ...]
+ *      }
+ *      nk_end(ctx);
+ *
+ * In the grand concept window and widget declarations need to occur after input
+ * handling and before drawing to screen. Not doing so can result in higher
+ * latency or at worst invalid behavior. Furthermore make sure that `nk_clear`
+ * is called at the end of the frame. While nuklear's default platform backends
+ * already call `nk_clear` for you if you write your own backend not calling
+ * `nk_clear` can cause asserts or even worse undefined behavior.
+ *
+ *      struct nk_context ctx;
+ *      nk_init_xxx(&ctx, ...);
+ *      while (1) {
+ *          Event evt;
+ *          nk_input_begin(&ctx);
+ *          while (GetEvent(&evt)) {
+ *              if (evt.type == MOUSE_MOVE)
+ *                  nk_input_motion(&ctx, evt.motion.x, evt.motion.y);
+ *              else if (evt.type == [...]) {
+ *                  nk_input_xxx(...);
+ *              }
+ *          }
+ *          nk_input_end(&ctx);
+ *
+ *          if (nk_begin_xxx(...) {
+ *              [...]
+ *          }
+ *          nk_end(ctx);
+ *
+ *          const struct nk_command *cmd = 0;
+ *          nk_foreach(cmd, &ctx) {
+ *          case NK_COMMAND_LINE:
+ *              your_draw_line_function(...)
+ *              break;
+ *          case NK_COMMAND_RECT
+ *              your_draw_rect_function(...)
+ *              break;
+ *          case ...:
+ *              [...]
+ *          }
+ *          nk_clear(&ctx);
+ *      }
+ *      nk_free(&ctx);
+ *
+ *  Reference
+ *  -------------------
+ *  nk_begin                            - starts a new window; needs to be called every frame for every window (unless hidden) or otherwise the window gets removed
+ *  nk_begin_titled                     - extended window start with separated title and identifier to allow multiple windows with same name but not title
+ *  nk_end                              - needs to be called at the end of the window building process to process scaling, scrollbars and general cleanup
+ *
+ *  nk_window_find                      - finds and returns the window with give name
+ *  nk_window_get_bounds                - returns a rectangle with screen position and size of the currently processed window.
+ *  nk_window_get_position              - returns the position of the currently processed window
+ *  nk_window_get_size                  - returns the size with width and height of the currently processed window
+ *  nk_window_get_width                 - returns the width of the currently processed window
+ *  nk_window_get_height                - returns the height of the currently processed window
+ *  nk_window_get_panel                 - returns the underlying panel which contains all processing state of the current window
+ *  nk_window_get_content_region        - returns the position and size of the currently visible and non-clipped space inside the currently processed window
+ *  nk_window_get_content_region_min    - returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
+ *  nk_window_get_content_region_max    - returns the upper rectangle position of the currently visible and non-clipped space inside the currently processed window
+ *  nk_window_get_content_region_size   - returns the size of the currently visible and non-clipped space inside the currently processed window
+ *  nk_window_get_canvas                - returns the draw command buffer. Can be used to draw custom widgets
+ *
+ *  nk_window_has_focus                 - returns if the currently processed window is currently active
+ *  nk_window_is_collapsed              - returns if the window with given name is currently minimized/collapsed
+ *  nk_window_is_closed                 - returns if the currently processed window was closed
+ *  nk_window_is_hidden                 - returns if the currently processed window was hidden
+ *  nk_window_is_active                 - same as nk_window_has_focus for some reason
+ *  nk_window_is_hovered                - returns if the currently processed window is currently being hovered by mouse
+ *  nk_window_is_any_hovered            - return if any window currently hovered
+ *  nk_item_is_any_active               - returns if any window or widgets is currently hovered or active
+ *
+ *  nk_window_set_bounds                - updates position and size of the currently processed window
+ *  nk_window_set_position              - updates position of the currently process window
+ *  nk_window_set_size                  - updates the size of the currently processed window
+ *  nk_window_set_focus                 - set the currently processed window as active window
+ *
+ *  nk_window_close                     - closes the window with given window name which deletes the window at the end of the frame
+ *  nk_window_collapse                  - collapses the window with given window name
+ *  nk_window_collapse_if               - collapses the window with given window name if the given condition was met
+ *  nk_window_show                      - hides a visible or reshows a hidden window
+ *  nk_window_show_if                   - hides/shows a window depending on condition
+ */
+enum nk_panel_flags {
+    NK_WINDOW_BORDER            = NK_FLAG(0), /* Draws a border around the window to visually separate window from the background */
+    NK_WINDOW_MOVABLE           = NK_FLAG(1), /* The movable flag indicates that a window can be moved by user input or by dragging the window header */
+    NK_WINDOW_SCALABLE          = NK_FLAG(2), /* The scalable flag indicates that a window can be scaled by user input by dragging a scaler icon at the button of the window */
+    NK_WINDOW_CLOSABLE          = NK_FLAG(3), /* adds a closable icon into the header */
+    NK_WINDOW_MINIMIZABLE       = NK_FLAG(4), /* adds a minimize icon into the header */
+    NK_WINDOW_NO_SCROLLBAR      = NK_FLAG(5), /* Removes the scrollbar from the window */
+    NK_WINDOW_TITLE             = NK_FLAG(6), /* Forces a header at the top at the window showing the title */
+    NK_WINDOW_SCROLL_AUTO_HIDE  = NK_FLAG(7), /* Automatically hides the window scrollbar if no user interaction: also requires delta time in `nk_context` to be set each frame */
+    NK_WINDOW_BACKGROUND        = NK_FLAG(8), /* Always keep window in the background */
+    NK_WINDOW_SCALE_LEFT        = NK_FLAG(9), /* Puts window scaler in the left-ottom corner instead right-bottom*/
+    NK_WINDOW_NO_INPUT          = NK_FLAG(10) /* Prevents window of scaling, moving or getting focus */
+};
+/*  nk_begin - starts a new window; needs to be called every frame for every window (unless hidden) or otherwise the window gets removed
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @title window title and identifier. Needs to be persistent over frames to identify the window
+ *      @bounds initial position and window size. However if you do not define `NK_WINDOW_SCALABLE` or `NK_WINDOW_MOVABLE` you can set window position and size every frame
+ *      @flags window flags defined in `enum nk_panel_flags` with a number of different window behaviors
+ *  Return values:
+ *      returns 1 if the window can be filled up with widgets from this point until `nk_end or 0 otherwise for example if minimized `*/
+NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags);
+/*  nk_begin_titled - extended window start with separated title and identifier to allow multiple windows with same name but not title
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name window identifier. Needs to be persistent over frames to identify the window
+ *      @title window title displayed inside header if flag `NK_WINDOW_TITLE` or either `NK_WINDOW_CLOSABLE` or `NK_WINDOW_MINIMIZED` was set
+ *      @bounds initial position and window size. However if you do not define `NK_WINDOW_SCALABLE` or `NK_WINDOW_MOVABLE` you can set window position and size every frame
+ *      @flags window flags defined in `enum nk_panel_flags` with a number of different window behaviors
+ *  Return values:
+ *      returns 1 if the window can be filled up with widgets from this point until `nk_end or 0 otherwise `*/
+NK_API int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags);
+/*  nk_end - needs to be called at the end of the window building process to process scaling, scrollbars and general cleanup.
+ *  All widget calls after this functions will result in asserts or no state changes
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct */
+NK_API void nk_end(struct nk_context *ctx);
+/*  nk_window_find - finds and returns the window with give name
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name window identifier
+ *  Return values:
+ *      returns a `nk_window` struct pointing to the identified window or 0 if no window with given name was found */
+NK_API struct nk_window *nk_window_find(struct nk_context *ctx, const char *name);
+/*  nk_window_get_bounds - returns a rectangle with screen position and size of the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns a `nk_rect` struct with window upper left position and size */
+NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx);
+/*  nk_window_get_position - returns the position of the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns a `nk_vec2` struct with window upper left position */
+NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx);
+/*  nk_window_get_size - returns the size with width and height of the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns a `nk_vec2` struct with window size */
+NK_API struct nk_vec2 nk_window_get_size(const struct nk_context*);
+/*  nk_window_get_width - returns the width of the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns the window width */
+NK_API float nk_window_get_width(const struct nk_context*);
+/*  nk_window_get_height - returns the height of the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns the window height */
+NK_API float nk_window_get_height(const struct nk_context*);
+/*  nk_window_get_panel - returns the underlying panel which contains all processing state of the current window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns a pointer to window internal `nk_panel` state. DO NOT keep this pointer around it is only valid until `nk_end` */
+NK_API struct nk_panel* nk_window_get_panel(struct nk_context*);
+/*  nk_window_get_content_region - returns the position and size of the currently visible and non-clipped space inside the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns `nk_rect` struct with screen position and size (no scrollbar offset) of the visible space inside the current window */
+NK_API struct nk_rect nk_window_get_content_region(struct nk_context*);
+/*  nk_window_get_content_region_min - returns the upper left position of the currently visible and non-clipped space inside the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns `nk_vec2` struct with  upper left screen position (no scrollbar offset) of the visible space inside the current window */
+NK_API struct nk_vec2 nk_window_get_content_region_min(struct nk_context*);
+/*  nk_window_get_content_region_max - returns the lower right screen position of the currently visible and non-clipped space inside the currently processed window.
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns `nk_vec2` struct with lower right screen position (no scrollbar offset) of the visible space inside the current window */
+NK_API struct nk_vec2 nk_window_get_content_region_max(struct nk_context*);
+/*  nk_window_get_content_region_size - returns the size of the currently visible and non-clipped space inside the currently processed window
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns `nk_vec2` struct with size the visible space inside the current window */
+NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context*);
+/*  nk_window_get_canvas - returns the draw command buffer. Can be used to draw custom widgets
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns a pointer to window internal `nk_command_buffer` struct used as drawing canvas. Can be used to do custom drawing */
+NK_API struct nk_command_buffer* nk_window_get_canvas(struct nk_context*);
+/*  nk_window_has_focus - returns if the currently processed window is currently active
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns 0 if current window is not active or 1 if it is */
+NK_API int nk_window_has_focus(const struct nk_context*);
+/*  nk_window_is_collapsed - returns if the window with given name is currently minimized/collapsed
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of window you want to check is collapsed
+ *  Return values:
+ *      returns 1 if current window is minimized and 0 if window not found or is not minimized */
+NK_API int nk_window_is_collapsed(struct nk_context *ctx, const char *name);
+/*  nk_window_is_closed - returns if the window with given name was closed by calling `nk_close`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of window you want to check is closed
+ *  Return values:
+ *      returns 1 if current window was closed or 0 window not found or not closed */
+NK_API int nk_window_is_closed(struct nk_context*, const char*);
+/*  nk_window_is_hidden - returns if the window with given name is hidden
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of window you want to check is hidden
+ *  Return values:
+ *      returns 1 if current window is hidden or 0 window not found or visible */
+NK_API int nk_window_is_hidden(struct nk_context*, const char*);
+/*  nk_window_is_active - same as nk_window_has_focus for some reason
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of window you want to check is hidden
+ *  Return values:
+ *      returns 1 if current window is active or 0 window not found or not active */
+NK_API int nk_window_is_active(struct nk_context*, const char*);
+/*  nk_window_is_hovered - return if the current window is being hovered
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns 1 if current window is hovered or 0 otherwise */
+NK_API int nk_window_is_hovered(struct nk_context*);
+/*  nk_window_is_any_hovered - returns if the any window is being hovered
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns 1 if any window is hovered or 0 otherwise */
+NK_API int nk_window_is_any_hovered(struct nk_context*);
+/*  nk_item_is_any_active - returns if the any window is being hovered or any widget is currently active.
+ *  Can be used to decide if input should be processed by UI or your specific input handling.
+ *  Example could be UI and 3D camera to move inside a 3D space.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *  Return values:
+ *      returns 1 if any window is hovered or any item is active or 0 otherwise */
+NK_API int nk_item_is_any_active(struct nk_context*);
+/*  nk_window_set_bounds - updates position and size of the currently processed window
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to modify both position and size
+ *      @bounds points to a `nk_rect` struct with the new position and size of currently active window */
+NK_API void nk_window_set_bounds(struct nk_context*, const char *name, struct nk_rect bounds);
+/*  nk_window_set_position - updates position of the currently processed window
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to modify position of
+ *      @pos points to a `nk_vec2` struct with the new position of currently active window */
+NK_API void nk_window_set_position(struct nk_context*, const char *name, struct nk_vec2 pos);
+/*  nk_window_set_size - updates size of the currently processed window
+ *  IMPORTANT: only call this function between calls `nk_begin_xxx` and `nk_end`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to modify size of
+ *      @size points to a `nk_vec2` struct with the new size of currently active window */
+NK_API void nk_window_set_size(struct nk_context*, const char *name, struct nk_vec2);
+/*  nk_window_set_focus - sets the window with given name as active
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to be set active */
+NK_API void nk_window_set_focus(struct nk_context*, const char *name);
+/*  nk_window_close - closed a window and marks it for being freed at the end of the frame
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to be closed */
+NK_API void nk_window_close(struct nk_context *ctx, const char *name);
+/*  nk_window_collapse - updates collapse state of a window with given name
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to be either collapse or maximize */
+NK_API void nk_window_collapse(struct nk_context*, const char *name, enum nk_collapse_states state);
+/*  nk_window_collapse - updates collapse state of a window with given name if given condition is met
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to be either collapse or maximize
+ *      @state the window should be put into
+ *      @condition that has to be true to actually commit the collapse state change */
+NK_API void nk_window_collapse_if(struct nk_context*, const char *name, enum nk_collapse_states, int cond);
+/*  nk_window_show - updates visibility state of a window with given name
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to be either collapse or maximize
+ *      @state with either visible or hidden to modify the window with */
+NK_API void nk_window_show(struct nk_context*, const char *name, enum nk_show_states);
+/*  nk_window_show_if - updates visibility state of a window with given name if a given condition is met
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @name of the window to be either collapse or maximize
+ *      @state with either visible or hidden to modify the window with
+ *      @condition that has to be true to actually commit the visible state change */
+NK_API void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
+/* =============================================================================
+ *
+ *                                  LAYOUT
+ *
+ * ============================================================================= */
+/*  Layouting in general describes placing widget inside a window with position and size.
+ *  While in this particular implementation there are five different APIs for layouting
+ *  each with different trade offs between control and ease of use.
+ *
+ *  All layouting methods in this library are based around the concept of a row.
+ *  A row has a height the window content grows by and a number of columns and each
+ *  layouting method specifies how each widget is placed inside the row.
+ *  After a row has been allocated by calling a layouting functions and then
+ *  filled with widgets will advance an internal pointer over the allocated row.
+ *
+ *  To actually define a layout you just call the appropriate layouting function
+ *  and each subsequent widget call will place the widget as specified. Important
+ *  here is that if you define more widgets then columns defined inside the layout
+ *  functions it will allocate the next row without you having to make another layouting
+ *  call.
+ *
+ *  Biggest limitation with using all these APIs outside the `nk_layout_space_xxx` API
+ *  is that you have to define the row height for each. However the row height
+ *  often depends on the height of the font.
+ *
+ *  To fix that internally nuklear uses a minimum row height that is set to the
+ *  height plus padding of currently active font and overwrites the row height
+ *  value if zero.
+ *
+ *  If you manually want to change the minimum row height then
+ *  use nk_layout_set_min_row_height, and use nk_layout_reset_min_row_height to
+ *  reset it back to be derived from font height.
+ *
+ *  Also if you change the font in nuklear it will automatically change the minimum
+ *  row height for you and. This means if you change the font but still want
+ *  a minimum row height smaller than the font you have to repush your value.
+ *
+ *  For actually more advanced UI I would even recommend using the `nk_layout_space_xxx`
+ *  layouting method in combination with a cassowary constraint solver (there are
+ *  some versions on github with permissive license model) to take over all control over widget
+ *  layouting yourself. However for quick and dirty layouting using all the other layouting
+ *  functions should be fine.
+ *
+ *  Usage
+ *  -------------------
+ *  1.) nk_layout_row_dynamic
+ *  The easiest layouting function is `nk_layout_row_dynamic`. It provides each
+ *  widgets with same horizontal space inside the row and dynamically grows
+ *  if the owning window grows in width. So the number of columns dictates
+ *  the size of each widget dynamically by formula:
+ *
+ *      widget_width = (window_width - padding - spacing) * (1/colum_count)
+ *
+ *  Just like all other layouting APIs if you define more widget than columns this
+ *  library will allocate a new row and keep all layouting parameters previously
+ *  defined.
+ *
+ *      if (nk_begin_xxx(...) {
+ *          // first row with height: 30 composed of two widgets
+ *          nk_layout_row_dynamic(&ctx, 30, 2);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *
+ *          // second row with same parameter as defined above
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *
+ *          // third row uses 0 for height which will use auto layouting
+ *          nk_layout_row_dynamic(&ctx, 0, 2);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *      }
+ *      nk_end(...);
+ *
+ *  2.) nk_layout_row_static
+ *  Another easy layouting function is `nk_layout_row_static`. It provides each
+ *  widget with same horizontal pixel width inside the row and does not grow
+ *  if the owning window scales smaller or bigger.
+ *
+ *      if (nk_begin_xxx(...) {
+ *          // first row with height: 30 composed of two widgets with width: 80
+ *          nk_layout_row_static(&ctx, 30, 80, 2);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *
+ *          // second row with same parameter as defined above
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *
+ *          // third row uses 0 for height which will use auto layouting
+ *          nk_layout_row_static(&ctx, 0, 80, 2);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *      }
+ *      nk_end(...);
+ *
+ *  3.) nk_layout_row_xxx
+ *  A little bit more advanced layouting API are functions `nk_layout_row_begin`,
+ *  `nk_layout_row_push` and `nk_layout_row_end`. They allow to directly
+ *  specify each column pixel or window ratio in a row. It supports either
+ *  directly setting per column pixel width or widget window ratio but not
+ *  both. Furthermore it is a immediate mode API so each value is directly
+ *  pushed before calling a widget. Therefore the layout is not automatically
+ *  repeating like the last two layouting functions.
+ *
+ *      if (nk_begin_xxx(...) {
+ *          // first row with height: 25 composed of two widgets with width 60 and 40
+ *          nk_layout_row_begin(ctx, NK_STATIC, 25, 2);
+ *          nk_layout_row_push(ctx, 60);
+ *          nk_widget(...);
+ *          nk_layout_row_push(ctx, 40);
+ *          nk_widget(...);
+ *          nk_layout_row_end(ctx);
+ *
+ *          // second row with height: 25 composed of two widgets with window ratio 0.25 and 0.75
+ *          nk_layout_row_begin(ctx, NK_DYNAMIC, 25, 2);
+ *          nk_layout_row_push(ctx, 0.25f);
+ *          nk_widget(...);
+ *          nk_layout_row_push(ctx, 0.75f);
+ *          nk_widget(...);
+ *          nk_layout_row_end(ctx);
+ *
+ *          // third row with auto generated height: composed of two widgets with window ratio 0.25 and 0.75
+ *          nk_layout_row_begin(ctx, NK_DYNAMIC, 0, 2);
+ *          nk_layout_row_push(ctx, 0.25f);
+ *          nk_widget(...);
+ *          nk_layout_row_push(ctx, 0.75f);
+ *          nk_widget(...);
+ *          nk_layout_row_end(ctx);
+ *      }
+ *      nk_end(...);
+ *
+ *  4.) nk_layout_row
+ *  The array counterpart to API nk_layout_row_xxx is the single nk_layout_row
+ *  functions. Instead of pushing either pixel or window ratio for every widget
+ *  it allows to define it by array. The trade of for less control is that
+ *  `nk_layout_row` is automatically repeating. Otherwise the behavior is the
+ *  same.
+ *
+ *      if (nk_begin_xxx(...) {
+ *          // two rows with height: 30 composed of two widgets with width 60 and 40
+ *          const float size[] = {60,40};
+ *          nk_layout_row(ctx, NK_STATIC, 30, 2, ratio);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *
+ *          // two rows with height: 30 composed of two widgets with window ratio 0.25 and 0.75
+ *          const float ratio[] = {0.25, 0.75};
+ *          nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratio);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *
+ *          // two rows with auto generated height composed of two widgets with window ratio 0.25 and 0.75
+ *          const float ratio[] = {0.25, 0.75};
+ *          nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratio);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *      }
+ *      nk_end(...);
+ *
+ *  5.) nk_layout_row_template_xxx
+ *  The most complex and second most flexible API is a simplified flexbox version without
+ *  line wrapping and weights for dynamic widgets. It is an immediate mode API but
+ *  unlike `nk_layout_row_xxx` it has auto repeat behavior and needs to be called
+ *  before calling the templated widgets.
+ *  The row template layout has three different per widget size specifier. The first
+ *  one is the static widget size specifier with fixed widget pixel width. They do
+ *  not grow if the row grows and will always stay the same. The second size
+ *  specifier is nk_layout_row_template_push_variable which defines a
+ *  minimum widget size but it also can grow if more space is available not taken
+ *  by other widgets. Finally there are dynamic widgets which are completely flexible
+ *  and unlike variable widgets can even shrink to zero if not enough space
+ *  is provided.
+ *
+ *      if (nk_begin_xxx(...) {
+ *          // two rows with height: 30 composed of three widgets
+ *          nk_layout_row_template_begin(ctx, 30);
+ *          nk_layout_row_template_push_dynamic(ctx);
+ *          nk_layout_row_template_push_variable(ctx, 80);
+ *          nk_layout_row_template_push_static(ctx, 80);
+ *          nk_layout_row_template_end(ctx);
+ *
+ *          nk_widget(...); // dynamic widget can go to zero if not enough space
+ *          nk_widget(...); // variable widget with min 80 pixel but can grow bigger if enough space
+ *          nk_widget(...); // static widget with fixed 80 pixel width
+ *
+ *          // second row same layout
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *          nk_widget(...);
+ *      }
+ *      nk_end(...);
+ *
+ *  6.) nk_layout_space_xxx
+ *  Finally the most flexible API directly allows you to place widgets inside the
+ *  window. The space layout API is an immediate mode API which does not support
+ *  row auto repeat and directly sets position and size of a widget. Position
+ *  and size hereby can be either specified as ratio of allocated space or
+ *  allocated space local position and pixel size. Since this API is quite
+ *  powerful there are a number of utility functions to get the available space
+ *  and convert between local allocated space and screen space.
+ *
+ *      if (nk_begin_xxx(...) {
+ *          // static row with height: 500 (you can set column count to INT_MAX if you don't want to be bothered)
+ *          nk_layout_space_begin(ctx, NK_STATIC, 500, INT_MAX);
+ *          nk_layout_space_push(ctx, nk_rect(0,0,150,200));
+ *          nk_widget(...);
+ *          nk_layout_space_push(ctx, nk_rect(200,200,100,200));
+ *          nk_widget(...);
+ *          nk_layout_space_end(ctx);
+ *
+ *          // dynamic row with height: 500 (you can set column count to INT_MAX if you don't want to be bothered)
+ *          nk_layout_space_begin(ctx, NK_DYNAMIC, 500, INT_MAX);
+ *          nk_layout_space_push(ctx, nk_rect(0.5,0.5,0.1,0.1));
+ *          nk_widget(...);
+ *          nk_layout_space_push(ctx, nk_rect(0.7,0.6,0.1,0.1));
+ *          nk_widget(...);
+ *      }
+ *      nk_end(...);
+ *
+ *  Reference
+ *  -------------------
+ *  nk_layout_set_min_row_height            - set the currently used minimum row height to a specified value
+ *  nk_layout_reset_min_row_height          - resets the currently used minimum row height to font height
+ *
+ *  nk_layout_widget_bounds                 - calculates current width a static layout row can fit inside a window
+ *  nk_layout_ratio_from_pixel              - utility functions to calculate window ratio from pixel size
+ *
+ *  nk_layout_row_dynamic                   - current layout is divided into n same sized growing columns
+ *  nk_layout_row_static                    - current layout is divided into n same fixed sized columns
+ *  nk_layout_row_begin                     - starts a new row with given height and number of columns
+ *  nk_layout_row_push                      - pushes another column with given size or window ratio
+ *  nk_layout_row_end                       - finished previously started row
+ *  nk_layout_row                           - specifies row columns in array as either window ratio or size
+ *
+ *  nk_layout_row_template_begin            - begins the row template declaration
+ *  nk_layout_row_template_push_dynamic     - adds a dynamic column that dynamically grows and can go to zero if not enough space
+ *  nk_layout_row_template_push_variable    - adds a variable column that dynamically grows but does not shrink below specified pixel width
+ *  nk_layout_row_template_push_static      - adds a static column that does not grow and will always have the same size
+ *  nk_layout_row_template_end              - marks the end of the row template
+ *
+ *  nk_layout_space_begin                   - begins a new layouting space that allows to specify each widgets position and size
+ *  nk_layout_space_push                    - pushes position and size of the next widget in own coordinate space either as pixel or ratio
+ *  nk_layout_space_end                     - marks the end of the layouting space
+ *
+ *  nk_layout_space_bounds                  - callable after nk_layout_space_begin and returns total space allocated
+ *  nk_layout_space_to_screen               - converts vector from nk_layout_space coordinate space into screen space
+ *  nk_layout_space_to_local                - converts vector from screen space into nk_layout_space coordinates
+ *  nk_layout_space_rect_to_screen          - converts rectangle from nk_layout_space coordinate space into screen space
+ *  nk_layout_space_rect_to_local           - converts rectangle from screen space into nk_layout_space coordinates
+ */
+/*  nk_layout_set_min_row_height - sets the currently used minimum row height.
+ *  IMPORTANT: The passed height needs to include both your preferred row height
+ *  as well as padding. No internal padding is added.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ *      @height new minimum row height to be used for auto generating the row height */
+NK_API void nk_layout_set_min_row_height(struct nk_context*, float height);
+/*  nk_layout_reset_min_row_height - Reset the currently used minimum row height
+ *  back to font height + text padding + additional padding (style_window.min_row_height_padding)
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_begin_xxx` */
+NK_API void nk_layout_reset_min_row_height(struct nk_context*);
+/*  nk_layout_widget_bounds - returns the width of the next row allocate by one of the layouting functions
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` */
+NK_API struct nk_rect nk_layout_widget_bounds(struct nk_context*);
+/*  nk_layout_ratio_from_pixel - utility functions to calculate window ratio from pixel size
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context`
+ *      @pixel_width to convert to window ratio */
+NK_API float nk_layout_ratio_from_pixel(struct nk_context*, float pixel_width);
+/*  nk_layout_row_dynamic - Sets current row layout to share horizontal space
+ *  between @cols number of widgets evenly. Once called all subsequent widget
+ *  calls greater than @cols will allocate a new row with same layout.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ *      @row_height holds height of each widget in row or zero for auto layouting
+ *      @cols number of widget inside row */
+NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols);
+/*  nk_layout_row_static - Sets current row layout to fill @cols number of widgets
+ *  in row with same @item_width horizontal size. Once called all subsequent widget
+ *  calls greater than @cols will allocate a new row with same layout.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ *      @height holds row height to allocate from panel for widget height
+ *      @item_width holds width of each widget in row
+ *      @cols number of widget inside row */
+NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols);
+/*  nk_layout_row_begin - Starts a new dynamic or fixed row with given height and columns.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_begin_xxx`
+ *      @fmt either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
+ *      @row_height holds height of each widget in row or zero for auto layouting
+ *      @cols number of widget inside row */
+NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols);
+/*  nk_layout_row_push - Specifies either window ratio or width of a single column
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_row_begin`
+ *      @value either a window ratio or fixed width depending on @fmt in previous `nk_layout_row_begin` call */
+NK_API void nk_layout_row_push(struct nk_context*, float value);
+/*  nk_layout_row_end - finished previously started row
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_row_begin` */
+NK_API void nk_layout_row_end(struct nk_context*);
+/*  nk_layout_row - specifies row columns in array as either window ratio or size
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context`
+ *      @fmt either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
+ *      @row_height holds height of each widget in row or zero for auto layouting
+ *      @cols number of widget inside row */
+NK_API void nk_layout_row(struct nk_context*, enum nk_layout_format, float height, int cols, const float *ratio);
+/*  nk_layout_row_template_begin - Begins the row template declaration
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @row_height holds height of each widget in row or zero for auto layouting */
+NK_API void nk_layout_row_template_begin(struct nk_context*, float row_height);
+/*  nk_layout_row_template_push_dynamic - adds a dynamic column that dynamically grows and can go to zero if not enough space
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_row_template_begin` */
+NK_API void nk_layout_row_template_push_dynamic(struct nk_context*);
+/*  nk_layout_row_template_push_variable - adds a variable column that dynamically grows but does not shrink below specified pixel width
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_row_template_begin`
+ *      @min_width holds the minimum pixel width the next column must be */
+NK_API void nk_layout_row_template_push_variable(struct nk_context*, float min_width);
+/*  nk_layout_row_template_push_static - adds a static column that does not grow and will always have the same size
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_row_template_begin`
+ *      @width holds the absolute pixel width value the next column must be */
+NK_API void nk_layout_row_template_push_static(struct nk_context*, float width);
+/*  nk_layout_row_template_end - marks the end of the row template
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_row_template_begin` */
+NK_API void nk_layout_row_template_end(struct nk_context*);
+/*  nk_layout_space_begin - begins a new layouting space that allows to specify each widgets position and size.
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct
+ *      @fmt either `NK_DYNAMIC` for window ratio or `NK_STATIC` for fixed size columns
+ *      @row_height holds height of each widget in row or zero for auto layouting
+ *      @widget_count number of widgets inside row */
+NK_API void nk_layout_space_begin(struct nk_context*, enum nk_layout_format, float height, int widget_count);
+/*  nk_layout_space_push - pushes position and size of the next widget in own coordinate space either as pixel or ratio
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ *      @bounds position and size in laoyut space local coordinates */
+NK_API void nk_layout_space_push(struct nk_context*, struct nk_rect);
+/*  nk_layout_space_end - marks the end of the layout space
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin` */
+NK_API void nk_layout_space_end(struct nk_context*);
+/*  nk_layout_space_bounds - returns total space allocated for `nk_layout_space`
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin` */
+NK_API struct nk_rect nk_layout_space_bounds(struct nk_context*);
+/*  nk_layout_space_to_screen - converts vector from nk_layout_space coordinate space into screen space
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ *      @vec position to convert from layout space into screen coordinate space */
+NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context*, struct nk_vec2);
+/*  nk_layout_space_to_screen - converts vector from layout space into screen space
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ *      @vec position to convert from screen space into layout coordinate space */
+NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context*, struct nk_vec2);
+/*  nk_layout_space_rect_to_screen - converts rectangle from screen space into layout space
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ *      @bounds rectangle to convert from layout space into screen space */
+NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context*, struct nk_rect);
+/*  nk_layout_space_rect_to_local - converts rectangle from layout space into screen space
+ *  Parameters:
+ *      @ctx must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
+ *      @bounds rectangle to convert from screen space into layout space */
+NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct nk_rect);
+/* =============================================================================
+ *
+ *                                  GROUP
+ *
+ * ============================================================================= */
+NK_API int nk_group_begin(struct nk_context*, const char *title, nk_flags);
+NK_API int nk_group_scrolled_offset_begin(struct nk_context*, nk_uint *x_offset, nk_uint *y_offset, const char*, nk_flags);
+NK_API int nk_group_scrolled_begin(struct nk_context*, struct nk_scroll*, const char *title, nk_flags);
+NK_API void nk_group_scrolled_end(struct nk_context*);
+NK_API void nk_group_end(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  LIST VIEW
+ *
+ * ============================================================================= */
+struct nk_list_view {
+/* public: */
+    int begin, end, count;
+/* private: */
+    int total_height;
+    struct nk_context *ctx;
+    nk_uint *scroll_pointer;
+    nk_uint scroll_value;
+};
+NK_API int nk_list_view_begin(struct nk_context*, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count);
+NK_API void nk_list_view_end(struct nk_list_view*);
+/* =============================================================================
+ *
+ *                                  TREE
+ *
+ * ============================================================================= */
+#define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
+#define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
+NK_API int nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
+#define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
+#define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
+NK_API int nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
+NK_API void nk_tree_pop(struct nk_context*);
+NK_API int nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
+NK_API int nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
+NK_API void nk_tree_state_pop(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  WIDGET
+ *
+ * ============================================================================= */
+enum nk_widget_layout_states {
+    NK_WIDGET_INVALID, /* The widget cannot be seen and is completely out of view */
+    NK_WIDGET_VALID, /* The widget is completely inside the window and can be updated and drawn */
+    NK_WIDGET_ROM /* The widget is partially visible and cannot be updated */
+};
+enum nk_widget_states {
+    NK_WIDGET_STATE_MODIFIED    = NK_FLAG(1),
+    NK_WIDGET_STATE_INACTIVE    = NK_FLAG(2), /* widget is neither active nor hovered */
+    NK_WIDGET_STATE_ENTERED     = NK_FLAG(3), /* widget has been hovered on the current frame */
+    NK_WIDGET_STATE_HOVER       = NK_FLAG(4), /* widget is being hovered */
+    NK_WIDGET_STATE_ACTIVED     = NK_FLAG(5),/* widget is currently activated */
+    NK_WIDGET_STATE_LEFT        = NK_FLAG(6), /* widget is from this frame on not hovered anymore */
+    NK_WIDGET_STATE_HOVERED     = NK_WIDGET_STATE_HOVER|NK_WIDGET_STATE_MODIFIED, /* widget is being hovered */
+    NK_WIDGET_STATE_ACTIVE      = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED /* widget is currently activated */
+};
+NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
+NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, struct nk_context*, struct nk_vec2);
+NK_API struct nk_rect nk_widget_bounds(struct nk_context*);
+NK_API struct nk_vec2 nk_widget_position(struct nk_context*);
+NK_API struct nk_vec2 nk_widget_size(struct nk_context*);
+NK_API float nk_widget_width(struct nk_context*);
+NK_API float nk_widget_height(struct nk_context*);
+NK_API int nk_widget_is_hovered(struct nk_context*);
+NK_API int nk_widget_is_mouse_clicked(struct nk_context*, enum nk_buttons);
+NK_API int nk_widget_has_mouse_click_down(struct nk_context*, enum nk_buttons, int down);
+NK_API void nk_spacing(struct nk_context*, int cols);
+/* =============================================================================
+ *
+ *                                  TEXT
+ *
+ * ============================================================================= */
+enum nk_text_align {
+    NK_TEXT_ALIGN_LEFT        = 0x01,
+    NK_TEXT_ALIGN_CENTERED    = 0x02,
+    NK_TEXT_ALIGN_RIGHT       = 0x04,
+    NK_TEXT_ALIGN_TOP         = 0x08,
+    NK_TEXT_ALIGN_MIDDLE      = 0x10,
+    NK_TEXT_ALIGN_BOTTOM      = 0x20
+};
+enum nk_text_alignment {
+    NK_TEXT_LEFT        = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_LEFT,
+    NK_TEXT_CENTERED    = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_CENTERED,
+    NK_TEXT_RIGHT       = NK_TEXT_ALIGN_MIDDLE|NK_TEXT_ALIGN_RIGHT
+};
+NK_API void nk_text(struct nk_context*, const char*, int, nk_flags);
+NK_API void nk_text_colored(struct nk_context*, const char*, int, nk_flags, struct nk_color);
+NK_API void nk_text_wrap(struct nk_context*, const char*, int);
+NK_API void nk_text_wrap_colored(struct nk_context*, const char*, int, struct nk_color);
+NK_API void nk_label(struct nk_context*, const char*, nk_flags align);
+NK_API void nk_label_colored(struct nk_context*, const char*, nk_flags align, struct nk_color);
+NK_API void nk_label_wrap(struct nk_context*, const char*);
+NK_API void nk_label_colored_wrap(struct nk_context*, const char*, struct nk_color);
+NK_API void nk_image(struct nk_context*, struct nk_image);
+#ifdef NK_INCLUDE_STANDARD_VARARGS
+NK_API void nk_labelf(struct nk_context*, nk_flags, const char*, ...);
+NK_API void nk_labelf_colored(struct nk_context*, nk_flags align, struct nk_color, const char*,...);
+NK_API void nk_labelf_wrap(struct nk_context*, const char*,...);
+NK_API void nk_labelf_colored_wrap(struct nk_context*, struct nk_color, const char*,...);
+NK_API void nk_value_bool(struct nk_context*, const char *prefix, int);
+NK_API void nk_value_int(struct nk_context*, const char *prefix, int);
+NK_API void nk_value_uint(struct nk_context*, const char *prefix, unsigned int);
+NK_API void nk_value_float(struct nk_context*, const char *prefix, float);
+NK_API void nk_value_color_byte(struct nk_context*, const char *prefix, struct nk_color);
+NK_API void nk_value_color_float(struct nk_context*, const char *prefix, struct nk_color);
+NK_API void nk_value_color_hex(struct nk_context*, const char *prefix, struct nk_color);
+#endif
+/* =============================================================================
+ *
+ *                                  BUTTON
+ *
+ * ============================================================================= */
+NK_API int nk_button_text(struct nk_context*, const char *title, int len);
+NK_API int nk_button_label(struct nk_context*, const char *title);
+NK_API int nk_button_color(struct nk_context*, struct nk_color);
+NK_API int nk_button_symbol(struct nk_context*, enum nk_symbol_type);
+NK_API int nk_button_image(struct nk_context*, struct nk_image img);
+NK_API int nk_button_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags text_alignment);
+NK_API int nk_button_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
+NK_API int nk_button_image_label(struct nk_context*, struct nk_image img, const char*, nk_flags text_alignment);
+NK_API int nk_button_image_text(struct nk_context*, struct nk_image img, const char*, int, nk_flags alignment);
+NK_API int nk_button_text_styled(struct nk_context*, const struct nk_style_button*, const char *title, int len);
+NK_API int nk_button_label_styled(struct nk_context*, const struct nk_style_button*, const char *title);
+NK_API int nk_button_symbol_styled(struct nk_context*, const struct nk_style_button*, enum nk_symbol_type);
+NK_API int nk_button_image_styled(struct nk_context*, const struct nk_style_button*, struct nk_image img);
+NK_API int nk_button_symbol_text_styled(struct nk_context*,const struct nk_style_button*, enum nk_symbol_type, const char*, int, nk_flags alignment);
+NK_API int nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align);
+NK_API int nk_button_image_label_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, nk_flags text_alignment);
+NK_API int nk_button_image_text_styled(struct nk_context*,const struct nk_style_button*, struct nk_image img, const char*, int, nk_flags alignment);
+NK_API void nk_button_set_behavior(struct nk_context*, enum nk_button_behavior);
+NK_API int nk_button_push_behavior(struct nk_context*, enum nk_button_behavior);
+NK_API int nk_button_pop_behavior(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  CHECKBOX
+ *
+ * ============================================================================= */
+NK_API int nk_check_label(struct nk_context*, const char*, int active);
+NK_API int nk_check_text(struct nk_context*, const char*, int,int active);
+NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
+NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
+NK_API int nk_checkbox_label(struct nk_context*, const char*, int *active);
+NK_API int nk_checkbox_text(struct nk_context*, const char*, int, int *active);
+NK_API int nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
+NK_API int nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
+/* =============================================================================
+ *
+ *                                  RADIO BUTTON
+ *
+ * ============================================================================= */
+NK_API int nk_radio_label(struct nk_context*, const char*, int *active);
+NK_API int nk_radio_text(struct nk_context*, const char*, int, int *active);
+NK_API int nk_option_label(struct nk_context*, const char*, int active);
+NK_API int nk_option_text(struct nk_context*, const char*, int, int active);
+/* =============================================================================
+ *
+ *                                  SELECTABLE
+ *
+ * ============================================================================= */
+NK_API int nk_selectable_label(struct nk_context*, const char*, nk_flags align, int *value);
+NK_API int nk_selectable_text(struct nk_context*, const char*, int, nk_flags align, int *value);
+NK_API int nk_selectable_image_label(struct nk_context*,struct nk_image,  const char*, nk_flags align, int *value);
+NK_API int nk_selectable_image_text(struct nk_context*,struct nk_image, const char*, int, nk_flags align, int *value);
+NK_API int nk_select_label(struct nk_context*, const char*, nk_flags align, int value);
+NK_API int nk_select_text(struct nk_context*, const char*, int, nk_flags align, int value);
+NK_API int nk_select_image_label(struct nk_context*, struct nk_image,const char*, nk_flags align, int value);
+NK_API int nk_select_image_text(struct nk_context*, struct nk_image,const char*, int, nk_flags align, int value);
+/* =============================================================================
+ *
+ *                                  SLIDER
+ *
+ * ============================================================================= */
+NK_API float nk_slide_float(struct nk_context*, float min, float val, float max, float step);
+NK_API int nk_slide_int(struct nk_context*, int min, int val, int max, int step);
+NK_API int nk_slider_float(struct nk_context*, float min, float *val, float max, float step);
+NK_API int nk_slider_int(struct nk_context*, int min, int *val, int max, int step);
+/* =============================================================================
+ *
+ *                                  PROGRESSBAR
+ *
+ * ============================================================================= */
+NK_API int nk_progress(struct nk_context*, nk_size *cur, nk_size max, int modifyable);
+NK_API nk_size nk_prog(struct nk_context*, nk_size cur, nk_size max, int modifyable);
+
+/* =============================================================================
+ *
+ *                                  COLOR PICKER
+ *
+ * ============================================================================= */
+NK_API struct nk_color nk_color_picker(struct nk_context*, struct nk_color, enum nk_color_format);
+NK_API int nk_color_pick(struct nk_context*, struct nk_color*, enum nk_color_format);
+/* =============================================================================
+ *
+ *                                  PROPERTIES
+ *
+ * ============================================================================= */
+NK_API void nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
+NK_API void nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
+NK_API void nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
+NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
+NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
+NK_API double nk_propertyd(struct nk_context*, const char *name, double min, double val, double max, double step, float inc_per_pixel);
+/* =============================================================================
+ *
+ *                                  TEXT EDIT
+ *
+ * ============================================================================= */
+enum nk_edit_flags {
+    NK_EDIT_DEFAULT                 = 0,
+    NK_EDIT_READ_ONLY               = NK_FLAG(0),
+    NK_EDIT_AUTO_SELECT             = NK_FLAG(1),
+    NK_EDIT_SIG_ENTER               = NK_FLAG(2),
+    NK_EDIT_ALLOW_TAB               = NK_FLAG(3),
+    NK_EDIT_NO_CURSOR               = NK_FLAG(4),
+    NK_EDIT_SELECTABLE              = NK_FLAG(5),
+    NK_EDIT_CLIPBOARD               = NK_FLAG(6),
+    NK_EDIT_CTRL_ENTER_NEWLINE      = NK_FLAG(7),
+    NK_EDIT_NO_HORIZONTAL_SCROLL    = NK_FLAG(8),
+    NK_EDIT_ALWAYS_INSERT_MODE      = NK_FLAG(9),
+    NK_EDIT_MULTILINE               = NK_FLAG(10),
+    NK_EDIT_GOTO_END_ON_ACTIVATE    = NK_FLAG(11)
+};
+enum nk_edit_types {
+    NK_EDIT_SIMPLE  = NK_EDIT_ALWAYS_INSERT_MODE,
+    NK_EDIT_FIELD   = NK_EDIT_SIMPLE|NK_EDIT_SELECTABLE|NK_EDIT_CLIPBOARD,
+    NK_EDIT_BOX     = NK_EDIT_ALWAYS_INSERT_MODE| NK_EDIT_SELECTABLE| NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB|NK_EDIT_CLIPBOARD,
+    NK_EDIT_EDITOR  = NK_EDIT_SELECTABLE|NK_EDIT_MULTILINE|NK_EDIT_ALLOW_TAB| NK_EDIT_CLIPBOARD
+};
+enum nk_edit_events {
+    NK_EDIT_ACTIVE      = NK_FLAG(0), /* edit widget is currently being modified */
+    NK_EDIT_INACTIVE    = NK_FLAG(1), /* edit widget is not active and is not being modified */
+    NK_EDIT_ACTIVATED   = NK_FLAG(2), /* edit widget went from state inactive to state active */
+    NK_EDIT_DEACTIVATED = NK_FLAG(3), /* edit widget went from state active to state inactive */
+    NK_EDIT_COMMITED    = NK_FLAG(4) /* edit widget has received an enter and lost focus */
+};
+NK_API nk_flags nk_edit_string(struct nk_context*, nk_flags, char *buffer, int *len, int max, nk_plugin_filter);
+NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context*, nk_flags, char *buffer, int max, nk_plugin_filter);
+NK_API nk_flags nk_edit_buffer(struct nk_context*, nk_flags, struct nk_text_edit*, nk_plugin_filter);
+NK_API void nk_edit_focus(struct nk_context*, nk_flags flags);
+NK_API void nk_edit_unfocus(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  CHART
+ *
+ * ============================================================================= */
+NK_API int nk_chart_begin(struct nk_context*, enum nk_chart_type, int num, float min, float max);
+NK_API int nk_chart_begin_colored(struct nk_context*, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max);
+NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value);
+NK_API void nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type, struct nk_color, struct nk_color active, int count, float min_value, float max_value);
+NK_API nk_flags nk_chart_push(struct nk_context*, float);
+NK_API nk_flags nk_chart_push_slot(struct nk_context*, float, int);
+NK_API void nk_chart_end(struct nk_context*);
+NK_API void nk_plot(struct nk_context*, enum nk_chart_type, const float *values, int count, int offset);
+NK_API void nk_plot_function(struct nk_context*, enum nk_chart_type, void *userdata, float(*value_getter)(void* user, int index), int count, int offset);
+/* =============================================================================
+ *
+ *                                  POPUP
+ *
+ * ============================================================================= */
+NK_API int nk_popup_begin(struct nk_context*, enum nk_popup_type, const char*, nk_flags, struct nk_rect bounds);
+NK_API void nk_popup_close(struct nk_context*);
+NK_API void nk_popup_end(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  COMBOBOX
+ *
+ * ============================================================================= */
+NK_API int nk_combo(struct nk_context*, const char **items, int count, int selected, int item_height, struct nk_vec2 size);
+NK_API int nk_combo_separator(struct nk_context*, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size);
+NK_API int nk_combo_string(struct nk_context*, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size);
+NK_API int nk_combo_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void *userdata, int selected, int count, int item_height, struct nk_vec2 size);
+NK_API void nk_combobox(struct nk_context*, const char **items, int count, int *selected, int item_height, struct nk_vec2 size);
+NK_API void nk_combobox_string(struct nk_context*, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size);
+NK_API void nk_combobox_separator(struct nk_context*, const char *items_separated_by_separator, int separator,int *selected, int count, int item_height, struct nk_vec2 size);
+NK_API void nk_combobox_callback(struct nk_context*, void(*item_getter)(void*, int, const char**), void*, int *selected, int count, int item_height, struct nk_vec2 size);
+/* =============================================================================
+ *
+ *                                  ABSTRACT COMBOBOX
+ *
+ * ============================================================================= */
+NK_API int nk_combo_begin_text(struct nk_context*, const char *selected, int, struct nk_vec2 size);
+NK_API int nk_combo_begin_label(struct nk_context*, const char *selected, struct nk_vec2 size);
+NK_API int nk_combo_begin_color(struct nk_context*, struct nk_color color, struct nk_vec2 size);
+NK_API int nk_combo_begin_symbol(struct nk_context*,  enum nk_symbol_type,  struct nk_vec2 size);
+NK_API int nk_combo_begin_symbol_label(struct nk_context*, const char *selected, enum nk_symbol_type, struct nk_vec2 size);
+NK_API int nk_combo_begin_symbol_text(struct nk_context*, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size);
+NK_API int nk_combo_begin_image(struct nk_context*, struct nk_image img,  struct nk_vec2 size);
+NK_API int nk_combo_begin_image_label(struct nk_context*, const char *selected, struct nk_image, struct nk_vec2 size);
+NK_API int nk_combo_begin_image_text(struct nk_context*,  const char *selected, int, struct nk_image, struct nk_vec2 size);
+NK_API int nk_combo_item_label(struct nk_context*, const char*, nk_flags alignment);
+NK_API int nk_combo_item_text(struct nk_context*, const char*,int, nk_flags alignment);
+NK_API int nk_combo_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
+NK_API int nk_combo_item_image_text(struct nk_context*, struct nk_image, const char*, int,nk_flags alignment);
+NK_API int nk_combo_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
+NK_API int nk_combo_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
+NK_API void nk_combo_close(struct nk_context*);
+NK_API void nk_combo_end(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  CONTEXTUAL
+ *
+ * ============================================================================= */
+NK_API int nk_contextual_begin(struct nk_context*, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds);
+NK_API int nk_contextual_item_text(struct nk_context*, const char*, int,nk_flags align);
+NK_API int nk_contextual_item_label(struct nk_context*, const char*, nk_flags align);
+NK_API int nk_contextual_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
+NK_API int nk_contextual_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
+NK_API int nk_contextual_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
+NK_API int nk_contextual_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
+NK_API void nk_contextual_close(struct nk_context*);
+NK_API void nk_contextual_end(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  TOOLTIP
+ *
+ * ============================================================================= */
+NK_API void nk_tooltip(struct nk_context*, const char*);
+NK_API int nk_tooltip_begin(struct nk_context*, float width);
+NK_API void nk_tooltip_end(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  MENU
+ *
+ * ============================================================================= */
+NK_API void nk_menubar_begin(struct nk_context*);
+NK_API void nk_menubar_end(struct nk_context*);
+NK_API int nk_menu_begin_text(struct nk_context*, const char* title, int title_len, nk_flags align, struct nk_vec2 size);
+NK_API int nk_menu_begin_label(struct nk_context*, const char*, nk_flags align, struct nk_vec2 size);
+NK_API int nk_menu_begin_image(struct nk_context*, const char*, struct nk_image, struct nk_vec2 size);
+NK_API int nk_menu_begin_image_text(struct nk_context*, const char*, int,nk_flags align,struct nk_image, struct nk_vec2 size);
+NK_API int nk_menu_begin_image_label(struct nk_context*, const char*, nk_flags align,struct nk_image, struct nk_vec2 size);
+NK_API int nk_menu_begin_symbol(struct nk_context*, const char*, enum nk_symbol_type, struct nk_vec2 size);
+NK_API int nk_menu_begin_symbol_text(struct nk_context*, const char*, int,nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
+NK_API int nk_menu_begin_symbol_label(struct nk_context*, const char*, nk_flags align,enum nk_symbol_type, struct nk_vec2 size);
+NK_API int nk_menu_item_text(struct nk_context*, const char*, int,nk_flags align);
+NK_API int nk_menu_item_label(struct nk_context*, const char*, nk_flags alignment);
+NK_API int nk_menu_item_image_label(struct nk_context*, struct nk_image, const char*, nk_flags alignment);
+NK_API int nk_menu_item_image_text(struct nk_context*, struct nk_image, const char*, int len, nk_flags alignment);
+NK_API int nk_menu_item_symbol_text(struct nk_context*, enum nk_symbol_type, const char*, int, nk_flags alignment);
+NK_API int nk_menu_item_symbol_label(struct nk_context*, enum nk_symbol_type, const char*, nk_flags alignment);
+NK_API void nk_menu_close(struct nk_context*);
+NK_API void nk_menu_end(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  STYLE
+ *
+ * ============================================================================= */
+enum nk_style_colors {
+    NK_COLOR_TEXT,
+    NK_COLOR_WINDOW,
+    NK_COLOR_HEADER,
+    NK_COLOR_BORDER,
+    NK_COLOR_BUTTON,
+    NK_COLOR_BUTTON_HOVER,
+    NK_COLOR_BUTTON_ACTIVE,
+    NK_COLOR_TOGGLE,
+    NK_COLOR_TOGGLE_HOVER,
+    NK_COLOR_TOGGLE_CURSOR,
+    NK_COLOR_SELECT,
+    NK_COLOR_SELECT_ACTIVE,
+    NK_COLOR_SLIDER,
+    NK_COLOR_SLIDER_CURSOR,
+    NK_COLOR_SLIDER_CURSOR_HOVER,
+    NK_COLOR_SLIDER_CURSOR_ACTIVE,
+    NK_COLOR_PROPERTY,
+    NK_COLOR_EDIT,
+    NK_COLOR_EDIT_CURSOR,
+    NK_COLOR_COMBO,
+    NK_COLOR_CHART,
+    NK_COLOR_CHART_COLOR,
+    NK_COLOR_CHART_COLOR_HIGHLIGHT,
+    NK_COLOR_SCROLLBAR,
+    NK_COLOR_SCROLLBAR_CURSOR,
+    NK_COLOR_SCROLLBAR_CURSOR_HOVER,
+    NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,
+    NK_COLOR_TAB_HEADER,
+    NK_COLOR_COUNT
+};
+enum nk_style_cursor {
+    NK_CURSOR_ARROW,
+    NK_CURSOR_TEXT,
+    NK_CURSOR_MOVE,
+    NK_CURSOR_RESIZE_VERTICAL,
+    NK_CURSOR_RESIZE_HORIZONTAL,
+    NK_CURSOR_RESIZE_TOP_LEFT_DOWN_RIGHT,
+    NK_CURSOR_RESIZE_TOP_RIGHT_DOWN_LEFT,
+    NK_CURSOR_COUNT
+};
+NK_API void nk_style_default(struct nk_context*);
+NK_API void nk_style_from_table(struct nk_context*, const struct nk_color*);
+NK_API void nk_style_load_cursor(struct nk_context*, enum nk_style_cursor, const struct nk_cursor*);
+NK_API void nk_style_load_all_cursors(struct nk_context*, struct nk_cursor*);
+NK_API const char* nk_style_get_color_by_name(enum nk_style_colors);
+NK_API void nk_style_set_font(struct nk_context*, const struct nk_user_font*);
+NK_API int nk_style_set_cursor(struct nk_context*, enum nk_style_cursor);
+NK_API void nk_style_show_cursor(struct nk_context*);
+NK_API void nk_style_hide_cursor(struct nk_context*);
+
+NK_API int nk_style_push_font(struct nk_context*, const struct nk_user_font*);
+NK_API int nk_style_push_float(struct nk_context*, float*, float);
+NK_API int nk_style_push_vec2(struct nk_context*, struct nk_vec2*, struct nk_vec2);
+NK_API int nk_style_push_style_item(struct nk_context*, struct nk_style_item*, struct nk_style_item);
+NK_API int nk_style_push_flags(struct nk_context*, nk_flags*, nk_flags);
+NK_API int nk_style_push_color(struct nk_context*, struct nk_color*, struct nk_color);
+
+NK_API int nk_style_pop_font(struct nk_context*);
+NK_API int nk_style_pop_float(struct nk_context*);
+NK_API int nk_style_pop_vec2(struct nk_context*);
+NK_API int nk_style_pop_style_item(struct nk_context*);
+NK_API int nk_style_pop_flags(struct nk_context*);
+NK_API int nk_style_pop_color(struct nk_context*);
+/* =============================================================================
+ *
+ *                                  COLOR
+ *
+ * ============================================================================= */
+NK_API struct nk_color nk_rgb(int r, int g, int b);
+NK_API struct nk_color nk_rgb_iv(const int *rgb);
+NK_API struct nk_color nk_rgb_bv(const nk_byte* rgb);
+NK_API struct nk_color nk_rgb_f(float r, float g, float b);
+NK_API struct nk_color nk_rgb_fv(const float *rgb);
+NK_API struct nk_color nk_rgb_hex(const char *rgb);
+
+NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
+NK_API struct nk_color nk_rgba_u32(nk_uint);
+NK_API struct nk_color nk_rgba_iv(const int *rgba);
+NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba);
+NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a);
+NK_API struct nk_color nk_rgba_fv(const float *rgba);
+NK_API struct nk_color nk_rgba_hex(const char *rgb);
+
+NK_API struct nk_color nk_hsv(int h, int s, int v);
+NK_API struct nk_color nk_hsv_iv(const int *hsv);
+NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv);
+NK_API struct nk_color nk_hsv_f(float h, float s, float v);
+NK_API struct nk_color nk_hsv_fv(const float *hsv);
+
+NK_API struct nk_color nk_hsva(int h, int s, int v, int a);
+NK_API struct nk_color nk_hsva_iv(const int *hsva);
+NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva);
+NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a);
+NK_API struct nk_color nk_hsva_fv(const float *hsva);
+
+/* color (conversion nuklear --> user) */
+NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color);
+NK_API void nk_color_fv(float *rgba_out, struct nk_color);
+NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color);
+NK_API void nk_color_dv(double *rgba_out, struct nk_color);
+
+NK_API nk_uint nk_color_u32(struct nk_color);
+NK_API void nk_color_hex_rgba(char *output, struct nk_color);
+NK_API void nk_color_hex_rgb(char *output, struct nk_color);
+
+NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color);
+NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color);
+NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color);
+NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color);
+NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color);
+NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color);
+
+NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color);
+NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color);
+NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color);
+NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color);
+NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color);
+NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color);
+/* =============================================================================
+ *
+ *                                  IMAGE
+ *
+ * ============================================================================= */
+NK_API nk_handle nk_handle_ptr(void*);
+NK_API nk_handle nk_handle_id(int);
+NK_API struct nk_image nk_image_handle(nk_handle);
+NK_API struct nk_image nk_image_ptr(void*);
+NK_API struct nk_image nk_image_id(int);
+NK_API int nk_image_is_subimage(const struct nk_image* img);
+NK_API struct nk_image nk_subimage_ptr(void*, unsigned short w, unsigned short h, struct nk_rect sub_region);
+NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region);
+NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region);
+/* =============================================================================
+ *
+ *                                  MATH
+ *
+ * ============================================================================= */
+NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed);
+NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading);
+
+NK_API struct nk_vec2 nk_vec2(float x, float y);
+NK_API struct nk_vec2 nk_vec2i(int x, int y);
+NK_API struct nk_vec2 nk_vec2v(const float *xy);
+NK_API struct nk_vec2 nk_vec2iv(const int *xy);
+
+NK_API struct nk_rect nk_get_null_rect(void);
+NK_API struct nk_rect nk_rect(float x, float y, float w, float h);
+NK_API struct nk_rect nk_recti(int x, int y, int w, int h);
+NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size);
+NK_API struct nk_rect nk_rectv(const float *xywh);
+NK_API struct nk_rect nk_rectiv(const int *xywh);
+NK_API struct nk_vec2 nk_rect_pos(struct nk_rect);
+NK_API struct nk_vec2 nk_rect_size(struct nk_rect);
+/* =============================================================================
+ *
+ *                                  STRING
+ *
+ * ============================================================================= */
+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, 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);
+/* =============================================================================
+ *
+ *                                  UTF-8
+ *
+ * ============================================================================= */
+NK_API int nk_utf_decode(const char*, nk_rune*, int);
+NK_API int nk_utf_encode(nk_rune, char*, int);
+NK_API int nk_utf_len(const char*, int byte_len);
+NK_API const char* nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len);
+/* ===============================================================
+ *
+ *                          FONT
+ *
+ * ===============================================================*/
+/*  Font handling in this library was designed to be quite customizable and lets
+    you decide what you want to use and what you want to provide. There are three
+    different ways to use the font atlas. The first two will use your font
+    handling scheme and only requires essential data to run nuklear. The next
+    slightly more advanced features is font handling with vertex buffer output.
+    Finally the most complex API wise is using nuklear's font baking API.
+
+    1.) Using your own implementation without vertex buffer output
+    --------------------------------------------------------------
+    So first up the easiest way to do font handling is by just providing a
+    `nk_user_font` struct which only requires the height in pixel of the used
+    font and a callback to calculate the width of a string. This way of handling
+    fonts is best fitted for using the normal draw shape command API where you
+    do all the text drawing yourself and the library does not require any kind
+    of deeper knowledge about which font handling mechanism you use.
+    IMPORTANT: the `nk_user_font` pointer provided to nuklear has to persist
+    over the complete life time! I know this sucks but it is currently the only
+    way to switch between fonts.
+
+        float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
+        {
+            your_font_type *type = handle.ptr;
+            float text_width = ...;
+            return text_width;
+        }
+
+        struct nk_user_font font;
+        font.userdata.ptr = &your_font_class_or_struct;
+        font.height = your_font_height;
+        font.width = your_text_width_calculation;
+
+        struct nk_context ctx;
+        nk_init_default(&ctx, &font);
+
+    2.) Using your own implementation with vertex buffer output
+    --------------------------------------------------------------
+    While the first approach works fine if you don't want to use the optional
+    vertex buffer output it is not enough if you do. To get font handling working
+    for these cases you have to provide two additional parameters inside the
+    `nk_user_font`. First a texture atlas handle used to draw text as subimages
+    of a bigger font atlas texture and a callback to query a character's glyph
+    information (offset, size, ...). So it is still possible to provide your own
+    font and use the vertex buffer output.
+
+        float your_text_width_calculation(nk_handle handle, float height, const char *text, int len)
+        {
+            your_font_type *type = handle.ptr;
+            float text_width = ...;
+            return text_width;
+        }
+        void query_your_font_glyph(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
+        {
+            your_font_type *type = handle.ptr;
+            glyph.width = ...;
+            glyph.height = ...;
+            glyph.xadvance = ...;
+            glyph.uv[0].x = ...;
+            glyph.uv[0].y = ...;
+            glyph.uv[1].x = ...;
+            glyph.uv[1].y = ...;
+            glyph.offset.x = ...;
+            glyph.offset.y = ...;
+        }
+
+        struct nk_user_font font;
+        font.userdata.ptr = &your_font_class_or_struct;
+        font.height = your_font_height;
+        font.width = your_text_width_calculation;
+        font.query = query_your_font_glyph;
+        font.texture.id = your_font_texture;
+
+        struct nk_context ctx;
+        nk_init_default(&ctx, &font);
+
+    3.) Nuklear font baker
+    ------------------------------------
+    The final approach if you do not have a font handling functionality or don't
+    want to use it in this library is by using the optional font baker.
+    The font baker APIs can be used to create a font plus font atlas texture
+    and can be used with or without the vertex buffer output.
+
+    It still uses the `nk_user_font` struct and the two different approaches
+    previously stated still work. The font baker is not located inside
+    `nk_context` like all other systems since it can be understood as more of
+    an extension to nuklear and does not really depend on any `nk_context` state.
+
+    Font baker need to be initialized first by one of the nk_font_atlas_init_xxx
+    functions. If you don't care about memory just call the default version
+    `nk_font_atlas_init_default` which will allocate all memory from the standard library.
+    If you want to control memory allocation but you don't care if the allocated
+    memory is temporary and therefore can be freed directly after the baking process
+    is over or permanent you can call `nk_font_atlas_init`.
+
+    After successfully initializing the font baker you can add Truetype(.ttf) fonts from
+    different sources like memory or from file by calling one of the `nk_font_atlas_add_xxx`.
+    functions. Adding font will permanently store each font, font config and ttf memory block(!)
+    inside the font atlas and allows to reuse the font atlas. If you don't want to reuse
+    the font baker by for example adding additional fonts you can call
+    `nk_font_atlas_cleanup` after the baking process is over (after calling nk_font_atlas_end).
+
+    As soon as you added all fonts you wanted you can now start the baking process
+    for every selected glyph to image by calling `nk_font_atlas_bake`.
+    The baking process returns image memory, width and height which can be used to
+    either create your own image object or upload it to any graphics library.
+    No matter which case you finally have to call `nk_font_atlas_end` which
+    will free all temporary memory including the font atlas image so make sure
+    you created our texture beforehand. `nk_font_atlas_end` requires a handle
+    to your font texture or object and optionally fills a `struct nk_draw_null_texture`
+    which can be used for the optional vertex output. If you don't want it just
+    set the argument to `NULL`.
+
+    At this point you are done and if you don't want to reuse the font atlas you
+    can call `nk_font_atlas_cleanup` to free all truetype blobs and configuration
+    memory. Finally if you don't use the font atlas and any of it's fonts anymore
+    you need to call `nk_font_atlas_clear` to free all memory still being used.
+
+        struct nk_font_atlas atlas;
+        nk_font_atlas_init_default(&atlas);
+        nk_font_atlas_begin(&atlas);
+        nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, 0);
+        nk_font *font2 = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font2.ttf", 16, 0);
+        const void* img = nk_font_atlas_bake(&atlas, &img_width, &img_height, NK_FONT_ATLAS_RGBA32);
+        nk_font_atlas_end(&atlas, nk_handle_id(texture), 0);
+
+        struct nk_context ctx;
+        nk_init_default(&ctx, &font->handle);
+        while (1) {
+
+        }
+        nk_font_atlas_clear(&atlas);
+
+    The font baker API is probably the most complex API inside this library and
+    I would suggest reading some of my examples `example/` to get a grip on how
+    to use the font atlas. There are a number of details I left out. For example
+    how to merge fonts, configure a font with `nk_font_config` to use other languages,
+    use another texture coordinate format and a lot more:
+
+        struct nk_font_config cfg = nk_font_config(font_pixel_height);
+        cfg.merge_mode = nk_false or nk_true;
+        cfg.range = nk_font_korean_glyph_ranges();
+        cfg.coord_type = NK_COORD_PIXEL;
+        nk_font *font = nk_font_atlas_add_from_file(&atlas, "Path/To/Your/TTF_Font.ttf", 13, &cfg);
+
+*/
+struct nk_user_font_glyph;
+typedef float(*nk_text_width_f)(nk_handle, float h, const char*, int len);
+typedef void(*nk_query_font_glyph_f)(nk_handle handle, float font_height,
+                                    struct nk_user_font_glyph *glyph,
+                                    nk_rune codepoint, nk_rune next_codepoint);
+
+#if defined(NK_INCLUDE_VERTEX_BUFFER_OUTPUT) || defined(NK_INCLUDE_SOFTWARE_FONT)
+struct nk_user_font_glyph {
+    struct nk_vec2 uv[2];
+    /* texture coordinates */
+    struct nk_vec2 offset;
+    /* offset between top left and glyph */
+    float width, height;
+    /* size of the glyph  */
+    float xadvance;
+    /* offset to the next glyph */
+};
+#endif
+
+struct nk_user_font {
+    nk_handle userdata;
+    /* user provided font handle */
+    float height;
+    /* max height of the font */
+    nk_text_width_f width;
+    /* font string width in pixel callback */
+#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+    nk_query_font_glyph_f query;
+    /* font glyph callback to query drawing info */
+    nk_handle texture;
+    /* texture handle to the used font atlas or texture */
+#endif
+};
+
+#ifdef NK_INCLUDE_FONT_BAKING
+enum nk_font_coord_type {
+    NK_COORD_UV, /* texture coordinates inside font glyphs are clamped between 0-1 */
+    NK_COORD_PIXEL /* texture coordinates inside font glyphs are in absolute pixel */
+};
+
+struct nk_baked_font {
+    float height;
+    /* height of the font  */
+    float ascent, descent;
+    /* font glyphs ascent and descent  */
+    nk_rune glyph_offset;
+    /* glyph array offset inside the font glyph baking output array  */
+    nk_rune glyph_count;
+    /* number of glyphs of this font inside the glyph baking array output */
+    const nk_rune *ranges;
+    /* font codepoint ranges as pairs of (from/to) and 0 as last element */
+};
+
+struct nk_font_config {
+    struct nk_font_config *next;
+    /* NOTE: only used internally */
+    void *ttf_blob;
+    /* pointer to loaded TTF file memory block.
+     * NOTE: not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
+    nk_size ttf_size;
+    /* size of the loaded TTF file memory block
+     * NOTE: not needed for nk_font_atlas_add_from_memory and nk_font_atlas_add_from_file. */
+
+    unsigned char ttf_data_owned_by_atlas;
+    /* used inside font atlas: default to: 0*/
+    unsigned char merge_mode;
+    /* merges this font into the last font */
+    unsigned char pixel_snap;
+    /* align every character to pixel boundary (if true set oversample (1,1)) */
+    unsigned char oversample_v, oversample_h;
+    /* rasterize at hight quality for sub-pixel position */
+    unsigned char padding[3];
+
+    float size;
+    /* baked pixel height of the font */
+    enum nk_font_coord_type coord_type;
+    /* texture coordinate format with either pixel or UV coordinates */
+    struct nk_vec2 spacing;
+    /* extra pixel spacing between glyphs  */
+    const nk_rune *range;
+    /* list of unicode ranges (2 values per range, zero terminated) */
+    struct nk_baked_font *font;
+    /* font to setup in the baking process: NOTE: not needed for font atlas */
+    nk_rune fallback_glyph;
+    /* fallback glyph to use if a given rune is not found */
+};
+
+struct nk_font_glyph {
+    nk_rune codepoint;
+    float xadvance;
+    float x0, y0, x1, y1, w, h;
+    float u0, v0, u1, v1;
+};
+
+struct nk_font {
+    struct nk_font *next;
+    struct nk_user_font handle;
+    struct nk_baked_font info;
+    float scale;
+    struct nk_font_glyph *glyphs;
+    const struct nk_font_glyph *fallback;
+    nk_rune fallback_codepoint;
+    nk_handle texture;
+    struct nk_font_config *config;
+};
+
+enum nk_font_atlas_format {
+    NK_FONT_ATLAS_ALPHA8,
+    NK_FONT_ATLAS_RGBA32
+};
+
+struct nk_font_atlas {
+    void *pixel;
+    int tex_width;
+    int tex_height;
+
+    struct nk_allocator permanent;
+    struct nk_allocator temporary;
+
+    struct nk_recti custom;
+    struct nk_cursor cursors[NK_CURSOR_COUNT];
+
+    int glyph_count;
+    struct nk_font_glyph *glyphs;
+    struct nk_font *default_font;
+    struct nk_font *fonts;
+    struct nk_font_config *config;
+    int font_num;
+};
+
+/* some language glyph codepoint ranges */
+NK_API const nk_rune *nk_font_default_glyph_ranges(void);
+NK_API const nk_rune *nk_font_chinese_glyph_ranges(void);
+NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(void);
+NK_API const nk_rune *nk_font_korean_glyph_ranges(void);
+
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+NK_API void nk_font_atlas_init_default(struct nk_font_atlas*);
+#endif
+NK_API void nk_font_atlas_init(struct nk_font_atlas*, struct nk_allocator*);
+NK_API void nk_font_atlas_init_custom(struct nk_font_atlas*, struct nk_allocator *persistent, struct nk_allocator *transient);
+NK_API void nk_font_atlas_begin(struct nk_font_atlas*);
+NK_API struct nk_font_config nk_font_config(float pixel_height);
+NK_API struct nk_font *nk_font_atlas_add(struct nk_font_atlas*, const struct nk_font_config*);
+#ifdef NK_INCLUDE_DEFAULT_FONT
+NK_API struct nk_font* nk_font_atlas_add_default(struct nk_font_atlas*, float height, const struct nk_font_config*);
+#endif
+NK_API struct nk_font* nk_font_atlas_add_from_memory(struct nk_font_atlas *atlas, void *memory, nk_size size, float height, const struct nk_font_config *config);
+#ifdef NK_INCLUDE_STANDARD_IO
+NK_API struct nk_font* nk_font_atlas_add_from_file(struct nk_font_atlas *atlas, const char *file_path, float height, const struct nk_font_config*);
+#endif
+NK_API struct nk_font *nk_font_atlas_add_compressed(struct nk_font_atlas*, void *memory, nk_size size, float height, const struct nk_font_config*);
+NK_API struct nk_font* nk_font_atlas_add_compressed_base85(struct nk_font_atlas*, const char *data, float height, const struct nk_font_config *config);
+NK_API const void* nk_font_atlas_bake(struct nk_font_atlas*, int *width, int *height, enum nk_font_atlas_format);
+NK_API void nk_font_atlas_end(struct nk_font_atlas*, nk_handle tex, struct nk_draw_null_texture*);
+NK_API const struct nk_font_glyph* nk_font_find_glyph(struct nk_font*, nk_rune unicode);
+NK_API void nk_font_atlas_cleanup(struct nk_font_atlas *atlas);
+NK_API void nk_font_atlas_clear(struct nk_font_atlas*);
+
+#endif
+
+/* ==============================================================
+ *
+ *                          MEMORY BUFFER
+ *
+ * ===============================================================*/
+/*  A basic (double)-buffer with linear allocation and resetting as only
+    freeing policy. The buffer's main purpose is to control all memory management
+    inside the GUI toolkit and still leave memory control as much as possible in
+    the hand of the user while also making sure the library is easy to use if
+    not as much control is needed.
+    In general all memory inside this library can be provided from the user in
+    three different ways.
+
+    The first way and the one providing most control is by just passing a fixed
+    size memory block. In this case all control lies in the hand of the user
+    since he can exactly control where the memory comes from and how much memory
+    the library should consume. Of course using the fixed size API removes the
+    ability to automatically resize a buffer if not enough memory is provided so
+    you have to take over the resizing. While being a fixed sized buffer sounds
+    quite limiting, it is very effective in this library since the actual memory
+    consumption is quite stable and has a fixed upper bound for a lot of cases.
+
+    If you don't want to think about how much memory the library should allocate
+    at all time or have a very dynamic UI with unpredictable memory consumption
+    habits but still want control over memory allocation you can use the dynamic
+    allocator based API. The allocator consists of two callbacks for allocating
+    and freeing memory and optional userdata so you can plugin your own allocator.
+
+    The final and easiest way can be used by defining
+    NK_INCLUDE_DEFAULT_ALLOCATOR which uses the standard library memory
+    allocation functions malloc and free and takes over complete control over
+    memory in this library.
+*/
+struct nk_memory_status {
+    void *memory;
+    unsigned int type;
+    nk_size size;
+    nk_size allocated;
+    nk_size needed;
+    nk_size calls;
+};
+
+enum nk_allocation_type {
+    NK_BUFFER_FIXED,
+    NK_BUFFER_DYNAMIC
+};
+
+enum nk_buffer_allocation_type {
+    NK_BUFFER_FRONT,
+    NK_BUFFER_BACK,
+    NK_BUFFER_MAX
+};
+
+struct nk_buffer_marker {
+    int active;
+    nk_size offset;
+};
+
+struct nk_memory {void *ptr;nk_size size;};
+struct nk_buffer {
+    struct nk_buffer_marker marker[NK_BUFFER_MAX];
+    /* buffer marker to free a buffer to a certain offset */
+    struct nk_allocator pool;
+    /* allocator callback for dynamic buffers */
+    enum nk_allocation_type type;
+    /* memory management type */
+    struct nk_memory memory;
+    /* memory and size of the current memory block */
+    float grow_factor;
+    /* growing factor for dynamic memory management */
+    nk_size allocated;
+    /* total amount of memory allocated */
+    nk_size needed;
+    /* totally consumed memory given that enough memory is present */
+    nk_size calls;
+    /* number of allocation calls */
+    nk_size size;
+    /* current size of the buffer */
+};
+
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+NK_API void nk_buffer_init_default(struct nk_buffer*);
+#endif
+NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_size size);
+NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
+NK_API void nk_buffer_info(struct nk_memory_status*, struct nk_buffer*);
+NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align);
+NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
+NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
+NK_API void nk_buffer_clear(struct nk_buffer*);
+NK_API void nk_buffer_free(struct nk_buffer*);
+NK_API void *nk_buffer_memory(struct nk_buffer*);
+NK_API const void *nk_buffer_memory_const(const struct nk_buffer*);
+NK_API nk_size nk_buffer_total(struct nk_buffer*);
+
+/* ==============================================================
+ *
+ *                          STRING
+ *
+ * ===============================================================*/
+/*  Basic string buffer which is only used in context with the text editor
+ *  to manage and manipulate dynamic or fixed size string content. This is _NOT_
+ *  the default string handling method. The only instance you should have any contact
+ *  with this API is if you interact with an `nk_text_edit` object inside one of the
+ *  copy and paste functions and even there only for more advanced cases. */
+struct nk_str {
+    struct nk_buffer buffer;
+    int len; /* in codepoints/runes/glyphs */
+};
+
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+NK_API void nk_str_init_default(struct nk_str*);
+#endif
+NK_API void nk_str_init(struct nk_str*, const struct nk_allocator*, nk_size size);
+NK_API void nk_str_init_fixed(struct nk_str*, void *memory, nk_size size);
+NK_API void nk_str_clear(struct nk_str*);
+NK_API void nk_str_free(struct nk_str*);
+
+NK_API int nk_str_append_text_char(struct nk_str*, const char*, int);
+NK_API int nk_str_append_str_char(struct nk_str*, const char*);
+NK_API int nk_str_append_text_utf8(struct nk_str*, const char*, int);
+NK_API int nk_str_append_str_utf8(struct nk_str*, const char*);
+NK_API int nk_str_append_text_runes(struct nk_str*, const nk_rune*, int);
+NK_API int nk_str_append_str_runes(struct nk_str*, const nk_rune*);
+
+NK_API int nk_str_insert_at_char(struct nk_str*, int pos, const char*, int);
+NK_API int nk_str_insert_at_rune(struct nk_str*, int pos, const char*, int);
+
+NK_API int nk_str_insert_text_char(struct nk_str*, int pos, const char*, int);
+NK_API int nk_str_insert_str_char(struct nk_str*, int pos, const char*);
+NK_API int nk_str_insert_text_utf8(struct nk_str*, int pos, const char*, int);
+NK_API int nk_str_insert_str_utf8(struct nk_str*, int pos, const char*);
+NK_API int nk_str_insert_text_runes(struct nk_str*, int pos, const nk_rune*, int);
+NK_API int nk_str_insert_str_runes(struct nk_str*, int pos, const nk_rune*);
+
+NK_API void nk_str_remove_chars(struct nk_str*, int len);
+NK_API void nk_str_remove_runes(struct nk_str *str, int len);
+NK_API void nk_str_delete_chars(struct nk_str*, int pos, int len);
+NK_API void nk_str_delete_runes(struct nk_str*, int pos, int len);
+
+NK_API char *nk_str_at_char(struct nk_str*, int pos);
+NK_API char *nk_str_at_rune(struct nk_str*, int pos, nk_rune *unicode, int *len);
+NK_API nk_rune nk_str_rune_at(const struct nk_str*, int pos);
+NK_API const char *nk_str_at_char_const(const struct nk_str*, int pos);
+NK_API const char *nk_str_at_const(const struct nk_str*, int pos, nk_rune *unicode, int *len);
+
+NK_API char *nk_str_get(struct nk_str*);
+NK_API const char *nk_str_get_const(const struct nk_str*);
+NK_API int nk_str_len(struct nk_str*);
+NK_API int nk_str_len_char(struct nk_str*);
+
+/*===============================================================
+ *
+ *                      TEXT EDITOR
+ *
+ * ===============================================================*/
+/* Editing text in this library is handled by either `nk_edit_string` or
+ * `nk_edit_buffer`. But like almost everything in this library there are multiple
+ * ways of doing it and a balance between control and ease of use with memory
+ * as well as functionality controlled by flags.
+ *
+ * This library generally allows three different levels of memory control:
+ * First of is the most basic way of just providing a simple char array with
+ * string length. This method is probably the easiest way of handling simple
+ * user text input. Main upside is complete control over memory while the biggest
+ * downside in comparison with the other two approaches is missing undo/redo.
+ *
+ * For UIs that require undo/redo the second way was created. It is based on
+ * a fixed size nk_text_edit struct, which has an internal undo/redo stack.
+ * This is mainly useful if you want something more like a text editor but don't want
+ * to have a dynamically growing buffer.
+ *
+ * The final way is using a dynamically growing nk_text_edit struct, which
+ * has both a default version if you don't care where memory comes from and an
+ * allocator version if you do. While the text editor is quite powerful for its
+ * complexity I would not recommend editing gigabytes of data with it.
+ * It is rather designed for uses cases which make sense for a GUI library not for
+ * an full blown text editor.
+ */
+#ifndef NK_TEXTEDIT_UNDOSTATECOUNT
+#define NK_TEXTEDIT_UNDOSTATECOUNT     99
+#endif
+
+#ifndef NK_TEXTEDIT_UNDOCHARCOUNT
+#define NK_TEXTEDIT_UNDOCHARCOUNT      999
+#endif
+
+struct nk_text_edit;
+struct nk_clipboard {
+    nk_handle userdata;
+    nk_plugin_paste paste;
+    nk_plugin_copy copy;
+};
+
+struct nk_text_undo_record {
+   int where;
+   short insert_length;
+   short delete_length;
+   short char_storage;
+};
+
+struct nk_text_undo_state {
+   struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT];
+   nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT];
+   short undo_point;
+   short redo_point;
+   short undo_char_point;
+   short redo_char_point;
+};
+
+enum nk_text_edit_type {
+    NK_TEXT_EDIT_SINGLE_LINE,
+    NK_TEXT_EDIT_MULTI_LINE
+};
+
+enum nk_text_edit_mode {
+    NK_TEXT_EDIT_MODE_VIEW,
+    NK_TEXT_EDIT_MODE_INSERT,
+    NK_TEXT_EDIT_MODE_REPLACE
+};
+
+struct nk_text_edit {
+    struct nk_clipboard clip;
+    struct nk_str string;
+    nk_plugin_filter filter;
+    struct nk_vec2 scrollbar;
+
+    int cursor;
+    int select_start;
+    int select_end;
+    unsigned char mode;
+    unsigned char cursor_at_end_of_line;
+    unsigned char initialized;
+    unsigned char has_preferred_x;
+    unsigned char single_line;
+    unsigned char active;
+    unsigned char padding1;
+    float preferred_x;
+    struct nk_text_undo_state undo;
+};
+
+/* filter function */
+NK_API int nk_filter_default(const struct nk_text_edit*, nk_rune unicode);
+NK_API int nk_filter_ascii(const struct nk_text_edit*, nk_rune unicode);
+NK_API int nk_filter_float(const struct nk_text_edit*, nk_rune unicode);
+NK_API int nk_filter_decimal(const struct nk_text_edit*, nk_rune unicode);
+NK_API int nk_filter_hex(const struct nk_text_edit*, nk_rune unicode);
+NK_API int nk_filter_oct(const struct nk_text_edit*, nk_rune unicode);
+NK_API int nk_filter_binary(const struct nk_text_edit*, nk_rune unicode);
+
+/* text editor */
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+NK_API void nk_textedit_init_default(struct nk_text_edit*);
+#endif
+NK_API void nk_textedit_init(struct nk_text_edit*, struct nk_allocator*, nk_size size);
+NK_API void nk_textedit_init_fixed(struct nk_text_edit*, void *memory, nk_size size);
+NK_API void nk_textedit_free(struct nk_text_edit*);
+NK_API void nk_textedit_text(struct nk_text_edit*, const char*, int total_len);
+NK_API void nk_textedit_delete(struct nk_text_edit*, int where, int len);
+NK_API void nk_textedit_delete_selection(struct nk_text_edit*);
+NK_API void nk_textedit_select_all(struct nk_text_edit*);
+NK_API int nk_textedit_cut(struct nk_text_edit*);
+NK_API int nk_textedit_paste(struct nk_text_edit*, char const*, int len);
+NK_API void nk_textedit_undo(struct nk_text_edit*);
+NK_API void nk_textedit_redo(struct nk_text_edit*);
+
+/* ===============================================================
+ *
+ *                          DRAWING
+ *
+ * ===============================================================*/
+/*  This library was designed to be render backend agnostic so it does
+    not draw anything to screen. Instead all drawn shapes, widgets
+    are made of, are buffered into memory and make up a command queue.
+    Each frame therefore fills the command buffer with draw commands
+    that then need to be executed by the user and his own render backend.
+    After that the command buffer needs to be cleared and a new frame can be
+    started. It is probably important to note that the command buffer is the main
+    drawing API and the optional vertex buffer API only takes this format and
+    converts it into a hardware accessible format.
+
+    To use the command queue to draw your own widgets you can access the
+    command buffer of each window by calling `nk_window_get_canvas` after
+    previously having called `nk_begin`:
+
+        void draw_red_rectangle_widget(struct nk_context *ctx)
+        {
+            struct nk_command_buffer *canvas;
+            struct nk_input *input = &ctx->input;
+            canvas = nk_window_get_canvas(ctx);
+
+            struct nk_rect space;
+            enum nk_widget_layout_states state;
+            state = nk_widget(&space, ctx);
+            if (!state) return;
+
+            if (state != NK_WIDGET_ROM)
+                update_your_widget_by_user_input(...);
+            nk_fill_rect(canvas, space, 0, nk_rgb(255,0,0));
+        }
+
+        if (nk_begin(...)) {
+            nk_layout_row_dynamic(ctx, 25, 1);
+            draw_red_rectangle_widget(ctx);
+        }
+        nk_end(..)
+
+    Important to know if you want to create your own widgets is the `nk_widget`
+    call. It allocates space on the panel reserved for this widget to be used,
+    but also returns the state of the widget space. If your widget is not seen and does
+    not have to be updated it is '0' and you can just return. If it only has
+    to be drawn the state will be `NK_WIDGET_ROM` otherwise you can do both
+    update and draw your widget. The reason for separating is to only draw and
+    update what is actually necessary which is crucial for performance.
+*/
+enum nk_command_type {
+    NK_COMMAND_NOP,
+    NK_COMMAND_SCISSOR,
+    NK_COMMAND_LINE,
+    NK_COMMAND_CURVE,
+    NK_COMMAND_RECT,
+    NK_COMMAND_RECT_FILLED,
+    NK_COMMAND_RECT_MULTI_COLOR,
+    NK_COMMAND_CIRCLE,
+    NK_COMMAND_CIRCLE_FILLED,
+    NK_COMMAND_ARC,
+    NK_COMMAND_ARC_FILLED,
+    NK_COMMAND_TRIANGLE,
+    NK_COMMAND_TRIANGLE_FILLED,
+    NK_COMMAND_POLYGON,
+    NK_COMMAND_POLYGON_FILLED,
+    NK_COMMAND_POLYLINE,
+    NK_COMMAND_TEXT,
+    NK_COMMAND_IMAGE,
+    NK_COMMAND_CUSTOM
+};
+
+/* command base and header of every command inside the buffer */
+struct nk_command {
+    enum nk_command_type type;
+    nk_size next;
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    nk_handle userdata;
+#endif
+};
+
+struct nk_command_scissor {
+    struct nk_command header;
+    short x, y;
+    unsigned short w, h;
+};
+
+struct nk_command_line {
+    struct nk_command header;
+    unsigned short line_thickness;
+    struct nk_vec2i begin;
+    struct nk_vec2i end;
+    struct nk_color color;
+};
+
+struct nk_command_curve {
+    struct nk_command header;
+    unsigned short line_thickness;
+    struct nk_vec2i begin;
+    struct nk_vec2i end;
+    struct nk_vec2i ctrl[2];
+    struct nk_color color;
+};
+
+struct nk_command_rect {
+    struct nk_command header;
+    unsigned short rounding;
+    unsigned short line_thickness;
+    short x, y;
+    unsigned short w, h;
+    struct nk_color color;
+};
+
+struct nk_command_rect_filled {
+    struct nk_command header;
+    unsigned short rounding;
+    short x, y;
+    unsigned short w, h;
+    struct nk_color color;
+};
+
+struct nk_command_rect_multi_color {
+    struct nk_command header;
+    short x, y;
+    unsigned short w, h;
+    struct nk_color left;
+    struct nk_color top;
+    struct nk_color bottom;
+    struct nk_color right;
+};
+
+struct nk_command_triangle {
+    struct nk_command header;
+    unsigned short line_thickness;
+    struct nk_vec2i a;
+    struct nk_vec2i b;
+    struct nk_vec2i c;
+    struct nk_color color;
+};
+
+struct nk_command_triangle_filled {
+    struct nk_command header;
+    struct nk_vec2i a;
+    struct nk_vec2i b;
+    struct nk_vec2i c;
+    struct nk_color color;
+};
+
+struct nk_command_circle {
+    struct nk_command header;
+    short x, y;
+    unsigned short line_thickness;
+    unsigned short w, h;
+    struct nk_color color;
+};
+
+struct nk_command_circle_filled {
+    struct nk_command header;
+    short x, y;
+    unsigned short w, h;
+    struct nk_color color;
+};
+
+struct nk_command_arc {
+    struct nk_command header;
+    short cx, cy;
+    unsigned short r;
+    unsigned short line_thickness;
+    float a[2];
+    struct nk_color color;
+};
+
+struct nk_command_arc_filled {
+    struct nk_command header;
+    short cx, cy;
+    unsigned short r;
+    float a[2];
+    struct nk_color color;
+};
+
+struct nk_command_polygon {
+    struct nk_command header;
+    struct nk_color color;
+    unsigned short line_thickness;
+    unsigned short point_count;
+    struct nk_vec2i points[1];
+};
+
+struct nk_command_polygon_filled {
+    struct nk_command header;
+    struct nk_color color;
+    unsigned short point_count;
+    struct nk_vec2i points[1];
+};
+
+struct nk_command_polyline {
+    struct nk_command header;
+    struct nk_color color;
+    unsigned short line_thickness;
+    unsigned short point_count;
+    struct nk_vec2i points[1];
+};
+
+struct nk_command_image {
+    struct nk_command header;
+    short x, y;
+    unsigned short w, h;
+    struct nk_image img;
+    struct nk_color col;
+};
+
+typedef void (*nk_command_custom_callback)(void *canvas, short x,short y,
+    unsigned short w, unsigned short h, nk_handle callback_data);
+struct nk_command_custom {
+    struct nk_command header;
+    short x, y;
+    unsigned short w, h;
+    nk_handle callback_data;
+    nk_command_custom_callback callback;
+};
+
+struct nk_command_text {
+    struct nk_command header;
+    const struct nk_user_font *font;
+    struct nk_color background;
+    struct nk_color foreground;
+    short x, y;
+    unsigned short w, h;
+    float height;
+    int length;
+    char string[1];
+};
+
+enum nk_command_clipping {
+    NK_CLIPPING_OFF = nk_false,
+    NK_CLIPPING_ON = nk_true
+};
+
+struct nk_command_buffer {
+    struct nk_buffer *base;
+    struct nk_rect clip;
+    int use_clipping;
+    nk_handle userdata;
+    nk_size begin, end, last;
+};
+
+/* shape outlines */
+NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color);
+NK_API void nk_stroke_curve(struct nk_command_buffer*, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color);
+NK_API void nk_stroke_rect(struct nk_command_buffer*, struct nk_rect, float rounding, float line_thickness, struct nk_color);
+NK_API void nk_stroke_circle(struct nk_command_buffer*, struct nk_rect, float line_thickness, struct nk_color);
+NK_API void nk_stroke_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color);
+NK_API void nk_stroke_triangle(struct nk_command_buffer*, float, float, float, float, float, float, float line_thichness, struct nk_color);
+NK_API void nk_stroke_polyline(struct nk_command_buffer*, float *points, int point_count, float line_thickness, struct nk_color col);
+NK_API void nk_stroke_polygon(struct nk_command_buffer*, float*, int point_count, float line_thickness, struct nk_color);
+
+/* filled shades */
+NK_API void nk_fill_rect(struct nk_command_buffer*, struct nk_rect, float rounding, struct nk_color);
+NK_API void nk_fill_rect_multi_color(struct nk_command_buffer*, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom);
+NK_API void nk_fill_circle(struct nk_command_buffer*, struct nk_rect, struct nk_color);
+NK_API void nk_fill_arc(struct nk_command_buffer*, float cx, float cy, float radius, float a_min, float a_max, struct nk_color);
+NK_API void nk_fill_triangle(struct nk_command_buffer*, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color);
+NK_API void nk_fill_polygon(struct nk_command_buffer*, float*, int point_count, struct nk_color);
+
+/* misc */
+NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
+NK_API void nk_draw_text(struct nk_command_buffer*, struct nk_rect, const char *text, int len, const struct nk_user_font*, struct nk_color, struct nk_color);
+NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
+NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
+
+/* ===============================================================
+ *
+ *                          INPUT
+ *
+ * ===============================================================*/
+struct nk_mouse_button {
+    int down;
+    unsigned int clicked;
+    struct nk_vec2 clicked_pos;
+};
+struct nk_mouse {
+    struct nk_mouse_button buttons[NK_BUTTON_MAX];
+    struct nk_vec2 pos;
+    struct nk_vec2 prev;
+    struct nk_vec2 delta;
+    struct nk_vec2 scroll_delta;
+    unsigned char grab;
+    unsigned char grabbed;
+    unsigned char ungrab;
+};
+
+struct nk_key {
+    int down;
+    unsigned int clicked;
+};
+struct nk_keyboard {
+    struct nk_key keys[NK_KEY_MAX];
+    char text[NK_INPUT_MAX];
+    int text_len;
+};
+
+struct nk_input {
+    struct nk_keyboard keyboard;
+    struct nk_mouse mouse;
+};
+
+NK_API int nk_input_has_mouse_click(const struct nk_input*, enum nk_buttons);
+NK_API int nk_input_has_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
+NK_API int nk_input_has_mouse_click_down_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect, int down);
+NK_API int nk_input_is_mouse_click_in_rect(const struct nk_input*, enum nk_buttons, struct nk_rect);
+NK_API int nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, int down);
+NK_API int nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
+NK_API int nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
+NK_API int nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
+NK_API int nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
+NK_API int nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
+NK_API int nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
+NK_API int nk_input_is_mouse_released(const struct nk_input*, enum nk_buttons);
+NK_API int nk_input_is_key_pressed(const struct nk_input*, enum nk_keys);
+NK_API int nk_input_is_key_released(const struct nk_input*, enum nk_keys);
+NK_API int nk_input_is_key_down(const struct nk_input*, enum nk_keys);
+
+/* ===============================================================
+ *
+ *                          DRAW LIST
+ *
+ * ===============================================================*/
+#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+/*  The optional vertex buffer draw list provides a 2D drawing context
+    with antialiasing functionality which takes basic filled or outlined shapes
+    or a path and outputs vertexes, elements and draw commands.
+    The actual draw list API is not required to be used directly while using this
+    library since converting the default library draw command output is done by
+    just calling `nk_convert` but I decided to still make this library accessible
+    since it can be useful.
+
+    The draw list is based on a path buffering and polygon and polyline
+    rendering API which allows a lot of ways to draw 2D content to screen.
+    In fact it is probably more powerful than needed but allows even more crazy
+    things than this library provides by default.
+*/
+typedef nk_ushort nk_draw_index;
+enum nk_draw_list_stroke {
+    NK_STROKE_OPEN = nk_false,
+    /* build up path has no connection back to the beginning */
+    NK_STROKE_CLOSED = nk_true
+    /* build up path has a connection back to the beginning */
+};
+
+enum nk_draw_vertex_layout_attribute {
+    NK_VERTEX_POSITION,
+    NK_VERTEX_COLOR,
+    NK_VERTEX_TEXCOORD,
+    NK_VERTEX_ATTRIBUTE_COUNT
+};
+
+enum nk_draw_vertex_layout_format {
+    NK_FORMAT_SCHAR,
+    NK_FORMAT_SSHORT,
+    NK_FORMAT_SINT,
+    NK_FORMAT_UCHAR,
+    NK_FORMAT_USHORT,
+    NK_FORMAT_UINT,
+    NK_FORMAT_FLOAT,
+    NK_FORMAT_DOUBLE,
+
+NK_FORMAT_COLOR_BEGIN,
+    NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
+    NK_FORMAT_R16G15B16,
+    NK_FORMAT_R32G32B32,
+
+    NK_FORMAT_R8G8B8A8,
+    NK_FORMAT_B8G8R8A8,
+    NK_FORMAT_R16G15B16A16,
+    NK_FORMAT_R32G32B32A32,
+    NK_FORMAT_R32G32B32A32_FLOAT,
+    NK_FORMAT_R32G32B32A32_DOUBLE,
+
+    NK_FORMAT_RGB32,
+    NK_FORMAT_RGBA32,
+NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
+    NK_FORMAT_COUNT
+};
+
+#define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
+struct nk_draw_vertex_layout_element {
+    enum nk_draw_vertex_layout_attribute attribute;
+    enum nk_draw_vertex_layout_format format;
+    nk_size offset;
+};
+
+struct nk_draw_command {
+    unsigned int elem_count;
+    /* number of elements in the current draw batch */
+    struct nk_rect clip_rect;
+    /* current screen clipping rectangle */
+    nk_handle texture;
+    /* current texture to set */
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    nk_handle userdata;
+#endif
+};
+
+struct nk_draw_list {
+    struct nk_rect clip_rect;
+    struct nk_vec2 circle_vtx[12];
+    struct nk_convert_config config;
+
+    struct nk_buffer *buffer;
+    struct nk_buffer *vertices;
+    struct nk_buffer *elements;
+
+    unsigned int element_count;
+    unsigned int vertex_count;
+    unsigned int cmd_count;
+    nk_size cmd_offset;
+
+    unsigned int path_count;
+    unsigned int path_offset;
+
+    enum nk_anti_aliasing line_AA;
+    enum nk_anti_aliasing shape_AA;
+
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    nk_handle userdata;
+#endif
+};
+
+/* draw list */
+NK_API void nk_draw_list_init(struct nk_draw_list*);
+NK_API void nk_draw_list_setup(struct nk_draw_list*, const struct nk_convert_config*, struct nk_buffer *cmds, struct nk_buffer *vertices, struct nk_buffer *elements, enum nk_anti_aliasing line_aa,enum nk_anti_aliasing shape_aa);
+NK_API void nk_draw_list_clear(struct nk_draw_list*);
+
+/* drawing */
+#define nk_draw_list_foreach(cmd, can, b) for((cmd)=nk__draw_list_begin(can, b); (cmd)!=0; (cmd)=nk__draw_list_next(cmd, b, can))
+NK_API const struct nk_draw_command* nk__draw_list_begin(const struct nk_draw_list*, const struct nk_buffer*);
+NK_API const struct nk_draw_command* nk__draw_list_next(const struct nk_draw_command*, const struct nk_buffer*, const struct nk_draw_list*);
+NK_API const struct nk_draw_command* nk__draw_list_end(const struct nk_draw_list*, const struct nk_buffer*);
+NK_API void nk_draw_list_clear(struct nk_draw_list *list);
+
+/* path */
+NK_API void nk_draw_list_path_clear(struct nk_draw_list*);
+NK_API void nk_draw_list_path_line_to(struct nk_draw_list*, struct nk_vec2 pos);
+NK_API void nk_draw_list_path_arc_to_fast(struct nk_draw_list*, struct nk_vec2 center, float radius, int a_min, int a_max);
+NK_API void nk_draw_list_path_arc_to(struct nk_draw_list*, struct nk_vec2 center, float radius, float a_min, float a_max, unsigned int segments);
+NK_API void nk_draw_list_path_rect_to(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, float rounding);
+NK_API void nk_draw_list_path_curve_to(struct nk_draw_list*, struct nk_vec2 p2, struct nk_vec2 p3, struct nk_vec2 p4, unsigned int num_segments);
+NK_API void nk_draw_list_path_fill(struct nk_draw_list*, struct nk_color);
+NK_API void nk_draw_list_path_stroke(struct nk_draw_list*, struct nk_color, enum nk_draw_list_stroke closed, float thickness);
+
+/* stroke */
+NK_API void nk_draw_list_stroke_line(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_color, float thickness);
+NK_API void nk_draw_list_stroke_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding, float thickness);
+NK_API void nk_draw_list_stroke_triangle(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_vec2 c, struct nk_color, float thickness);
+NK_API void nk_draw_list_stroke_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color, unsigned int segs, float thickness);
+NK_API void nk_draw_list_stroke_curve(struct nk_draw_list*, struct nk_vec2 p0, struct nk_vec2 cp0, struct nk_vec2 cp1, struct nk_vec2 p1, struct nk_color, unsigned int segments, float thickness);
+NK_API void nk_draw_list_stroke_poly_line(struct nk_draw_list*, const struct nk_vec2 *pnts, const unsigned int cnt, struct nk_color, enum nk_draw_list_stroke, float thickness, enum nk_anti_aliasing);
+
+/* fill */
+NK_API void nk_draw_list_fill_rect(struct nk_draw_list*, struct nk_rect rect, struct nk_color, float rounding);
+NK_API void nk_draw_list_fill_rect_multi_color(struct nk_draw_list*, struct nk_rect rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom);
+NK_API void nk_draw_list_fill_triangle(struct nk_draw_list*, struct nk_vec2 a, struct nk_vec2 b, struct nk_vec2 c, struct nk_color);
+NK_API void nk_draw_list_fill_circle(struct nk_draw_list*, struct nk_vec2 center, float radius, struct nk_color col, unsigned int segs);
+NK_API void nk_draw_list_fill_poly_convex(struct nk_draw_list*, const struct nk_vec2 *points, const unsigned int count, struct nk_color, enum nk_anti_aliasing);
+
+/* misc */
+NK_API void nk_draw_list_add_image(struct nk_draw_list*, struct nk_image texture, struct nk_rect rect, struct nk_color);
+NK_API void nk_draw_list_add_text(struct nk_draw_list*, const struct nk_user_font*, struct nk_rect, const char *text, int len, float font_height, struct nk_color);
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata);
+#endif
+
+#endif
+
+/* ===============================================================
+ *
+ *                          GUI
+ *
+ * ===============================================================*/
+enum nk_style_item_type {
+    NK_STYLE_ITEM_COLOR,
+    NK_STYLE_ITEM_IMAGE
+};
+
+union nk_style_item_data {
+    struct nk_image image;
+    struct nk_color color;
+};
+
+struct nk_style_item {
+    enum nk_style_item_type type;
+    union nk_style_item_data data;
+};
+
+struct nk_style_text {
+    struct nk_color color;
+    struct nk_vec2 padding;
+};
+
+struct nk_style_button {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+
+    /* text */
+    struct nk_color text_background;
+    struct nk_color text_normal;
+    struct nk_color text_hover;
+    struct nk_color text_active;
+    nk_flags text_alignment;
+
+    /* properties */
+    float border;
+    float rounding;
+    struct nk_vec2 padding;
+    struct nk_vec2 image_padding;
+    struct nk_vec2 touch_padding;
+
+    /* optional user callbacks */
+    nk_handle userdata;
+    void(*draw_begin)(struct nk_command_buffer*, nk_handle userdata);
+    void(*draw_end)(struct nk_command_buffer*, nk_handle userdata);
+};
+
+struct nk_style_toggle {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+
+    /* cursor */
+    struct nk_style_item cursor_normal;
+    struct nk_style_item cursor_hover;
+
+    /* text */
+    struct nk_color text_normal;
+    struct nk_color text_hover;
+    struct nk_color text_active;
+    struct nk_color text_background;
+    nk_flags text_alignment;
+
+    /* properties */
+    struct nk_vec2 padding;
+    struct nk_vec2 touch_padding;
+    float spacing;
+    float border;
+
+    /* optional user callbacks */
+    nk_handle userdata;
+    void(*draw_begin)(struct nk_command_buffer*, nk_handle);
+    void(*draw_end)(struct nk_command_buffer*, nk_handle);
+};
+
+struct nk_style_selectable {
+    /* background (inactive) */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item pressed;
+
+    /* background (active) */
+    struct nk_style_item normal_active;
+    struct nk_style_item hover_active;
+    struct nk_style_item pressed_active;
+
+    /* text color (inactive) */
+    struct nk_color text_normal;
+    struct nk_color text_hover;
+    struct nk_color text_pressed;
+
+    /* text color (active) */
+    struct nk_color text_normal_active;
+    struct nk_color text_hover_active;
+    struct nk_color text_pressed_active;
+    struct nk_color text_background;
+    nk_flags text_alignment;
+
+    /* properties */
+    float rounding;
+    struct nk_vec2 padding;
+    struct nk_vec2 touch_padding;
+    struct nk_vec2 image_padding;
+
+    /* optional user callbacks */
+    nk_handle userdata;
+    void(*draw_begin)(struct nk_command_buffer*, nk_handle);
+    void(*draw_end)(struct nk_command_buffer*, nk_handle);
+};
+
+struct nk_style_slider {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+
+    /* background bar */
+    struct nk_color bar_normal;
+    struct nk_color bar_hover;
+    struct nk_color bar_active;
+    struct nk_color bar_filled;
+
+    /* cursor */
+    struct nk_style_item cursor_normal;
+    struct nk_style_item cursor_hover;
+    struct nk_style_item cursor_active;
+
+    /* properties */
+    float border;
+    float rounding;
+    float bar_height;
+    struct nk_vec2 padding;
+    struct nk_vec2 spacing;
+    struct nk_vec2 cursor_size;
+
+    /* optional buttons */
+    int show_buttons;
+    struct nk_style_button inc_button;
+    struct nk_style_button dec_button;
+    enum nk_symbol_type inc_symbol;
+    enum nk_symbol_type dec_symbol;
+
+    /* optional user callbacks */
+    nk_handle userdata;
+    void(*draw_begin)(struct nk_command_buffer*, nk_handle);
+    void(*draw_end)(struct nk_command_buffer*, nk_handle);
+};
+
+struct nk_style_progress {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+
+    /* cursor */
+    struct nk_style_item cursor_normal;
+    struct nk_style_item cursor_hover;
+    struct nk_style_item cursor_active;
+    struct nk_color cursor_border_color;
+
+    /* properties */
+    float rounding;
+    float border;
+    float cursor_border;
+    float cursor_rounding;
+    struct nk_vec2 padding;
+
+    /* optional user callbacks */
+    nk_handle userdata;
+    void(*draw_begin)(struct nk_command_buffer*, nk_handle);
+    void(*draw_end)(struct nk_command_buffer*, nk_handle);
+};
+
+struct nk_style_scrollbar {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+
+    /* cursor */
+    struct nk_style_item cursor_normal;
+    struct nk_style_item cursor_hover;
+    struct nk_style_item cursor_active;
+    struct nk_color cursor_border_color;
+
+    /* properties */
+    float border;
+    float rounding;
+    float border_cursor;
+    float rounding_cursor;
+    struct nk_vec2 padding;
+
+    /* optional buttons */
+    int show_buttons;
+    struct nk_style_button inc_button;
+    struct nk_style_button dec_button;
+    enum nk_symbol_type inc_symbol;
+    enum nk_symbol_type dec_symbol;
+
+    /* optional user callbacks */
+    nk_handle userdata;
+    void(*draw_begin)(struct nk_command_buffer*, nk_handle);
+    void(*draw_end)(struct nk_command_buffer*, nk_handle);
+};
+
+struct nk_style_edit {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+    struct nk_style_scrollbar scrollbar;
+
+    /* cursor  */
+    struct nk_color cursor_normal;
+    struct nk_color cursor_hover;
+    struct nk_color cursor_text_normal;
+    struct nk_color cursor_text_hover;
+
+    /* text (unselected) */
+    struct nk_color text_normal;
+    struct nk_color text_hover;
+    struct nk_color text_active;
+
+    /* text (selected) */
+    struct nk_color selected_normal;
+    struct nk_color selected_hover;
+    struct nk_color selected_text_normal;
+    struct nk_color selected_text_hover;
+
+    /* properties */
+    float border;
+    float rounding;
+    float cursor_size;
+    struct nk_vec2 scrollbar_size;
+    struct nk_vec2 padding;
+    float row_padding;
+};
+
+struct nk_style_property {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+
+    /* text */
+    struct nk_color label_normal;
+    struct nk_color label_hover;
+    struct nk_color label_active;
+
+    /* symbols */
+    enum nk_symbol_type sym_left;
+    enum nk_symbol_type sym_right;
+
+    /* properties */
+    float border;
+    float rounding;
+    struct nk_vec2 padding;
+
+    struct nk_style_edit edit;
+    struct nk_style_button inc_button;
+    struct nk_style_button dec_button;
+
+    /* optional user callbacks */
+    nk_handle userdata;
+    void(*draw_begin)(struct nk_command_buffer*, nk_handle);
+    void(*draw_end)(struct nk_command_buffer*, nk_handle);
+};
+
+struct nk_style_chart {
+    /* colors */
+    struct nk_style_item background;
+    struct nk_color border_color;
+    struct nk_color selected_color;
+    struct nk_color color;
+
+    /* properties */
+    float border;
+    float rounding;
+    struct nk_vec2 padding;
+};
+
+struct nk_style_combo {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+    struct nk_color border_color;
+
+    /* label */
+    struct nk_color label_normal;
+    struct nk_color label_hover;
+    struct nk_color label_active;
+
+    /* symbol */
+    struct nk_color symbol_normal;
+    struct nk_color symbol_hover;
+    struct nk_color symbol_active;
+
+    /* button */
+    struct nk_style_button button;
+    enum nk_symbol_type sym_normal;
+    enum nk_symbol_type sym_hover;
+    enum nk_symbol_type sym_active;
+
+    /* properties */
+    float border;
+    float rounding;
+    struct nk_vec2 content_padding;
+    struct nk_vec2 button_padding;
+    struct nk_vec2 spacing;
+};
+
+struct nk_style_tab {
+    /* background */
+    struct nk_style_item background;
+    struct nk_color border_color;
+    struct nk_color text;
+
+    /* button */
+    struct nk_style_button tab_maximize_button;
+    struct nk_style_button tab_minimize_button;
+    struct nk_style_button node_maximize_button;
+    struct nk_style_button node_minimize_button;
+    enum nk_symbol_type sym_minimize;
+    enum nk_symbol_type sym_maximize;
+
+    /* properties */
+    float border;
+    float rounding;
+    float indent;
+    struct nk_vec2 padding;
+    struct nk_vec2 spacing;
+};
+
+enum nk_style_header_align {
+    NK_HEADER_LEFT,
+    NK_HEADER_RIGHT
+};
+struct nk_style_window_header {
+    /* background */
+    struct nk_style_item normal;
+    struct nk_style_item hover;
+    struct nk_style_item active;
+
+    /* button */
+    struct nk_style_button close_button;
+    struct nk_style_button minimize_button;
+    enum nk_symbol_type close_symbol;
+    enum nk_symbol_type minimize_symbol;
+    enum nk_symbol_type maximize_symbol;
+
+    /* title */
+    struct nk_color label_normal;
+    struct nk_color label_hover;
+    struct nk_color label_active;
+
+    /* properties */
+    enum nk_style_header_align align;
+    struct nk_vec2 padding;
+    struct nk_vec2 label_padding;
+    struct nk_vec2 spacing;
+};
+
+struct nk_style_window {
+    struct nk_style_window_header header;
+    struct nk_style_item fixed_background;
+    struct nk_color background;
+
+    struct nk_color border_color;
+    struct nk_color popup_border_color;
+    struct nk_color combo_border_color;
+    struct nk_color contextual_border_color;
+    struct nk_color menu_border_color;
+    struct nk_color group_border_color;
+    struct nk_color tooltip_border_color;
+    struct nk_style_item scaler;
+
+    float border;
+    float combo_border;
+    float contextual_border;
+    float menu_border;
+    float group_border;
+    float tooltip_border;
+    float popup_border;
+    float min_row_height_padding;
+
+    float rounding;
+    struct nk_vec2 spacing;
+    struct nk_vec2 scrollbar_size;
+    struct nk_vec2 min_size;
+
+    struct nk_vec2 padding;
+    struct nk_vec2 group_padding;
+    struct nk_vec2 popup_padding;
+    struct nk_vec2 combo_padding;
+    struct nk_vec2 contextual_padding;
+    struct nk_vec2 menu_padding;
+    struct nk_vec2 tooltip_padding;
+};
+
+struct nk_style {
+    const struct nk_user_font *font;
+    const struct nk_cursor *cursors[NK_CURSOR_COUNT];
+    const struct nk_cursor *cursor_active;
+    struct nk_cursor *cursor_last;
+    int cursor_visible;
+
+    struct nk_style_text text;
+    struct nk_style_button button;
+    struct nk_style_button contextual_button;
+    struct nk_style_button menu_button;
+    struct nk_style_toggle option;
+    struct nk_style_toggle checkbox;
+    struct nk_style_selectable selectable;
+    struct nk_style_slider slider;
+    struct nk_style_progress progress;
+    struct nk_style_property property;
+    struct nk_style_edit edit;
+    struct nk_style_chart chart;
+    struct nk_style_scrollbar scrollh;
+    struct nk_style_scrollbar scrollv;
+    struct nk_style_tab tab;
+    struct nk_style_combo combo;
+    struct nk_style_window window;
+};
+
+NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
+NK_API struct nk_style_item nk_style_item_color(struct nk_color);
+NK_API struct nk_style_item nk_style_item_hide(void);
+
+/*==============================================================
+ *                          PANEL
+ * =============================================================*/
+#ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
+#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
+#endif
+#ifndef NK_CHART_MAX_SLOT
+#define NK_CHART_MAX_SLOT 4
+#endif
+
+enum nk_panel_type {
+    NK_PANEL_WINDOW     = NK_FLAG(0),
+    NK_PANEL_GROUP      = NK_FLAG(1),
+    NK_PANEL_POPUP      = NK_FLAG(2),
+    NK_PANEL_CONTEXTUAL = NK_FLAG(4),
+    NK_PANEL_COMBO      = NK_FLAG(5),
+    NK_PANEL_MENU       = NK_FLAG(6),
+    NK_PANEL_TOOLTIP    = NK_FLAG(7)
+};
+enum nk_panel_set {
+    NK_PANEL_SET_NONBLOCK = NK_PANEL_CONTEXTUAL|NK_PANEL_COMBO|NK_PANEL_MENU|NK_PANEL_TOOLTIP,
+    NK_PANEL_SET_POPUP = NK_PANEL_SET_NONBLOCK|NK_PANEL_POPUP,
+    NK_PANEL_SET_SUB = NK_PANEL_SET_POPUP|NK_PANEL_GROUP
+};
+
+struct nk_chart_slot {
+    enum nk_chart_type type;
+    struct nk_color color;
+    struct nk_color highlight;
+    float min, max, range;
+    int count;
+    struct nk_vec2 last;
+    int index;
+};
+
+struct nk_chart {
+    int slot;
+    float x, y, w, h;
+    struct nk_chart_slot slots[NK_CHART_MAX_SLOT];
+};
+
+enum nk_panel_row_layout_type {
+    NK_LAYOUT_DYNAMIC_FIXED = 0,
+    NK_LAYOUT_DYNAMIC_ROW,
+    NK_LAYOUT_DYNAMIC_FREE,
+    NK_LAYOUT_DYNAMIC,
+    NK_LAYOUT_STATIC_FIXED,
+    NK_LAYOUT_STATIC_ROW,
+    NK_LAYOUT_STATIC_FREE,
+    NK_LAYOUT_STATIC,
+    NK_LAYOUT_TEMPLATE,
+    NK_LAYOUT_COUNT
+};
+struct nk_row_layout {
+    enum nk_panel_row_layout_type type;
+    int index;
+    float height;
+    float min_height;
+    int columns;
+    const float *ratio;
+    float item_width;
+    float item_height;
+    float item_offset;
+    float filled;
+    struct nk_rect item;
+    int tree_depth;
+    float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS];
+};
+
+struct nk_popup_buffer {
+    nk_size begin;
+    nk_size parent;
+    nk_size last;
+    nk_size end;
+    int active;
+};
+
+struct nk_menu_state {
+    float x, y, w, h;
+    struct nk_scroll offset;
+};
+
+struct nk_panel {
+    enum nk_panel_type type;
+    nk_flags flags;
+    struct nk_rect bounds;
+    nk_uint *offset_x;
+    nk_uint *offset_y;
+    float at_x, at_y, max_x;
+    float footer_height;
+    float header_height;
+    float border;
+    unsigned int has_scrolling;
+    struct nk_rect clip;
+    struct nk_menu_state menu;
+    struct nk_row_layout row;
+    struct nk_chart chart;
+    struct nk_command_buffer *buffer;
+    struct nk_panel *parent;
+};
+
+/*==============================================================
+ *                          WINDOW
+ * =============================================================*/
+#ifndef NK_WINDOW_MAX_NAME
+#define NK_WINDOW_MAX_NAME 64
+#endif
+
+struct nk_table;
+enum nk_window_flags {
+    NK_WINDOW_PRIVATE       = NK_FLAG(11),
+    NK_WINDOW_DYNAMIC       = NK_WINDOW_PRIVATE,
+    /* special window type growing up in height while being filled to a certain maximum height */
+    NK_WINDOW_ROM           = NK_FLAG(12),
+    /* sets window widgets into a read only mode and does not allow input changes */
+    NK_WINDOW_NOT_INTERACTIVE = NK_WINDOW_ROM|NK_WINDOW_NO_INPUT,
+    /* prevents all interaction caused by input to either window or widgets inside */
+    NK_WINDOW_HIDDEN        = NK_FLAG(13),
+    /* Hides window and stops any window interaction and drawing */
+    NK_WINDOW_CLOSED        = NK_FLAG(14),
+    /* Directly closes and frees the window at the end of the frame */
+    NK_WINDOW_MINIMIZED     = NK_FLAG(15),
+    /* marks the window as minimized */
+    NK_WINDOW_REMOVE_ROM    = NK_FLAG(16)
+    /* Removes read only mode at the end of the window */
+};
+
+struct nk_popup_state {
+    struct nk_window *win;
+    enum nk_panel_type type;
+    struct nk_popup_buffer buf;
+    nk_hash name;
+    int active;
+    unsigned combo_count;
+    unsigned con_count, con_old;
+    unsigned active_con;
+    struct nk_rect header;
+};
+
+struct nk_edit_state {
+    nk_hash name;
+    unsigned int seq;
+    unsigned int old;
+    int active, prev;
+    int cursor;
+    int sel_start;
+    int sel_end;
+    struct nk_scroll scrollbar;
+    unsigned char mode;
+    unsigned char single_line;
+};
+
+struct nk_property_state {
+    int active, prev;
+    char buffer[NK_MAX_NUMBER_BUFFER];
+    int length;
+    int cursor;
+    int select_start;
+    int select_end;
+    nk_hash name;
+    unsigned int seq;
+    unsigned int old;
+    int state;
+};
+
+struct nk_window {
+    unsigned int seq;
+    nk_hash name;
+    char name_string[NK_WINDOW_MAX_NAME];
+    nk_flags flags;
+
+    struct nk_rect bounds;
+    struct nk_scroll scrollbar;
+    struct nk_command_buffer buffer;
+    struct nk_panel *layout;
+    float scrollbar_hiding_timer;
+
+    /* persistent widget state */
+    struct nk_property_state property;
+    struct nk_popup_state popup;
+    struct nk_edit_state edit;
+    unsigned int scrolled;
+
+    struct nk_table *tables;
+    unsigned int table_count;
+
+    /* window list hooks */
+    struct nk_window *next;
+    struct nk_window *prev;
+    struct nk_window *parent;
+};
+
+/*==============================================================
+ *                          STACK
+ * =============================================================*/
+/* The style modifier stack can be used to temporarily change a
+ * property inside `nk_style`. For example if you want a special
+ * red button you can temporarily push the old button color onto a stack
+ * draw the button with a red color and then you just pop the old color
+ * back from the stack:
+ *
+ *      nk_style_push_style_item(ctx, &ctx->style.button.normal, nk_style_item_color(nk_rgb(255,0,0)));
+ *      nk_style_push_style_item(ctx, &ctx->style.button.hover, nk_style_item_color(nk_rgb(255,0,0)));
+ *      nk_style_push_style_item(ctx, &ctx->style.button.active, nk_style_item_color(nk_rgb(255,0,0)));
+ *      nk_style_push_vec2(ctx, &cx->style.button.padding, nk_vec2(2,2));
+ *
+ *      nk_button(...);
+ *
+ *      nk_style_pop_style_item(ctx);
+ *      nk_style_pop_style_item(ctx);
+ *      nk_style_pop_style_item(ctx);
+ *      nk_style_pop_vec2(ctx);
+ *
+ * Nuklear has a stack for style_items, float properties, vector properties,
+ * flags, colors, fonts and for button_behavior. Each has it's own fixed size stack
+ * which can be changed at compile time.
+ */
+#ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
+#define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
+#endif
+
+#ifndef NK_FONT_STACK_SIZE
+#define NK_FONT_STACK_SIZE 8
+#endif
+
+#ifndef NK_STYLE_ITEM_STACK_SIZE
+#define NK_STYLE_ITEM_STACK_SIZE 16
+#endif
+
+#ifndef NK_FLOAT_STACK_SIZE
+#define NK_FLOAT_STACK_SIZE 32
+#endif
+
+#ifndef NK_VECTOR_STACK_SIZE
+#define NK_VECTOR_STACK_SIZE 16
+#endif
+
+#ifndef NK_FLAGS_STACK_SIZE
+#define NK_FLAGS_STACK_SIZE 32
+#endif
+
+#ifndef NK_COLOR_STACK_SIZE
+#define NK_COLOR_STACK_SIZE 32
+#endif
+
+#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
+    struct nk_config_stack_##name##_element {\
+        prefix##_##type *address;\
+        prefix##_##type old_value;\
+    }
+#define NK_CONFIG_STACK(type,size)\
+    struct nk_config_stack_##type {\
+        int head;\
+        struct nk_config_stack_##type##_element elements[size];\
+    }
+
+#define nk_float float
+NK_CONFIGURATION_STACK_TYPE(struct nk, style_item, style_item);
+NK_CONFIGURATION_STACK_TYPE(nk ,float, float);
+NK_CONFIGURATION_STACK_TYPE(struct nk, vec2, vec2);
+NK_CONFIGURATION_STACK_TYPE(nk ,flags, flags);
+NK_CONFIGURATION_STACK_TYPE(struct nk, color, color);
+NK_CONFIGURATION_STACK_TYPE(const struct nk, user_font, user_font*);
+NK_CONFIGURATION_STACK_TYPE(enum nk, button_behavior, button_behavior);
+
+NK_CONFIG_STACK(style_item, NK_STYLE_ITEM_STACK_SIZE);
+NK_CONFIG_STACK(float, NK_FLOAT_STACK_SIZE);
+NK_CONFIG_STACK(vec2, NK_VECTOR_STACK_SIZE);
+NK_CONFIG_STACK(flags, NK_FLAGS_STACK_SIZE);
+NK_CONFIG_STACK(color, NK_COLOR_STACK_SIZE);
+NK_CONFIG_STACK(user_font, NK_FONT_STACK_SIZE);
+NK_CONFIG_STACK(button_behavior, NK_BUTTON_BEHAVIOR_STACK_SIZE);
+
+struct nk_configuration_stacks {
+    struct nk_config_stack_style_item style_items;
+    struct nk_config_stack_float floats;
+    struct nk_config_stack_vec2 vectors;
+    struct nk_config_stack_flags flags;
+    struct nk_config_stack_color colors;
+    struct nk_config_stack_user_font fonts;
+    struct nk_config_stack_button_behavior button_behaviors;
+};
+
+/*==============================================================
+ *                          CONTEXT
+ * =============================================================*/
+#define NK_VALUE_PAGE_CAPACITY \
+    (((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint))) / 2)
+
+struct nk_table {
+    unsigned int seq;
+    unsigned int size;
+    nk_hash keys[NK_VALUE_PAGE_CAPACITY];
+    nk_uint values[NK_VALUE_PAGE_CAPACITY];
+    struct nk_table *next, *prev;
+};
+
+union nk_page_data {
+    struct nk_table tbl;
+    struct nk_panel pan;
+    struct nk_window win;
+};
+
+struct nk_page_element {
+    union nk_page_data data;
+    struct nk_page_element *next;
+    struct nk_page_element *prev;
+};
+
+struct nk_page {
+    unsigned int size;
+    struct nk_page *next;
+    struct nk_page_element win[1];
+};
+
+struct nk_pool {
+    struct nk_allocator alloc;
+    enum nk_allocation_type type;
+    unsigned int page_count;
+    struct nk_page *pages;
+    struct nk_page_element *freelist;
+    unsigned capacity;
+    nk_size size;
+    nk_size cap;
+};
+
+struct nk_context {
+/* public: can be accessed freely */
+    struct nk_input input;
+    struct nk_style style;
+    struct nk_buffer memory;
+    struct nk_clipboard clip;
+    nk_flags last_widget_state;
+    enum nk_button_behavior button_behavior;
+    struct nk_configuration_stacks stacks;
+    float delta_time_seconds;
+
+/* private:
+    should only be accessed if you
+    know what you are doing */
+#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+    struct nk_draw_list draw_list;
+#endif
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    nk_handle userdata;
+#endif
+    /* text editor objects are quite big because of an internal
+     * undo/redo stack. Therefore it does not make sense to have one for
+     * each window for temporary use cases, so I only provide *one* instance
+     * for all windows. This works because the content is cleared anyway */
+    struct nk_text_edit text_edit;
+    /* draw buffer used for overlay drawing operation like cursor */
+    struct nk_command_buffer overlay;
+
+    /* windows */
+    int build;
+    int use_pool;
+    struct nk_pool pool;
+    struct nk_window *begin;
+    struct nk_window *end;
+    struct nk_window *active;
+    struct nk_window *current;
+    struct nk_page_element *freelist;
+    unsigned int count;
+    unsigned int seq;
+};
+
+/* ==============================================================
+ *                          MATH
+ * =============================================================== */
+#define NK_PI 3.141592654f
+#define NK_UTF_INVALID 0xFFFD
+#define NK_MAX_FLOAT_PRECISION 2
+
+#define NK_UNUSED(x) ((void)(x))
+#define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
+#define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
+#define NK_ABS(a) (((a) < 0) ? -(a) : (a))
+#define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
+#define NK_INBOX(px, py, x, y, w, h)\
+    (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
+#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
+    (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0)))
+#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
+    (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
+
+#define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
+#define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
+#define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
+#define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
+
+#define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
+#define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
+#define nk_zero_struct(s) nk_zero(&s, sizeof(s))
+
+/* ==============================================================
+ *                          ALIGNMENT
+ * =============================================================== */
+/* Pointer to Integer type conversion for pointer alignment */
+#if defined(__PTRDIFF_TYPE__) /* This case should work for GCC*/
+# define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
+# define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
+#elif !defined(__GNUC__) /* works for compilers other than LLVM */
+# define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
+# define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
+#elif defined(NK_USE_FIXED_TYPES) /* used if we have <stdint.h> */
+# define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
+# define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
+#else /* generates warning but works */
+# define NK_UINT_TO_PTR(x) ((void*)(x))
+# define NK_PTR_TO_UINT(x) ((nk_size)(x))
+#endif
+
+#define NK_ALIGN_PTR(x, mask)\
+    (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
+#define NK_ALIGN_PTR_BACK(x, mask)\
+    (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
+
+#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
+#define NK_CONTAINER_OF(ptr,type,member)\
+    (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+template<typename T> struct nk_alignof;
+template<typename T, int size_diff> struct nk_helper{enum {value = size_diff};};
+template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};};
+template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
+    diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
+#define NK_ALIGNOF(t) (nk_alignof<t>::value)
+#elif defined(_MSC_VER)
+#define NK_ALIGNOF(t) (__alignof(t))
+#else
+#define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
+#endif
+
+#endif /* NK_NUKLEAR_H_ */
+/*
+ * ==============================================================
+ *
+ *                          IMPLEMENTATION
+ *
+ * ===============================================================
+ */
+#ifdef NK_IMPLEMENTATION
+
+#ifndef NK_POOL_DEFAULT_CAPACITY
+#define NK_POOL_DEFAULT_CAPACITY 16
+#endif
+
+#ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE
+#define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024)
+#endif
+
+#ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE
+#define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024)
+#endif
+
+/* standard library headers */
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+#include <stdlib.h> /* malloc, free */
+#endif
+#ifdef NK_INCLUDE_STANDARD_IO
+#include <stdio.h> /* fopen, fclose,... */
+#endif
+#ifdef NK_INCLUDE_STANDARD_VARARGS
+#include <stdarg.h> /* valist, va_start, va_end, ... */
+#endif
+#ifndef NK_ASSERT
+#include <assert.h>
+#define NK_ASSERT(expr) assert(expr)
+#endif
+
+#ifndef NK_MEMSET
+#define NK_MEMSET nk_memset
+#endif
+#ifndef NK_MEMCPY
+#define NK_MEMCPY nk_memcopy
+#endif
+#ifndef NK_SQRT
+#define NK_SQRT nk_sqrt
+#endif
+#ifndef NK_SIN
+#define NK_SIN nk_sin
+#endif
+#ifndef NK_COS
+#define NK_COS nk_cos
+#endif
+#ifndef NK_STRTOD
+#define NK_STRTOD nk_strtod
+#endif
+#ifndef NK_DTOA
+#define NK_DTOA nk_dtoa
+#endif
+
+#define NK_DEFAULT (-1)
+
+#ifndef NK_VSNPRINTF
+/* If your compiler does support `vsnprintf` I would highly recommend
+ * defining this to vsnprintf instead since `vsprintf` is basically
+ * unbelievable unsafe and should *NEVER* be used. But I have to support
+ * it since C89 only provides this unsafe version. */
+  #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\
+      (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
+      (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\
+      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\
+       defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
+      #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a)
+  #else
+    #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a)
+  #endif
+#endif
+
+#define NK_SCHAR_MIN (-127)
+#define NK_SCHAR_MAX 127
+#define NK_UCHAR_MIN 0
+#define NK_UCHAR_MAX 256
+#define NK_SSHORT_MIN (-32767)
+#define NK_SSHORT_MAX 32767
+#define NK_USHORT_MIN 0
+#define NK_USHORT_MAX 65535
+#define NK_SINT_MIN (-2147483647)
+#define NK_SINT_MAX 2147483647
+#define NK_UINT_MIN 0
+#define NK_UINT_MAX 4294967295u
+
+/* Make sure correct type size:
+ * This will fire with a negative subscript error if the type sizes
+ * are set incorrectly by the compiler, and compile out if not */
+NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
+NK_STATIC_ASSERT(sizeof(nk_ptr) == sizeof(void*));
+NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
+NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
+NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
+NK_STATIC_ASSERT(sizeof(nk_short) == 2);
+NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
+NK_STATIC_ASSERT(sizeof(nk_int) == 4);
+NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
+
+NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
+#define NK_FLOAT_PRECISION 0.00000000000001
+
+NK_GLOBAL const struct nk_color nk_red = {255,0,0,255};
+NK_GLOBAL const struct nk_color nk_green = {0,255,0,255};
+NK_GLOBAL const struct nk_color nk_blue = {0,0,255,255};
+NK_GLOBAL const struct nk_color nk_white = {255,255,255,255};
+NK_GLOBAL const struct nk_color nk_black = {0,0,0,255};
+NK_GLOBAL const struct nk_color nk_yellow = {255,255,0,255};
+
+/*
+ * ==============================================================
+ *
+ *                          MATH
+ *
+ * ===============================================================
+ */
+/*  Since nuklear is supposed to work on all systems providing floating point
+    math without any dependencies I also had to implement my own math functions
+    for sqrt, sin and cos. Since the actual highly accurate implementations for
+    the standard library functions are quite complex and I do not need high
+    precision for my use cases I use approximations.
+
+    Sqrt
+    ----
+    For square root nuklear uses the famous fast inverse square root:
+    https://en.wikipedia.org/wiki/Fast_inverse_square_root with
+    slightly tweaked magic constant. While on today's hardware it is
+    probably not faster it is still fast and accurate enough for
+    nuklear's use cases. IMPORTANT: this requires float format IEEE 754
+
+    Sine/Cosine
+    -----------
+    All constants inside both function are generated Remez's minimax
+    approximations for value range 0...2*PI. The reason why I decided to
+    approximate exactly that range is that nuklear only needs sine and
+    cosine to generate circles which only requires that exact range.
+    In addition I used Remez instead of Taylor for additional precision:
+    www.lolengine.net/blog/2011/12/21/better-function-approximations.
+
+    The tool I used to generate constants for both sine and cosine
+    (it can actually approximate a lot more functions) can be
+    found here: www.lolengine.net/wiki/oss/lolremez
+*/
+NK_INTERN float
+nk_inv_sqrt(float number)
+{
+    float x2;
+    const float threehalfs = 1.5f;
+    union {nk_uint i; float f;} conv = {0};
+    conv.f = number;
+    x2 = number * 0.5f;
+    conv.i = 0x5f375A84 - (conv.i >> 1);
+    conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
+    return conv.f;
+}
+
+NK_INTERN float
+nk_sqrt(float x)
+{
+    return x * nk_inv_sqrt(x);
+}
+
+NK_INTERN float
+nk_sin(float x)
+{
+    NK_STORAGE const float a0 = +1.91059300966915117e-31f;
+    NK_STORAGE const float a1 = +1.00086760103908896f;
+    NK_STORAGE const float a2 = -1.21276126894734565e-2f;
+    NK_STORAGE const float a3 = -1.38078780785773762e-1f;
+    NK_STORAGE const float a4 = -2.67353392911981221e-2f;
+    NK_STORAGE const float a5 = +2.08026600266304389e-2f;
+    NK_STORAGE const float a6 = -3.03996055049204407e-3f;
+    NK_STORAGE const float a7 = +1.38235642404333740e-4f;
+    return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
+}
+
+NK_INTERN float
+nk_cos(float x)
+{
+    NK_STORAGE const float a0 = +1.00238601909309722f;
+    NK_STORAGE const float a1 = -3.81919947353040024e-2f;
+    NK_STORAGE const float a2 = -3.94382342128062756e-1f;
+    NK_STORAGE const float a3 = -1.18134036025221444e-1f;
+    NK_STORAGE const float a4 = +1.07123798512170878e-1f;
+    NK_STORAGE const float a5 = -1.86637164165180873e-2f;
+    NK_STORAGE const float a6 = +9.90140908664079833e-4f;
+    NK_STORAGE const float a7 = -5.23022132118824778e-14f;
+    return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
+}
+
+NK_INTERN nk_uint
+nk_round_up_pow2(nk_uint v)
+{
+    v--;
+    v |= v >> 1;
+    v |= v >> 2;
+    v |= v >> 4;
+    v |= v >> 8;
+    v |= v >> 16;
+    v++;
+    return v;
+}
+
+NK_API struct nk_rect
+nk_get_null_rect(void)
+{
+    return nk_null_rect;
+}
+
+NK_API struct nk_rect
+nk_rect(float x, float y, float w, float h)
+{
+    struct nk_rect r;
+    r.x = x; r.y = y;
+    r.w = w; r.h = h;
+    return r;
+}
+
+NK_API struct nk_rect
+nk_recti(int x, int y, int w, int h)
+{
+    struct nk_rect r;
+    r.x = (float)x;
+    r.y = (float)y;
+    r.w = (float)w;
+    r.h = (float)h;
+    return r;
+}
+
+NK_API struct nk_rect
+nk_recta(struct nk_vec2 pos, struct nk_vec2 size)
+{
+    return nk_rect(pos.x, pos.y, size.x, size.y);
+}
+
+NK_API struct nk_rect
+nk_rectv(const float *r)
+{
+    return nk_rect(r[0], r[1], r[2], r[3]);
+}
+
+NK_API struct nk_rect
+nk_rectiv(const int *r)
+{
+    return nk_recti(r[0], r[1], r[2], r[3]);
+}
+
+NK_API struct nk_vec2
+nk_rect_pos(struct nk_rect r)
+{
+    struct nk_vec2 ret;
+    ret.x = r.x; ret.y = r.y;
+    return ret;
+}
+
+NK_API struct nk_vec2
+nk_rect_size(struct nk_rect r)
+{
+    struct nk_vec2 ret;
+    ret.x = r.w; ret.y = r.h;
+    return ret;
+}
+
+NK_INTERN struct nk_rect
+nk_shrink_rect(struct nk_rect r, float amount)
+{
+    struct nk_rect res;
+    r.w = NK_MAX(r.w, 2 * amount);
+    r.h = NK_MAX(r.h, 2 * amount);
+    res.x = r.x + amount;
+    res.y = r.y + amount;
+    res.w = r.w - 2 * amount;
+    res.h = r.h - 2 * amount;
+    return res;
+}
+
+NK_INTERN struct nk_rect
+nk_pad_rect(struct nk_rect r, struct nk_vec2 pad)
+{
+    r.w = NK_MAX(r.w, 2 * pad.x);
+    r.h = NK_MAX(r.h, 2 * pad.y);
+    r.x += pad.x; r.y += pad.y;
+    r.w -= 2 * pad.x;
+    r.h -= 2 * pad.y;
+    return r;
+}
+
+NK_API struct nk_vec2
+nk_vec2(float x, float y)
+{
+    struct nk_vec2 ret;
+    ret.x = x; ret.y = y;
+    return ret;
+}
+
+NK_API struct nk_vec2
+nk_vec2i(int x, int y)
+{
+    struct nk_vec2 ret;
+    ret.x = (float)x;
+    ret.y = (float)y;
+    return ret;
+}
+
+NK_API struct nk_vec2
+nk_vec2v(const float *v)
+{
+    return nk_vec2(v[0], v[1]);
+}
+
+NK_API struct nk_vec2
+nk_vec2iv(const int *v)
+{
+    return nk_vec2i(v[0], v[1]);
+}
+
+/*
+ * ==============================================================
+ *
+ *                          UTIL
+ *
+ * ===============================================================
+ */
+NK_INTERN int nk_str_match_here(const char *regexp, const char *text);
+NK_INTERN int nk_str_match_star(int c, const char *regexp, const char *text);
+NK_INTERN int nk_is_lower(int c) {return (c >= 'a' && c <= 'z') || (c >= 0xE0 && c <= 0xFF);}
+NK_INTERN int nk_is_upper(int c){return (c >= 'A' && c <= 'Z') || (c >= 0xC0 && c <= 0xDF);}
+NK_INTERN int nk_to_upper(int c) {return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;}
+NK_INTERN int nk_to_lower(int c) {return (c >= 'A' && c <= 'Z') ? (c - ('a' + 'A')) : c;}
+
+NK_INTERN void*
+nk_memcopy(void *dst0, const void *src0, nk_size length)
+{
+    nk_ptr t;
+    char *dst = (char*)dst0;
+    const char *src = (const char*)src0;
+    if (length == 0 || dst == src)
+        goto done;
+
+    #define nk_word int
+    #define nk_wsize sizeof(nk_word)
+    #define nk_wmask (nk_wsize-1)
+    #define NK_TLOOP(s) if (t) NK_TLOOP1(s)
+    #define NK_TLOOP1(s) do { s; } while (--t)
+
+    if (dst < src) {
+        t = (nk_ptr)src; /* only need low bits */
+        if ((t | (nk_ptr)dst) & nk_wmask) {
+            if ((t ^ (nk_ptr)dst) & nk_wmask || length < nk_wsize)
+                t = length;
+            else
+                t = nk_wsize - (t & nk_wmask);
+            length -= t;
+            NK_TLOOP1(*dst++ = *src++);
+        }
+        t = length / nk_wsize;
+        NK_TLOOP(*(nk_word*)(void*)dst = *(const nk_word*)(const void*)src;
+            src += nk_wsize; dst += nk_wsize);
+        t = length & nk_wmask;
+        NK_TLOOP(*dst++ = *src++);
+    } else {
+        src += length;
+        dst += length;
+        t = (nk_ptr)src;
+        if ((t | (nk_ptr)dst) & nk_wmask) {
+            if ((t ^ (nk_ptr)dst) & nk_wmask || length <= nk_wsize)
+                t = length;
+            else
+                t &= nk_wmask;
+            length -= t;
+            NK_TLOOP1(*--dst = *--src);
+        }
+        t = length / nk_wsize;
+        NK_TLOOP(src -= nk_wsize; dst -= nk_wsize;
+            *(nk_word*)(void*)dst = *(const nk_word*)(const void*)src);
+        t = length & nk_wmask;
+        NK_TLOOP(*--dst = *--src);
+    }
+    #undef nk_word
+    #undef nk_wsize
+    #undef nk_wmask
+    #undef NK_TLOOP
+    #undef NK_TLOOP1
+done:
+    return (dst0);
+}
+
+NK_INTERN void
+nk_memset(void *ptr, int c0, nk_size size)
+{
+    #define nk_word unsigned
+    #define nk_wsize sizeof(nk_word)
+    #define nk_wmask (nk_wsize - 1)
+    nk_byte *dst = (nk_byte*)ptr;
+    unsigned c = 0;
+    nk_size t = 0;
+
+    if ((c = (nk_byte)c0) != 0) {
+        c = (c << 8) | c; /* at least 16-bits  */
+        if (sizeof(unsigned int) > 2)
+            c = (c << 16) | c; /* at least 32-bits*/
+    }
+
+    /* too small of a word count */
+    dst = (nk_byte*)ptr;
+    if (size < 3 * nk_wsize) {
+        while (size--) *dst++ = (nk_byte)c0;
+        return;
+    }
+
+    /* align destination */
+    if ((t = NK_PTR_TO_UINT(dst) & nk_wmask) != 0) {
+        t = nk_wsize -t;
+        size -= t;
+        do {
+            *dst++ = (nk_byte)c0;
+        } while (--t != 0);
+    }
+
+    /* fill word */
+    t = size / nk_wsize;
+    do {
+        *(nk_word*)((void*)dst) = c;
+        dst += nk_wsize;
+    } while (--t != 0);
+
+    /* fill trailing bytes */
+    t = (size & nk_wmask);
+    if (t != 0) {
+        do {
+            *dst++ = (nk_byte)c0;
+        } while (--t != 0);
+    }
+
+    #undef nk_word
+    #undef nk_wsize
+    #undef nk_wmask
+}
+
+NK_INTERN void
+nk_zero(void *ptr, nk_size size)
+{
+    NK_ASSERT(ptr);
+    NK_MEMSET(ptr, 0, size);
+}
+
+NK_API int
+nk_strlen(const char *str)
+{
+    int siz = 0;
+    NK_ASSERT(str);
+    while (str && *str++ != '\0') siz++;
+    return siz;
+}
+
+NK_API int
+nk_strtoi(const char *str, const char **endptr)
+{
+    int neg = 1;
+    const char *p = str;
+    int value = 0;
+
+    NK_ASSERT(str);
+    if (!str) return 0;
+
+    /* skip whitespace */
+    while (*p == ' ') p++;
+    if (*p == '-') {
+        neg = -1;
+        p++;
+    }
+    while (*p && *p >= '0' && *p <= '9') {
+        value = value * 10 + (int) (*p - '0');
+        p++;
+    }
+    if (endptr)
+        *endptr = p;
+    return neg*value;
+}
+
+NK_API double
+nk_strtod(const char *str, const char **endptr)
+{
+    double m;
+    double neg = 1.0;
+    const char *p = str;
+    double value = 0;
+    double number = 0;
+
+    NK_ASSERT(str);
+    if (!str) return 0;
+
+    /* skip whitespace */
+    while (*p == ' ') p++;
+    if (*p == '-') {
+        neg = -1.0;
+        p++;
+    }
+
+    while (*p && *p != '.' && *p != 'e') {
+        value = value * 10.0 + (double) (*p - '0');
+        p++;
+    }
+
+    if (*p == '.') {
+        p++;
+        for(m = 0.1; *p && *p != 'e'; p++ ) {
+            value = value + (double) (*p - '0') * m;
+            m *= 0.1;
+        }
+    }
+    if (*p == 'e') {
+        int i, pow, div;
+        p++;
+        if (*p == '-') {
+            div = nk_true;
+            p++;
+        } else if (*p == '+') {
+            div = nk_false;
+            p++;
+        } else div = nk_false;
+
+        for (pow = 0; *p; p++)
+            pow = pow * 10 + (int) (*p - '0');
+
+        for (m = 1.0, i = 0; i < pow; i++)
+            m *= 10.0;
+
+        if (div)
+            value /= m;
+        else value *= m;
+    }
+    number = value * neg;
+    if (endptr)
+        *endptr = p;
+    return number;
+}
+
+NK_API float
+nk_strtof(const char *str, const char **endptr)
+{
+    float float_value;
+    double double_value;
+    double_value = NK_STRTOD(str, endptr);
+    float_value = (float)double_value;
+    return float_value;
+}
+
+NK_API int
+nk_stricmp(const char *s1, const char *s2)
+{
+    nk_int c1,c2,d;
+    do {
+        c1 = *s1++;
+        c2 = *s2++;
+        d = c1 - c2;
+        while (d) {
+            if (c1 <= 'Z' && c1 >= 'A') {
+                d += ('a' - 'A');
+                if (!d) break;
+            }
+            if (c2 <= 'Z' && c2 >= 'A') {
+                d -= ('a' - 'A');
+                if (!d) break;
+            }
+            return ((d >= 0) << 1) - 1;
+        }
+    } while (c1);
+    return 0;
+}
+
+NK_API int
+nk_stricmpn(const char *s1, const char *s2, int n)
+{
+    int c1,c2,d;
+    NK_ASSERT(n >= 0);
+    do {
+        c1 = *s1++;
+        c2 = *s2++;
+        if (!n--) return 0;
+
+        d = c1 - c2;
+        while (d) {
+            if (c1 <= 'Z' && c1 >= 'A') {
+                d += ('a' - 'A');
+                if (!d) break;
+            }
+            if (c2 <= 'Z' && c2 >= 'A') {
+                d -= ('a' - 'A');
+                if (!d) break;
+            }
+            return ((d >= 0) << 1) - 1;
+        }
+    } while (c1);
+    return 0;
+}
+
+NK_INTERN int
+nk_str_match_here(const char *regexp, const char *text)
+{
+    if (regexp[0] == '\0')
+        return 1;
+    if (regexp[1] == '*')
+        return nk_str_match_star(regexp[0], regexp+2, text);
+    if (regexp[0] == '$' && regexp[1] == '\0')
+        return *text == '\0';
+    if (*text!='\0' && (regexp[0]=='.' || regexp[0]==*text))
+        return nk_str_match_here(regexp+1, text+1);
+    return 0;
+}
+
+NK_INTERN int
+nk_str_match_star(int c, const char *regexp, const char *text)
+{
+    do {/* a '* matches zero or more instances */
+        if (nk_str_match_here(regexp, text))
+            return 1;
+    } while (*text != '\0' && (*text++ == c || c == '.'));
+    return 0;
+}
+
+NK_API int
+nk_strfilter(const char *text, const char *regexp)
+{
+    /*
+    c    matches any literal character c
+    .    matches any single character
+    ^    matches the beginning of the input string
+    $    matches the end of the input string
+    *    matches zero or more occurrences of the previous character*/
+    if (regexp[0] == '^')
+        return nk_str_match_here(regexp+1, text);
+    do {    /* must look even if string is empty */
+        if (nk_str_match_here(regexp, text))
+            return 1;
+    } while (*text++ != '\0');
+    return 0;
+}
+
+NK_API int
+nk_strmatch_fuzzy_text(const char *str, int str_len,
+    const char *pattern, int *out_score)
+{
+    /* Returns true if each character in pattern is found sequentially within str
+     * if found then out_score is also set. Score value has no intrinsic meaning.
+     * Range varies with pattern. Can only compare scores with same search pattern. */
+
+    /* ------- scores --------- */
+    /* bonus for adjacent matches */
+    #define NK_ADJACENCY_BONUS 5
+    /* bonus if match occurs after a separator */
+    #define NK_SEPARATOR_BONUS 10
+    /* bonus if match is uppercase and prev is lower */
+    #define NK_CAMEL_BONUS 10
+    /* penalty applied for every letter in str before the first match */
+    #define NK_LEADING_LETTER_PENALTY (-3)
+    /* maximum penalty for leading letters */
+    #define NK_MAX_LEADING_LETTER_PENALTY (-9)
+    /* penalty for every letter that doesn't matter */
+    #define NK_UNMATCHED_LETTER_PENALTY (-1)
+
+    /* loop variables */
+    int score = 0;
+    char const * pattern_iter = pattern;
+    int str_iter = 0;
+    int prev_matched = nk_false;
+    int prev_lower = nk_false;
+    /* true so if first letter match gets separator bonus*/
+    int prev_separator = nk_true;
+
+    /* use "best" matched letter if multiple string letters match the pattern */
+    char const * best_letter = 0;
+    int best_letter_score = 0;
+
+    /* loop over strings */
+    NK_ASSERT(str);
+    NK_ASSERT(pattern);
+    if (!str || !str_len || !pattern) return 0;
+    while (str_iter < str_len)
+    {
+        const char pattern_letter = *pattern_iter;
+        const char str_letter = str[str_iter];
+
+        int next_match = *pattern_iter != '\0' &&
+            nk_to_lower(pattern_letter) == nk_to_lower(str_letter);
+        int rematch = best_letter && nk_to_upper(*best_letter) == nk_to_upper(str_letter);
+
+        int advanced = next_match && best_letter;
+        int pattern_repeat = best_letter && *pattern_iter != '\0';
+        pattern_repeat = pattern_repeat &&
+            nk_to_lower(*best_letter) == nk_to_lower(pattern_letter);
+
+        if (advanced || pattern_repeat) {
+            score += best_letter_score;
+            best_letter = 0;
+            best_letter_score = 0;
+        }
+
+        if (next_match || rematch)
+        {
+            int new_score = 0;
+            /* Apply penalty for each letter before the first pattern match */
+            if (pattern_iter == pattern) {
+                int count = (int)(&str[str_iter] - str);
+                int penalty = NK_LEADING_LETTER_PENALTY * count;
+                if (penalty < NK_MAX_LEADING_LETTER_PENALTY)
+                    penalty = NK_MAX_LEADING_LETTER_PENALTY;
+
+                score += penalty;
+            }
+
+            /* apply bonus for consecutive bonuses */
+            if (prev_matched)
+                new_score += NK_ADJACENCY_BONUS;
+
+            /* apply bonus for matches after a separator */
+            if (prev_separator)
+                new_score += NK_SEPARATOR_BONUS;
+
+            /* apply bonus across camel case boundaries */
+            if (prev_lower && nk_is_upper(str_letter))
+                new_score += NK_CAMEL_BONUS;
+
+            /* update pattern iter IFF the next pattern letter was matched */
+            if (next_match)
+                ++pattern_iter;
+
+            /* update best letter in str which may be for a "next" letter or a rematch */
+            if (new_score >= best_letter_score) {
+                /* apply penalty for now skipped letter */
+                if (best_letter != 0)
+                    score += NK_UNMATCHED_LETTER_PENALTY;
+
+                best_letter = &str[str_iter];
+                best_letter_score = new_score;
+            }
+            prev_matched = nk_true;
+        } else {
+            score += NK_UNMATCHED_LETTER_PENALTY;
+            prev_matched = nk_false;
+        }
+
+        /* separators should be more easily defined */
+        prev_lower = nk_is_lower(str_letter) != 0;
+        prev_separator = str_letter == '_' || str_letter == ' ';
+
+        ++str_iter;
+    }
+
+    /* apply score for last match */
+    if (best_letter)
+        score += best_letter_score;
+
+    /* did not match full pattern */
+    if (*pattern_iter != '\0')
+        return nk_false;
+
+    if (out_score)
+        *out_score = score;
+    return nk_true;
+}
+
+NK_API int
+nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score)
+{return nk_strmatch_fuzzy_text(str, nk_strlen(str), pattern, out_score);}
+
+NK_INTERN int
+nk_string_float_limit(char *string, int prec)
+{
+    int dot = 0;
+    char *c = string;
+    while (*c) {
+        if (*c == '.') {
+            dot = 1;
+            c++;
+            continue;
+        }
+        if (dot == (prec+1)) {
+            *c = 0;
+            break;
+        }
+        if (dot > 0) dot++;
+        c++;
+    }
+    return (int)(c - string);
+}
+
+NK_INTERN double
+nk_pow(double x, int n)
+{
+    /*  check the sign of n */
+    double r = 1;
+    int plus = n >= 0;
+    n = (plus) ? n : -n;
+    while (n > 0) {
+        if ((n & 1) == 1)
+            r *= x;
+        n /= 2;
+        x *= x;
+    }
+    return plus ? r : 1.0 / r;
+}
+
+NK_INTERN int
+nk_ifloord(double x)
+{
+    x = (double)((int)x - ((x < 0.0) ? 1 : 0));
+    return (int)x;
+}
+
+NK_INTERN int
+nk_ifloorf(float x)
+{
+    x = (float)((int)x - ((x < 0.0f) ? 1 : 0));
+    return (int)x;
+}
+
+NK_INTERN int
+nk_iceilf(float x)
+{
+    if (x >= 0) {
+        int i = (int)x;
+        return (x > i) ? i+1: i;
+    } else {
+        int t = (int)x;
+        float r = x - (float)t;
+        return (r > 0.0f) ? t+1: t;
+    }
+}
+
+NK_INTERN int
+nk_log10(double n)
+{
+    int neg;
+    int ret;
+    int exp = 0;
+
+    neg = (n < 0) ? 1 : 0;
+    ret = (neg) ? (int)-n : (int)n;
+    while ((ret / 10) > 0) {
+        ret /= 10;
+        exp++;
+    }
+    if (neg) exp = -exp;
+    return exp;
+}
+
+NK_INTERN void
+nk_strrev_ascii(char *s)
+{
+    int len = nk_strlen(s);
+    int end = len / 2;
+    int i = 0;
+    char t;
+    for (; i < end; ++i) {
+        t = s[i];
+        s[i] = s[len - 1 - i];
+        s[len -1 - i] = t;
+    }
+}
+
+NK_INTERN char*
+nk_itoa(char *s, long n)
+{
+    long i = 0;
+    if (n == 0) {
+        s[i++] = '0';
+        s[i] = 0;
+        return s;
+    }
+    if (n < 0) {
+        s[i++] = '-';
+        n = -n;
+    }
+    while (n > 0) {
+        s[i++] = (char)('0' + (n % 10));
+        n /= 10;
+    }
+    s[i] = 0;
+    if (s[0] == '-')
+        ++s;
+
+    nk_strrev_ascii(s);
+    return s;
+}
+
+NK_INTERN char*
+nk_dtoa(char *s, double n)
+{
+    int useExp = 0;
+    int digit = 0, m = 0, m1 = 0;
+    char *c = s;
+    int neg = 0;
+
+    NK_ASSERT(s);
+    if (!s) return 0;
+
+    if (n == 0.0) {
+        s[0] = '0'; s[1] = '\0';
+        return s;
+    }
+
+    neg = (n < 0);
+    if (neg) n = -n;
+
+    /* calculate magnitude */
+    m = nk_log10(n);
+    useExp = (m >= 14 || (neg && m >= 9) || m <= -9);
+    if (neg) *(c++) = '-';
+
+    /* set up for scientific notation */
+    if (useExp) {
+        if (m < 0)
+           m -= 1;
+        n = n / (double)nk_pow(10.0, m);
+        m1 = m;
+        m = 0;
+    }
+    if (m < 1.0) {
+        m = 0;
+    }
+
+    /* convert the number */
+    while (n > NK_FLOAT_PRECISION || m >= 0) {
+        double weight = nk_pow(10.0, m);
+        if (weight > 0) {
+            double t = (double)n / weight;
+            digit = nk_ifloord(t);
+            n -= ((double)digit * weight);
+            *(c++) = (char)('0' + (char)digit);
+        }
+        if (m == 0 && n > 0)
+            *(c++) = '.';
+        m--;
+    }
+
+    if (useExp) {
+        /* convert the exponent */
+        int i, j;
+        *(c++) = 'e';
+        if (m1 > 0) {
+            *(c++) = '+';
+        } else {
+            *(c++) = '-';
+            m1 = -m1;
+        }
+        m = 0;
+        while (m1 > 0) {
+            *(c++) = (char)('0' + (char)(m1 % 10));
+            m1 /= 10;
+            m++;
+        }
+        c -= m;
+        for (i = 0, j = m-1; i<j; i++, j--) {
+            /* swap without temporary */
+            c[i] ^= c[j];
+            c[j] ^= c[i];
+            c[i] ^= c[j];
+        }
+        c += m;
+    }
+    *(c) = '\0';
+    return s;
+}
+
+#ifdef NK_INCLUDE_STANDARD_VARARGS
+#ifndef NK_INCLUDE_STANDARD_IO
+static int
+nk_vsnprintf(char *buf, int buf_size, const char *fmt, va_list args)
+{
+    enum nk_arg_type {
+        NK_ARG_TYPE_CHAR,
+        NK_ARG_TYPE_SHORT,
+        NK_ARG_TYPE_DEFAULT,
+        NK_ARG_TYPE_LONG
+    };
+    enum nk_arg_flags {
+        NK_ARG_FLAG_LEFT = 0x01,
+        NK_ARG_FLAG_PLUS = 0x02,
+        NK_ARG_FLAG_SPACE = 0x04,
+        NK_ARG_FLAG_NUM = 0x10,
+        NK_ARG_FLAG_ZERO = 0x20
+    };
+
+    char number_buffer[NK_MAX_NUMBER_BUFFER];
+    enum nk_arg_type arg_type = NK_ARG_TYPE_DEFAULT;
+    int precision = NK_DEFAULT;
+    int width = NK_DEFAULT;
+    nk_flags flag = 0;
+
+    int len = 0;
+    int result = -1;
+    const char *iter = fmt;
+
+    NK_ASSERT(buf);
+    NK_ASSERT(buf_size);
+    if (!buf || !buf_size || !fmt) return 0;
+    for (iter = fmt; *iter && len < buf_size; iter++) {
+        /* copy all non-format characters */
+        while (*iter && (*iter != '%') && (len < buf_size))
+            buf[len++] = *iter++;
+        if (!(*iter) || len >= buf_size) break;
+        iter++;
+
+        /* flag arguments */
+        while (*iter) {
+            if (*iter == '-') flag |= NK_ARG_FLAG_LEFT;
+            else if (*iter == '+') flag |= NK_ARG_FLAG_PLUS;
+            else if (*iter == ' ') flag |= NK_ARG_FLAG_SPACE;
+            else if (*iter == '#') flag |= NK_ARG_FLAG_NUM;
+            else if (*iter == '0') flag |= NK_ARG_FLAG_ZERO;
+            else break;
+            iter++;
+        }
+
+        /* width argument */
+        width = NK_DEFAULT;
+        if (*iter >= '1' && *iter <= '9') {
+            const char *end;
+            width = nk_strtoi(iter, &end);
+            if (end == iter)
+                width = -1;
+            else iter = end;
+        } else if (*iter == '*') {
+            width = va_arg(args, int);
+            iter++;
+        }
+
+        /* precision argument */
+        precision = NK_DEFAULT;
+        if (*iter == '.') {
+            iter++;
+            if (*iter == '*') {
+                precision = va_arg(args, int);
+                iter++;
+            } else {
+                const char *end;
+                precision = nk_strtoi(iter, &end);
+                if (end == iter)
+                    precision = -1;
+                else iter = end;
+            }
+        }
+
+        /* length modifier */
+        if (*iter == 'h') {
+            if (*(iter+1) == 'h') {
+                arg_type = NK_ARG_TYPE_CHAR;
+                iter++;
+            } else arg_type = NK_ARG_TYPE_SHORT;
+            iter++;
+        } else if (*iter == 'l') {
+            arg_type = NK_ARG_TYPE_LONG;
+            iter++;
+        } else arg_type = NK_ARG_TYPE_DEFAULT;
+
+        /* specifier */
+        if (*iter == '%') {
+            NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
+            NK_ASSERT(precision == NK_DEFAULT);
+            NK_ASSERT(width == NK_DEFAULT);
+            if (len < buf_size)
+                buf[len++] = '%';
+        } else if (*iter == 's') {
+            /* string  */
+            const char *str = va_arg(args, const char*);
+            NK_ASSERT(str != buf && "buffer and argument are not allowed to overlap!");
+            NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
+            NK_ASSERT(precision == NK_DEFAULT);
+            NK_ASSERT(width == NK_DEFAULT);
+            if (str == buf) return -1;
+            while (str && *str && len < buf_size)
+                buf[len++] = *str++;
+        } else if (*iter == 'n') {
+            /* current length callback */
+            signed int *n = va_arg(args, int*);
+            NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
+            NK_ASSERT(precision == NK_DEFAULT);
+            NK_ASSERT(width == NK_DEFAULT);
+            if (n) *n = len;
+        } else if (*iter == 'c' || *iter == 'i' || *iter == 'd') {
+            /* signed integer */
+            long value = 0;
+            const char *num_iter;
+            int num_len, num_print, padding;
+            int cur_precision = NK_MAX(precision, 1);
+            int cur_width = NK_MAX(width, 0);
+
+            /* retrieve correct value type */
+            if (arg_type == NK_ARG_TYPE_CHAR)
+                value = (signed char)va_arg(args, int);
+            else if (arg_type == NK_ARG_TYPE_SHORT)
+                value = (signed short)va_arg(args, int);
+            else if (arg_type == NK_ARG_TYPE_LONG)
+                value = va_arg(args, signed long);
+            else if (*iter == 'c')
+                value = (unsigned char)va_arg(args, int);
+            else value = va_arg(args, signed int);
+
+            /* convert number to string */
+            nk_itoa(number_buffer, value);
+            num_len = nk_strlen(number_buffer);
+            padding = NK_MAX(cur_width - NK_MAX(cur_precision, num_len), 0);
+            if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
+                padding = NK_MAX(padding-1, 0);
+
+            /* fill left padding up to a total of `width` characters */
+            if (!(flag & NK_ARG_FLAG_LEFT)) {
+                while (padding-- > 0 && (len < buf_size)) {
+                    if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
+                        buf[len++] = '0';
+                    else buf[len++] = ' ';
+                }
+            }
+
+            /* copy string value representation into buffer */
+            if ((flag & NK_ARG_FLAG_PLUS) && value >= 0 && len < buf_size)
+                buf[len++] = '+';
+            else if ((flag & NK_ARG_FLAG_SPACE) && value >= 0 && len < buf_size)
+                buf[len++] = ' ';
+
+            /* fill up to precision number of digits with '0' */
+            num_print = NK_MAX(cur_precision, num_len);
+            while (precision && (num_print > num_len) && (len < buf_size)) {
+                buf[len++] = '0';
+                num_print--;
+            }
+
+            /* copy string value representation into buffer */
+            num_iter = number_buffer;
+            while (precision && *num_iter && len < buf_size)
+                buf[len++] = *num_iter++;
+
+            /* fill right padding up to width characters */
+            if (flag & NK_ARG_FLAG_LEFT) {
+                while ((padding-- > 0) && (len < buf_size))
+                    buf[len++] = ' ';
+            }
+        } else if (*iter == 'o' || *iter == 'x' || *iter == 'X' || *iter == 'u') {
+            /* unsigned integer */
+            unsigned long value = 0;
+            int num_len = 0, num_print, padding = 0;
+            int cur_precision = NK_MAX(precision, 1);
+            int cur_width = NK_MAX(width, 0);
+            unsigned int base = (*iter == 'o') ? 8: (*iter == 'u')? 10: 16;
+
+            /* print oct/hex/dec value */
+            const char *upper_output_format = "0123456789ABCDEF";
+            const char *lower_output_format = "0123456789abcdef";
+            const char *output_format = (*iter == 'x') ?
+                lower_output_format: upper_output_format;
+
+            /* retrieve correct value type */
+            if (arg_type == NK_ARG_TYPE_CHAR)
+                value = (unsigned char)va_arg(args, int);
+            else if (arg_type == NK_ARG_TYPE_SHORT)
+                value = (unsigned short)va_arg(args, int);
+            else if (arg_type == NK_ARG_TYPE_LONG)
+                value = va_arg(args, unsigned long);
+            else value = va_arg(args, unsigned int);
+
+            do {
+                /* convert decimal number into hex/oct number */
+                int digit = output_format[value % base];
+                if (num_len < NK_MAX_NUMBER_BUFFER)
+                    number_buffer[num_len++] = (char)digit;
+                value /= base;
+            } while (value > 0);
+
+            num_print = NK_MAX(cur_precision, num_len);
+            padding = NK_MAX(cur_width - NK_MAX(cur_precision, num_len), 0);
+            if (flag & NK_ARG_FLAG_NUM)
+                padding = NK_MAX(padding-1, 0);
+
+            /* fill left padding up to a total of `width` characters */
+            if (!(flag & NK_ARG_FLAG_LEFT)) {
+                while ((padding-- > 0) && (len < buf_size)) {
+                    if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
+                        buf[len++] = '0';
+                    else buf[len++] = ' ';
+                }
+            }
+
+            /* fill up to precision number of digits */
+            if (num_print && (flag & NK_ARG_FLAG_NUM)) {
+                if ((*iter == 'o') && (len < buf_size)) {
+                    buf[len++] = '0';
+                } else if ((*iter == 'x') && ((len+1) < buf_size)) {
+                    buf[len++] = '0';
+                    buf[len++] = 'x';
+                } else if ((*iter == 'X') && ((len+1) < buf_size)) {
+                    buf[len++] = '0';
+                    buf[len++] = 'X';
+                }
+            }
+            while (precision && (num_print > num_len) && (len < buf_size)) {
+                buf[len++] = '0';
+                num_print--;
+            }
+
+            /* reverse number direction */
+            while (num_len > 0) {
+                if (precision && (len < buf_size))
+                    buf[len++] = number_buffer[num_len-1];
+                num_len--;
+            }
+
+            /* fill right padding up to width characters */
+            if (flag & NK_ARG_FLAG_LEFT) {
+                while ((padding-- > 0) && (len < buf_size))
+                    buf[len++] = ' ';
+            }
+        } else if (*iter == 'f') {
+            /* floating point */
+            const char *num_iter;
+            int cur_precision = (precision < 0) ? 6: precision;
+            int prefix, cur_width = NK_MAX(width, 0);
+            double value = va_arg(args, double);
+            int num_len = 0, frac_len = 0, dot = 0;
+            int padding = 0;
+
+            NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
+            NK_DTOA(number_buffer, value);
+            num_len = nk_strlen(number_buffer);
+
+            /* calculate padding */
+            num_iter = number_buffer;
+            while (*num_iter && *num_iter != '.')
+                num_iter++;
+
+            prefix = (*num_iter == '.')?(int)(num_iter - number_buffer)+1:0;
+            padding = NK_MAX(cur_width - (prefix + NK_MIN(cur_precision, num_len - prefix)) , 0);
+            if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
+                padding = NK_MAX(padding-1, 0);
+
+            /* fill left padding up to a total of `width` characters */
+            if (!(flag & NK_ARG_FLAG_LEFT)) {
+                while (padding-- > 0 && (len < buf_size)) {
+                    if (flag & NK_ARG_FLAG_ZERO)
+                        buf[len++] = '0';
+                    else buf[len++] = ' ';
+                }
+            }
+
+            /* copy string value representation into buffer */
+            num_iter = number_buffer;
+            if ((flag & NK_ARG_FLAG_PLUS) && (value >= 0) && (len < buf_size))
+                buf[len++] = '+';
+            else if ((flag & NK_ARG_FLAG_SPACE) && (value >= 0) && (len < buf_size))
+                buf[len++] = ' ';
+            while (*num_iter) {
+                if (dot) frac_len++;
+                if (len < buf_size)
+                    buf[len++] = *num_iter;
+                if (*num_iter == '.') dot = 1;
+                if (frac_len >= cur_precision) break;
+                num_iter++;
+            }
+
+            /* fill number up to precision */
+            while (frac_len < cur_precision) {
+                if (!dot && len < buf_size) {
+                    buf[len++] = '.';
+                    dot = 1;
+                }
+                if (len < buf_size)
+                    buf[len++] = '0';
+                frac_len++;
+            }
+
+            /* fill right padding up to width characters */
+            if (flag & NK_ARG_FLAG_LEFT) {
+                while ((padding-- > 0) && (len < buf_size))
+                    buf[len++] = ' ';
+            }
+        } else {
+            /* Specifier not supported: g,G,e,E,p,z */
+            NK_ASSERT(0 && "specifier is not supported!");
+            return result;
+        }
+    }
+    buf[(len >= buf_size)?(buf_size-1):len] = 0;
+    result = (len >= buf_size)?-1:len;
+    return result;
+}
+#endif
+
+NK_INTERN int
+nk_strfmt(char *buf, int buf_size, const char *fmt, va_list args)
+{
+    int result = -1;
+    NK_ASSERT(buf);
+    NK_ASSERT(buf_size);
+    if (!buf || !buf_size || !fmt) return 0;
+#ifdef NK_INCLUDE_STANDARD_IO
+    result = NK_VSNPRINTF(buf, (nk_size)buf_size, fmt, args);
+    result = (result >= buf_size) ? -1: result;
+    buf[buf_size-1] = 0;
+#else
+    result = nk_vsnprintf(buf, buf_size, fmt, args);
+#endif
+    return result;
+}
+#endif
+
+NK_API nk_hash
+nk_murmur_hash(const void * key, int len, nk_hash seed)
+{
+    /* 32-Bit MurmurHash3: https://code.google.com/p/smhasher/wiki/MurmurHash3*/
+    #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
+    union {const nk_uint *i; const nk_byte *b;} conv = {0};
+    const nk_byte *data = (const nk_byte*)key;
+    const int nblocks = len/4;
+    nk_uint h1 = seed;
+    const nk_uint c1 = 0xcc9e2d51;
+    const nk_uint c2 = 0x1b873593;
+    const nk_byte *tail;
+    const nk_uint *blocks;
+    nk_uint k1;
+    int i;
+
+    /* body */
+    if (!key) return 0;
+    conv.b = (data + nblocks*4);
+    blocks = (const nk_uint*)conv.i;
+    for (i = -nblocks; i; ++i) {
+        k1 = blocks[i];
+        k1 *= c1;
+        k1 = NK_ROTL(k1,15);
+        k1 *= c2;
+
+        h1 ^= k1;
+        h1 = NK_ROTL(h1,13);
+        h1 = h1*5+0xe6546b64;
+    }
+
+    /* tail */
+    tail = (const nk_byte*)(data + nblocks*4);
+    k1 = 0;
+    switch (len & 3) {
+    case 3: k1 ^= (nk_uint)(tail[2] << 16);
+    case 2: k1 ^= (nk_uint)(tail[1] << 8u);
+    case 1: k1 ^= tail[0];
+            k1 *= c1;
+            k1 = NK_ROTL(k1,15);
+            k1 *= c2;
+            h1 ^= k1;
+    default: break;
+    }
+
+    /* finalization */
+    h1 ^= (nk_uint)len;
+    /* fmix32 */
+    h1 ^= h1 >> 16;
+    h1 *= 0x85ebca6b;
+    h1 ^= h1 >> 13;
+    h1 *= 0xc2b2ae35;
+    h1 ^= h1 >> 16;
+
+    #undef NK_ROTL
+    return h1;
+}
+
+#ifdef NK_INCLUDE_STANDARD_IO
+NK_INTERN char*
+nk_file_load(const char* path, nk_size* siz, struct nk_allocator *alloc)
+{
+    char *buf;
+    FILE *fd;
+    long ret;
+
+    NK_ASSERT(path);
+    NK_ASSERT(siz);
+    NK_ASSERT(alloc);
+    if (!path || !siz || !alloc)
+        return 0;
+
+    fd = fopen(path, "rb");
+    if (!fd) return 0;
+    fseek(fd, 0, SEEK_END);
+    ret = ftell(fd);
+    if (ret < 0) {
+        fclose(fd);
+        return 0;
+    }
+    *siz = (nk_size)ret;
+    fseek(fd, 0, SEEK_SET);
+    buf = (char*)alloc->alloc(alloc->userdata,0, *siz);
+    NK_ASSERT(buf);
+    if (!buf) {
+        fclose(fd);
+        return 0;
+    }
+    *siz = (nk_size)fread(buf, *siz, 1, fd);
+    fclose(fd);
+    return buf;
+}
+#endif
+
+/*
+ * ==============================================================
+ *
+ *                          COLOR
+ *
+ * ===============================================================
+ */
+NK_INTERN int
+nk_parse_hex(const char *p, int length)
+{
+    int i = 0;
+    int len = 0;
+    while (len < length) {
+        i <<= 4;
+        if (p[len] >= 'a' && p[len] <= 'f')
+            i += ((p[len] - 'a') + 10);
+        else if (p[len] >= 'A' && p[len] <= 'F')
+            i += ((p[len] - 'A') + 10);
+        else i += (p[len] - '0');
+        len++;
+    }
+    return i;
+}
+
+NK_API struct nk_color
+nk_rgba(int r, int g, int b, int a)
+{
+    struct nk_color ret;
+    ret.r = (nk_byte)NK_CLAMP(0, r, 255);
+    ret.g = (nk_byte)NK_CLAMP(0, g, 255);
+    ret.b = (nk_byte)NK_CLAMP(0, b, 255);
+    ret.a = (nk_byte)NK_CLAMP(0, a, 255);
+    return ret;
+}
+
+NK_API struct nk_color
+nk_rgb_hex(const char *rgb)
+{
+    struct nk_color col;
+    const char *c = rgb;
+    if (*c == '#') c++;
+    col.r = (nk_byte)nk_parse_hex(c, 2);
+    col.g = (nk_byte)nk_parse_hex(c+2, 2);
+    col.b = (nk_byte)nk_parse_hex(c+4, 2);
+    col.a = 255;
+    return col;
+}
+
+NK_API struct nk_color
+nk_rgba_hex(const char *rgb)
+{
+    struct nk_color col;
+    const char *c = rgb;
+    if (*c == '#') c++;
+    col.r = (nk_byte)nk_parse_hex(c, 2);
+    col.g = (nk_byte)nk_parse_hex(c+2, 2);
+    col.b = (nk_byte)nk_parse_hex(c+4, 2);
+    col.a = (nk_byte)nk_parse_hex(c+6, 2);
+    return col;
+}
+
+NK_API void
+nk_color_hex_rgba(char *output, struct nk_color col)
+{
+    #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
+    output[0] = (char)NK_TO_HEX((col.r & 0xF0) >> 4);
+    output[1] = (char)NK_TO_HEX((col.r & 0x0F));
+    output[2] = (char)NK_TO_HEX((col.g & 0xF0) >> 4);
+    output[3] = (char)NK_TO_HEX((col.g & 0x0F));
+    output[4] = (char)NK_TO_HEX((col.b & 0xF0) >> 4);
+    output[5] = (char)NK_TO_HEX((col.b & 0x0F));
+    output[6] = (char)NK_TO_HEX((col.a & 0xF0) >> 4);
+    output[7] = (char)NK_TO_HEX((col.a & 0x0F));
+    output[8] = '\0';
+    #undef NK_TO_HEX
+}
+
+NK_API void
+nk_color_hex_rgb(char *output, struct nk_color col)
+{
+    #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
+    output[0] = (char)NK_TO_HEX((col.r & 0xF0) >> 4);
+    output[1] = (char)NK_TO_HEX((col.r & 0x0F));
+    output[2] = (char)NK_TO_HEX((col.g & 0xF0) >> 4);
+    output[3] = (char)NK_TO_HEX((col.g & 0x0F));
+    output[4] = (char)NK_TO_HEX((col.b & 0xF0) >> 4);
+    output[5] = (char)NK_TO_HEX((col.b & 0x0F));
+    output[6] = '\0';
+    #undef NK_TO_HEX
+}
+
+NK_API struct nk_color
+nk_rgba_iv(const int *c)
+{
+    return nk_rgba(c[0], c[1], c[2], c[3]);
+}
+
+NK_API struct nk_color
+nk_rgba_bv(const nk_byte *c)
+{
+    return nk_rgba(c[0], c[1], c[2], c[3]);
+}
+
+NK_API struct nk_color
+nk_rgb(int r, int g, int b)
+{
+    struct nk_color ret;
+    ret.r = (nk_byte)NK_CLAMP(0, r, 255);
+    ret.g = (nk_byte)NK_CLAMP(0, g, 255);
+    ret.b = (nk_byte)NK_CLAMP(0, b, 255);
+    ret.a = (nk_byte)255;
+    return ret;
+}
+
+NK_API struct nk_color
+nk_rgb_iv(const int *c)
+{
+    return nk_rgb(c[0], c[1], c[2]);
+}
+
+NK_API struct nk_color
+nk_rgb_bv(const nk_byte* c)
+{
+    return nk_rgb(c[0], c[1], c[2]);
+}
+
+NK_API struct nk_color
+nk_rgba_u32(nk_uint in)
+{
+    struct nk_color ret;
+    ret.r = (in & 0xFF);
+    ret.g = ((in >> 8) & 0xFF);
+    ret.b = ((in >> 16) & 0xFF);
+    ret.a = (nk_byte)((in >> 24) & 0xFF);
+    return ret;
+}
+
+NK_API struct nk_color
+nk_rgba_f(float r, float g, float b, float a)
+{
+    struct nk_color ret;
+    ret.r = (nk_byte)(NK_SATURATE(r) * 255.0f);
+    ret.g = (nk_byte)(NK_SATURATE(g) * 255.0f);
+    ret.b = (nk_byte)(NK_SATURATE(b) * 255.0f);
+    ret.a = (nk_byte)(NK_SATURATE(a) * 255.0f);
+    return ret;
+}
+
+NK_API struct nk_color
+nk_rgba_fv(const float *c)
+{
+    return nk_rgba_f(c[0], c[1], c[2], c[3]);
+}
+
+NK_API struct nk_color
+nk_rgb_f(float r, float g, float b)
+{
+    struct nk_color ret;
+    ret.r = (nk_byte)(NK_SATURATE(r) * 255.0f);
+    ret.g = (nk_byte)(NK_SATURATE(g) * 255.0f);
+    ret.b = (nk_byte)(NK_SATURATE(b) * 255.0f);
+    ret.a = 255;
+    return ret;
+}
+
+NK_API struct nk_color
+nk_rgb_fv(const float *c)
+{
+    return nk_rgb_f(c[0], c[1], c[2]);
+}
+
+NK_API struct nk_color
+nk_hsv(int h, int s, int v)
+{
+    return nk_hsva(h, s, v, 255);
+}
+
+NK_API struct nk_color
+nk_hsv_iv(const int *c)
+{
+    return nk_hsv(c[0], c[1], c[2]);
+}
+
+NK_API struct nk_color
+nk_hsv_bv(const nk_byte *c)
+{
+    return nk_hsv(c[0], c[1], c[2]);
+}
+
+NK_API struct nk_color
+nk_hsv_f(float h, float s, float v)
+{
+    return nk_hsva_f(h, s, v, 1.0f);
+}
+
+NK_API struct nk_color
+nk_hsv_fv(const float *c)
+{
+    return nk_hsv_f(c[0], c[1], c[2]);
+}
+
+NK_API struct nk_color
+nk_hsva(int h, int s, int v, int a)
+{
+    float hf = ((float)NK_CLAMP(0, h, 255)) / 255.0f;
+    float sf = ((float)NK_CLAMP(0, s, 255)) / 255.0f;
+    float vf = ((float)NK_CLAMP(0, v, 255)) / 255.0f;
+    float af = ((float)NK_CLAMP(0, a, 255)) / 255.0f;
+    return nk_hsva_f(hf, sf, vf, af);
+}
+
+NK_API struct nk_color
+nk_hsva_iv(const int *c)
+{
+    return nk_hsva(c[0], c[1], c[2], c[3]);
+}
+
+NK_API struct nk_color
+nk_hsva_bv(const nk_byte *c)
+{
+    return nk_hsva(c[0], c[1], c[2], c[3]);
+}
+
+NK_API struct nk_color
+nk_hsva_f(float h, float s, float v, float a)
+{
+    struct nk_colorf out = {0,0,0,0};
+    float p, q, t, f;
+    int i;
+
+    if (s <= 0.0f) {
+        out.r = v; out.g = v; out.b = v;
+        return nk_rgb_f(out.r, out.g, out.b);
+    }
+
+    h = h / (60.0f/360.0f);
+    i = (int)h;
+    f = h - (float)i;
+    p = v * (1.0f - s);
+    q = v * (1.0f - (s * f));
+    t = v * (1.0f - s * (1.0f - f));
+
+    switch (i) {
+    case 0: default: out.r = v; out.g = t; out.b = p; break;
+    case 1: out.r = q; out.g = v; out.b = p; break;
+    case 2: out.r = p; out.g = v; out.b = t; break;
+    case 3: out.r = p; out.g = q; out.b = v; break;
+    case 4: out.r = t; out.g = p; out.b = v; break;
+    case 5: out.r = v; out.g = p; out.b = q; break;
+    }
+    return nk_rgba_f(out.r, out.g, out.b, a);
+}
+
+NK_API struct nk_color
+nk_hsva_fv(const float *c)
+{
+    return nk_hsva_f(c[0], c[1], c[2], c[3]);
+}
+
+NK_API nk_uint
+nk_color_u32(struct nk_color in)
+{
+    nk_uint out = (nk_uint)in.r;
+    out |= ((nk_uint)in.g << 8);
+    out |= ((nk_uint)in.b << 16);
+    out |= ((nk_uint)in.a << 24);
+    return out;
+}
+
+NK_API void
+nk_color_f(float *r, float *g, float *b, float *a, struct nk_color in)
+{
+    NK_STORAGE const float s = 1.0f/255.0f;
+    *r = (float)in.r * s;
+    *g = (float)in.g * s;
+    *b = (float)in.b * s;
+    *a = (float)in.a * s;
+}
+
+NK_API void
+nk_color_fv(float *c, struct nk_color in)
+{
+    nk_color_f(&c[0], &c[1], &c[2], &c[3], in);
+}
+
+NK_API void
+nk_color_d(double *r, double *g, double *b, double *a, struct nk_color in)
+{
+    NK_STORAGE const double s = 1.0/255.0;
+    *r = (double)in.r * s;
+    *g = (double)in.g * s;
+    *b = (double)in.b * s;
+    *a = (double)in.a * s;
+}
+
+NK_API void
+nk_color_dv(double *c, struct nk_color in)
+{
+    nk_color_d(&c[0], &c[1], &c[2], &c[3], in);
+}
+
+NK_API void
+nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color in)
+{
+    float a;
+    nk_color_hsva_f(out_h, out_s, out_v, &a, in);
+}
+
+NK_API void
+nk_color_hsv_fv(float *out, struct nk_color in)
+{
+    float a;
+    nk_color_hsva_f(&out[0], &out[1], &out[2], &a, in);
+}
+
+NK_API void
+nk_color_hsva_f(float *out_h, float *out_s,
+    float *out_v, float *out_a, struct nk_color in)
+{
+    float chroma;
+    float K = 0.0f;
+    float r,g,b,a;
+
+    nk_color_f(&r,&g,&b,&a, in);
+    if (g < b) {
+        const float t = g; g = b; b = t;
+        K = -1.f;
+    }
+    if (r < g) {
+        const float t = r; r = g; g = t;
+        K = -2.f/6.0f - K;
+    }
+    chroma = r - ((g < b) ? g: b);
+    *out_h = NK_ABS(K + (g - b)/(6.0f * chroma + 1e-20f));
+    *out_s = chroma / (r + 1e-20f);
+    *out_v = r;
+    *out_a = (float)in.a / 255.0f;
+}
+
+NK_API void
+nk_color_hsva_fv(float *out, struct nk_color in)
+{
+    nk_color_hsva_f(&out[0], &out[1], &out[2], &out[3], in);
+}
+
+NK_API void
+nk_color_hsva_i(int *out_h, int *out_s, int *out_v,
+                int *out_a, struct nk_color in)
+{
+    float h,s,v,a;
+    nk_color_hsva_f(&h, &s, &v, &a, in);
+    *out_h = (nk_byte)(h * 255.0f);
+    *out_s = (nk_byte)(s * 255.0f);
+    *out_v = (nk_byte)(v * 255.0f);
+    *out_a = (nk_byte)(a * 255.0f);
+}
+
+NK_API void
+nk_color_hsva_iv(int *out, struct nk_color in)
+{
+    nk_color_hsva_i(&out[0], &out[1], &out[2], &out[3], in);
+}
+
+NK_API void
+nk_color_hsva_bv(nk_byte *out, struct nk_color in)
+{
+    int tmp[4];
+    nk_color_hsva_i(&tmp[0], &tmp[1], &tmp[2], &tmp[3], in);
+    out[0] = (nk_byte)tmp[0];
+    out[1] = (nk_byte)tmp[1];
+    out[2] = (nk_byte)tmp[2];
+    out[3] = (nk_byte)tmp[3];
+}
+
+NK_API void
+nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color in)
+{
+    int tmp[4];
+    nk_color_hsva_i(&tmp[0], &tmp[1], &tmp[2], &tmp[3], in);
+    *h = (nk_byte)tmp[0];
+    *s = (nk_byte)tmp[1];
+    *v = (nk_byte)tmp[2];
+    *a = (nk_byte)tmp[3];
+}
+
+NK_API void
+nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color in)
+{
+    int a;
+    nk_color_hsva_i(out_h, out_s, out_v, &a, in);
+}
+
+NK_API void
+nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color in)
+{
+    int tmp[4];
+    nk_color_hsva_i(&tmp[0], &tmp[1], &tmp[2], &tmp[3], in);
+    *out_h = (nk_byte)tmp[0];
+    *out_s = (nk_byte)tmp[1];
+    *out_v = (nk_byte)tmp[2];
+}
+
+NK_API void
+nk_color_hsv_iv(int *out, struct nk_color in)
+{
+    nk_color_hsv_i(&out[0], &out[1], &out[2], in);
+}
+
+NK_API void
+nk_color_hsv_bv(nk_byte *out, struct nk_color in)
+{
+    int tmp[4];
+    nk_color_hsv_i(&tmp[0], &tmp[1], &tmp[2], in);
+    out[0] = (nk_byte)tmp[0];
+    out[1] = (nk_byte)tmp[1];
+    out[2] = (nk_byte)tmp[2];
+}
+/*
+ * ==============================================================
+ *
+ *                          IMAGE
+ *
+ * ===============================================================
+ */
+NK_API nk_handle
+nk_handle_ptr(void *ptr)
+{
+    nk_handle handle = {0};
+    handle.ptr = ptr;
+    return handle;
+}
+
+NK_API nk_handle
+nk_handle_id(int id)
+{
+    nk_handle handle;
+    nk_zero_struct(handle);
+    handle.id = id;
+    return handle;
+}
+
+NK_API struct nk_image
+nk_subimage_ptr(void *ptr, unsigned short w, unsigned short h, struct nk_rect r)
+{
+    struct nk_image s;
+    nk_zero(&s, sizeof(s));
+    s.handle.ptr = ptr;
+    s.w = w; s.h = h;
+    s.region[0] = (unsigned short)r.x;
+    s.region[1] = (unsigned short)r.y;
+    s.region[2] = (unsigned short)r.w;
+    s.region[3] = (unsigned short)r.h;
+    return s;
+}
+
+NK_API struct nk_image
+nk_subimage_id(int id, unsigned short w, unsigned short h, struct nk_rect r)
+{
+    struct nk_image s;
+    nk_zero(&s, sizeof(s));
+    s.handle.id = id;
+    s.w = w; s.h = h;
+    s.region[0] = (unsigned short)r.x;
+    s.region[1] = (unsigned short)r.y;
+    s.region[2] = (unsigned short)r.w;
+    s.region[3] = (unsigned short)r.h;
+    return s;
+}
+
+NK_API struct nk_image
+nk_subimage_handle(nk_handle handle, unsigned short w, unsigned short h,
+    struct nk_rect r)
+{
+    struct nk_image s;
+    nk_zero(&s, sizeof(s));
+    s.handle = handle;
+    s.w = w; s.h = h;
+    s.region[0] = (unsigned short)r.x;
+    s.region[1] = (unsigned short)r.y;
+    s.region[2] = (unsigned short)r.w;
+    s.region[3] = (unsigned short)r.h;
+    return s;
+}
+
+NK_API struct nk_image
+nk_image_handle(nk_handle handle)
+{
+    struct nk_image s;
+    nk_zero(&s, sizeof(s));
+    s.handle = handle;
+    s.w = 0; s.h = 0;
+    s.region[0] = 0;
+    s.region[1] = 0;
+    s.region[2] = 0;
+    s.region[3] = 0;
+    return s;
+}
+
+NK_API struct nk_image
+nk_image_ptr(void *ptr)
+{
+    struct nk_image s;
+    nk_zero(&s, sizeof(s));
+    NK_ASSERT(ptr);
+    s.handle.ptr = ptr;
+    s.w = 0; s.h = 0;
+    s.region[0] = 0;
+    s.region[1] = 0;
+    s.region[2] = 0;
+    s.region[3] = 0;
+    return s;
+}
+
+NK_API struct nk_image
+nk_image_id(int id)
+{
+    struct nk_image s;
+    nk_zero(&s, sizeof(s));
+    s.handle.id = id;
+    s.w = 0; s.h = 0;
+    s.region[0] = 0;
+    s.region[1] = 0;
+    s.region[2] = 0;
+    s.region[3] = 0;
+    return s;
+}
+
+NK_API int
+nk_image_is_subimage(const struct nk_image* img)
+{
+    NK_ASSERT(img);
+    return !(img->w == 0 && img->h == 0);
+}
+
+NK_INTERN void
+nk_unify(struct nk_rect *clip, const struct nk_rect *a, float x0, float y0,
+    float x1, float y1)
+{
+    NK_ASSERT(a);
+    NK_ASSERT(clip);
+    clip->x = NK_MAX(a->x, x0);
+    clip->y = NK_MAX(a->y, y0);
+    clip->w = NK_MIN(a->x + a->w, x1) - clip->x;
+    clip->h = NK_MIN(a->y + a->h, y1) - clip->y;
+    clip->w = NK_MAX(0, clip->w);
+    clip->h = NK_MAX(0, clip->h);
+}
+
+NK_API void
+nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r,
+    float pad_x, float pad_y, enum nk_heading direction)
+{
+    float w_half, h_half;
+    NK_ASSERT(result);
+
+    r.w = NK_MAX(2 * pad_x, r.w);
+    r.h = NK_MAX(2 * pad_y, r.h);
+    r.w = r.w - 2 * pad_x;
+    r.h = r.h - 2 * pad_y;
+
+    r.x = r.x + pad_x;
+    r.y = r.y + pad_y;
+
+    w_half = r.w / 2.0f;
+    h_half = r.h / 2.0f;
+
+    if (direction == NK_UP) {
+        result[0] = nk_vec2(r.x + w_half, r.y);
+        result[1] = nk_vec2(r.x + r.w, r.y + r.h);
+        result[2] = nk_vec2(r.x, r.y + r.h);
+    } else if (direction == NK_RIGHT) {
+        result[0] = nk_vec2(r.x, r.y);
+        result[1] = nk_vec2(r.x + r.w, r.y + h_half);
+        result[2] = nk_vec2(r.x, r.y + r.h);
+    } else if (direction == NK_DOWN) {
+        result[0] = nk_vec2(r.x, r.y);
+        result[1] = nk_vec2(r.x + r.w, r.y);
+        result[2] = nk_vec2(r.x + w_half, r.y + r.h);
+    } else {
+        result[0] = nk_vec2(r.x, r.y + h_half);
+        result[1] = nk_vec2(r.x + r.w, r.y);
+        result[2] = nk_vec2(r.x + r.w, r.y + r.h);
+    }
+}
+
+NK_INTERN int
+nk_text_clamp(const struct nk_user_font *font, const char *text,
+    int text_len, float space, int *glyphs, float *text_width,
+    nk_rune *sep_list, int sep_count)
+{
+    int i = 0;
+    int glyph_len = 0;
+    float last_width = 0;
+    nk_rune unicode = 0;
+    float width = 0;
+    int len = 0;
+    int g = 0;
+    float s;
+
+    int sep_len = 0;
+    int sep_g = 0;
+    float sep_width = 0;
+    sep_count = NK_MAX(sep_count,0);
+
+    glyph_len = nk_utf_decode(text, &unicode, text_len);
+    while (glyph_len && (width < space) && (len < text_len)) {
+        len += glyph_len;
+        s = font->width(font->userdata, font->height, text, len);
+        for (i = 0; i < sep_count; ++i) {
+            if (unicode != sep_list[i]) continue;
+            sep_width = last_width = width;
+            sep_g = g+1;
+            sep_len = len;
+            break;
+        }
+        if (i == sep_count){
+            last_width = sep_width = width;
+            sep_g = g+1;
+        }
+        width = s;
+        glyph_len = nk_utf_decode(&text[len], &unicode, text_len - len);
+        g++;
+    }
+    if (len >= text_len) {
+        *glyphs = g;
+        *text_width = last_width;
+        return len;
+    } else {
+        *glyphs = sep_g;
+        *text_width = sep_width;
+        return (!sep_len) ? len: sep_len;
+    }
+}
+
+enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
+NK_INTERN struct nk_vec2
+nk_text_calculate_text_bounds(const struct nk_user_font *font,
+    const char *begin, int byte_len, float row_height, const char **remaining,
+    struct nk_vec2 *out_offset, int *glyphs, int op)
+{
+    float line_height = row_height;
+    struct nk_vec2 text_size = nk_vec2(0,0);
+    float line_width = 0.0f;
+
+    float glyph_width;
+    int glyph_len = 0;
+    nk_rune unicode = 0;
+    int text_len = 0;
+    if (!begin || byte_len <= 0 || !font)
+        return nk_vec2(0,row_height);
+
+    glyph_len = nk_utf_decode(begin, &unicode, byte_len);
+    if (!glyph_len) return text_size;
+    glyph_width = font->width(font->userdata, font->height, begin, glyph_len);
+
+    *glyphs = 0;
+    while ((text_len < byte_len) && glyph_len) {
+        if (unicode == '\n') {
+            text_size.x = NK_MAX(text_size.x, line_width);
+            text_size.y += line_height;
+            line_width = 0;
+            *glyphs+=1;
+            if (op == NK_STOP_ON_NEW_LINE)
+                break;
+
+            text_len++;
+            glyph_len = nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
+            continue;
+        }
+
+        if (unicode == '\r') {
+            text_len++;
+            *glyphs+=1;
+            glyph_len = nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
+            continue;
+        }
+
+        *glyphs = *glyphs + 1;
+        text_len += glyph_len;
+        line_width += (float)glyph_width;
+        glyph_len = nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
+        glyph_width = font->width(font->userdata, font->height, begin+text_len, glyph_len);
+        continue;
+    }
+
+    if (text_size.x < line_width)
+        text_size.x = line_width;
+    if (out_offset)
+        *out_offset = nk_vec2(line_width, text_size.y + line_height);
+    if (line_width > 0 || text_size.y == 0.0f)
+        text_size.y += line_height;
+    if (remaining)
+        *remaining = begin+text_len;
+    return text_size;
+}
+
+/* ==============================================================
+ *
+ *                          UTF-8
+ *
+ * ===============================================================*/
+NK_GLOBAL const nk_byte nk_utfbyte[NK_UTF_SIZE+1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
+NK_GLOBAL const nk_byte nk_utfmask[NK_UTF_SIZE+1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
+NK_GLOBAL const nk_uint nk_utfmin[NK_UTF_SIZE+1] = {0, 0, 0x80, 0x800, 0x10000};
+NK_GLOBAL const nk_uint nk_utfmax[NK_UTF_SIZE+1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
+
+NK_INTERN int
+nk_utf_validate(nk_rune *u, int i)
+{
+    NK_ASSERT(u);
+    if (!u) return 0;
+    if (!NK_BETWEEN(*u, nk_utfmin[i], nk_utfmax[i]) ||
+         NK_BETWEEN(*u, 0xD800, 0xDFFF))
+            *u = NK_UTF_INVALID;
+    for (i = 1; *u > nk_utfmax[i]; ++i);
+    return i;
+}
+
+NK_INTERN nk_rune
+nk_utf_decode_byte(char c, int *i)
+{
+    NK_ASSERT(i);
+    if (!i) return 0;
+    for(*i = 0; *i < (int)NK_LEN(nk_utfmask); ++(*i)) {
+        if (((nk_byte)c & nk_utfmask[*i]) == nk_utfbyte[*i])
+            return (nk_byte)(c & ~nk_utfmask[*i]);
+    }
+    return 0;
+}
+
+NK_API int
+nk_utf_decode(const char *c, nk_rune *u, int clen)
+{
+    int i, j, len, type=0;
+    nk_rune udecoded;
+
+    NK_ASSERT(c);
+    NK_ASSERT(u);
+
+    if (!c || !u) return 0;
+    if (!clen) return 0;
+    *u = NK_UTF_INVALID;
+
+    udecoded = nk_utf_decode_byte(c[0], &len);
+    if (!NK_BETWEEN(len, 1, NK_UTF_SIZE))
+        return 1;
+
+    for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
+        udecoded = (udecoded << 6) | nk_utf_decode_byte(c[i], &type);
+        if (type != 0)
+            return j;
+    }
+    if (j < len)
+        return 0;
+    *u = udecoded;
+    nk_utf_validate(u, len);
+    return len;
+}
+
+NK_INTERN char
+nk_utf_encode_byte(nk_rune u, int i)
+{
+    return (char)((nk_utfbyte[i]) | ((nk_byte)u & ~nk_utfmask[i]));
+}
+
+NK_API int
+nk_utf_encode(nk_rune u, char *c, int clen)
+{
+    int len, i;
+    len = nk_utf_validate(&u, 0);
+    if (clen < len || !len || len > NK_UTF_SIZE)
+        return 0;
+
+    for (i = len - 1; i != 0; --i) {
+        c[i] = nk_utf_encode_byte(u, 0);
+        u >>= 6;
+    }
+    c[0] = nk_utf_encode_byte(u, len);
+    return len;
+}
+
+NK_API int
+nk_utf_len(const char *str, int len)
+{
+    const char *text;
+    int glyphs = 0;
+    int text_len;
+    int glyph_len;
+    int src_len = 0;
+    nk_rune unicode;
+
+    NK_ASSERT(str);
+    if (!str || !len) return 0;
+
+    text = str;
+    text_len = len;
+    glyph_len = nk_utf_decode(text, &unicode, text_len);
+    while (glyph_len && src_len < len) {
+        glyphs++;
+        src_len = src_len + glyph_len;
+        glyph_len = nk_utf_decode(text + src_len, &unicode, text_len - src_len);
+    }
+    return glyphs;
+}
+
+NK_API const char*
+nk_utf_at(const char *buffer, int length, int index,
+    nk_rune *unicode, int *len)
+{
+    int i = 0;
+    int src_len = 0;
+    int glyph_len = 0;
+    const char *text;
+    int text_len;
+
+    NK_ASSERT(buffer);
+    NK_ASSERT(unicode);
+    NK_ASSERT(len);
+
+    if (!buffer || !unicode || !len) return 0;
+    if (index < 0) {
+        *unicode = NK_UTF_INVALID;
+        *len = 0;
+        return 0;
+    }
+
+    text = buffer;
+    text_len = length;
+    glyph_len = nk_utf_decode(text, unicode, text_len);
+    while (glyph_len) {
+        if (i == index) {
+            *len = glyph_len;
+            break;
+        }
+
+        i++;
+        src_len = src_len + glyph_len;
+        glyph_len = nk_utf_decode(text + src_len, unicode, text_len - src_len);
+    }
+    if (i != index) return 0;
+    return buffer + src_len;
+}
+
+/* ==============================================================
+ *
+ *                          BUFFER
+ *
+ * ===============================================================*/
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+NK_INTERN void* nk_malloc(nk_handle unused, void *old,nk_size size)
+{NK_UNUSED(unused); NK_UNUSED(old); return malloc(size);}
+NK_INTERN void nk_mfree(nk_handle unused, void *ptr)
+{NK_UNUSED(unused); free(ptr);}
+
+NK_API void
+nk_buffer_init_default(struct nk_buffer *buffer)
+{
+    struct nk_allocator alloc;
+    alloc.userdata.ptr = 0;
+    alloc.alloc = nk_malloc;
+    alloc.free = nk_mfree;
+    nk_buffer_init(buffer, &alloc, NK_BUFFER_DEFAULT_INITIAL_SIZE);
+}
+#endif
+
+NK_API void
+nk_buffer_init(struct nk_buffer *b, const struct nk_allocator *a,
+    nk_size initial_size)
+{
+    NK_ASSERT(b);
+    NK_ASSERT(a);
+    NK_ASSERT(initial_size);
+    if (!b || !a || !initial_size) return;
+
+    nk_zero(b, sizeof(*b));
+    b->type = NK_BUFFER_DYNAMIC;
+    b->memory.ptr = a->alloc(a->userdata,0, initial_size);
+    b->memory.size = initial_size;
+    b->size = initial_size;
+    b->grow_factor = 2.0f;
+    b->pool = *a;
+}
+
+NK_API void
+nk_buffer_init_fixed(struct nk_buffer *b, void *m, nk_size size)
+{
+    NK_ASSERT(b);
+    NK_ASSERT(m);
+    NK_ASSERT(size);
+    if (!b || !m || !size) return;
+
+    nk_zero(b, sizeof(*b));
+    b->type = NK_BUFFER_FIXED;
+    b->memory.ptr = m;
+    b->memory.size = size;
+    b->size = size;
+}
+
+NK_INTERN void*
+nk_buffer_align(void *unaligned, nk_size align, nk_size *alignment,
+    enum nk_buffer_allocation_type type)
+{
+    void *memory = 0;
+    switch (type) {
+    default:
+    case NK_BUFFER_MAX:
+    case NK_BUFFER_FRONT:
+        if (align) {
+            memory = NK_ALIGN_PTR(unaligned, align);
+            *alignment = (nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
+        } else {
+            memory = unaligned;
+            *alignment = 0;
+        }
+        break;
+    case NK_BUFFER_BACK:
+        if (align) {
+            memory = NK_ALIGN_PTR_BACK(unaligned, align);
+            *alignment = (nk_size)((nk_byte*)unaligned - (nk_byte*)memory);
+        } else {
+            memory = unaligned;
+            *alignment = 0;
+        }
+        break;
+    }
+    return memory;
+}
+
+NK_INTERN void*
+nk_buffer_realloc(struct nk_buffer *b, nk_size capacity, nk_size *size)
+{
+    void *temp;
+    nk_size buffer_size;
+
+    NK_ASSERT(b);
+    NK_ASSERT(size);
+    if (!b || !size || !b->pool.alloc || !b->pool.free)
+        return 0;
+
+    buffer_size = b->memory.size;
+    temp = b->pool.alloc(b->pool.userdata, b->memory.ptr, capacity);
+    NK_ASSERT(temp);
+    if (!temp) return 0;
+
+    *size = capacity;
+    if (temp != b->memory.ptr) {
+        NK_MEMCPY(temp, b->memory.ptr, buffer_size);
+        b->pool.free(b->pool.userdata, b->memory.ptr);
+    }
+
+    if (b->size == buffer_size) {
+        /* no back buffer so just set correct size */
+        b->size = capacity;
+        return temp;
+    } else {
+        /* copy back buffer to the end of the new buffer */
+        void *dst, *src;
+        nk_size back_size;
+        back_size = buffer_size - b->size;
+        dst = nk_ptr_add(void, temp, capacity - back_size);
+        src = nk_ptr_add(void, temp, b->size);
+        NK_MEMCPY(dst, src, back_size);
+        b->size = capacity - back_size;
+    }
+    return temp;
+}
+
+NK_INTERN void*
+nk_buffer_alloc(struct nk_buffer *b, enum nk_buffer_allocation_type type,
+    nk_size size, nk_size align)
+{
+    int full;
+    nk_size alignment;
+    void *unaligned;
+    void *memory;
+
+    NK_ASSERT(b);
+    NK_ASSERT(size);
+    if (!b || !size) return 0;
+    b->needed += size;
+
+    /* calculate total size with needed alignment + size */
+    if (type == NK_BUFFER_FRONT)
+        unaligned = nk_ptr_add(void, b->memory.ptr, b->allocated);
+    else unaligned = nk_ptr_add(void, b->memory.ptr, b->size - size);
+    memory = nk_buffer_align(unaligned, align, &alignment, type);
+
+    /* check if buffer has enough memory*/
+    if (type == NK_BUFFER_FRONT)
+        full = ((b->allocated + size + alignment) > b->size);
+    else full = ((b->size - NK_MIN(b->size,(size + alignment))) <= b->allocated);
+
+    if (full) {
+        nk_size capacity;
+        if (b->type != NK_BUFFER_DYNAMIC)
+            return 0;
+        NK_ASSERT(b->pool.alloc && b->pool.free);
+        if (b->type != NK_BUFFER_DYNAMIC || !b->pool.alloc || !b->pool.free)
+            return 0;
+
+        /* buffer is full so allocate bigger buffer if dynamic */
+        capacity = (nk_size)((float)b->memory.size * b->grow_factor);
+        capacity = NK_MAX(capacity, nk_round_up_pow2((nk_uint)(b->allocated + size)));
+        b->memory.ptr = nk_buffer_realloc(b, capacity, &b->memory.size);
+        if (!b->memory.ptr) return 0;
+
+        /* align newly allocated pointer */
+        if (type == NK_BUFFER_FRONT)
+            unaligned = nk_ptr_add(void, b->memory.ptr, b->allocated);
+        else unaligned = nk_ptr_add(void, b->memory.ptr, b->size - size);
+        memory = nk_buffer_align(unaligned, align, &alignment, type);
+    }
+    if (type == NK_BUFFER_FRONT)
+        b->allocated += size + alignment;
+    else b->size -= (size + alignment);
+    b->needed += alignment;
+    b->calls++;
+    return memory;
+}
+
+NK_API void
+nk_buffer_push(struct nk_buffer *b, enum nk_buffer_allocation_type type,
+    const void *memory, nk_size size, nk_size align)
+{
+    void *mem = nk_buffer_alloc(b, type, size, align);
+    if (!mem) return;
+    NK_MEMCPY(mem, memory, size);
+}
+
+NK_API void
+nk_buffer_mark(struct nk_buffer *buffer, enum nk_buffer_allocation_type type)
+{
+    NK_ASSERT(buffer);
+    if (!buffer) return;
+    buffer->marker[type].active = nk_true;
+    if (type == NK_BUFFER_BACK)
+        buffer->marker[type].offset = buffer->size;
+    else buffer->marker[type].offset = buffer->allocated;
+}
+
+NK_API void
+nk_buffer_reset(struct nk_buffer *buffer, enum nk_buffer_allocation_type type)
+{
+    NK_ASSERT(buffer);
+    if (!buffer) return;
+    if (type == NK_BUFFER_BACK) {
+        /* reset back buffer either back to marker or empty */
+        buffer->needed -= (buffer->memory.size - buffer->marker[type].offset);
+        if (buffer->marker[type].active)
+            buffer->size = buffer->marker[type].offset;
+        else buffer->size = buffer->memory.size;
+        buffer->marker[type].active = nk_false;
+    } else {
+        /* reset front buffer either back to back marker or empty */
+        buffer->needed -= (buffer->allocated - buffer->marker[type].offset);
+        if (buffer->marker[type].active)
+            buffer->allocated = buffer->marker[type].offset;
+        else buffer->allocated = 0;
+        buffer->marker[type].active = nk_false;
+    }
+}
+
+NK_API void
+nk_buffer_clear(struct nk_buffer *b)
+{
+    NK_ASSERT(b);
+    if (!b) return;
+    b->allocated = 0;
+    b->size = b->memory.size;
+    b->calls = 0;
+    b->needed = 0;
+}
+
+NK_API void
+nk_buffer_free(struct nk_buffer *b)
+{
+    NK_ASSERT(b);
+    if (!b || !b->memory.ptr) return;
+    if (b->type == NK_BUFFER_FIXED) return;
+    if (!b->pool.free) return;
+    NK_ASSERT(b->pool.free);
+    b->pool.free(b->pool.userdata, b->memory.ptr);
+}
+
+NK_API void
+nk_buffer_info(struct nk_memory_status *s, struct nk_buffer *b)
+{
+    NK_ASSERT(b);
+    NK_ASSERT(s);
+    if (!s || !b) return;
+    s->allocated = b->allocated;
+    s->size =  b->memory.size;
+    s->needed = b->needed;
+    s->memory = b->memory.ptr;
+    s->calls = b->calls;
+}
+
+NK_API void*
+nk_buffer_memory(struct nk_buffer *buffer)
+{
+    NK_ASSERT(buffer);
+    if (!buffer) return 0;
+    return buffer->memory.ptr;
+}
+
+NK_API const void*
+nk_buffer_memory_const(const struct nk_buffer *buffer)
+{
+    NK_ASSERT(buffer);
+    if (!buffer) return 0;
+    return buffer->memory.ptr;
+}
+
+NK_API nk_size
+nk_buffer_total(struct nk_buffer *buffer)
+{
+    NK_ASSERT(buffer);
+    if (!buffer) return 0;
+    return buffer->memory.size;
+}
+
+/*
+ * ==============================================================
+ *
+ *                          STRING
+ *
+ * ===============================================================
+ */
+#ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
+NK_API void
+nk_str_init_default(struct nk_str *str)
+{
+    struct nk_allocator alloc;
+    alloc.userdata.ptr = 0;
+    alloc.alloc = nk_malloc;
+    alloc.free = nk_mfree;
+    nk_buffer_init(&str->buffer, &alloc, 32);
+    str->len = 0;
+}
+#endif
+
+NK_API void
+nk_str_init(struct nk_str *str, const struct nk_allocator *alloc, nk_size size)
+{
+    nk_buffer_init(&str->buffer, alloc, size);
+    str->len = 0;
+}
+
+NK_API void
+nk_str_init_fixed(struct nk_str *str, void *memory, nk_size size)
+{
+    nk_buffer_init_fixed(&str->buffer, memory, size);
+    str->len = 0;
+}
+
+NK_API int
+nk_str_append_text_char(struct nk_str *s, const char *str, int len)
+{
+    char *mem;
+    NK_ASSERT(s);
+    NK_ASSERT(str);
+    if (!s || !str || !len) return 0;
+    mem = (char*)nk_buffer_alloc(&s->buffer, NK_BUFFER_FRONT, (nk_size)len * sizeof(char), 0);
+    if (!mem) return 0;
+    NK_MEMCPY(mem, str, (nk_size)len * sizeof(char));
+    s->len += nk_utf_len(str, len);
+    return len;
+}
+
+NK_API int
+nk_str_append_str_char(struct nk_str *s, const char *str)
+{
+    return nk_str_append_text_char(s, str, nk_strlen(str));
+}
+
+NK_API int
+nk_str_append_text_utf8(struct nk_str *str, const char *text, int len)
+{
+    int i = 0;
+    int byte_len = 0;
+    nk_rune unicode;
+    if (!str || !text || !len) return 0;
+    for (i = 0; i < len; ++i)
+        byte_len += nk_utf_decode(text+byte_len, &unicode, 4);
+    nk_str_append_text_char(str, text, byte_len);
+    return len;
+}
+
+NK_API int
+nk_str_append_str_utf8(struct nk_str *str, const char *text)
+{
+    int runes = 0;
+    int byte_len = 0;
+    int num_runes = 0;
+    int glyph_len = 0;
+    nk_rune unicode;
+    if (!str || !text) return 0;
+
+    glyph_len = byte_len = nk_utf_decode(text+byte_len, &unicode, 4);
+    while (unicode != '\0' && glyph_len) {
+        glyph_len = nk_utf_decode(text+byte_len, &unicode, 4);
+        byte_len += glyph_len;
+        num_runes++;
+    }
+    nk_str_append_text_char(str, text, byte_len);
+    return runes;
+}
+
+NK_API int
+nk_str_append_text_runes(struct nk_str *str, const nk_rune *text, int len)
+{
+    int i = 0;
+    int byte_len = 0;
+    nk_glyph glyph;
+
+    NK_ASSERT(str);
+    if (!str || !text || !len) return 0;
+    for (i = 0; i < len; ++i) {
+        byte_len = nk_utf_encode(text[i], glyph, NK_UTF_SIZE);
+        if (!byte_len) break;
+        nk_str_append_text_char(str, glyph, byte_len);
+    }
+    return len;
+}
+
+NK_API int
+nk_str_append_str_runes(struct nk_str *str, const nk_rune *runes)
+{
+    int i = 0;
+    nk_glyph glyph;
+    int byte_len;
+    NK_ASSERT(str);
+    if (!str || !runes) return 0;
+    while (runes[i] != '\0') {
+        byte_len = nk_utf_encode(runes[i], glyph, NK_UTF_SIZE);
+        nk_str_append_text_char(str, glyph, byte_len);
+        i++;
+    }
+    return i;
+}
+
+NK_API int
+nk_str_insert_at_char(struct nk_str *s, int pos, const char *str, int len)
+{
+    int i;
+    void *mem;
+    char *src;
+    char *dst;
+
+    int copylen;
+    NK_ASSERT(s);
+    NK_ASSERT(str);
+    NK_ASSERT(len >= 0);
+    if (!s || !str || !len || (nk_size)pos > s->buffer.allocated) return 0;
+    if ((s->buffer.allocated + (nk_size)len >= s->buffer.memory.size) &&
+        (s->buffer.type == NK_BUFFER_FIXED)) return 0;
+
+    copylen = (int)s->buffer.allocated - pos;
+    if (!copylen) {
+        nk_str_append_text_char(s, str, len);
+        return 1;
+    }
+    mem = nk_buffer_alloc(&s->buffer, NK_BUFFER_FRONT, (nk_size)len * sizeof(char), 0);
+    if (!mem) return 0;
+
+    /* memmove */
+    NK_ASSERT(((int)pos + (int)len + ((int)copylen - 1)) >= 0);
+    NK_ASSERT(((int)pos + ((int)copylen - 1)) >= 0);
+    dst = nk_ptr_add(char, s->buffer.memory.ptr, pos + len + (copylen - 1));
+    src = nk_ptr_add(char, s->buffer.memory.ptr, pos + (copylen-1));
+    for (i = 0; i < copylen; ++i) *dst-- = *src--;
+    mem = nk_ptr_add(void, s->buffer.memory.ptr, pos);
+    NK_MEMCPY(mem, str, (nk_size)len * sizeof(char));
+    s->len = nk_utf_len((char *)s->buffer.memory.ptr, (int)s->buffer.allocated);
+    return 1;
+}
+
+NK_API int
+nk_str_insert_at_rune(struct nk_str *str, int pos, const char *cstr, int len)
+{
+    int glyph_len;
+    nk_rune unicode;
+    const char *begin;
+    const char *buffer;
+
+    NK_ASSERT(str);
+    NK_ASSERT(cstr);
+    NK_ASSERT(len);
+    if (!str || !cstr || !len) return 0;
+    begin = nk_str_at_rune(str, pos, &unicode, &glyph_len);
+    if (!str->len)
+        return nk_str_append_text_char(str, cstr, len);
+    buffer = nk_str_get_const(str);
+    if (!begin) return 0;
+    return nk_str_insert_at_char(str, (int)(begin - buffer), cstr, len);
+}
+
+NK_API int
+nk_str_insert_text_char(struct nk_str *str, int pos, const char *text, int len)
+{
+    return nk_str_insert_text_utf8(str, pos, text, len);
+}
+
+NK_API int
+nk_str_insert_str_char(struct nk_str *str, int pos, const char *text)
+{
+    return nk_str_insert_text_utf8(str, pos, text, nk_strlen(text));
+}
+
+NK_API int
+nk_str_insert_text_utf8(struct nk_str *str, int pos, const char *text, int len)
+{
+    int i = 0;
+    int byte_len = 0;
+    nk_rune unicode;
+
+    NK_ASSERT(str);
+    NK_ASSERT(text);
+    if (!str || !text || !len) return 0;
+    for (i = 0; i < len; ++i)
+        byte_len += nk_utf_decode(text+byte_len, &unicode, 4);
+    nk_str_insert_at_rune(str, pos, text, byte_len);
+    return len;
+}
+
+NK_API int
+nk_str_insert_str_utf8(struct nk_str *str, int pos, const char *text)
+{
+    int runes = 0;
+    int byte_len = 0;
+    int num_runes = 0;
+    int glyph_len = 0;
+    nk_rune unicode;
+    if (!str || !text) return 0;
+
+    glyph_len = byte_len = nk_utf_decode(text+byte_len, &unicode, 4);
+    while (unicode != '\0' && glyph_len) {
+        glyph_len = nk_utf_decode(text+byte_len, &unicode, 4);
+        byte_len += glyph_len;
+        num_runes++;
+    }
+    nk_str_insert_at_rune(str, pos, text, byte_len);
+    return runes;
+}
+
+NK_API int
+nk_str_insert_text_runes(struct nk_str *str, int pos, const nk_rune *runes, int len)
+{
+    int i = 0;
+    int byte_len = 0;
+    nk_glyph glyph;
+
+    NK_ASSERT(str);
+    if (!str || !runes || !len) return 0;
+    for (i = 0; i < len; ++i) {
+        byte_len = nk_utf_encode(runes[i], glyph, NK_UTF_SIZE);
+        if (!byte_len) break;
+        nk_str_insert_at_rune(str, pos+i, glyph, byte_len);
+    }
+    return len;
+}
+
+NK_API int
+nk_str_insert_str_runes(struct nk_str *str, int pos, const nk_rune *runes)
+{
+    int i = 0;
+    nk_glyph glyph;
+    int byte_len;
+    NK_ASSERT(str);
+    if (!str || !runes) return 0;
+    while (runes[i] != '\0') {
+        byte_len = nk_utf_encode(runes[i], glyph, NK_UTF_SIZE);
+        nk_str_insert_at_rune(str, pos+i, glyph, byte_len);
+        i++;
+    }
+    return i;
+}
+
+NK_API void
+nk_str_remove_chars(struct nk_str *s, int len)
+{
+    NK_ASSERT(s);
+    NK_ASSERT(len >= 0);
+    if (!s || len < 0 || (nk_size)len > s->buffer.allocated) return;
+    NK_ASSERT(((int)s->buffer.allocated - (int)len) >= 0);
+    s->buffer.allocated -= (nk_size)len;
+    s->len = nk_utf_len((char *)s->buffer.memory.ptr, (int)s->buffer.allocated);
+}
+
+NK_API void
+nk_str_remove_runes(struct nk_str *str, int len)
+{
+    int index;
+    const char *begin;
+    const char *end;
+    nk_rune unicode;
+
+    NK_ASSERT(str);
+    NK_ASSERT(len >= 0);
+    if (!str || len < 0) return;
+    if (len >= str->len) {
+        str->len = 0;
+        return;
+    }
+
+    index = str->len - len;
+    begin = nk_str_at_rune(str, index, &unicode, &len);
+    end = (const char*)str->buffer.memory.ptr + str->buffer.allocated;
+    nk_str_remove_chars(str, (int)(end-begin)+1);
+}
+
+NK_API void
+nk_str_delete_chars(struct nk_str *s, int pos, int len)
+{
+    NK_ASSERT(s);
+    if (!s || !len || (nk_size)pos > s->buffer.allocated ||
+        (nk_size)(pos + len) > s->buffer.allocated) return;
+
+    if ((nk_size)(pos + len) < s->buffer.allocated) {
+        /* memmove */
+        char *dst = nk_ptr_add(char, s->buffer.memory.ptr, pos);
+        char *src = nk_ptr_add(char, s->buffer.memory.ptr, pos + len);
+        NK_MEMCPY(dst, src, s->buffer.allocated - (nk_size)(pos + len));
+        NK_ASSERT(((int)s->buffer.allocated - (int)len) >= 0);
+        s->buffer.allocated -= (nk_size)len;
+    } else nk_str_remove_chars(s, len);
+    s->len = nk_utf_len((char *)s->buffer.memory.ptr, (int)s->buffer.allocated);
+}
+
+NK_API void
+nk_str_delete_runes(struct nk_str *s, int pos, int len)
+{
+    char *temp;
+    nk_rune unicode;
+    char *begin;
+    char *end;
+    int unused;
+
+    NK_ASSERT(s);
+    NK_ASSERT(s->len >= pos + len);
+    if (s->len < pos + len)
+        len = NK_CLAMP(0, (s->len - pos), s->len);
+    if (!len) return;
+
+    temp = (char *)s->buffer.memory.ptr;
+    begin = nk_str_at_rune(s, pos, &unicode, &unused);
+    if (!begin) return;
+    s->buffer.memory.ptr = begin;
+    end = nk_str_at_rune(s, len, &unicode, &unused);
+    s->buffer.memory.ptr = temp;
+    if (!end) return;
+    nk_str_delete_chars(s, (int)(begin - temp), (int)(end - begin));
+}
+
+NK_API char*
+nk_str_at_char(struct nk_str *s, int pos)
+{
+    NK_ASSERT(s);
+    if (!s || pos > (int)s->buffer.allocated) return 0;
+    return nk_ptr_add(char, s->buffer.memory.ptr, pos);
+}
+
+NK_API char*
+nk_str_at_rune(struct nk_str *str, int pos, nk_rune *unicode, int *len)
+{
+    int i = 0;
+    int src_len = 0;
+    int glyph_len = 0;
+    char *text;
+    int text_len;
+
+    NK_ASSERT(str);
+    NK_ASSERT(unicode);
+    NK_ASSERT(len);
+
+    if (!str || !unicode || !len) return 0;
+    if (pos < 0) {
+        *unicode = 0;
+        *len = 0;
+        return 0;
+    }
+
+    text = (char*)str->buffer.memory.ptr;
+    text_len = (int)str->buffer.allocated;
+    glyph_len = nk_utf_decode(text, unicode, text_len);
+    while (glyph_len) {
+        if (i == pos) {
+            *len = glyph_len;
+            break;
+        }
+
+        i++;
+        src_len = src_len + glyph_len;
+        glyph_len = nk_utf_decode(text + src_len, unicode, text_len - src_len);
+    }
+    if (i != pos) return 0;
+    return text + src_len;
+}
+
+NK_API const char*
+nk_str_at_char_const(const struct nk_str *s, int pos)
+{
+    NK_ASSERT(s);
+    if (!s || pos > (int)s->buffer.allocated) return 0;
+    return nk_ptr_add(char, s->buffer.memory.ptr, pos);
+}
+
+NK_API const char*
+nk_str_at_const(const struct nk_str *str, int pos, nk_rune *unicode, int *len)
+{
+    int i = 0;
+    int src_len = 0;
+    int glyph_len = 0;
+    char *text;
+    int text_len;
+
+    NK_ASSERT(str);
+    NK_ASSERT(unicode);
+    NK_ASSERT(len);
+
+    if (!str || !unicode || !len) return 0;
+    if (pos < 0) {
+        *unicode = 0;
+        *len = 0;
+        return 0;
+    }
+
+    text = (char*)str->buffer.memory.ptr;
+    text_len = (int)str->buffer.allocated;
+    glyph_len = nk_utf_decode(text, unicode, text_len);
+    while (glyph_len) {
+        if (i == pos) {
+            *len = glyph_len;
+            break;
+        }
+
+        i++;
+        src_len = src_len + glyph_len;
+        glyph_len = nk_utf_decode(text + src_len, unicode, text_len - src_len);
+    }
+    if (i != pos) return 0;
+    return text + src_len;
+}
+
+NK_API nk_rune
+nk_str_rune_at(const struct nk_str *str, int pos)
+{
+    int len;
+    nk_rune unicode = 0;
+    nk_str_at_const(str, pos, &unicode, &len);
+    return unicode;
+}
+
+NK_API char*
+nk_str_get(struct nk_str *s)
+{
+    NK_ASSERT(s);
+    if (!s || !s->len || !s->buffer.allocated) return 0;
+    return (char*)s->buffer.memory.ptr;
+}
+
+NK_API const char*
+nk_str_get_const(const struct nk_str *s)
+{
+    NK_ASSERT(s);
+    if (!s || !s->len || !s->buffer.allocated) return 0;
+    return (const char*)s->buffer.memory.ptr;
+}
+
+NK_API int
+nk_str_len(struct nk_str *s)
+{
+    NK_ASSERT(s);
+    if (!s || !s->len || !s->buffer.allocated) return 0;
+    return s->len;
+}
+
+NK_API int
+nk_str_len_char(struct nk_str *s)
+{
+    NK_ASSERT(s);
+    if (!s || !s->len || !s->buffer.allocated) return 0;
+    return (int)s->buffer.allocated;
+}
+
+NK_API void
+nk_str_clear(struct nk_str *str)
+{
+    NK_ASSERT(str);
+    nk_buffer_clear(&str->buffer);
+    str->len = 0;
+}
+
+NK_API void
+nk_str_free(struct nk_str *str)
+{
+    NK_ASSERT(str);
+    nk_buffer_free(&str->buffer);
+    str->len = 0;
+}
+
+/*
+ * ==============================================================
+ *
+ *                      Command buffer
+ *
+ * ===============================================================
+*/
+NK_INTERN void
+nk_command_buffer_init(struct nk_command_buffer *cmdbuf,
+    struct nk_buffer *buffer, enum nk_command_clipping clip)
+{
+    NK_ASSERT(cmdbuf);
+    NK_ASSERT(buffer);
+    if (!cmdbuf || !buffer) return;
+    cmdbuf->base = buffer;
+    cmdbuf->use_clipping = clip;
+    cmdbuf->begin = buffer->allocated;
+    cmdbuf->end = buffer->allocated;
+    cmdbuf->last = buffer->allocated;
+}
+
+NK_INTERN void
+nk_command_buffer_reset(struct nk_command_buffer *buffer)
+{
+    NK_ASSERT(buffer);
+    if (!buffer) return;
+    buffer->begin = 0;
+    buffer->end = 0;
+    buffer->last = 0;
+    buffer->clip = nk_null_rect;
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    buffer->userdata.ptr = 0;
+#endif
+}
+
+NK_INTERN void*
+nk_command_buffer_push(struct nk_command_buffer* b,
+    enum nk_command_type t, nk_size size)
+{
+    NK_STORAGE const nk_size align = NK_ALIGNOF(struct nk_command);
+    struct nk_command *cmd;
+    nk_size alignment;
+    void *unaligned;
+    void *memory;
+
+    NK_ASSERT(b);
+    NK_ASSERT(b->base);
+    if (!b) return 0;
+    cmd = (struct nk_command*)nk_buffer_alloc(b->base,NK_BUFFER_FRONT,size,align);
+    if (!cmd) return 0;
+
+    /* make sure the offset to the next command is aligned */
+    b->last = (nk_size)((nk_byte*)cmd - (nk_byte*)b->base->memory.ptr);
+    unaligned = (nk_byte*)cmd + size;
+    memory = NK_ALIGN_PTR(unaligned, align);
+    alignment = (nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
+#ifdef NK_ZERO_COMMAND_MEMORY
+    NK_MEMSET(cmd, 0, size + alignment);
+#endif
+
+    cmd->type = t;
+    cmd->next = b->base->allocated + alignment;
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    cmd->userdata = b->userdata;
+#endif
+    b->end = cmd->next;
+    return cmd;
+}
+
+NK_API void
+nk_push_scissor(struct nk_command_buffer *b, struct nk_rect r)
+{
+    struct nk_command_scissor *cmd;
+    NK_ASSERT(b);
+    if (!b) return;
+
+    b->clip.x = r.x;
+    b->clip.y = r.y;
+    b->clip.w = r.w;
+    b->clip.h = r.h;
+    cmd = (struct nk_command_scissor*)
+        nk_command_buffer_push(b, NK_COMMAND_SCISSOR, sizeof(*cmd));
+
+    if (!cmd) return;
+    cmd->x = (short)r.x;
+    cmd->y = (short)r.y;
+    cmd->w = (unsigned short)NK_MAX(0, r.w);
+    cmd->h = (unsigned short)NK_MAX(0, r.h);
+}
+
+NK_API void
+nk_stroke_line(struct nk_command_buffer *b, float x0, float y0,
+    float x1, float y1, float line_thickness, struct nk_color c)
+{
+    struct nk_command_line *cmd;
+    NK_ASSERT(b);
+    if (!b || line_thickness <= 0) return;
+    cmd = (struct nk_command_line*)
+        nk_command_buffer_push(b, NK_COMMAND_LINE, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    cmd->begin.x = (short)x0;
+    cmd->begin.y = (short)y0;
+    cmd->end.x = (short)x1;
+    cmd->end.y = (short)y1;
+    cmd->color = c;
+}
+
+NK_API void
+nk_stroke_curve(struct nk_command_buffer *b, float ax, float ay,
+    float ctrl0x, float ctrl0y, float ctrl1x, float ctrl1y,
+    float bx, float by, float line_thickness, struct nk_color col)
+{
+    struct nk_command_curve *cmd;
+    NK_ASSERT(b);
+    if (!b || col.a == 0 || line_thickness <= 0) return;
+
+    cmd = (struct nk_command_curve*)
+        nk_command_buffer_push(b, NK_COMMAND_CURVE, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    cmd->begin.x = (short)ax;
+    cmd->begin.y = (short)ay;
+    cmd->ctrl[0].x = (short)ctrl0x;
+    cmd->ctrl[0].y = (short)ctrl0y;
+    cmd->ctrl[1].x = (short)ctrl1x;
+    cmd->ctrl[1].y = (short)ctrl1y;
+    cmd->end.x = (short)bx;
+    cmd->end.y = (short)by;
+    cmd->color = col;
+}
+
+NK_API void
+nk_stroke_rect(struct nk_command_buffer *b, struct nk_rect rect,
+    float rounding, float line_thickness, struct nk_color c)
+{
+    struct nk_command_rect *cmd;
+    NK_ASSERT(b);
+    if (!b || c.a == 0 || rect.w == 0 || rect.h == 0 || line_thickness <= 0) return;
+    if (b->use_clipping) {
+        const struct nk_rect *clip = &b->clip;
+        if (!NK_INTERSECT(rect.x, rect.y, rect.w, rect.h,
+            clip->x, clip->y, clip->w, clip->h)) return;
+    }
+    cmd = (struct nk_command_rect*)
+        nk_command_buffer_push(b, NK_COMMAND_RECT, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->rounding = (unsigned short)rounding;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    cmd->x = (short)rect.x;
+    cmd->y = (short)rect.y;
+    cmd->w = (unsigned short)NK_MAX(0, rect.w);
+    cmd->h = (unsigned short)NK_MAX(0, rect.h);
+    cmd->color = c;
+}
+
+NK_API void
+nk_fill_rect(struct nk_command_buffer *b, struct nk_rect rect,
+    float rounding, struct nk_color c)
+{
+    struct nk_command_rect_filled *cmd;
+    NK_ASSERT(b);
+    if (!b || c.a == 0 || rect.w == 0 || rect.h == 0) return;
+    if (b->use_clipping) {
+        const struct nk_rect *clip = &b->clip;
+        if (!NK_INTERSECT(rect.x, rect.y, rect.w, rect.h,
+            clip->x, clip->y, clip->w, clip->h)) return;
+    }
+
+    cmd = (struct nk_command_rect_filled*)
+        nk_command_buffer_push(b, NK_COMMAND_RECT_FILLED, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->rounding = (unsigned short)rounding;
+    cmd->x = (short)rect.x;
+    cmd->y = (short)rect.y;
+    cmd->w = (unsigned short)NK_MAX(0, rect.w);
+    cmd->h = (unsigned short)NK_MAX(0, rect.h);
+    cmd->color = c;
+}
+
+NK_API void
+nk_fill_rect_multi_color(struct nk_command_buffer *b, struct nk_rect rect,
+    struct nk_color left, struct nk_color top, struct nk_color right,
+    struct nk_color bottom)
+{
+    struct nk_command_rect_multi_color *cmd;
+    NK_ASSERT(b);
+    if (!b || rect.w == 0 || rect.h == 0) return;
+    if (b->use_clipping) {
+        const struct nk_rect *clip = &b->clip;
+        if (!NK_INTERSECT(rect.x, rect.y, rect.w, rect.h,
+            clip->x, clip->y, clip->w, clip->h)) return;
+    }
+
+    cmd = (struct nk_command_rect_multi_color*)
+        nk_command_buffer_push(b, NK_COMMAND_RECT_MULTI_COLOR, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->x = (short)rect.x;
+    cmd->y = (short)rect.y;
+    cmd->w = (unsigned short)NK_MAX(0, rect.w);
+    cmd->h = (unsigned short)NK_MAX(0, rect.h);
+    cmd->left = left;
+    cmd->top = top;
+    cmd->right = right;
+    cmd->bottom = bottom;
+}
+
+NK_API void
+nk_stroke_circle(struct nk_command_buffer *b, struct nk_rect r,
+    float line_thickness, struct nk_color c)
+{
+    struct nk_command_circle *cmd;
+    if (!b || r.w == 0 || r.h == 0 || line_thickness <= 0) return;
+    if (b->use_clipping) {
+        const struct nk_rect *clip = &b->clip;
+        if (!NK_INTERSECT(r.x, r.y, r.w, r.h, clip->x, clip->y, clip->w, clip->h))
+            return;
+    }
+
+    cmd = (struct nk_command_circle*)
+        nk_command_buffer_push(b, NK_COMMAND_CIRCLE, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    cmd->x = (short)r.x;
+    cmd->y = (short)r.y;
+    cmd->w = (unsigned short)NK_MAX(r.w, 0);
+    cmd->h = (unsigned short)NK_MAX(r.h, 0);
+    cmd->color = c;
+}
+
+NK_API void
+nk_fill_circle(struct nk_command_buffer *b, struct nk_rect r, struct nk_color c)
+{
+    struct nk_command_circle_filled *cmd;
+    NK_ASSERT(b);
+    if (!b || c.a == 0 || r.w == 0 || r.h == 0) return;
+    if (b->use_clipping) {
+        const struct nk_rect *clip = &b->clip;
+        if (!NK_INTERSECT(r.x, r.y, r.w, r.h, clip->x, clip->y, clip->w, clip->h))
+            return;
+    }
+
+    cmd = (struct nk_command_circle_filled*)
+        nk_command_buffer_push(b, NK_COMMAND_CIRCLE_FILLED, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->x = (short)r.x;
+    cmd->y = (short)r.y;
+    cmd->w = (unsigned short)NK_MAX(r.w, 0);
+    cmd->h = (unsigned short)NK_MAX(r.h, 0);
+    cmd->color = c;
+}
+
+NK_API void
+nk_stroke_arc(struct nk_command_buffer *b, float cx, float cy, float radius,
+    float a_min, float a_max, float line_thickness, struct nk_color c)
+{
+    struct nk_command_arc *cmd;
+    if (!b || c.a == 0 || line_thickness <= 0) return;
+    cmd = (struct nk_command_arc*)
+        nk_command_buffer_push(b, NK_COMMAND_ARC, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    cmd->cx = (short)cx;
+    cmd->cy = (short)cy;
+    cmd->r = (unsigned short)radius;
+    cmd->a[0] = a_min;
+    cmd->a[1] = a_max;
+    cmd->color = c;
+}
+
+NK_API void
+nk_fill_arc(struct nk_command_buffer *b, float cx, float cy, float radius,
+    float a_min, float a_max, struct nk_color c)
+{
+    struct nk_command_arc_filled *cmd;
+    NK_ASSERT(b);
+    if (!b || c.a == 0) return;
+    cmd = (struct nk_command_arc_filled*)
+        nk_command_buffer_push(b, NK_COMMAND_ARC_FILLED, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->cx = (short)cx;
+    cmd->cy = (short)cy;
+    cmd->r = (unsigned short)radius;
+    cmd->a[0] = a_min;
+    cmd->a[1] = a_max;
+    cmd->color = c;
+}
+
+NK_API void
+nk_stroke_triangle(struct nk_command_buffer *b, float x0, float y0, float x1,
+    float y1, float x2, float y2, float line_thickness, struct nk_color c)
+{
+    struct nk_command_triangle *cmd;
+    NK_ASSERT(b);
+    if (!b || c.a == 0 || line_thickness <= 0) return;
+    if (b->use_clipping) {
+        const struct nk_rect *clip = &b->clip;
+        if (!NK_INBOX(x0, y0, clip->x, clip->y, clip->w, clip->h) &&
+            !NK_INBOX(x1, y1, clip->x, clip->y, clip->w, clip->h) &&
+            !NK_INBOX(x2, y2, clip->x, clip->y, clip->w, clip->h))
+            return;
+    }
+
+    cmd = (struct nk_command_triangle*)
+        nk_command_buffer_push(b, NK_COMMAND_TRIANGLE, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    cmd->a.x = (short)x0;
+    cmd->a.y = (short)y0;
+    cmd->b.x = (short)x1;
+    cmd->b.y = (short)y1;
+    cmd->c.x = (short)x2;
+    cmd->c.y = (short)y2;
+    cmd->color = c;
+}
+
+NK_API void
+nk_fill_triangle(struct nk_command_buffer *b, float x0, float y0, float x1,
+    float y1, float x2, float y2, struct nk_color c)
+{
+    struct nk_command_triangle_filled *cmd;
+    NK_ASSERT(b);
+    if (!b || c.a == 0) return;
+    if (!b) return;
+    if (b->use_clipping) {
+        const struct nk_rect *clip = &b->clip;
+        if (!NK_INBOX(x0, y0, clip->x, clip->y, clip->w, clip->h) &&
+            !NK_INBOX(x1, y1, clip->x, clip->y, clip->w, clip->h) &&
+            !NK_INBOX(x2, y2, clip->x, clip->y, clip->w, clip->h))
+            return;
+    }
+
+    cmd = (struct nk_command_triangle_filled*)
+        nk_command_buffer_push(b, NK_COMMAND_TRIANGLE_FILLED, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->a.x = (short)x0;
+    cmd->a.y = (short)y0;
+    cmd->b.x = (short)x1;
+    cmd->b.y = (short)y1;
+    cmd->c.x = (short)x2;
+    cmd->c.y = (short)y2;
+    cmd->color = c;
+}
+
+NK_API void
+nk_stroke_polygon(struct nk_command_buffer *b,  float *points, int point_count,
+    float line_thickness, struct nk_color col)
+{
+    int i;
+    nk_size size = 0;
+    struct nk_command_polygon *cmd;
+
+    NK_ASSERT(b);
+    if (!b || col.a == 0 || line_thickness <= 0) return;
+    size = sizeof(*cmd) + sizeof(short) * 2 * (nk_size)point_count;
+    cmd = (struct nk_command_polygon*) nk_command_buffer_push(b, NK_COMMAND_POLYGON, size);
+    if (!cmd) return;
+    cmd->color = col;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    cmd->point_count = (unsigned short)point_count;
+    for (i = 0; i < point_count; ++i) {
+        cmd->points[i].x = (short)points[i*2];
+        cmd->points[i].y = (short)points[i*2+1];
+    }
+}
+
+NK_API void
+nk_fill_polygon(struct nk_command_buffer *b, float *points, int point_count,
+    struct nk_color col)
+{
+    int i;
+    nk_size size = 0;
+    struct nk_command_polygon_filled *cmd;
+
+    NK_ASSERT(b);
+    if (!b || col.a == 0) return;
+    size = sizeof(*cmd) + sizeof(short) * 2 * (nk_size)point_count;
+    cmd = (struct nk_command_polygon_filled*)
+        nk_command_buffer_push(b, NK_COMMAND_POLYGON_FILLED, size);
+    if (!cmd) return;
+    cmd->color = col;
+    cmd->point_count = (unsigned short)point_count;
+    for (i = 0; i < point_count; ++i) {
+        cmd->points[i].x = (short)points[i*2+0];
+        cmd->points[i].y = (short)points[i*2+1];
+    }
+}
+
+NK_API void
+nk_stroke_polyline(struct nk_command_buffer *b, float *points, int point_count,
+    float line_thickness, struct nk_color col)
+{
+    int i;
+    nk_size size = 0;
+    struct nk_command_polyline *cmd;
+
+    NK_ASSERT(b);
+    if (!b || col.a == 0 || line_thickness <= 0) return;
+    size = sizeof(*cmd) + sizeof(short) * 2 * (nk_size)point_count;
+    cmd = (struct nk_command_polyline*) nk_command_buffer_push(b, NK_COMMAND_POLYLINE, size);
+    if (!cmd) return;
+    cmd->color = col;
+    cmd->point_count = (unsigned short)point_count;
+    cmd->line_thickness = (unsigned short)line_thickness;
+    for (i = 0; i < point_count; ++i) {
+        cmd->points[i].x = (short)points[i*2];
+        cmd->points[i].y = (short)points[i*2+1];
+    }
+}
+
+NK_API void
+nk_draw_image(struct nk_command_buffer *b, struct nk_rect r,
+    const struct nk_image *img, struct nk_color col)
+{
+    struct nk_command_image *cmd;
+    NK_ASSERT(b);
+    if (!b) return;
+    if (b->use_clipping) {
+        const struct nk_rect *c = &b->clip;
+        if (c->w == 0 || c->h == 0 || !NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h))
+            return;
+    }
+
+    cmd = (struct nk_command_image*)
+        nk_command_buffer_push(b, NK_COMMAND_IMAGE, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->x = (short)r.x;
+    cmd->y = (short)r.y;
+    cmd->w = (unsigned short)NK_MAX(0, r.w);
+    cmd->h = (unsigned short)NK_MAX(0, r.h);
+    cmd->img = *img;
+    cmd->col = col;
+}
+
+NK_API void
+nk_push_custom(struct nk_command_buffer *b, struct nk_rect r,
+    nk_command_custom_callback cb, nk_handle usr)
+{
+    struct nk_command_custom *cmd;
+    NK_ASSERT(b);
+    if (!b) return;
+    if (b->use_clipping) {
+        const struct nk_rect *c = &b->clip;
+        if (c->w == 0 || c->h == 0 || !NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h))
+            return;
+    }
+
+    cmd = (struct nk_command_custom*)
+        nk_command_buffer_push(b, NK_COMMAND_CUSTOM, sizeof(*cmd));
+    if (!cmd) return;
+    cmd->x = (short)r.x;
+    cmd->y = (short)r.y;
+    cmd->w = (unsigned short)NK_MAX(0, r.w);
+    cmd->h = (unsigned short)NK_MAX(0, r.h);
+    cmd->callback_data = usr;
+    cmd->callback = cb;
+}
+
+NK_API void
+nk_draw_text(struct nk_command_buffer *b, struct nk_rect r,
+    const char *string, int length, const struct nk_user_font *font,
+    struct nk_color bg, struct nk_color fg)
+{
+    float text_width = 0;
+    struct nk_command_text *cmd;
+
+    NK_ASSERT(b);
+    NK_ASSERT(font);
+    if (!b || !string || !length || (bg.a == 0 && fg.a == 0)) return;
+    if (b->use_clipping) {
+        const struct nk_rect *c = &b->clip;
+        if (c->w == 0 || c->h == 0 || !NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h))
+            return;
+    }
+
+    /* make sure text fits inside bounds */
+    text_width = font->width(font->userdata, font->height, string, length);
+    if (text_width > r.w){
+        int glyphs = 0;
+        float txt_width = (float)text_width;
+        length = nk_text_clamp(font, string, length, r.w, &glyphs, &txt_width, 0,0);
+    }
+
+    if (!length) return;
+    cmd = (struct nk_command_text*)
+        nk_command_buffer_push(b, NK_COMMAND_TEXT, sizeof(*cmd) + (nk_size)(length + 1));
+    if (!cmd) return;
+    cmd->x = (short)r.x;
+    cmd->y = (short)r.y;
+    cmd->w = (unsigned short)r.w;
+    cmd->h = (unsigned short)r.h;
+    cmd->background = bg;
+    cmd->foreground = fg;
+    cmd->font = font;
+    cmd->length = length;
+    cmd->height = font->height;
+    NK_MEMCPY(cmd->string, string, (nk_size)length);
+    cmd->string[length] = '\0';
+}
+
+/* ==============================================================
+ *
+ *                          DRAW LIST
+ *
+ * ===============================================================*/
+#ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
+NK_API void
+nk_draw_list_init(struct nk_draw_list *list)
+{
+    nk_size i = 0;
+    NK_ASSERT(list);
+    if (!list) return;
+    nk_zero(list, sizeof(*list));
+    for (i = 0; i < NK_LEN(list->circle_vtx); ++i) {
+        const float a = ((float)i / (float)NK_LEN(list->circle_vtx)) * 2 * NK_PI;
+        list->circle_vtx[i].x = (float)NK_COS(a);
+        list->circle_vtx[i].y = (float)NK_SIN(a);
+    }
+}
+
+NK_API void
+nk_draw_list_setup(struct nk_draw_list *canvas, const struct nk_convert_config *config,
+    struct nk_buffer *cmds, struct nk_buffer *vertices, struct nk_buffer *elements,
+    enum nk_anti_aliasing line_aa, enum nk_anti_aliasing shape_aa)
+{
+    NK_ASSERT(canvas);
+    NK_ASSERT(config);
+    NK_ASSERT(cmds);
+    NK_ASSERT(vertices);
+    NK_ASSERT(elements);
+    if (!canvas || !config || !cmds || !vertices || !elements)
+        return;
+
+    canvas->buffer = cmds;
+    canvas->config = *config;
+    canvas->elements = elements;
+    canvas->vertices = vertices;
+    canvas->line_AA = line_aa;
+    canvas->shape_AA = shape_aa;
+    canvas->clip_rect = nk_null_rect;
+}
+
+NK_API const struct nk_draw_command*
+nk__draw_list_begin(const struct nk_draw_list *canvas, const struct nk_buffer *buffer)
+{
+    nk_byte *memory;
+    nk_size offset;
+    const struct nk_draw_command *cmd;
+
+    NK_ASSERT(buffer);
+    if (!buffer || !buffer->size || !canvas->cmd_count)
+        return 0;
+
+    memory = (nk_byte*)buffer->memory.ptr;
+    offset = buffer->memory.size - canvas->cmd_offset;
+    cmd = nk_ptr_add(const struct nk_draw_command, memory, offset);
+    return cmd;
+}
+
+NK_API const struct nk_draw_command*
+nk__draw_list_end(const struct nk_draw_list *canvas, const struct nk_buffer *buffer)
+{
+    nk_size size;
+    nk_size offset;
+    nk_byte *memory;
+    const struct nk_draw_command *end;
+
+    NK_ASSERT(buffer);
+    NK_ASSERT(canvas);
+    if (!buffer || !canvas)
+        return 0;
+
+    memory = (nk_byte*)buffer->memory.ptr;
+    size = buffer->memory.size;
+    offset = size - canvas->cmd_offset;
+    end = nk_ptr_add(const struct nk_draw_command, memory, offset);
+    end -= (canvas->cmd_count-1);
+    return end;
+}
+
+NK_API const struct nk_draw_command*
+nk__draw_list_next(const struct nk_draw_command *cmd,
+    const struct nk_buffer *buffer, const struct nk_draw_list *canvas)
+{
+    const struct nk_draw_command *end;
+    NK_ASSERT(buffer);
+    NK_ASSERT(canvas);
+    if (!cmd || !buffer || !canvas)
+        return 0;
+
+    end = nk__draw_list_end(canvas, buffer);
+    if (cmd <= end) return 0;
+    return (cmd-1);
+}
+
+NK_API void
+nk_draw_list_clear(struct nk_draw_list *list)
+{
+    NK_ASSERT(list);
+    if (!list) return;
+    if (list->buffer)
+        nk_buffer_clear(list->buffer);
+    if (list->vertices)
+        nk_buffer_clear(list->vertices);
+    if (list->elements)
+        nk_buffer_clear(list->elements);
+
+    list->element_count = 0;
+    list->vertex_count = 0;
+    list->cmd_offset = 0;
+    list->cmd_count = 0;
+    list->path_count = 0;
+    list->vertices = 0;
+    list->elements = 0;
+    list->clip_rect = nk_null_rect;
+}
+
+NK_INTERN struct nk_vec2*
+nk_draw_list_alloc_path(struct nk_draw_list *list, int count)
+{
+    struct nk_vec2 *points;
+    NK_STORAGE const nk_size point_align = NK_ALIGNOF(struct nk_vec2);
+    NK_STORAGE const nk_size point_size = sizeof(struct nk_vec2);
+    points = (struct nk_vec2*)
+        nk_buffer_alloc(list->buffer, NK_BUFFER_FRONT,
+                        point_size * (nk_size)count, point_align);
+
+    if (!points) return 0;
+    if (!list->path_offset) {
+        void *memory = nk_buffer_memory(list->buffer);
+        list->path_offset = (unsigned int)((nk_byte*)points - (nk_byte*)memory);
+    }
+    list->path_count += (unsigned int)count;
+    return points;
+}
+
+NK_INTERN struct nk_vec2
+nk_draw_list_path_last(struct nk_draw_list *list)
+{
+    void *memory;
+    struct nk_vec2 *point;
+    NK_ASSERT(list->path_count);
+    memory = nk_buffer_memory(list->buffer);
+    point = nk_ptr_add(struct nk_vec2, memory, list->path_offset);
+    point += (list->path_count-1);
+    return *point;
+}
+
+NK_INTERN struct nk_draw_command*
+nk_draw_list_push_command(struct nk_draw_list *list, struct nk_rect clip,
+    nk_handle texture)
+{
+    NK_STORAGE const nk_size cmd_align = NK_ALIGNOF(struct nk_draw_command);
+    NK_STORAGE const nk_size cmd_size = sizeof(struct nk_draw_command);
+    struct nk_draw_command *cmd;
+
+    NK_ASSERT(list);
+    cmd = (struct nk_draw_command*)
+        nk_buffer_alloc(list->buffer, NK_BUFFER_BACK, cmd_size, cmd_align);
+
+    if (!cmd) return 0;
+    if (!list->cmd_count) {
+        nk_byte *memory = (nk_byte*)nk_buffer_memory(list->buffer);
+        nk_size total = nk_buffer_total(list->buffer);
+        memory = nk_ptr_add(nk_byte, memory, total);
+        list->cmd_offset = (nk_size)(memory - (nk_byte*)cmd);
+    }
+
+    cmd->elem_count = 0;
+    cmd->clip_rect = clip;
+    cmd->texture = texture;
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    cmd->userdata = list->userdata;
+#endif
+
+    list->cmd_count++;
+    list->clip_rect = clip;
+    return cmd;
+}
+
+NK_INTERN struct nk_draw_command*
+nk_draw_list_command_last(struct nk_draw_list *list)
+{
+    void *memory;
+    nk_size size;
+    struct nk_draw_command *cmd;
+    NK_ASSERT(list->cmd_count);
+
+    memory = nk_buffer_memory(list->buffer);
+    size = nk_buffer_total(list->buffer);
+    cmd = nk_ptr_add(struct nk_draw_command, memory, size - list->cmd_offset);
+    return (cmd - (list->cmd_count-1));
+}
+
+NK_INTERN void
+nk_draw_list_add_clip(struct nk_draw_list *list, struct nk_rect rect)
+{
+    NK_ASSERT(list);
+    if (!list) return;
+    if (!list->cmd_count) {
+        nk_draw_list_push_command(list, rect, list->config.null.texture);
+    } else {
+        struct nk_draw_command *prev = nk_draw_list_command_last(list);
+        if (prev->elem_count == 0)
+            prev->clip_rect = rect;
+        nk_draw_list_push_command(list, rect, prev->texture);
+    }
+}
+
+NK_INTERN void
+nk_draw_list_push_image(struct nk_draw_list *list, nk_handle texture)
+{
+    NK_ASSERT(list);
+    if (!list) return;
+    if (!list->cmd_count) {
+        nk_draw_list_push_command(list, nk_null_rect, texture);
+    } else {
+        struct nk_draw_command *prev = nk_draw_list_command_last(list);
+        if (prev->elem_count == 0)
+            prev->texture = texture;
+        else if (prev->texture.id != texture.id)
+            nk_draw_list_push_command(list, prev->clip_rect, texture);
+    }
+}
+
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+NK_API void
+nk_draw_list_push_userdata(struct nk_draw_list *list, nk_handle userdata)
+{
+    list->userdata = userdata;
+}
+#endif
+
+NK_INTERN void*
+nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
+{
+    void *vtx;
+    NK_ASSERT(list);
+    if (!list) return 0;
+    vtx = nk_buffer_alloc(list->vertices, NK_BUFFER_FRONT,
+        list->config.vertex_size*count, list->config.vertex_alignment);
+    if (!vtx) return 0;
+    list->vertex_count += (unsigned int)count;
+    return vtx;
+}
+
+NK_INTERN nk_draw_index*
+nk_draw_list_alloc_elements(struct nk_draw_list *list, nk_size count)
+{
+    nk_draw_index *ids;
+    struct nk_draw_command *cmd;
+    NK_STORAGE const nk_size elem_align = NK_ALIGNOF(nk_draw_index);
+    NK_STORAGE const nk_size elem_size = sizeof(nk_draw_index);
+    NK_ASSERT(list);
+    if (!list) return 0;
+
+    ids = (nk_draw_index*)
+        nk_buffer_alloc(list->elements, NK_BUFFER_FRONT, elem_size*count, elem_align);
+    if (!ids) return 0;
+    cmd = nk_draw_list_command_last(list);
+    list->element_count += (unsigned int)count;
+    cmd->elem_count += (unsigned int)count;
+    return ids;
+}
+
+NK_INTERN int
+nk_draw_vertex_layout_element_is_end_of_layout(
+    const struct nk_draw_vertex_layout_element *element)
+{
+    return (element->attribute == NK_VERTEX_ATTRIBUTE_COUNT ||
+            element->format == NK_FORMAT_COUNT);
+}
+
+NK_INTERN void
+nk_draw_vertex_color(void *attribute, const float *values,
+    enum nk_draw_vertex_layout_format format)
+{
+    /* if this triggers you tried to provide a value format for a color */
+    NK_ASSERT(format >= NK_FORMAT_COLOR_BEGIN);
+    NK_ASSERT(format <= NK_FORMAT_COLOR_END);
+    if (format < NK_FORMAT_COLOR_BEGIN || format > NK_FORMAT_COLOR_END) return;
+
+    switch (format) {
+    default: NK_ASSERT(0 && "Invalid vertex layout color format"); break;
+    case NK_FORMAT_R8G8B8A8:
+    case NK_FORMAT_R8G8B8: {
+        struct nk_color col = nk_rgba_fv(values);
+        NK_MEMCPY(attribute, &col.r, sizeof(col));
+    } break;
+    case NK_FORMAT_B8G8R8A8: {
+        struct nk_color col = nk_rgba_fv(values);
+        struct nk_color bgra = nk_rgba(col.b, col.g, col.r, col.a);
+        NK_MEMCPY(attribute, &bgra, sizeof(bgra));
+    } break;
+    case NK_FORMAT_R16G15B16: {
+        nk_ushort col[3];
+        col[0] = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
+        col[1] = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
+        col[2] = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
+        NK_MEMCPY(attribute, col, sizeof(col));
+    } break;
+    case NK_FORMAT_R16G15B16A16: {
+        nk_ushort col[4];
+        col[0] = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
+        col[1] = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
+        col[2] = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
+        col[3] = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[3] * NK_USHORT_MAX, NK_USHORT_MAX);
+        NK_MEMCPY(attribute, col, sizeof(col));
+    } break;
+    case NK_FORMAT_R32G32B32: {
+        nk_uint col[3];
+        col[0] = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
+        col[1] = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
+        col[2] = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
+        NK_MEMCPY(attribute, col, sizeof(col));
+    } break;
+    case NK_FORMAT_R32G32B32A32: {
+        nk_uint col[4];
+        col[0] = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
+        col[1] = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
+        col[2] = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
+        col[3] = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[3] * NK_UINT_MAX, NK_UINT_MAX);
+        NK_MEMCPY(attribute, col, sizeof(col));
+    } break;
+    case NK_FORMAT_R32G32B32A32_FLOAT:
+        NK_MEMCPY(attribute, values, sizeof(float)*4);
+        break;
+    case NK_FORMAT_R32G32B32A32_DOUBLE: {
+        double col[4];
+        col[0] = (double)NK_SATURATE(values[0]);
+        col[1] = (double)NK_SATURATE(values[1]);
+        col[2] = (double)NK_SATURATE(values[2]);
+        col[3] = (double)NK_SATURATE(values[3]);
+        NK_MEMCPY(attribute, col, sizeof(col));
+    } break;
+    case NK_FORMAT_RGB32:
+    case NK_FORMAT_RGBA32: {
+        struct nk_color col = nk_rgba_fv(values);
+        nk_uint color = nk_color_u32(col);
+        NK_MEMCPY(attribute, &color, sizeof(color));
+    } break;
+    }
+}
+
+NK_INTERN void
+nk_draw_vertex_element(void *dst, const float *values, int value_count,
+    enum nk_draw_vertex_layout_format format)
+{
+    int value_index;
+    void *attribute = dst;
+    /* if this triggers you tried to provide a color format for a value */
+    NK_ASSERT(format < NK_FORMAT_COLOR_BEGIN);
+    if (format >= NK_FORMAT_COLOR_BEGIN && format <= NK_FORMAT_COLOR_END) return;
+    for (value_index = 0; value_index < value_count; ++value_index) {
+        switch (format) {
+        default: NK_ASSERT(0 && "invalid vertex layout format"); break;
+        case NK_FORMAT_SCHAR: {
+            char value = (char)NK_CLAMP(NK_SCHAR_MIN, values[value_index], NK_SCHAR_MAX);
+            NK_MEMCPY(attribute, &value, sizeof(value));
+            attribute = (void*)((char*)attribute + sizeof(char));
+        } break;
+        case NK_FORMAT_SSHORT: {
+            nk_short value = (nk_short)NK_CLAMP(NK_SSHORT_MIN, values[value_index], NK_SSHORT_MAX);
+            NK_MEMCPY(attribute, &value, sizeof(value));
+            attribute = (void*)((char*)attribute + sizeof(value));
+        } break;
+        case NK_FORMAT_SINT: {
+            nk_int value = (nk_int)NK_CLAMP(NK_SINT_MIN, values[value_index], NK_SINT_MAX);
+            NK_MEMCPY(attribute, &value, sizeof(value));
+            attribute = (void*)((char*)attribute + sizeof(nk_int));
+        } break;
+        case NK_FORMAT_UCHAR: {
+            unsigned char value = (unsigned char)NK_CLAMP(NK_UCHAR_MIN, values[value_index], NK_UCHAR_MAX);
+            NK_MEMCPY(attribute, &value, sizeof(value));
+            attribute = (void*)((char*)attribute + sizeof(unsigned char));
+        } break;
+        case NK_FORMAT_USHORT: {
+            nk_ushort value = (nk_ushort)NK_CLAMP(NK_USHORT_MIN, values[value_index], NK_USHORT_MAX);
+            NK_MEMCPY(attribute, &value, sizeof(value));
+            attribute = (void*)((char*)attribute + sizeof(value));
+            } break;
+        case NK_FORMAT_UINT: {
+            nk_uint value = (nk_uint)NK_CLAMP(NK_UINT_MIN, values[value_index], NK_UINT_MAX);
+            NK_MEMCPY(attribute, &value, sizeof(value));
+            attribute = (void*)((char*)attribute + sizeof(nk_uint));
+        } break;
+        case NK_FORMAT_FLOAT:
+            NK_MEMCPY(attribute, &values[value_index], sizeof(values[value_index]));
+            attribute = (void*)((char*)attribute + sizeof(float));
+            break;
+        case NK_FORMAT_DOUBLE: {
+            double value = (double)values[value_index];
+            NK_MEMCPY(attribute, &value, sizeof(value));
+            attribute = (void*)((char*)attribute + sizeof(double));
+            } break;
+        }
+    }
+}
+
+NK_INTERN void*
+nk_draw_vertex(void *dst, const struct nk_convert_config *config,
+    struct nk_vec2 pos, struct nk_vec2 uv, struct nk_colorf color)
+{
+    void *result = (void*)((char*)dst + config->vertex_size);
+    const struct nk_draw_vertex_layout_element *elem_iter = config->vertex_layout;
+    while (!nk_draw_vertex_layout_element_is_end_of_layout(elem_iter)) {
+        void *address = (void*)((char*)dst + elem_iter->offset);
+        switch (elem_iter->attribute) {
+        case NK_VERTEX_ATTRIBUTE_COUNT:
+        default: NK_ASSERT(0 && "wrong element attribute");
+        case NK_VERTEX_POSITION: nk_draw_vertex_element(address, &pos.x, 2, elem_iter->format); break;
+        case NK_VERTEX_TEXCOORD: nk_draw_vertex_element(address, &uv.x, 2, elem_iter->format); break;
+        case NK_VERTEX_COLOR: nk_draw_vertex_color(address, &color.r, elem_iter->format); break;
+        }
+        elem_iter++;
+    }
+    return result;
+}
+
+NK_API void
+nk_draw_list_stroke_poly_line(struct nk_draw_list *list, const struct nk_vec2 *points,
+    const unsigned int points_count, struct nk_color color, enum nk_draw_list_stroke closed,
+    float thickness, enum nk_anti_aliasing aliasing)
+{
+    nk_size count;
+    int thick_line;
+    struct nk_colorf col;
+    struct nk_colorf col_trans;
+    NK_ASSERT(list);
+    if (!list || points_count < 2) return;
+
+    color.a = (nk_byte)((float)color.a * list->config.global_alpha);
+    count = points_count;
+    if (!closed) count = points_count-1;
+    thick_line = thickness > 1.0f;
+
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    nk_draw_list_push_userdata(list, list->userdata);
+#endif
+
+    color.a = (nk_byte)((float)color.a * list->config.global_alpha);
+    nk_color_fv(&col.r, color);
+    col_trans = col;
+    col_trans.a = 0;
+
+    if (aliasing == NK_ANTI_ALIASING_ON) {
+        /* ANTI-ALIASED STROKE */
+        const float AA_SIZE = 1.0f;
+        NK_STORAGE const nk_size pnt_align = NK_ALIGNOF(struct nk_vec2);
+        NK_STORAGE const nk_size pnt_size = sizeof(struct nk_vec2);
+
+        /* allocate vertices and elements  */
+        nk_size i1 = 0;
+        nk_size vertex_offset;
+        nk_size index = list->vertex_count;
+
+        const nk_size idx_count = (thick_line) ?  (count * 18) : (count * 12);
+        const nk_size vtx_count = (thick_line) ? (points_count * 4): (points_count *3);
+
+        void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
+        nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
+
+        nk_size size;
+        struct nk_vec2 *normals, *temp;
+        if (!vtx || !ids) return;
+
+        /* temporary allocate normals + points */
+        vertex_offset = (nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
+        nk_buffer_mark(list->vertices, NK_BUFFER_FRONT);
+        size = pnt_size * ((thick_line) ? 5 : 3) * points_count;
+        normals = (struct nk_vec2*) nk_buffer_alloc(list->vertices, NK_BUFFER_FRONT, size, pnt_align);
+        NK_ASSERT(normals);
+        if (!normals) return;
+        temp = normals + points_count;
+
+        /* make sure vertex pointer is still correct */
+        vtx = (void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
+
+        /* calculate normals */
+        for (i1 = 0; i1 < count; ++i1) {
+            const nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
+            struct nk_vec2 diff = nk_vec2_sub(points[i2], points[i1]);
+            float len;
+
+            /* vec2 inverted length  */
+            len = nk_vec2_len_sqr(diff);
+            if (len != 0.0f)
+                len = nk_inv_sqrt(len);
+            else len = 1.0f;
+
+            diff = nk_vec2_muls(diff, len);
+            normals[i1].x = diff.y;
+            normals[i1].y = -diff.x;
+        }
+
+        if (!closed)
+            normals[points_count-1] = normals[points_count-2];
+
+        if (!thick_line) {
+            nk_size idx1, i;
+            if (!closed) {
+                struct nk_vec2 d;
+                temp[0] = nk_vec2_add(points[0], nk_vec2_muls(normals[0], AA_SIZE));
+                temp[1] = nk_vec2_sub(points[0], nk_vec2_muls(normals[0], AA_SIZE));
+                d = nk_vec2_muls(normals[points_count-1], AA_SIZE);
+                temp[(points_count-1) * 2 + 0] = nk_vec2_add(points[points_count-1], d);
+                temp[(points_count-1) * 2 + 1] = nk_vec2_sub(points[points_count-1], d);
+            }
+
+            /* fill elements */
+            idx1 = index;
+            for (i1 = 0; i1 < count; i1++) {
+                struct nk_vec2 dm;
+                float dmr2;
+                nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
+                nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 3);
+
+                /* average normals */
+                dm = nk_vec2_muls(nk_vec2_add(normals[i1], normals[i2]), 0.5f);
+                dmr2 = dm.x * dm.x + dm.y* dm.y;
+                if (dmr2 > 0.000001f) {
+                    float scale = 1.0f/dmr2;
+                    scale = NK_MIN(100.0f, scale);
+                    dm = nk_vec2_muls(dm, scale);
+                }
+
+                dm = nk_vec2_muls(dm, AA_SIZE);
+                temp[i2*2+0] = nk_vec2_add(points[i2], dm);
+                temp[i2*2+1] = nk_vec2_sub(points[i2], dm);
+
+                ids[0] = (nk_draw_index)(idx2 + 0); ids[1] = (nk_draw_index)(idx1+0);
+                ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
+                ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+0);
+                ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
+                ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
+                ids[10]= (nk_draw_index)(idx2 + 0); ids[11]= (nk_draw_index)(idx2+1);
+                ids += 12;
+                idx1 = idx2;
+            }
+
+            /* fill vertices */
+            for (i = 0; i < points_count; ++i) {
+                const struct nk_vec2 uv = list->config.null.uv;
+                vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col);
+                vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans);
+                vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans);
+            }
+        } else {
+            nk_size idx1, i;
+            const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
+            if (!closed) {
+                struct nk_vec2 d1 = nk_vec2_muls(normals[0], half_inner_thickness + AA_SIZE);
+                struct nk_vec2 d2 = nk_vec2_muls(normals[0], half_inner_thickness);
+
+                temp[0] = nk_vec2_add(points[0], d1);
+                temp[1] = nk_vec2_add(points[0], d2);
+                temp[2] = nk_vec2_sub(points[0], d2);
+                temp[3] = nk_vec2_sub(points[0], d1);
+
+                d1 = nk_vec2_muls(normals[points_count-1], half_inner_thickness + AA_SIZE);
+                d2 = nk_vec2_muls(normals[points_count-1], half_inner_thickness);
+
+                temp[(points_count-1)*4+0] = nk_vec2_add(points[points_count-1], d1);
+                temp[(points_count-1)*4+1] = nk_vec2_add(points[points_count-1], d2);
+                temp[(points_count-1)*4+2] = nk_vec2_sub(points[points_count-1], d2);
+                temp[(points_count-1)*4+3] = nk_vec2_sub(points[points_count-1], d1);
+            }
+
+            /* add all elements */
+            idx1 = index;
+            for (i1 = 0; i1 < count; ++i1) {
+                struct nk_vec2 dm_out, dm_in;
+                const nk_size i2 = ((i1+1) == points_count) ? 0: (i1 + 1);
+                nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 4);
+
+                /* average normals */
+                struct nk_vec2 dm = nk_vec2_muls(nk_vec2_add(normals[i1], normals[i2]), 0.5f);
+                float dmr2 = dm.x * dm.x + dm.y* dm.y;
+                if (dmr2 > 0.000001f) {
+                    float scale = 1.0f/dmr2;
+                    scale = NK_MIN(100.0f, scale);
+                    dm = nk_vec2_muls(dm, scale);
+                }
+
+                dm_out = nk_vec2_muls(dm, ((half_inner_thickness) + AA_SIZE));
+                dm_in = nk_vec2_muls(dm, half_inner_thickness);
+                temp[i2*4+0] = nk_vec2_add(points[i2], dm_out);
+                temp[i2*4+1] = nk_vec2_add(points[i2], dm_in);
+                temp[i2*4+2] = nk_vec2_sub(points[i2], dm_in);
+                temp[i2*4+3] = nk_vec2_sub(points[i2], dm_out);
+
+                /* add indexes */
+                ids[0] = (nk_draw_index)(idx2 + 1); ids[1] = (nk_draw_index)(idx1+1);
+                ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
+                ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+1);
+                ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
+                ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
+                ids[10]= (nk_draw_index)(idx2 + 0); ids[11] = (nk_draw_index)(idx2+1);
+                ids[12]= (nk_draw_index)(idx2 + 2); ids[13] = (nk_draw_index)(idx1+2);
+                ids[14]= (nk_draw_index)(idx1 + 3); ids[15] = (nk_draw_index)(idx1+3);
+                ids[16]= (nk_draw_index)(idx2 + 3); ids[17] = (nk_draw_index)(idx2+2);
+                ids += 18;
+                idx1 = idx2;
+            }
+
+            /* add vertices */
+            for (i = 0; i < points_count; ++i) {
+                const struct nk_vec2 uv = list->config.null.uv;
+                vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans);
+                vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col);
+                vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col);
+                vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+3], uv, col_trans);
+            }
+        }
+        /* free temporary normals + points */
+        nk_buffer_reset(list->vertices, NK_BUFFER_FRONT);
+    } else {
+        /* NON ANTI-ALIASED STROKE */
+        nk_size i1 = 0;
+        nk_size idx = list->vertex_count;
+        const nk_size idx_count = count * 6;
+        const nk_size vtx_count = count * 4;
+        void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
+        nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
+        if (!vtx || !ids) return;
+
+        for (i1 = 0; i1 < count; ++i1) {
+            float dx, dy;
+            const struct nk_vec2 uv = list->config.null.uv;
+            const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1;
+            const struct nk_vec2 p1 = points[i1];
+            const struct nk_vec2 p2 = points[i2];
+            struct nk_vec2 diff = nk_vec2_sub(p2, p1);
+            float len;
+
+            /* vec2 inverted length  */
+            len = nk_vec2_len_sqr(diff);
+            if (len != 0.0f)
+                len = nk_inv_sqrt(len);
+            else len = 1.0f;
+            diff = nk_vec2_muls(diff, len);
+
+            /* add vertices */
+            dx = diff.x * (thickness * 0.5f);
+            dy = diff.y * (thickness * 0.5f);
+
+            vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(p1.x + dy, p1.y - dx), uv, col);
+            vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(p2.x + dy, p2.y - dx), uv, col);
+            vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(p2.x - dy, p2.y + dx), uv, col);
+            vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(p1.x - dy, p1.y + dx), uv, col);
+
+            ids[0] = (nk_draw_index)(idx+0); ids[1] = (nk_draw_index)(idx+1);
+            ids[2] = (nk_draw_index)(idx+2); ids[3] = (nk_draw_index)(idx+0);
+            ids[4] = (nk_draw_index)(idx+2); ids[5] = (nk_draw_index)(idx+3);
+
+            ids += 6;
+            idx += 4;
+        }
+    }
+}
+
+NK_API void
+nk_draw_list_fill_poly_convex(struct nk_draw_list *list,
+    const struct nk_vec2 *points, const unsigned int points_count,
+    struct nk_color color, enum nk_anti_aliasing aliasing)
+{
+    struct nk_colorf col;
+    struct nk_colorf col_trans;
+
+    NK_STORAGE const nk_size pnt_align = NK_ALIGNOF(struct nk_vec2);
+    NK_STORAGE const nk_size pnt_size = sizeof(struct nk_vec2);
+    NK_ASSERT(list);
+    if (!list || points_count < 3) return;
+
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+    nk_draw_list_push_userdata(list, list->userdata);
+#endif
+
+    color.a = (nk_byte)((float)color.a * list->config.global_alpha);
+    nk_color_fv(&col.r, color);
+    col_trans = col;
+    col_trans.a = 0;
+
+    if (aliasing == NK_ANTI_ALIASING_ON) {
+        nk_size i = 0;
+        nk_size i0 = 0;
+        nk_size i1 = 0;
+
+        const float AA_SIZE = 1.0f;
+        nk_size vertex_offset = 0;
+        nk_size index = list->vertex_count;
+
+        const nk_size idx_count = (points_count-2)*3 + points_count*6;
+        const nk_size vtx_count = (points_count*2);
+
+        void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
+        nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
+
+        nk_size size = 0;
+        struct nk_vec2 *normals = 0;
+        unsigned int vtx_inner_idx = (unsigned int)(index + 0);
+        unsigned int vtx_outer_idx = (unsigned int)(index + 1);
+        if (!vtx || !ids) return;
+
+        /* temporary allocate normals */
+        vertex_offset = (nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
+        nk_buffer_mark(list->vertices, NK_BUFFER_FRONT);
+        size = pnt_size * points_count;
+        normals = (struct nk_vec2*) nk_buffer_alloc(list->vertices, NK_BUFFER_FRONT, size, pnt_align);
+        NK_ASSERT(normals);
+        if (!normals) return;
+        vtx = (void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
+
+        /* add elements */
+        for (i = 2; i < points_count; i++) {
+            ids[0] = (nk_draw_index)(vtx_inner_idx);
+            ids[1] = (nk_draw_index)(vtx_inner_idx + ((i-1) << 1));
+            ids[2] = (nk_draw_index)(vtx_inner_idx + (i << 1));
+            ids += 3;
+        }
+
+        /* compute normals */
+        for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
+            struct nk_vec2 p0 = points[i0];
+            struct nk_vec2 p1 = points[i1];
+            struct nk_vec2 diff = nk_vec2_sub(p1, p0);
+
+            /* vec2 inverted length  */
+            float len = nk_vec2_len_sqr(diff);
+            if (len != 0.0f)
+                len = nk_inv_sqrt(len);
+            else len = 1.0f;
+            diff = nk_vec2_muls(diff, len);
+
+            normals[i0].x = diff.y;
+            normals[i0].y = -diff.x;
+        }
+
+        /* add vertices + indexes */
+        for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
+            const struct nk_vec2 uv = list->config.null.uv;
+            struct nk_vec2 n0 = normals[i0];
+            struct nk_vec2 n1 = normals[i1];
+            struct nk_vec2 dm = nk_vec2_muls(nk_vec2_add(n0, n1), 0.5f);
+            float dmr2 = dm.x*dm.x + dm.y*dm.y;
+            if (dmr2 > 0.000001f) {
+                float scale = 1.0f / dmr2;
+                scale = NK_MIN(scale, 100.0f);
+                dm = nk_vec2_muls(dm, scale);
+            }
+            dm = nk_vec2_muls(dm, AA_SIZE * 0.5f);
+
+            /* add vertices */
+            vtx = nk_draw_vertex(vtx, &list->config, nk_vec2_sub(points[i1], dm), uv, col);
+            vtx = nk_draw_vertex(vtx, &list->config, nk_vec2_add(points[i1], dm), uv, col_trans);
+
+            /* add indexes */
+            ids[0] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
+            ids[1] = (nk_draw_index)(vtx_inner_idx+(i0<<1));
+            ids[2] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
+            ids[3] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
+            ids[4] = (nk_draw_index)(vtx_outer_idx+(i1<<1));
+            ids[5] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
+            ids += 6;
+        }
+        /* free temporary normals + points */
+        nk_buffer_reset(list->vertices, NK_BUFFER_FRONT);
+    } else {
+        nk_size i = 0;
+        nk_size index = list->vertex_count;
+        const nk_size idx_count = (points_count-2)*3;
+        const nk_size vtx_count = points_count;
+        void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
+        nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
+
+        if (!vtx || !ids) return;
+        for (i = 0; i < vtx_count; ++i)
+            vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col);
+        for (i = 2; i < points_count; ++i) {
+            ids[0] = (nk_draw_index)index;
+            ids[1] = (nk_draw_index)(index+ i - 1);
+            ids[2] = (nk_draw_index)(index+i);
+            ids += 3;
+        }
+    }
+}
+
+NK_API void
+nk_draw_list_path_clear(struct nk_draw_list *list)
+{
+    NK_ASSERT(list);
+    if (!list) return;
+    nk_buffer_reset(list->buffer, NK_BUFFER_FRONT);
+    list->path_count = 0;
+    list->path_offset = 0;
+}
+
+NK_API void
+nk_draw_list_path_line_to(struct nk_draw_list *list, struct nk_vec2 pos)
+{
+    struct nk_vec2 *points = 0;
+    struct nk_draw_command *cmd = 0;
+    NK_ASSERT(list);
+    if (!list) return;
+    if (!list->cmd_count)
+        nk_draw_list_add_clip(list, nk_null_rect);
+
+    cmd = nk_draw_list_command_last(list);
+    if (cmd && cmd->texture.ptr != list->config.null.texture.ptr)
+        nk_draw_list_push_image(list, list->config.null.texture);
+
+    points = nk_draw_list_alloc_path(list, 1);
+    if (!points) return;
+    points[0] = pos;
+}
+
+NK_API void
+nk_draw_list_path_arc_to_fast(struct nk_draw_list *list, struct nk_vec2 center,
+    float radius, int a_min, int a_max)
+{
+    int a = 0;
+    NK_ASSERT(list);
+    if (!list) return;
+    if (a_min <= a_max) {
+        for (a = a_min; a <= a_max; a++) {
+            const struct nk_vec2 c = list->circle_vtx[(nk_size)a % NK_LEN(list->circle_vtx)];
+            const float x = center.x + c.x * radius;
+            const float y = center.y + c.y * radius;
+            nk_draw_list_path_line_to(list, nk_vec2(x, y));
+        }
+    }
+}
+
+NK_API void
+nk_draw_list_path_arc_to(struct nk_draw_list *list, struct nk_vec2 center,
+    float radius, float a_min, float a_max, unsigned int segments)
+{
+    unsigned int i = 0;
+    NK_ASSERT(list);
+    if (!list) return;
+    if (radius == 0.0f) return;
+
+    /*  This algorithm for arc drawing relies on these two trigonometric identities[1]:
+            sin(a + b) = sin(a) * cos(b) + cos(a) * sin(b)
+            cos(a + b) = cos(a) * cos(b) - sin(a) * sin(b)
+
+        Two coordinates (x, y) of a point on a circle centered on
+        the origin can be written in polar form as:
+            x = r * cos(a)
+            y = r * sin(a)
+        where r is the radius of the circle,
+            a is the angle between (x, y) and the origin.
+
+        This allows us to rotate the coordinates around the
+        origin by an angle b using the following transformation:
+            x' = r * cos(a + b) = x * cos(b) - y * sin(b)
+            y' = r * sin(a + b) = y * cos(b) + x * sin(b)
+
+        [1] https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Angle_sum_and_difference_identities
+    */
+    const float d_angle = (a_max - a_min) / (float)segments;
+    const float sin_d = (float)NK_SIN(d_angle);
+    const float cos_d = (float)NK_COS(d_angle);
+
+    float cx = (float)NK_COS(a_min) * radius;
+    float cy = (float)NK_SIN(a_min) * radius;
+    for(i = 0; i <= segments; ++i) {
+        const float x = center.x + cx;
+        const float y = center.y + cy;
+        nk_draw_list_path_line_to(list, nk_vec2(x, y));
+
+        const float new_cx = cx * cos_d - cy * sin_d;
+        const float new_cy = cy * cos_d + cx * sin_d;
+        cx = new_cx;
+        cy = new_cy;
+    }
+}
+
+NK_API void
+nk_draw_list_path_rect_to(struct nk_draw_list *list, struct nk_vec2 a,
+    struct nk_vec2 b, float rounding)
+{
+    float r;
+    NK_ASSERT(list);
+    if (!list) return;
+    r = rounding;
+    r = NK_MIN(r, ((b.x-a.x) < 0) ? -(b.x-a.x): (b.x-a.x));
+    r = NK_MIN(r, ((b.y-a.y) < 0) ? -(b.y-a.y): (b.y-a.y));
+
+    if (r == 0.0f) {
+        nk_draw_list_path_line_to(list, a);
+        nk_draw_list_path_line_to(list, nk_vec2(b.x,a.y));
+        nk_draw_list_path_line_to(list, b);
+        nk_draw_list_path_line_to(list, nk_vec2(a.x,b.y));
+    } else {
+        nk_draw_list_path_arc_to_fast(list, nk_vec2(a.x + r, a.y + r), r, 6, 9);
+        nk_draw_list_path_arc_to_fast(list, nk_vec2(b.x - r, a.y + r), r, 9, 12);
+        nk_draw_list_path_arc_to_fast(list, nk_vec2(b.x - r, b.y - r), r, 0, 3);
+        nk_draw_list_path_arc_to_fast(list, nk_vec2(a.x + r, b.y - r), r, 3, 6);
+    }
+}
+
+NK_API void
+nk_draw_list_path_curve_to(struct nk_draw_list *list, struct nk_vec2 p2,
+    struct nk_vec2 p3, struct nk_vec2 p4, unsigned int num_segments)
+{
+    float t_step;
+    unsigned int i_step;
+    struct nk_vec2 p1;
+
+    NK_ASSERT(list);
+    NK_ASSERT(list->path_count);
+    if (!list || !list->path_count) return;
+    num_segments = NK_MAX(num_segments, 1);
+
+    p1 = nk_draw_list_path_last(list);
+    t_step = 1.0f/(float)num_segments;
+    for (i_step = 1; i_step <= num_segments; ++i_step) {
+        float t = t_step * (float)i_step;
+        float u = 1.0f - t;
+        float w1 = u*u*u;
+        float w2 = 3*u*u*t;
+        float w3 = 3*u*t*t;
+        float w4 = t * t *t;
+        float x = w1 * p1.x + w2 * p2.x + w3 * p3.x + w4 * p4.x;
+        float y = w1 * p1.y + w2 * p2.y + w3 * p3.y + w4 * p4.y;
+        nk_draw_list_path_line_to(list, nk_vec2(x,y));
+    }
+}
+
+NK_API void
+nk_draw_list_path_fill(struct nk_draw_list *list, struct nk_color color)
+{
+    struct nk_vec2 *points;
+    NK_ASSERT(list);
+    if (!list) return;
+    points = (struct nk_vec2*)nk_buffer_memory(list->buffer);
+    nk_draw_list_fill_poly_convex(list, points, list->path_count, color, list->config.shape_AA);
+    nk_draw_list_path_clear(list);
+}
+
+NK_API void
+nk_draw_list_path_stroke(struct nk_draw_list *list, struct nk_color color,
+    enum nk_draw_list_stroke closed, float thickness)
+{
+    struct nk_vec2 *points;
+    NK_ASSERT(list);
+    if (!list) return;
+    points = (struct nk_vec2*)nk_buffer_memory(list->buffer);
+    nk_draw_list_stroke_poly_line(list, points, list->path_count, color,
+        closed, thickness, list->config.line_AA);
+    nk_draw_list_path_clear(list);
+}
+
+NK_API void
+nk_draw_list_stroke_line(struct nk_draw_list *list, struct nk_vec2 a,
+    struct nk_vec2 b, struct nk_color col, float thickness)
+{
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+    if (list->line_AA == NK_ANTI_ALIASING_ON) {
+        nk_draw_list_path_line_to(list, a);
+        nk_draw_list_path_line_to(list, b);
+    } else {
+        nk_draw_list_path_line_to(list, nk_vec2_sub(a,nk_vec2(0.5f,0.5f)));
+        nk_draw_list_path_line_to(list, nk_vec2_sub(b,nk_vec2(0.5f,0.5f)));
+    }
+    nk_draw_list_path_stroke(list,  col, NK_STROKE_OPEN, thickness);
+}
+
+NK_API void
+nk_draw_list_fill_rect(struct nk_draw_list *list, struct nk_rect rect,
+    struct nk_color col, float rounding)
+{
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+
+    if (list->line_AA == NK_ANTI_ALIASING_ON) {
+        nk_draw_list_path_rect_to(list, nk_vec2(rect.x, rect.y),
+            nk_vec2(rect.x + rect.w, rect.y + rect.h), rounding);
+    } else {
+        nk_draw_list_path_rect_to(list, nk_vec2(rect.x-0.5f, rect.y-0.5f),
+            nk_vec2(rect.x + rect.w, rect.y + rect.h), rounding);
+    } nk_draw_list_path_fill(list,  col);
+}
+
+NK_API void
+nk_draw_list_stroke_rect(struct nk_draw_list *list, struct nk_rect rect,
+    struct nk_color col, float rounding, float thickness)
+{
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+    if (list->line_AA == NK_ANTI_ALIASING_ON) {
+        nk_draw_list_path_rect_to(list, nk_vec2(rect.x, rect.y),
+            nk_vec2(rect.x + rect.w, rect.y + rect.h), rounding);
+    } else {
+        nk_draw_list_path_rect_to(list, nk_vec2(rect.x-0.5f, rect.y-0.5f),
+            nk_vec2(rect.x + rect.w, rect.y + rect.h), rounding);
+    } nk_draw_list_path_stroke(list,  col, NK_STROKE_CLOSED, thickness);
+}
+
+NK_API void
+nk_draw_list_fill_rect_multi_color(struct nk_draw_list *list, struct nk_rect rect,
+    struct nk_color left, struct nk_color top, struct nk_color right,
+    struct nk_color bottom)
+{
+    void *vtx;
+    struct nk_colorf col_left, col_top;
+    struct nk_colorf col_right, col_bottom;
+    nk_draw_index *idx;
+    nk_draw_index index;
+
+    nk_color_fv(&col_left.r, left);
+    nk_color_fv(&col_right.r, right);
+    nk_color_fv(&col_top.r, top);
+    nk_color_fv(&col_bottom.r, bottom);
+
+    NK_ASSERT(list);
+    if (!list) return;
+
+    nk_draw_list_push_image(list, list->config.null.texture);
+    index = (nk_draw_index)list->vertex_count;
+    vtx = nk_draw_list_alloc_vertices(list, 4);
+    idx = nk_draw_list_alloc_elements(list, 6);
+    if (!vtx || !idx) return;
+
+    idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
+    idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
+    idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
+
+    vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y), list->config.null.uv, col_left);
+    vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y), list->config.null.uv, col_top);
+    vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x + rect.w, rect.y + rect.h), list->config.null.uv, col_right);
+    vtx = nk_draw_vertex(vtx, &list->config, nk_vec2(rect.x, rect.y + rect.h), list->config.null.uv, col_bottom);
+}
+
+NK_API void
+nk_draw_list_fill_triangle(struct nk_draw_list *list, struct nk_vec2 a,
+    struct nk_vec2 b, struct nk_vec2 c, struct nk_color col)
+{
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+    nk_draw_list_path_line_to(list, a);
+    nk_draw_list_path_line_to(list, b);
+    nk_draw_list_path_line_to(list, c);
+    nk_draw_list_path_fill(list, col);
+}
+
+NK_API void
+nk_draw_list_stroke_triangle(struct nk_draw_list *list, struct nk_vec2 a,
+    struct nk_vec2 b, struct nk_vec2 c, struct nk_color col, float thickness)
+{
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+    nk_draw_list_path_line_to(list, a);
+    nk_draw_list_path_line_to(list, b);
+    nk_draw_list_path_line_to(list, c);
+    nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
+}
+
+NK_API void
+nk_draw_list_fill_circle(struct nk_draw_list *list, struct nk_vec2 center,
+    float radius, struct nk_color col, unsigned int segs)
+{
+    float a_max;
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+    a_max = NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
+    nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
+    nk_draw_list_path_fill(list, col);
+}
+
+NK_API void
+nk_draw_list_stroke_circle(struct nk_draw_list *list, struct nk_vec2 center,
+    float radius, struct nk_color col, unsigned int segs, float thickness)
+{
+    float a_max;
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+    a_max = NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
+    nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
+    nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
+}
+
+NK_API void
+nk_draw_list_stroke_curve(struct nk_draw_list *list, struct nk_vec2 p0,
+    struct nk_vec2 cp0, struct nk_vec2 cp1, struct nk_vec2 p1,
+    struct nk_color col, unsigned int segments, float thickness)
+{
+    NK_ASSERT(list);
+    if (!list || !col.a) return;
+    nk_draw_list_path_line_to(list, p0);
+    nk_draw_list_path_curve_to(list, cp0, cp1, p1, segments);
+    nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
+}
+
+NK_INTERN void
+nk_draw_list_push_rect_uv(struct nk_draw_list *list, struct nk_vec2 a,
+    struct nk_vec2 c, struct nk_vec2 uva, struct nk_vec2 uvc,
+    struct nk_color color)
+{
+    void *vtx;
+    struct nk_vec2 uvb;
+    struct nk_vec2 uvd;
+    struct nk_vec2 b;
+    struct nk_vec2 d;
+
+    struct nk_colorf col;
+    nk_draw_index *idx;
+    nk_draw_index index;
+    NK_ASSERT(list);
+    if (!list) return;
+
+    nk_color_fv(&col.r, color);
+    uvb = nk_vec2(uvc.x, uva.y);
+    uvd = nk_vec2(uva.x, uvc.y);
+    b = nk_vec2(c.x, a.y);
+    d = nk_vec2(a.x, c.y);
+
+    index = (nk_draw_index)list->vertex_count;
+    vtx = nk_draw_list_alloc_vertices(list, 4);
+    idx = nk_draw_list_alloc_elements(list, 6);
+    if (!vtx || !idx) return;
+
+    idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
+    idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
+    idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
+
+    vtx = nk_draw_vertex(vtx, &list->config, a, uva, col);
+    vtx = nk_draw_vertex(vtx, &list->config, b, uvb, col);
+    vtx = nk_draw_vertex(vtx, &list->config, c, uvc, col);
+    vtx = nk_draw_vertex(vtx, &list->config, d, uvd, col);
+}
+
+NK_API void
+nk_draw_list_add_image(struct nk_draw_list *list, struct nk_image texture,
+    struct nk_rect rect, struct nk_color color)
+{
+    NK_ASSERT(list);
+    if (!list) return;
+    /* push new command with given texture */
+    nk_draw_list_push_image(list, texture.handle);
+    if (nk_image_is_subimage(&texture)) {
+        /* add region inside of the texture  */
+        struct nk_vec2 uv[2];
+        uv[0].x = (float)texture.region[0]/(float)texture.w;
+        uv[0].y = (float)texture.region[1]/(float)texture.h;
+        uv[1].x = (float)(texture.region[0] + texture.region[2])/(float)texture.w;
+        uv[1].y = (float)(texture.region[1] + texture.region[3])/(float)texture.h;
+        nk_draw_list_push_rect_uv(list, nk_vec2(rect.x, rect.y),
+            nk_vec2(rect.x + rect.w, rect.y + rect.h),  uv[0], uv[1], color);
+    } else nk_draw_list_push_rect_uv(list, nk_vec2(rect.x, rect.y),
+            nk_vec2(rect.x + rect.w, rect.y + rect.h),
+            nk_vec2(0.0f, 0.0f), nk_vec2(1.0f, 1.0f),color);
+}
+
+NK_API void
+nk_draw_list_add_text(struct nk_draw_list *list, const struct nk_user_font *font,
+    struct nk_rect rect, const char *text, int len, float font_height,
+    struct nk_color fg)
+{
+    float x = 0;
+    int text_len = 0;
+    nk_rune unicode = 0;
+    nk_rune next = 0;
+    int glyph_len = 0;
+    int next_glyph_len = 0;
+    struct nk_user_font_glyph g;
+
+    NK_ASSERT(list);
+    if (!list || !len || !text) return;
+    if (!NK_INTERSECT(rect.x, rect.y, rect.w, rect.h,
+        list->clip_rect.x, list->clip_rect.y, list->clip_rect.w, list->clip_rect.h)) return;
+
+    nk_draw_list_push_image(list, font->texture);
+    x = rect.x;
+    glyph_len = nk_utf_decode(text, &unicode, len);
+    if (!glyph_len) return;
+
+    /* draw every glyph image */
+    fg.a = (nk_byte)((float)fg.a * list->config.global_alpha);
+    while (text_len < len && glyph_len) {
+        float gx, gy, gh, gw;
+        float char_width = 0;
+        if (unicode == NK_UTF_INVALID) break;
+
+        /* query currently drawn glyph information */
+        next_glyph_len = nk_utf_decode(text + text_len + glyph_len, &next, (int)len - text_len);
+        font->query(font->userdata, font_height, &g, unicode,
+                    (next == NK_UTF_INVALID) ? '\0' : next);
+
+        /* calculate and draw glyph drawing rectangle and image */
+        gx = x + g.offset.x;
+        gy = rect.y + g.offset.y;
+        gw = g.width; gh = g.height;
+        char_width = g.xadvance;
+        nk_draw_list_push_rect_uv(list, nk_vec2(gx,gy), nk_vec2(gx + gw, gy+ gh),
+            g.uv[0], g.uv[1], fg);
+
+        /* offset next glyph */
+        text_len += glyph_len;
+        x += char_width;
+        glyph_len = next_glyph_len;
+        unicode = next;
+    }
+}
+
+NK_API nk_flags
+nk_convert(struct nk_context *ctx, struct nk_buffer *cmds,
+    struct nk_buffer *vertices, struct nk_buffer *elements,
+    const struct nk_convert_config *config)
+{
+    nk_flags res = NK_CONVERT_SUCCESS;
+    const struct nk_command *cmd;
+    NK_ASSERT(ctx);
+    NK_ASSERT(cmds);
+    NK_ASSERT(vertices);
+    NK_ASSERT(elements);
+    NK_ASSERT(config);
+    NK_ASSERT(config->vertex_layout);
+    NK_ASSERT(config->vertex_size);
+    if (!ctx || !cmds || !vertices || !elements || !config || !config->vertex_layout)
+        return NK_CONVERT_INVALID_PARAM;
+
+    nk_draw_list_setup(&ctx->draw_list, config, cmds, vertices, elements,
+        config->line_AA, config->shape_AA);
+    nk_foreach(cmd, ctx)
+    {
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+        ctx->draw_list.userdata = cmd->userdata;
+#endif
+        switch (cmd->type) {
+        case NK_COMMAND_NOP: break;
+        case NK_COMMAND_SCISSOR: {
+            const struct nk_command_scissor *s = (const struct nk_command_scissor*)cmd;
+            nk_draw_list_add_clip(&ctx->draw_list, nk_rect(s->x, s->y, s->w, s->h));
+        } break;
+        case NK_COMMAND_LINE: {
+            const struct nk_command_line *l = (const struct nk_command_line*)cmd;
+            nk_draw_list_stroke_line(&ctx->draw_list, nk_vec2(l->begin.x, l->begin.y),
+                nk_vec2(l->end.x, l->end.y), l->color, l->line_thickness);
+        } break;
+        case NK_COMMAND_CURVE: {
+            const struct nk_command_curve *q = (const struct nk_command_curve*)cmd;
+            nk_draw_list_stroke_curve(&ctx->draw_list, nk_vec2(q->begin.x, q->begin.y),
+                nk_vec2(q->ctrl[0].x, q->ctrl[0].y), nk_vec2(q->ctrl[1].x,
+                q->ctrl[1].y), nk_vec2(q->end.x, q->end.y), q->color,
+                config->curve_segment_count, q->line_thickness);
+        } break;
+        case NK_COMMAND_RECT: {
+            const struct nk_command_rect *r = (const struct nk_command_rect*)cmd;
+            nk_draw_list_stroke_rect(&ctx->draw_list, nk_rect(r->x, r->y, r->w, r->h),
+                r->color, (float)r->rounding, r->line_thickness);
+        } break;
+        case NK_COMMAND_RECT_FILLED: {
+            const struct nk_command_rect_filled *r = (const struct nk_command_rect_filled*)cmd;
+            nk_draw_list_fill_rect(&ctx->draw_list, nk_rect(r->x, r->y, r->w, r->h),
+                r->color, (float)r->rounding);
+        } break;
+        case NK_COMMAND_RECT_MULTI_COLOR: {
+            const struct nk_command_rect_multi_color *r = (const struct nk_command_rect_multi_color*)cmd;
+            nk_draw_list_fill_rect_multi_color(&ctx->draw_list, nk_rect(r->x, r->y, r->w, r->h),
+                r->left, r->top, r->right, r->bottom);
+        } break;
+        case NK_COMMAND_CIRCLE: {
+            const struct nk_command_circle *c = (const struct nk_command_circle*)cmd;
+            nk_draw_list_stroke_circle(&ctx->draw_list, nk_vec2((float)c->x + (float)c->w/2,
+                (float)c->y + (float)c->h/2), (float)c->w/2, c->color,
+                config->circle_segment_count, c->line_thickness);
+        } break;
+        case NK_COMMAND_CIRCLE_FILLED: {
+            const struct nk_command_circle_filled *c = (const struct nk_command_circle_filled *)cmd;
+            nk_draw_list_fill_circle(&ctx->draw_list, nk_vec2((float)c->x + (float)c->w/2,
+                (float)c->y + (float)c->h/2), (float)c->w/2, c->color,
+                config->circle_segment_count);
+        } break;
+        case NK_COMMAND_ARC: {
+            const struct nk_command_arc *c = (const struct nk_command_arc*)cmd;
+            nk_draw_list_path_line_to(&ctx->draw_list, nk_vec2(c->cx, c->cy));
+            nk_draw_list_path_arc_to(&ctx->draw_list, nk_vec2(c->cx, c->cy), c->r,
+                c->a[0], c->a[1], config->arc_segment_count);
+            nk_draw_list_path_stroke(&ctx->draw_list, c->color, NK_STROKE_CLOSED, c->line_thickness);
+        } break;
+        case NK_COMMAND_ARC_FILLED: {
+            const struct nk_command_arc_filled *c = (const struct nk_command_arc_filled*)cmd;
+            nk_draw_list_path_line_to(&ctx->draw_list, nk_vec2(c->cx, c->cy));
+            nk_draw_list_path_arc_to(&ctx->draw_list, nk_vec2(c->cx, c->cy), c->r,
+                c->a[0], c->a[1], config->arc_segment_count);
+            nk_draw_list_path_fill(&ctx->draw_list, c->color);
+        } break;
+        case NK_COMMAND_TRIANGLE: {
+            const struct nk_command_triangle *t = (const struct nk_command_triangle*)cmd;
+            nk_draw_list_stroke_triangle(&ctx->draw_list, nk_vec2(t->a.x, t->a.y),
+                nk_vec2(t->b.x, t->b.y), nk_vec2(t->c.x, t->c.y), t->color,
+                t->line_thickness);
+        } break;
+        case NK_COMMAND_TRIANGLE_FILLED: {
+            const struct nk_command_triangle_filled *t = (const struct nk_command_triangle_filled*)cmd;
+            nk_draw_list_fill_triangle(&ctx->draw_list, nk_vec2(t->a.x, t->a.y),
+                nk_vec2(t->b.x, t->b.y), nk_vec2(t->c.x, t->c.y), t->color);
+        } break;
+        case NK_COMMAND_POLYGON: {
+            int i;
+            const struct nk_command_polygon*p = (const struct nk_command_polygon*)cmd;
+            for (i = 0; i < p->point_count; ++i) {
+                struct nk_vec2 pnt = nk_vec2((float)p->points[i].x, (float)p->points[i].y);
+                nk_draw_list_path_line_to(&ctx->draw_list, pnt);
+            }
+            nk_draw_list_path_stroke(&ctx->draw_list, p->color, NK_STROKE_CLOSED, p->line_thickness);
+        } break;
+        case NK_COMMAND_POLYGON_FILLED: {
+            int i;
+            const struct nk_command_polygon_filled *p = (const struct nk_command_polygon_filled*)cmd;
+            for (i = 0; i < p->point_count; ++i) {
+                struct nk_vec2 pnt = nk_vec2((float)p->points[i].x, (float)p->points[i].y);
+                nk_draw_list_path_line_to(&ctx->draw_list, pnt);
+            }
+            nk_draw_list_path_fill(&ctx->draw_list, p->color);
+        } break;
+        case NK_COMMAND_POLYLINE: {
+            int i;
+            const struct nk_command_polyline *p = (const struct nk_command_polyline*)cmd;
+            for (i = 0; i < p->point_count; ++i) {
+                struct nk_vec2 pnt = nk_vec2((float)p->points[i].x, (float)p->points[i].y);
+                nk_draw_list_path_line_to(&ctx->draw_list, pnt);
+            }
+            nk_draw_list_path_stroke(&ctx->draw_list, p->color, NK_STROKE_OPEN, p->line_thickness);
+        } break;
+        case NK_COMMAND_TEXT: {
+            const struct nk_command_text *t = (const struct nk_command_text*)cmd;
+            nk_draw_list_add_text(&ctx->draw_list, t->font, nk_rect(t->x, t->y, t->w, t->h),
+                t->string, t->length, t->height, t->foreground);
+        } break;
+        case NK_COMMAND_IMAGE: {
+            const struct nk_command_image *i = (const struct nk_command_image*)cmd;
+            nk_draw_list_add_image(&ctx->draw_list, i->img, nk_rect(i->x, i->y, i->w, i->h), i->col);
+        } break;
+        case NK_COMMAND_CUSTOM: {
+            const struct nk_command_custom *c = (const struct nk_command_custom*)cmd;
+            c->callback(&ctx->draw_list, c->x, c->y, c->w, c->h, c->callback_data);
+        } break;
+        default: break;
+        }
+    }
+    res |= (cmds->needed > cmds->allocated + (cmds->memory.size - cmds->size)) ? NK_CONVERT_COMMAND_BUFFER_FULL: 0;
+    res |= (vertices->needed > vertices->allocated) ? NK_CONVERT_VERTEX_BUFFER_FULL: 0;
+    res |= (elements->needed > elements->allocated) ? NK_CONVERT_ELEMENT_BUFFER_FULL: 0;
+    return res;
+}
+NK_API const struct nk_draw_command*
+nk__draw_begin(const struct nk_context *ctx,
+    const struct nk_buffer *buffer)
+{return nk__draw_list_begin(&ctx->draw_list, buffer);}
+
+NK_API const struct nk_draw_command*
+nk__draw_end(const struct nk_context *ctx, const struct nk_buffer *buffer)
+{return nk__draw_list_end(&ctx->draw_list, buffer);}
+
+NK_API const struct nk_draw_command*
+nk__draw_next(const struct nk_draw_command *cmd,
+    const struct nk_buffer *buffer, const struct nk_context *ctx)
+{return nk__draw_list_next(cmd, buffer, &ctx->draw_list);}
+
+#endif
+
+/*
+ * ==============================================================
+ *
+ *                          FONT HANDLING
+ *
+ * ===============================================================
+ */
+#ifdef NK_INCLUDE_FONT_BAKING
+/* -------------------------------------------------------------
+ *
+ *                          RECT PACK
+ *
+ * --------------------------------------------------------------*/
+/* stb_rect_pack.h - v0.05 - public domain - rectangle packing */
+/* Sean Barrett 2014 */
+#define NK_RP__MAXVAL  0xffff
+typedef unsigned short nk_rp_coord;
+
+struct nk_rp_rect {
+    /* reserved for your use: */
+    int id;
+    /* input: */
+    nk_rp_coord w, h;
+    /* output: */
+    nk_rp_coord x, y;
+    int was_packed;
+    /* non-zero if valid packing */
+}; /* 16 bytes, nominally */
+
+struct nk_rp_node {
+    nk_rp_coord  x,y;
+    struct nk_rp_node  *next;
+};
+
+struct nk_rp_context {
+    int width;
+    int height;
+    int align;
+    int init_mode;
+    int heuristic;
+    int num_nodes;
+    struct nk_rp_node *active_head;
+    struct nk_rp_node *free_head;
+    struct nk_rp_node extra[2];
+    /* we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' */
+};
+
+struct nk_rp__findresult {
+    int x,y;
+    struct nk_rp_node **prev_link;
+};
+
+enum NK_RP_HEURISTIC {
+    NK_RP_HEURISTIC_Skyline_default=0,
+    NK_RP_HEURISTIC_Skyline_BL_sortHeight = NK_RP_HEURISTIC_Skyline_default,
+    NK_RP_HEURISTIC_Skyline_BF_sortHeight
+};
+enum NK_RP_INIT_STATE{NK_RP__INIT_skyline = 1};
+
+NK_INTERN void
+nk_rp_setup_allow_out_of_mem(struct nk_rp_context *context, int allow_out_of_mem)
+{
+    if (allow_out_of_mem)
+        /* if it's ok to run out of memory, then don't bother aligning them; */
+        /* this gives better packing, but may fail due to OOM (even though */
+        /* the rectangles easily fit). @TODO a smarter approach would be to only */
+        /* quantize once we've hit OOM, then we could get rid of this parameter. */
+        context->align = 1;
+    else {
+        /* if it's not ok to run out of memory, then quantize the widths */
+        /* so that num_nodes is always enough nodes. */
+        /* */
+        /* I.e. num_nodes * align >= width */
+        /*                  align >= width / num_nodes */
+        /*                  align = ceil(width/num_nodes) */
+        context->align = (context->width + context->num_nodes-1) / context->num_nodes;
+    }
+}
+
+NK_INTERN void
+nk_rp_init_target(struct nk_rp_context *context, int width, int height,
+    struct nk_rp_node *nodes, int num_nodes)
+{
+    int i;
+#ifndef STBRP_LARGE_RECTS
+    NK_ASSERT(width <= 0xffff && height <= 0xffff);
+#endif
+
+    for (i=0; i < num_nodes-1; ++i)
+        nodes[i].next = &nodes[i+1];
+    nodes[i].next = 0;
+    context->init_mode = NK_RP__INIT_skyline;
+    context->heuristic = NK_RP_HEURISTIC_Skyline_default;
+    context->free_head = &nodes[0];
+    context->active_head = &context->extra[0];
+    context->width = width;
+    context->height = height;
+    context->num_nodes = num_nodes;
+    nk_rp_setup_allow_out_of_mem(context, 0);
+
+    /* node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) */
+    context->extra[0].x = 0;
+    context->extra[0].y = 0;
+    context->extra[0].next = &context->extra[1];
+    context->extra[1].x = (nk_rp_coord) width;
+    context->extra[1].y = 65535;
+    context->extra[1].next = 0;
+}
+
+/* find minimum y position if it starts at x1 */
+NK_INTERN int
+nk_rp__skyline_find_min_y(struct nk_rp_context *c, struct nk_rp_node *first,
+    int x0, int width, int *pwaste)
+{
+    struct nk_rp_node *node = first;
+    int x1 = x0 + width;
+    int min_y, visited_width, waste_area;
+    NK_ASSERT(first->x <= x0);
+    NK_UNUSED(c);
+
+    NK_ASSERT(node->next->x > x0);
+    /* we ended up handling this in the caller for efficiency */
+    NK_ASSERT(node->x <= x0);
+
+    min_y = 0;
+    waste_area = 0;
+    visited_width = 0;
+    while (node->x < x1)
+    {
+        if (node->y > min_y) {
+            /* raise min_y higher. */
+            /* we've accounted for all waste up to min_y, */
+            /* but we'll now add more waste for everything we've visited */
+            waste_area += visited_width * (node->y - min_y);
+            min_y = node->y;
+            /* the first time through, visited_width might be reduced */
+            if (node->x < x0)
+            visited_width += node->next->x - x0;
+            else
+            visited_width += node->next->x - node->x;
+        } else {
+            /* add waste area */
+            int under_width = node->next->x - node->x;
+            if (under_width + visited_width > width)
+            under_width = width - visited_width;
+            waste_area += under_width * (min_y - node->y);
+            visited_width += under_width;
+        }
+        node = node->next;
+    }
+    *pwaste = waste_area;
+    return min_y;
+}
+
+NK_INTERN struct nk_rp__findresult
+nk_rp__skyline_find_best_pos(struct nk_rp_context *c, int width, int height)
+{
+    int best_waste = (1<<30), best_x, best_y = (1 << 30);
+    struct nk_rp__findresult fr;
+    struct nk_rp_node **prev, *node, *tail, **best = 0;
+
+    /* align to multiple of c->align */
+    width = (width + c->align - 1);
+    width -= width % c->align;
+    NK_ASSERT(width % c->align == 0);
+
+    node = c->active_head;
+    prev = &c->active_head;
+    while (node->x + width <= c->width) {
+        int y,waste;
+        y = nk_rp__skyline_find_min_y(c, node, node->x, width, &waste);
+        /* actually just want to test BL */
+        if (c->heuristic == NK_RP_HEURISTIC_Skyline_BL_sortHeight) {
+            /* bottom left */
+            if (y < best_y) {
+            best_y = y;
+            best = prev;
+            }
+        } else {
+            /* best-fit */
+            if (y + height <= c->height) {
+                /* can only use it if it first vertically */
+                if (y < best_y || (y == best_y && waste < best_waste)) {
+                    best_y = y;
+                    best_waste = waste;
+                    best = prev;
+                }
+            }
+        }
+        prev = &node->next;
+        node = node->next;
+    }
+    best_x = (best == 0) ? 0 : (*best)->x;
+
+    /* if doing best-fit (BF), we also have to try aligning right edge to each node position */
+    /* */
+    /* e.g, if fitting */
+    /* */
+    /*     ____________________ */
+    /*    |____________________| */
+    /* */
+    /*            into */
+    /* */
+    /*   |                         | */
+    /*   |             ____________| */
+    /*   |____________| */
+    /* */
+    /* then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned */
+    /* */
+    /* This makes BF take about 2x the time */
+    if (c->heuristic == NK_RP_HEURISTIC_Skyline_BF_sortHeight)
+    {
+        tail = c->active_head;
+        node = c->active_head;
+        prev = &c->active_head;
+        /* find first node that's admissible */
+        while (tail->x < width)
+            tail = tail->next;
+        while (tail)
+        {
+            int xpos = tail->x - width;
+            int y,waste;
+            NK_ASSERT(xpos >= 0);
+            /* find the left position that matches this */
+            while (node->next->x <= xpos) {
+                prev = &node->next;
+                node = node->next;
+            }
+            NK_ASSERT(node->next->x > xpos && node->x <= xpos);
+            y = nk_rp__skyline_find_min_y(c, node, xpos, width, &waste);
+            if (y + height < c->height) {
+                if (y <= best_y) {
+                    if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
+                        best_x = xpos;
+                        NK_ASSERT(y <= best_y);
+                        best_y = y;
+                        best_waste = waste;
+                        best = prev;
+                    }
+                }
+            }
+            tail = tail->next;
+        }
+    }
+    fr.prev_link = best;
+    fr.x = best_x;
+    fr.y = best_y;
+    return fr;
+}
+
+NK_INTERN struct nk_rp__findresult
+nk_rp__skyline_pack_rectangle(struct nk_rp_context *context, int width, int height)
+{
+    /* find best position according to heuristic */
+    struct nk_rp__findresult res = nk_rp__skyline_find_best_pos(context, width, height);
+    struct nk_rp_node *node, *cur;
+
+    /* bail if: */
+    /*    1. it failed */
+    /*    2. the best node doesn't fit (we don't always check this) */
+    /*    3. we're out of memory */
+    if (res.prev_link == 0 || res.y + height > context->height || context->free_head == 0) {
+        res.prev_link = 0;
+        return res;
+    }
+
+    /* on success, create new node */
+    node = context->free_head;
+    node->x = (nk_rp_coord) res.x;
+    node->y = (nk_rp_coord) (res.y + height);
+
+    context->free_head = node->next;
+
+    /* insert the new node into the right starting point, and */
+    /* let 'cur' point to the remaining nodes needing to be */
+    /* stitched back in */
+    cur = *res.prev_link;
+    if (cur->x < res.x) {
+        /* preserve the existing one, so start testing with the next one */
+        struct nk_rp_node *next = cur->next;
+        cur->next = node;
+        cur = next;
+    } else {
+        *res.prev_link = node;
+    }
+
+    /* from here, traverse cur and free the nodes, until we get to one */
+    /* that shouldn't be freed */
+    while (cur->next && cur->next->x <= res.x + width) {
+        struct nk_rp_node *next = cur->next;
+        /* move the current node to the free list */
+        cur->next = context->free_head;
+        context->free_head = cur;
+        cur = next;
+    }
+    /* stitch the list back in */
+    node->next = cur;
+
+    if (cur->x < res.x + width)
+        cur->x = (nk_rp_coord) (res.x + width);
+    return res;
+}
+
+NK_INTERN int
+nk_rect_height_compare(const void *a, const void *b)
+{
+    const struct nk_rp_rect *p = (const struct nk_rp_rect *) a;
+    const struct nk_rp_rect *q = (const struct nk_rp_rect *) b;
+    if (p->h > q->h)
+        return -1;
+    if (p->h < q->h)
+        return  1;
+    return (p->w > q->w) ? -1 : (p->w < q->w);
+}
+
+NK_INTERN int
+nk_rect_original_order(const void *a, const void *b)
+{
+    const struct nk_rp_rect *p = (const struct nk_rp_rect *) a;
+    const struct nk_rp_rect *q = (const struct nk_rp_rect *) b;
+    return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
+}
+
+NK_INTERN void
+nk_rp_qsort(struct nk_rp_rect *array, unsigned int len, int(*cmp)(const void*,const void*))
+{
+    /* iterative quick sort */
+    #define NK_MAX_SORT_STACK 64
+    unsigned right, left = 0, stack[NK_MAX_SORT_STACK], pos = 0;
+    unsigned seed = len/2 * 69069+1;
+    for (;;) {
+        for (; left+1 < len; len++) {
+            struct nk_rp_rect pivot, tmp;
+            if (pos == NK_MAX_SORT_STACK) len = stack[pos = 0];
+            pivot = array[left+seed%(len-left)];
+            seed = seed * 69069 + 1;
+            stack[pos++] = len;
+            for (right = left-1;;) {
+                while (cmp(&array[++right], &pivot) < 0);
+                while (cmp(&pivot, &array[--len]) < 0);
+                if (right >= len) break;
+                tmp = array[right];
+                array[right] = array[len];
+                array[len] = tmp;
+            }
+        }
+        if (pos == 0) break;
+        left = len;
+        len = stack[--pos];
+    }
+    #undef NK_MAX_SORT_STACK
+}
+
+NK_INTERN void
+nk_rp_pack_rects(struct nk_rp_context *context, struct nk_rp_rect *rects, int num_rects)
+{
+    int i;
+    /* we use the 'was_packed' field internally to allow sorting/unsorting */
+    for (i=0; i < num_rects; ++i) {
+        rects[i].was_packed = i;
+    }
+
+    /* sort according to heuristic */
+    nk_rp_qsort(rects, (unsigned)num_rects, nk_rect_height_compare);
+
+    for (i=0; i < num_rects; ++i) {
+        struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
+        if (fr.prev_link) {
+            rects[i].x = (nk_rp_coord) fr.x;
+            rects[i].y = (nk_rp_coord) fr.y;
+        } else {
+            rects[i].x = rects[i].y = NK_RP__MAXVAL;
+        }
+    }
+
+    /* unsort */
+    nk_rp_qsort(rects, (unsigned)num_rects, nk_rect_original_order);
+
+    /* set was_packed flags */
+    for (i=0; i < num_rects; ++i)
+        rects[i].was_packed = !(rects[i].x == NK_RP__MAXVAL && rects[i].y == NK_RP__MAXVAL);
+}
+
+/*
+ * ==============================================================
+ *
+ *                          TRUETYPE
+ *
+ * ===============================================================
+ */
+/* stb_truetype.h - v1.07 - public domain */
+#define NK_TT_MAX_OVERSAMPLE   8
+#define NK_TT__OVER_MASK  (NK_TT_MAX_OVERSAMPLE-1)
+
+struct nk_tt_bakedchar {
+    unsigned short x0,y0,x1,y1;
+    /* coordinates of bbox in bitmap */
+    float xoff,yoff,xadvance;
+};
+
+struct nk_tt_aligned_quad{
+    float x0,y0,s0,t0; /* top-left */
+    float x1,y1,s1,t1; /* bottom-right */
+};
+
+struct nk_tt_packedchar {
+    unsigned short x0,y0,x1,y1;
+    /* coordinates of bbox in bitmap */
+    float xoff,yoff,xadvance;
+    float xoff2,yoff2;
+};
+
+struct nk_tt_pack_range {
+    float font_size;
+    int first_unicode_codepoint_in_range;
+    /* if non-zero, then the chars are continuous, and this is the first codepoint */
+    int *array_of_unicode_codepoints;
+    /* if non-zero, then this is an array of unicode codepoints */
+    int num_chars;
+    struct nk_tt_packedchar *chardata_for_range; /* output */
+    unsigned char h_oversample, v_oversample;
+    /* don't set these, they're used internally */
+};
+
+struct nk_tt_pack_context {
+    void *pack_info;
+    int   width;
+    int   height;
+    int   stride_in_bytes;
+    int   padding;
+    unsigned int   h_oversample, v_oversample;
+    unsigned char *pixels;
+    void  *nodes;
+};
+
+struct nk_tt_fontinfo {
+    const unsigned char* data; /* pointer to .ttf file */
+    int fontstart;/* offset of start of font */
+    int numGlyphs;/* number of glyphs, needed for range checking */
+    int loca,head,glyf,hhea,hmtx,kern; /* table locations as offset from start of .ttf */
+    int index_map; /* a cmap mapping for our chosen character encoding */
+    int indexToLocFormat; /* format needed to map from glyph index to glyph */
+};
+
+enum {
+  NK_TT_vmove=1,
+  NK_TT_vline,
+  NK_TT_vcurve
+};
+
+struct nk_tt_vertex {
+    short x,y,cx,cy;
+    unsigned char type,padding;
+};
+
+struct nk_tt__bitmap{
+   int w,h,stride;
+   unsigned char *pixels;
+};
+
+struct nk_tt__hheap_chunk {
+    struct nk_tt__hheap_chunk *next;
+};
+struct nk_tt__hheap {
+    struct nk_allocator alloc;
+    struct nk_tt__hheap_chunk *head;
+    void   *first_free;
+    int    num_remaining_in_head_chunk;
+};
+
+struct nk_tt__edge {
+    float x0,y0, x1,y1;
+    int invert;
+};
+
+struct nk_tt__active_edge {
+    struct nk_tt__active_edge *next;
+    float fx,fdx,fdy;
+    float direction;
+    float sy;
+    float ey;
+};
+struct nk_tt__point {float x,y;};
+
+#define NK_TT_MACSTYLE_DONTCARE     0
+#define NK_TT_MACSTYLE_BOLD         1
+#define NK_TT_MACSTYLE_ITALIC       2
+#define NK_TT_MACSTYLE_UNDERSCORE   4
+#define NK_TT_MACSTYLE_NONE         8
+/* <= not same as 0, this makes us check the bitfield is 0 */
+
+enum { /* platformID */
+   NK_TT_PLATFORM_ID_UNICODE   =0,
+   NK_TT_PLATFORM_ID_MAC       =1,
+   NK_TT_PLATFORM_ID_ISO       =2,
+   NK_TT_PLATFORM_ID_MICROSOFT =3
+};
+
+enum { /* encodingID for NK_TT_PLATFORM_ID_UNICODE */
+   NK_TT_UNICODE_EID_UNICODE_1_0    =0,
+   NK_TT_UNICODE_EID_UNICODE_1_1    =1,
+   NK_TT_UNICODE_EID_ISO_10646      =2,
+   NK_TT_UNICODE_EID_UNICODE_2_0_BMP=3,
+   NK_TT_UNICODE_EID_UNICODE_2_0_FULL=4
+};
+
+enum { /* encodingID for NK_TT_PLATFORM_ID_MICROSOFT */
+   NK_TT_MS_EID_SYMBOL        =0,
+   NK_TT_MS_EID_UNICODE_BMP   =1,
+   NK_TT_MS_EID_SHIFTJIS      =2,
+   NK_TT_MS_EID_UNICODE_FULL  =10
+};
+
+enum { /* encodingID for NK_TT_PLATFORM_ID_MAC; same as Script Manager codes */
+   NK_TT_MAC_EID_ROMAN        =0,   NK_TT_MAC_EID_ARABIC       =4,
+   NK_TT_MAC_EID_JAPANESE     =1,   NK_TT_MAC_EID_HEBREW       =5,
+   NK_TT_MAC_EID_CHINESE_TRAD =2,   NK_TT_MAC_EID_GREEK        =6,
+   NK_TT_MAC_EID_KOREAN       =3,   NK_TT_MAC_EID_RUSSIAN      =7
+};
+
+enum { /* languageID for NK_TT_PLATFORM_ID_MICROSOFT; same as LCID... */
+       /* problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs */
+   NK_TT_MS_LANG_ENGLISH     =0x0409,   NK_TT_MS_LANG_ITALIAN     =0x0410,
+   NK_TT_MS_LANG_CHINESE     =0x0804,   NK_TT_MS_LANG_JAPANESE    =0x0411,
+   NK_TT_MS_LANG_DUTCH       =0x0413,   NK_TT_MS_LANG_KOREAN      =0x0412,
+   NK_TT_MS_LANG_FRENCH      =0x040c,   NK_TT_MS_LANG_RUSSIAN     =0x0419,
+   NK_TT_MS_LANG_GERMAN      =0x0407,   NK_TT_MS_LANG_SPANISH     =0x0409,
+   NK_TT_MS_LANG_HEBREW      =0x040d,   NK_TT_MS_LANG_SWEDISH     =0x041D
+};
+
+enum { /* languageID for NK_TT_PLATFORM_ID_MAC */
+   NK_TT_MAC_LANG_ENGLISH      =0 ,   NK_TT_MAC_LANG_JAPANESE     =11,
+   NK_TT_MAC_LANG_ARABIC       =12,   NK_TT_MAC_LANG_KOREAN       =23,
+   NK_TT_MAC_LANG_DUTCH        =4 ,   NK_TT_MAC_LANG_RUSSIAN      =32,
+   NK_TT_MAC_LANG_FRENCH       =1 ,   NK_TT_MAC_LANG_SPANISH      =6 ,
+   NK_TT_MAC_LANG_GERMAN       =2 ,   NK_TT_MAC_LANG_SWEDISH      =5 ,
+   NK_TT_MAC_LANG_HEBREW       =10,   NK_TT_MAC_LANG_CHINESE_SIMPLIFIED =33,
+   NK_TT_MAC_LANG_ITALIAN      =3 ,   NK_TT_MAC_LANG_CHINESE_TRAD =19
+};
+
+#define nk_ttBYTE(p)     (* (const nk_byte *) (p))
+#define nk_ttCHAR(p)     (* (const char *) (p))
+
+#if defined(NK_BIGENDIAN) && !defined(NK_ALLOW_UNALIGNED_TRUETYPE)
+   #define nk_ttUSHORT(p)   (* (nk_ushort *) (p))
+   #define nk_ttSHORT(p)    (* (nk_short *) (p))
+   #define nk_ttULONG(p)    (* (nk_uint *) (p))
+   #define nk_ttLONG(p)     (* (nk_int *) (p))
+#else
+    static nk_ushort nk_ttUSHORT(const nk_byte *p) { return (nk_ushort)(p[0]*256 + p[1]); }
+    static nk_short nk_ttSHORT(const nk_byte *p)   { return (nk_short)(p[0]*256 + p[1]); }
+    static nk_uint nk_ttULONG(const nk_byte *p)  { return (nk_uint)((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]); }
+#endif
+
+#define nk_tt_tag4(p,c0,c1,c2,c3)\
+    ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
+#define nk_tt_tag(p,str) nk_tt_tag4(p,str[0],str[1],str[2],str[3])
+
+NK_INTERN int nk_tt_GetGlyphShape(const struct nk_tt_fontinfo *info, struct nk_allocator *alloc,
+                                int glyph_index, struct nk_tt_vertex **pvertices);
+
+NK_INTERN nk_uint
+nk_tt__find_table(const nk_byte *data, nk_uint fontstart, const char *tag)
+{
+    /* @OPTIMIZE: binary search */
+    nk_int num_tables = nk_ttUSHORT(data+fontstart+4);
+    nk_uint tabledir = fontstart + 12;
+    nk_int i;
+    for (i = 0; i < num_tables; ++i) {
+        nk_uint loc = tabledir + (nk_uint)(16*i);
+        if (nk_tt_tag(data+loc+0, tag))
+            return nk_ttULONG(data+loc+8);
+    }
+    return 0;
+}
+
+NK_INTERN int
+nk_tt_InitFont(struct nk_tt_fontinfo *info, const unsigned char *data2, int fontstart)
+{
+    nk_uint cmap, t;
+    nk_int i,numTables;
+    const nk_byte *data = (const nk_byte *) data2;
+
+    info->data = data;
+    info->fontstart = fontstart;
+
+    cmap = nk_tt__find_table(data, (nk_uint)fontstart, "cmap");       /* required */
+    info->loca = (int)nk_tt__find_table(data, (nk_uint)fontstart, "loca"); /* required */
+    info->head = (int)nk_tt__find_table(data, (nk_uint)fontstart, "head"); /* required */
+    info->glyf = (int)nk_tt__find_table(data, (nk_uint)fontstart, "glyf"); /* required */
+    info->hhea = (int)nk_tt__find_table(data, (nk_uint)fontstart, "hhea"); /