|
@@ -164,7 +164,7 @@ static void create_d3d9_device(HWND wnd)
|
|
|
int main(void)
|
|
|
{
|
|
|
struct nk_context *ctx;
|
|
|
- struct nk_color background;
|
|
|
+ struct nk_colorf bg;
|
|
|
|
|
|
WNDCLASSW wc;
|
|
|
RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };
|
|
@@ -216,7 +216,7 @@ int main(void)
|
|
|
/*set_style(ctx, THEME_DARK);*/
|
|
|
#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)
|
|
|
{
|
|
|
/* Input */
|
|
@@ -251,14 +251,14 @@ int main(void)
|
|
|
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, 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);
|
|
|
- background = nk_color_picker(ctx, background, NK_RGBA);
|
|
|
+ bg = nk_color_picker(ctx, bg, NK_RGBA);
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
@@ -279,16 +279,13 @@ int main(void)
|
|
|
/* Draw */
|
|
|
{
|
|
|
HRESULT hr;
|
|
|
-
|
|
|
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));
|
|
|
|
|
|
hr = IDirect3DDevice9_BeginScene(device);
|
|
|
NK_ASSERT(SUCCEEDED(hr));
|
|
|
-
|
|
|
nk_d3d9_render(NK_ANTI_ALIASING_ON);
|
|
|
-
|
|
|
hr = IDirect3DDevice9_EndScene(device);
|
|
|
NK_ASSERT(SUCCEEDED(hr));
|
|
|
|
|
@@ -297,7 +294,6 @@ int main(void)
|
|
|
} else {
|
|
|
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
|
|
}
|
|
|
-
|
|
|
if (hr == D3DERR_DEVICELOST || hr == D3DERR_DEVICEHUNG || hr == D3DERR_DEVICEREMOVED) {
|
|
|
/* 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);
|
|
@@ -309,13 +305,9 @@ int main(void)
|
|
|
NK_ASSERT(SUCCEEDED(hr));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
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);
|
|
|
return 0;
|
|
|
}
|