Browse Source

Update demos to new color picker API

vurtun 7 years ago
parent
commit
2891c6afbc

+ 11 - 13
demo/d3d11/main.c

@@ -132,7 +132,7 @@ WindowProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
 int main(void)
 int main(void)
 {
 {
     struct nk_context *ctx;
     struct nk_context *ctx;
-    struct nk_color background;
+    struct nk_colorf bg;
 
 
     WNDCLASSW wc;
     WNDCLASSW wc;
     RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
     RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
@@ -211,7 +211,7 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (running)
     while (running)
     {
     {
         /* Input */
         /* Input */
@@ -247,14 +247,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -272,10 +272,8 @@ int main(void)
         #endif
         #endif
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
-        {/* Draw */
-        float bg[4];
-        nk_color_fv(bg, background);
-        ID3D11DeviceContext_ClearRenderTargetView(context, rt_view, bg);
+        /* Draw */
+        ID3D11DeviceContext_ClearRenderTargetView(context, rt_view, &bg.r);
         ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rt_view, NULL);
         ID3D11DeviceContext_OMSetRenderTargets(context, 1, &rt_view, NULL);
         nk_d3d11_render(context, NK_ANTI_ALIASING_ON);
         nk_d3d11_render(context, NK_ANTI_ALIASING_ON);
         hr = IDXGISwapChain_Present(swap_chain, 1, 0);
         hr = IDXGISwapChain_Present(swap_chain, 1, 0);
@@ -287,7 +285,7 @@ int main(void)
             /* window is not visible, so vsync won't work. Let's sleep a bit to reduce CPU usage */
             /* window is not visible, so vsync won't work. Let's sleep a bit to reduce CPU usage */
             Sleep(10);
             Sleep(10);
         }
         }
-        assert(SUCCEEDED(hr));}
+        assert(SUCCEEDED(hr));
     }
     }
 
 
     ID3D11DeviceContext_ClearState(context);
     ID3D11DeviceContext_ClearState(context);

+ 11 - 19
demo/d3d9/main.c

@@ -164,7 +164,7 @@ static void create_d3d9_device(HWND wnd)
 int main(void)
 int main(void)
 {
 {
     struct nk_context *ctx;
     struct nk_context *ctx;
-    struct nk_color background;
+    struct nk_colorf bg;
 
 
     WNDCLASSW wc;
     WNDCLASSW wc;
     RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
     RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
@@ -216,7 +216,7 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (running)
     while (running)
     {
     {
         /* Input */
         /* Input */
@@ -251,14 +251,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -279,16 +279,13 @@ int main(void)
         /* Draw */
         /* Draw */
         {
         {
             HRESULT hr;
             HRESULT hr;
-
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,
             hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,
-                D3DCOLOR_ARGB(background.a, background.r, background.g, background.b), 0.0f, 0);
+                D3DCOLOR_COLORVALUE(bg.a, bg.r, bg.g, bg.b), 0.0f, 0);
             NK_ASSERT(SUCCEEDED(hr));
             NK_ASSERT(SUCCEEDED(hr));
 
 
             hr = IDirect3DDevice9_BeginScene(device);
             hr = IDirect3DDevice9_BeginScene(device);
             NK_ASSERT(SUCCEEDED(hr));
             NK_ASSERT(SUCCEEDED(hr));
-
             nk_d3d9_render(NK_ANTI_ALIASING_ON);
             nk_d3d9_render(NK_ANTI_ALIASING_ON);
-
             hr = IDirect3DDevice9_EndScene(device);
             hr = IDirect3DDevice9_EndScene(device);
             NK_ASSERT(SUCCEEDED(hr));
             NK_ASSERT(SUCCEEDED(hr));
 
 
@@ -297,7 +294,6 @@ int main(void)
             } else {
             } else {
                 hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
                 hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
             }
             }
-
             if (hr == D3DERR_DEVICELOST || hr == D3DERR_DEVICEHUNG || hr == D3DERR_DEVICEREMOVED) {
             if (hr == D3DERR_DEVICELOST || hr == D3DERR_DEVICEHUNG || hr == D3DERR_DEVICEREMOVED) {
                 /* to recover from this, you'll need to recreate device and all the resources */
                 /* to recover from this, you'll need to recreate device and all the resources */
                 MessageBoxW(NULL, L"D3D9 device is lost or removed!", L"Error", 0);
                 MessageBoxW(NULL, L"D3D9 device is lost or removed!", L"Error", 0);
@@ -309,13 +305,9 @@ int main(void)
             NK_ASSERT(SUCCEEDED(hr));
             NK_ASSERT(SUCCEEDED(hr));
         }
         }
     }
     }
-
     nk_d3d9_shutdown();
     nk_d3d9_shutdown();
-    if (deviceEx) {
-        IDirect3DDevice9Ex_Release(deviceEx);
-    } else {
-        IDirect3DDevice9_Release(device);
-    }
+    if (deviceEx)IDirect3DDevice9Ex_Release(deviceEx);
+    else IDirect3DDevice9_Release(device);
     UnregisterClassW(wc.lpszClassName, wc.hInstance);
     UnregisterClassW(wc.lpszClassName, wc.hInstance);
     return 0;
     return 0;
 }
 }

+ 10 - 12
demo/glfw_opengl2/main.c

@@ -74,7 +74,7 @@ int main(void)
     static GLFWwindow *win;
     static GLFWwindow *win;
     int width = 0, height = 0;
     int width = 0, height = 0;
     struct nk_context *ctx;
     struct nk_context *ctx;
-    struct nk_color background;
+    struct nk_colorf bg;
 
 
     /* GLFW */
     /* GLFW */
     glfwSetErrorCallback(error_callback);
     glfwSetErrorCallback(error_callback);
@@ -109,7 +109,7 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (!glfwWindowShouldClose(win))
     while (!glfwWindowShouldClose(win))
     {
     {
         /* Input */
         /* Input */
@@ -138,14 +138,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -164,18 +164,16 @@ int main(void)
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw */
         /* Draw */
-        {float bg[4];
-        nk_color_fv(bg, background);
         glfwGetWindowSize(win, &width, &height);
         glfwGetWindowSize(win, &width, &height);
         glViewport(0, 0, width, height);
         glViewport(0, 0, width, height);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_glfw_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_glfw_render` modifies some global OpenGL state
          * with blending, scissor, face culling and depth test and defaults everything
          * with blending, scissor, face culling and depth test and defaults everything
          * back into a default state. Make sure to either save and restore or
          * back into a default state. Make sure to either save and restore or
          * reset your own state after drawing rendering the UI. */
          * reset your own state after drawing rendering the UI. */
         nk_glfw3_render(NK_ANTI_ALIASING_ON);
         nk_glfw3_render(NK_ANTI_ALIASING_ON);
-        glfwSwapBuffers(win);}
+        glfwSwapBuffers(win);
     }
     }
     nk_glfw3_shutdown();
     nk_glfw3_shutdown();
     glfwTerminate();
     glfwTerminate();

+ 10 - 12
demo/glfw_opengl3/main.c

@@ -78,7 +78,7 @@ int main(void)
     static GLFWwindow *win;
     static GLFWwindow *win;
     int width = 0, height = 0;
     int width = 0, height = 0;
     struct nk_context *ctx;
     struct nk_context *ctx;
-    struct nk_color background;
+    struct nk_colorf bg;
 
 
     /* GLFW */
     /* GLFW */
     glfwSetErrorCallback(error_callback);
     glfwSetErrorCallback(error_callback);
@@ -126,7 +126,7 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (!glfwWindowShouldClose(win))
     while (!glfwWindowShouldClose(win))
     {
     {
         /* Input */
         /* Input */
@@ -155,14 +155,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -181,19 +181,17 @@ int main(void)
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw */
         /* Draw */
-        {float bg[4];
-        nk_color_fv(bg, background);
         glfwGetWindowSize(win, &width, &height);
         glfwGetWindowSize(win, &width, &height);
         glViewport(0, 0, width, height);
         glViewport(0, 0, width, height);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_glfw_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_glfw_render` modifies some global OpenGL state
          * with blending, scissor, face culling, depth test and viewport and
          * with blending, scissor, face culling, depth test and viewport and
          * defaults everything back into a default state.
          * defaults everything back into a default state.
          * Make sure to either a.) save and restore or b.) reset your own state after
          * Make sure to either a.) save and restore or b.) reset your own state after
          * rendering the UI. */
          * rendering the UI. */
         nk_glfw3_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
         nk_glfw3_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
-        glfwSwapBuffers(win);}
+        glfwSwapBuffers(win);
     }
     }
     nk_glfw3_shutdown();
     nk_glfw3_shutdown();
     glfwTerminate();
     glfwTerminate();

+ 11 - 13
demo/sdl_opengl2/main.c

@@ -72,12 +72,12 @@ main(void)
     /* Platform */
     /* Platform */
     SDL_Window *win;
     SDL_Window *win;
     SDL_GLContext glContext;
     SDL_GLContext glContext;
-    struct nk_color background;
     int win_width, win_height;
     int win_width, win_height;
     int running = 1;
     int running = 1;
 
 
     /* GUI */
     /* GUI */
     struct nk_context *ctx;
     struct nk_context *ctx;
+    struct nk_colorf bg;
 
 
     /* SDL setup */
     /* SDL setup */
     SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
     SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
@@ -116,7 +116,7 @@ main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (running)
     while (running)
     {
     {
         /* Input */
         /* Input */
@@ -129,7 +129,7 @@ main(void)
         nk_input_end(ctx);
         nk_input_end(ctx);
 
 
         /* GUI */
         /* GUI */
-        if (nk_begin(ctx, "Demo", nk_rect(50, 50, 210, 250),
+        if (nk_begin(ctx, "Demo", nk_rect(50, 50, 230, 250),
             NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
             NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
             NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
             NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
         {
         {
@@ -149,14 +149,14 @@ main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -175,19 +175,17 @@ main(void)
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw */
         /* Draw */
-        {float bg[4];
-        nk_color_fv(bg, background);
         SDL_GetWindowSize(win, &win_width, &win_height);
         SDL_GetWindowSize(win, &win_width, &win_height);
         glViewport(0, 0, win_width, win_height);
         glViewport(0, 0, win_width, win_height);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_sdl_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_sdl_render` modifies some global OpenGL state
          * with blending, scissor, face culling, depth test and viewport and
          * with blending, scissor, face culling, depth test and viewport and
          * defaults everything back into a default state.
          * defaults everything back into a default state.
          * Make sure to either a.) save and restore or b.) reset your own state after
          * Make sure to either a.) save and restore or b.) reset your own state after
          * rendering the UI. */
          * rendering the UI. */
         nk_sdl_render(NK_ANTI_ALIASING_ON);
         nk_sdl_render(NK_ANTI_ALIASING_ON);
-        SDL_GL_SwapWindow(win);}
+        SDL_GL_SwapWindow(win);
     }
     }
 
 
 cleanup:
 cleanup:

+ 20 - 8
demo/sdl_opengl3/main.c

@@ -75,12 +75,12 @@ int main(void)
     /* Platform */
     /* Platform */
     SDL_Window *win;
     SDL_Window *win;
     SDL_GLContext glContext;
     SDL_GLContext glContext;
-    struct nk_color background;
     int win_width, win_height;
     int win_width, win_height;
     int running = 1;
     int running = 1;
 
 
     /* GUI */
     /* GUI */
     struct nk_context *ctx;
     struct nk_context *ctx;
+    struct nk_colorf bg;
 
 
     /* SDL setup */
     /* SDL setup */
     SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
     SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
@@ -127,7 +127,7 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (running)
     while (running)
     {
     {
         /* Input */
         /* Input */
@@ -139,9 +139,9 @@ int main(void)
         } nk_input_end(ctx);
         } nk_input_end(ctx);
 
 
         /* GUI */
         /* GUI */
-        if (nk_begin(ctx, "Demo1", nk_rect(50, 50, 200, 200),
+        if (nk_begin(ctx, "Demo", nk_rect(50, 50, 230, 250),
             NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
             NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
-            NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
+            NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
         {
         {
             enum {EASY, HARD};
             enum {EASY, HARD};
             static int op = EASY;
             static int op = EASY;
@@ -155,6 +155,20 @@ int main(void)
             if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
             if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
             nk_layout_row_dynamic(ctx, 22, 1);
             nk_layout_row_dynamic(ctx, 22, 1);
             nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
             nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
+
+            nk_layout_row_dynamic(ctx, 20, 1);
+            nk_label(ctx, "background:", NK_TEXT_LEFT);
+            nk_layout_row_dynamic(ctx, 25, 1);
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
+                nk_layout_row_dynamic(ctx, 120, 1);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
+                nk_layout_row_dynamic(ctx, 25, 1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
+                nk_combo_end(ctx);
+            }
         }
         }
         nk_end(ctx);
         nk_end(ctx);
 
 
@@ -171,19 +185,17 @@ int main(void)
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw */
         /* Draw */
-        {float bg[4];
-        nk_color_fv(bg, background);
         SDL_GetWindowSize(win, &win_width, &win_height);
         SDL_GetWindowSize(win, &win_width, &win_height);
         glViewport(0, 0, win_width, win_height);
         glViewport(0, 0, win_width, win_height);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_sdl_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_sdl_render` modifies some global OpenGL state
          * with blending, scissor, face culling, depth test and viewport and
          * with blending, scissor, face culling, depth test and viewport and
          * defaults everything back into a default state.
          * defaults everything back into a default state.
          * Make sure to either a.) save and restore or b.) reset your own state after
          * Make sure to either a.) save and restore or b.) reset your own state after
          * rendering the UI. */
          * rendering the UI. */
         nk_sdl_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
         nk_sdl_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_MEMORY, MAX_ELEMENT_MEMORY);
-        SDL_GL_SwapWindow(win);}
+        SDL_GL_SwapWindow(win);
     }
     }
 
 
 cleanup:
 cleanup:

+ 2 - 5
demo/sdl_opengles2/main.c

@@ -57,9 +57,7 @@
 SDL_Window *win;
 SDL_Window *win;
 int running = nk_true;
 int running = nk_true;
 
 
-    
-
-void 
+static void
 MainLoop(void* loopArg){
 MainLoop(void* loopArg){
     struct nk_context *ctx = (struct nk_context *)loopArg;
     struct nk_context *ctx = (struct nk_context *)loopArg;
 
 
@@ -135,8 +133,7 @@ MainLoop(void* loopArg){
     SDL_GL_SwapWindow(win);}
     SDL_GL_SwapWindow(win);}
 }
 }
 
 
-int
-main(int argc, char* argv[])
+int main(int argc, char* argv[])
 {
 {
     /* GUI */
     /* GUI */
     struct nk_context *ctx;
     struct nk_context *ctx;

+ 9 - 10
demo/sfml_opengl2/main.cpp

@@ -100,8 +100,8 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    struct nk_color background;
-    background = nk_rgb(28,48,62);
+    struct nk_colorf bg;
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (win.isOpen())
     while (win.isOpen())
     {
     {
         /* Input */
         /* Input */
@@ -138,14 +138,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -164,11 +164,10 @@ int main(void)
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw */
         /* Draw */
-        float bg[4];
         win.setActive(true);
         win.setActive(true);
         nk_color_fv(bg, background);
         nk_color_fv(bg, background);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_sfml_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_sfml_render` modifies some global OpenGL state
         * with blending, scissor, face culling and depth test and defaults everything
         * with blending, scissor, face culling and depth test and defaults everything
         * back into a default state. Make sure to either save and restore or
         * back into a default state. Make sure to either save and restore or

+ 9 - 9
demo/sfml_opengl3/main.cpp

@@ -106,8 +106,8 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    struct nk_color background;
-    background = nk_rgb(28,48,62);
+    struct nk_colorf bg;
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (win.isOpen())
     while (win.isOpen())
     {
     {
         /* Input */
         /* Input */
@@ -145,14 +145,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -175,7 +175,7 @@ int main(void)
         win.setActive(true);
         win.setActive(true);
         nk_color_fv(bg, background);
         nk_color_fv(bg, background);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_sfml_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_sfml_render` modifies some global OpenGL state
         * with blending, scissor, face culling and depth test and defaults everything
         * with blending, scissor, face culling and depth test and defaults everything
         * back into a default state. Make sure to either save and restore or
         * back into a default state. Make sure to either save and restore or

+ 10 - 12
demo/x11_opengl2/main.c

@@ -123,7 +123,7 @@ int main(void)
     struct XWindow win;
     struct XWindow win;
     GLXContext glContext;
     GLXContext glContext;
     struct nk_context *ctx;
     struct nk_context *ctx;
-    struct nk_color background;
+    struct nk_colorf bg;
 
 
     memset(&win, 0, sizeof(win));
     memset(&win, 0, sizeof(win));
     win.dpy = XOpenDisplay(NULL);
     win.dpy = XOpenDisplay(NULL);
@@ -258,7 +258,7 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (running)
     while (running)
     {
     {
         /* Input */
         /* Input */
@@ -293,14 +293,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -319,19 +319,17 @@ int main(void)
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw */
         /* Draw */
-        {float bg[4];
-        nk_color_fv(bg, background);
         XGetWindowAttributes(win.dpy, win.win, &win.attr);
         XGetWindowAttributes(win.dpy, win.win, &win.attr);
         glViewport(0, 0, win.width, win.height);
         glViewport(0, 0, win.width, win.height);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_x11_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_x11_render` modifies some global OpenGL state
          * with blending, scissor, face culling, depth test and viewport and
          * with blending, scissor, face culling, depth test and viewport and
          * defaults everything back into a default state.
          * defaults everything back into a default state.
          * Make sure to either a.) save and restore or b.) reset your own state after
          * Make sure to either a.) save and restore or b.) reset your own state after
          * rendering the UI. */
          * rendering the UI. */
         nk_x11_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
         nk_x11_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
-        glXSwapBuffers(win.dpy, win.win);}
+        glXSwapBuffers(win.dpy, win.win);
     }
     }
 
 
 cleanup:
 cleanup:

+ 10 - 12
demo/x11_opengl3/main.c

@@ -121,7 +121,7 @@ int main(void)
     struct XWindow win;
     struct XWindow win;
     GLXContext glContext;
     GLXContext glContext;
     struct nk_context *ctx;
     struct nk_context *ctx;
-    struct nk_color background;
+    struct nk_colorf bg;
 
 
     memset(&win, 0, sizeof(win));
     memset(&win, 0, sizeof(win));
     win.dpy = XOpenDisplay(NULL);
     win.dpy = XOpenDisplay(NULL);
@@ -255,7 +255,7 @@ int main(void)
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
     #endif
     #endif
 
 
-    background = nk_rgb(28,48,62);
+    bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
     while (running)
     while (running)
     {
     {
         /* Input */
         /* Input */
@@ -290,14 +290,14 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, background, nk_vec2(nk_widget_width(ctx),400))) {
+            if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 nk_layout_row_dynamic(ctx, 120, 1);
-                background = nk_color_picker(ctx, background, NK_RGBA);
+                bg = nk_color_picker(ctx, bg, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);
                 nk_layout_row_dynamic(ctx, 25, 1);
-                background.r = (nk_byte)nk_propertyi(ctx, "#R:", 0, background.r, 255, 1,1);
-                background.g = (nk_byte)nk_propertyi(ctx, "#G:", 0, background.g, 255, 1,1);
-                background.b = (nk_byte)nk_propertyi(ctx, "#B:", 0, background.b, 255, 1,1);
-                background.a = (nk_byte)nk_propertyi(ctx, "#A:", 0, background.a, 255, 1,1);
+                bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
+                bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
+                bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
+                bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
                 nk_combo_end(ctx);
                 nk_combo_end(ctx);
             }
             }
         }
         }
@@ -316,19 +316,17 @@ int main(void)
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw */
         /* Draw */
-        {float bg[4];
-        nk_color_fv(bg, background);
         XGetWindowAttributes(win.dpy, win.win, &win.attr);
         XGetWindowAttributes(win.dpy, win.win, &win.attr);
         glViewport(0, 0, win.width, win.height);
         glViewport(0, 0, win.width, win.height);
         glClear(GL_COLOR_BUFFER_BIT);
         glClear(GL_COLOR_BUFFER_BIT);
-        glClearColor(bg[0], bg[1], bg[2], bg[3]);
+        glClearColor(bg.r, bg.g, bg.b, bg.a);
         /* IMPORTANT: `nk_x11_render` modifies some global OpenGL state
         /* IMPORTANT: `nk_x11_render` modifies some global OpenGL state
          * with blending, scissor, face culling, depth test and viewport and
          * with blending, scissor, face culling, depth test and viewport and
          * defaults everything back into a default state.
          * defaults everything back into a default state.
          * Make sure to either a.) save and restore or b.) reset your own state after
          * Make sure to either a.) save and restore or b.) reset your own state after
          * rendering the UI. */
          * rendering the UI. */
         nk_x11_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
         nk_x11_render(NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
-        glXSwapBuffers(win.dpy, win.win);}
+        glXSwapBuffers(win.dpy, win.win);
     }
     }
 
 
 cleanup:
 cleanup:

+ 38 - 21
demo/x11_rawfb/main.c

@@ -85,14 +85,6 @@ die(const char *fmt, ...)
     exit(EXIT_FAILURE);
     exit(EXIT_FAILURE);
 }
 }
 
 
-static void*
-xcalloc(size_t siz, size_t n)
-{
-    void *ptr = calloc(siz, n);
-    if (!ptr) die("Out of memory\n");
-    return ptr;
-}
-
 static long
 static long
 timestamp(void)
 timestamp(void)
 {
 {
@@ -118,12 +110,32 @@ sleep_for(long t)
  *
  *
  * ===============================================================*/
  * ===============================================================*/
 /* This are some code examples to provide a small overview of what can be
 /* This are some code examples to provide a small overview of what can be
- * done with this library. To try out an example uncomment the include
- * and the corresponding function. */
-/*#include "../style.c"*/
-/*#include "../calculator.c"*/
-#include "../overview.c"
-#include "../node_editor.c"
+ * done with this library. To try out an example uncomment the defines */
+/*#define INCLUDE_ALL */
+/*#define INCLUDE_STYLE */
+/*#define INCLUDE_CALCULATOR */
+/*#define INCLUDE_OVERVIEW */
+/*#define INCLUDE_NODE_EDITOR */
+
+#ifdef INCLUDE_ALL
+  #define INCLUDE_STYLE
+  #define INCLUDE_CALCULATOR
+  #define INCLUDE_OVERVIEW
+  #define INCLUDE_NODE_EDITOR
+#endif
+
+#ifdef INCLUDE_STYLE
+  #include "../style.c"
+#endif
+#ifdef INCLUDE_CALCULATOR
+  #include "../calculator.c"
+#endif
+#ifdef INCLUDE_OVERVIEW
+  #include "../overview.c"
+#endif
+#ifdef INCLUDE_NODE_EDITOR
+  #include "../node_editor.c"
+#endif
 
 
 /* ===============================================================
 /* ===============================================================
  *
  *
@@ -141,7 +153,6 @@ main(void)
     struct rawfb_context *rawfb;
     struct rawfb_context *rawfb;
     void *fb = NULL;
     void *fb = NULL;
     unsigned char tex_scratch[512 * 512];
     unsigned char tex_scratch[512 * 512];
-    XSizeHints hints;
 
 
     /* X11 */
     /* X11 */
     memset(&xw, 0, sizeof xw);
     memset(&xw, 0, sizeof xw);
@@ -175,14 +186,14 @@ main(void)
 
 
     /* GUI */
     /* GUI */
     rawfb = nk_rawfb_init(fb, tex_scratch, xw.width, xw.height, xw.width * 4);
     rawfb = nk_rawfb_init(fb, tex_scratch, xw.width, xw.height, xw.width * 4);
-    if (!rawfb)
-        running = 0;
+    if (!rawfb) running = 0;
 
 
-    /* style.c */
+    #ifdef INCLUDE_STYLE
     /*set_style(ctx, THEME_WHITE);*/
     /*set_style(ctx, THEME_WHITE);*/
     /*set_style(ctx, THEME_RED);*/
     /*set_style(ctx, THEME_RED);*/
     /*set_style(ctx, THEME_BLUE);*/
     /*set_style(ctx, THEME_BLUE);*/
     /*set_style(ctx, THEME_DARK);*/
     /*set_style(ctx, THEME_DARK);*/
+    #endif
 
 
     while (running) {
     while (running) {
         /* Input */
         /* Input */
@@ -216,9 +227,15 @@ main(void)
         if (nk_window_is_closed(&rawfb->ctx, "Demo")) break;
         if (nk_window_is_closed(&rawfb->ctx, "Demo")) break;
 
 
         /* -------------- EXAMPLES ---------------- */
         /* -------------- EXAMPLES ---------------- */
-        /*calculator(ctx);*/
-        overview(&rawfb->ctx);
-        node_editor(&rawfb->ctx);
+        #ifdef INCLUDE_CALCULATOR
+          calculator(ctx);
+        #endif
+        #ifdef INCLUDE_OVERVIEW
+          overview(ctx);
+        #endif
+        #ifdef INCLUDE_NODE_EDITOR
+          node_editor(ctx);
+        #endif
         /* ----------------------------------------- */
         /* ----------------------------------------- */
 
 
         /* Draw framebuffer */
         /* Draw framebuffer */

+ 2 - 2
demo/x11_rawfb/nuklear_xlib.h

@@ -234,10 +234,10 @@ nk_xlib_handle_event(Display *dpy, int screen, Window win, XEvent *evt, struct r
         } return 1;
         } return 1;
     } else if (evt->type == Expose || evt->type == ConfigureNotify) {
     } else if (evt->type == Expose || evt->type == ConfigureNotify) {
         /* Window resize handler */
         /* Window resize handler */
+        void *fb;
+        unsigned int width, height;
         XWindowAttributes attr;
         XWindowAttributes attr;
         XGetWindowAttributes(dpy, win, &attr);
         XGetWindowAttributes(dpy, win, &attr);
-        unsigned int width, height;
-        void *fb;
 
 
         width = (unsigned int)attr.width;
         width = (unsigned int)attr.width;
         height = (unsigned int)attr.height;
         height = (unsigned int)attr.height;