Commit b5170fdb authored by Hanspeter Portner's avatar Hanspeter Portner

Squashed 'nuklear/' changes from ecf39956..2d8b6dca

2d8b6dca Fix invalid y_offset bug in nk_group_begin.
e79f08d6 fix NK_COMMAND_ARC/NK_COMMAND_ARC_FILLED.
15516bdc omk: don't clear draw_list.
ac7b9760 omk: fix lexer code to work with utf8.
9275be6f add support for syntax highlighting
9d91b7c3 Moved Changelog into documentation
2d31b3af Merge pull request #600 from cartman300/patch-1
c9189a25 Finished documenation conversion
ac0901e8 Update Readme.md
53185557 Add C# binding to the list
8027ebe0 Second last doc conversion commit
8709a881 Added input documentation translation
9a314f0e Finised context documentation translation
365c9827 Removed last remaining old doc file
8ae9160b Updated Readme
882e935c Added documentation html file as link
dd5f3520 Started documentation transition to markdeep
9cb143e1 Merge pull request #599 from nsawa/fix_nk_colorf_hsva_f
83e2c109 Fix nk_colorf_hsva_f alpha calculation
2891c6af Update demos to new color picker API
604a7dfa Merge branch 'master' of https://github.com/vurtun/gui
bd30c124 Fixed #544 color picker (breaking change)
b47463d2 Merge pull request #598 from mgerhardy/fixed-implicit-fallthrough
acaab2f4 Fixed implicit fallthrough warning
df96bac3 Merge pull request #590 from mgerhardy/travis
3f3091fc Merge pull request #596 from billsix/addReferenceToPyNuklear
363e9eef Merge pull request #595 from billsix/fixContextualOverviewText
0e808bcb Merge pull request #594 from fbbdev/better_gitignore
8c2fb99f add reference to pyNuklear
1b64d124 show full label in overview popup by expanding horizontal space
57d1a41b Ignore binary files on linux
5bbe3373 Removed docu typo
a9e87c61 Fixed Readme layout
f08b6203 Split license into dual license MIT/public domain
b17ec490 TRAVIS: include demo windows and activate warnings
6bddc5c5 Update demos configurables and removed warnings
07e422ec Fixed warnings found by gcc and clang
1a77fc87 Merge branch 'mgerhardy-issue585'
023c2da4 Fixed define intendation
683185e7 Merge branch 'issue585' of https://github.com/mgerhardy/nuklear into mgerhardy-issue585
5b9d6a9e Merge pull request #591 from mgerhardy/issue584
7bbad088 Merge pull request #589 from mgerhardy/issue588
61143c34 Fixed issue #585
107c920f Fixed second part of issue #584
be55f26a Fixed parts of issue #584
43277a4f Fixed issue #588
87d3e9f3 Added documentation for group
f83c8648 Fixed #583 small warning in GCC
b6e0e34c Fixed #582 nk_edit_buffer behavior
b2b08061 Fixed #581 progressbar drawing and behavior
267383a3 Merge pull request #574 from NuklearBomb/patch-2
1c07ceaa nk_layout_peek() bugfix
a9e5e729 Added extended submenus to overview.c
f7833d03 Fixed #569 and added additional formated tooltip
2fda8535 Fixed #567 fread size calculation
f5aeacdc Merge branch 'master' of https://github.com/vurtun/gui
16c6f2ae Fixed #560 nk_font_atlas_add
7e32431a Merge pull request #549 from GreenByteSoftware/master
0c4d93e1 Fixed #563 nk_font_atlas_cleanup behavior
9e2cce1e Removed not needed } from comment
5fbcdd0f Fixed #560 loading multiple fonts
05413607 Fixed warnings and UB in demo code
1d8aae2b Merge branch 'Predelnik-userdata-fix'
3636cb1c Fixed #511 and changed formatting
a012e7b4 Merge branch 'master' of https://github.com/vurtun/nuklear
988b4088 Fix NK_INCLUDE_COMMAND_USERDATA usage with images.
56b2612a Fixed #558 NK_WINDOW_NO_INPUT hidding windows bug
37a00a5f Fixed #555 closing minimized windows and drawing bug
6a13addb Fixed #413 font merging
f436c1a1 Merge pull request #550 from kstarzyk/add_osx_build_sfml_demo
89b32fb9 Merge pull request #553 from NuklearBomb/patch-1
e76ba09e Use NK_DTOA in function nk_do_property
c7d9d095 Ident
dde25790 Fix ident
bcd0234f Add OSX build for SFML demo
9a075409 Fix D3D9 rendering in certain scenarios
36a396fb Merge pull request #546 from nsawa/fix_gcc_warning_unused_variable
2f269f4d Fix: gcc warning unused variable.
c24e3d60 Merge branch 'master' of https://github.com/vurtun/gui
7eb08b8b Fixed #545 with window pos/size modifier
REVERT: ecf39956 Fix invalid y_offset bug in nk_group_begin.
REVERT: e8761c79 fix NK_COMMAND_ARC/NK_COMMAND_ARC_FILLED.
REVERT: 524c27e0 omk: don't clear draw_list.
REVERT: 0c787048 omk: fix lexer code to work with utf8.
REVERT: 5e70ec4b add support for syntax highlighting

git-subtree-dir: nuklear
git-subtree-split: 2d8b6dca629443e7bb6752b1f4920742891af5b3
parent 68da5ff8
demo/*/*.exe
demo/*/*.obj
demo/*/bin/*
example/bin/*
docs/xml
docs/build
docs/src
......
[submodule "docs/build/html"]
path = docs/build/html
url = https://github.com/nuklear-ui/nuklear-ui.github.io
conda:
file: docs/environment.yml
......@@ -11,5 +11,6 @@ before_install:
- if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository -y ppa:pyglfw/pyglfw && sudo apt-get update -qq && sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libglew-dev; fi
script:
- make -C demo/glfw_opengl3
- make -C demo/glfw_opengl3 CFLAGS="-Wall -DINCLUDE_ALL"
- make -C demo/glfw_opengl2
- make -C example
This diff is collapsed.
......@@ -25,6 +25,7 @@ render backends it only focuses on the actual UI.
- No global or hidden state
- Customizable library modules (you can compile and use only what you need)
- Optional font baker and vertex buffer output
- [Documentation](https://rawgit.com/vurtun/nuklear/master/doc/nuklear.html)
## Building
......@@ -98,15 +99,17 @@ languages. Furthermore there are no guarantee that all bindings will always be k
- [Java](https://github.com/glegris/nuklear4j) by Guillaume Legris
- [Golang](https://github.com/golang-ui/nuklear) by golang-ui@github.com
- [Rust](https://github.com/snuk182/nuklear-rust) by snuk182@github.com
- [Chicken](https://github.com/wasamasa/nuklear) by wasamasa@github.comx
- [Chicken](https://github.com/wasamasa/nuklear) by wasamasa@github.com
- [Nim](https://github.com/zacharycarter/nuklear-nim) by zacharycarter@github.com
- [Lua/Löve2d](https://github.com/keharriso/love-nuklear) by Kevin Harrison
- [Python](https://github.com/billsix/pyNuklear) by William Emerison Six
- [CSharp/.NET](https://github.com/cartman300/NuklearDotNet) by cartman300@github.com
## Credits
Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
Embeds `stb_texedit`, `stb_truetype` and `stb_rectpack` by Sean Barret (public domain)
Embeds `stb_texedit`, `stb_truetype` and `stb_rectpack` by Sean Barret (public domain)
Embeds `ProggyClean.ttf` font by Tristan Grimmer (MIT license).
......@@ -117,8 +120,44 @@ Barret for his amazing single header [libraries](https://github.com/nothings/stb
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.
```
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Micha Mettke
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------
```
......@@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS = -std=c99 -pedantic -O2
CFLAGS += -std=c99 -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)
......
......@@ -32,17 +32,32 @@
*
* ===============================================================*/
/* 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. */
#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])
/*#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
/* ===============================================================
*
......@@ -117,7 +132,7 @@ WindowProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
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 };
......@@ -189,12 +204,14 @@ int main(void)
/*nk_style_set_font(ctx, &droid->handle)*/;}
/* style.c */
#ifdef INCLUDE_STYLE
/*set_style(ctx, THEME_WHITE);*/
/*set_style(ctx, THEME_RED);*/
/*set_style(ctx, THEME_BLUE);*/
/*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 */
......@@ -230,29 +247,33 @@ 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);
}
}
nk_end(ctx);
/* -------------- EXAMPLES ---------------- */
/*calculator(ctx);*/
/*overview(ctx);*/
/*node_editor(ctx);*/
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(ctx);
#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);
nk_d3d11_render(context, NK_ANTI_ALIASING_ON);
hr = IDXGISwapChain_Present(swap_chain, 1, 0);
......@@ -264,7 +285,7 @@ int main(void)
/* window is not visible, so vsync won't work. Let's sleep a bit to reduce CPU usage */
Sleep(10);
}
assert(SUCCEEDED(hr));}
assert(SUCCEEDED(hr));
}
ID3D11DeviceContext_ClearState(context);
......
......@@ -29,17 +29,32 @@
*
* ===============================================================*/
/* 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. */
#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])
/*#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
/* ===============================================================
*
......@@ -149,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 };
......@@ -194,12 +209,14 @@ int main(void)
/*nk_style_set_font(ctx, &droid->handle)*/;}
/* style.c */
#ifdef INCLUDE_STYLE
/*set_style(ctx, THEME_WHITE);*/
/*set_style(ctx, THEME_RED);*/
/*set_style(ctx, THEME_BLUE);*/
/*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 */
......@@ -234,38 +251,41 @@ 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);
}
}
nk_end(ctx);
/* -------------- EXAMPLES ---------------- */
/*calculator(ctx);*/
/*overview(ctx);*/
/*node_editor(ctx);*/
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(ctx);
#endif
/* ----------------------------------------- */
/* 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));
......@@ -274,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);
......@@ -286,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;
}
......@@ -67,11 +67,55 @@ static struct {
IDirect3DStateBlock9 *state;
} d3d9;
NK_API void
nk_d3d9_create_state()
{
HRESULT hr;
hr = IDirect3DDevice9_BeginStateBlock(d3d9.device);
NK_ASSERT(SUCCEEDED(hr));
/* vertex format */
IDirect3DDevice9_SetFVF(d3d9.device, D3DFVF_XYZ + D3DFVF_DIFFUSE + D3DFVF_TEX1);
/* blend state */
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_ALPHABLENDENABLE, TRUE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_BLENDOP, D3DBLENDOP_ADD);
/* render state */
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_LIGHTING, FALSE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_ZENABLE, FALSE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_ZWRITEENABLE, FALSE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_CULLMODE, D3DCULL_NONE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_SCISSORTESTENABLE, TRUE);
/* sampler state */
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
/* texture stage state */
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
hr = IDirect3DDevice9_EndStateBlock(d3d9.device, &d3d9.state);
NK_ASSERT(SUCCEEDED(hr));
}
NK_API void
nk_d3d9_render(enum nk_anti_aliasing AA)
{
HRESULT hr;
nk_d3d9_create_state();
hr = IDirect3DStateBlock9_Apply(d3d9.state);
NK_ASSERT(SUCCEEDED(hr));
......@@ -146,6 +190,9 @@ nk_d3d9_render(enum nk_anti_aliasing AA)
}
nk_clear(&d3d9.ctx);
IDirect3DStateBlock9_Apply(d3d9.state);
IDirect3DStateBlock9_Release(d3d9.state);
}
static void
......@@ -168,7 +215,6 @@ NK_API void
nk_d3d9_release(void)
{
IDirect3DTexture9_Release(d3d9.texture);
IDirect3DStateBlock9_Release(d3d9.state);
}
static void
......@@ -203,47 +249,11 @@ nk_d3d9_create_font_texture()
NK_API void
nk_d3d9_resize(int width, int height)
{
HRESULT hr;
if (d3d9.texture) {
nk_d3d9_create_font_texture();
}
hr = IDirect3DDevice9_BeginStateBlock(d3d9.device);
NK_ASSERT(SUCCEEDED(hr));
/* vertex format */
IDirect3DDevice9_SetFVF(d3d9.device, D3DFVF_XYZ + D3DFVF_DIFFUSE + D3DFVF_TEX1);
/* blend state */
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_ALPHABLENDENABLE, TRUE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_BLENDOP, D3DBLENDOP_ADD);
/* render state */
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_LIGHTING, FALSE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_ZENABLE, FALSE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_ZWRITEENABLE, FALSE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_CULLMODE, D3DCULL_NONE);
IDirect3DDevice9_SetRenderState(d3d9.device, D3DRS_SCISSORTESTENABLE, TRUE);
/* sampler state */
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
IDirect3DDevice9_SetSamplerState(d3d9.device, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
/* texture stage state */
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
IDirect3DDevice9_SetTextureStageState(d3d9.device, 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
hr = IDirect3DDevice9_EndStateBlock(d3d9.device, &d3d9.state);
NK_ASSERT(SUCCEEDED(hr));
nk_d3d9_create_state();
nk_d3d9_get_projection_matrix(width, height, &d3d9.projection.m[0][0]);
d3d9.viewport.Width = width;
......
......@@ -24,17 +24,32 @@
*
* ===============================================================*/
/* 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. */
#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])
/*#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
/* ===============================================================
*
......@@ -94,10 +109,12 @@ int main(void)
ctx = nk_gdi_init(font, dc, WINDOW_WIDTH, WINDOW_HEIGHT);
/* style.c */
#ifdef INCLUDE_STYLE
/*set_style(ctx, THEME_WHITE);*/
/*set_style(ctx, THEME_RED);*/
/*set_style(ctx, THEME_BLUE);*/
/*set_style(ctx, THEME_DARK);*/
#endif
while (running)
{
......@@ -144,9 +161,15 @@ int main(void)
nk_end(ctx);
/* -------------- EXAMPLES ---------------- */
/*calculator(ctx);*/
/*overview(ctx);*/
/*node_editor(ctx);*/
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(ctx);
#endif
/* ----------------------------------------- */
/* Draw */
......
......@@ -23,18 +23,33 @@
* EXAMPLE
*
* ===============================================================*/
/* These 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. */
#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])
/*#include "../style.c"*/
/*#include "../calculator.c"*/
/*#include "../overview.c"*/
/*#include "../node_editor.c"*/
/* 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 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
/* ===============================================================
*
......@@ -90,10 +105,12 @@ int main(void)
nk_gdip_set_font(font);
/* style.c */
#ifdef INCLUDE_STYLE
/*set_style(ctx, THEME_WHITE);*/
/*set_style(ctx, THEME_RED);*/
/*set_style(ctx, THEME_BLUE);*/
/*set_style(ctx, THEME_DARK);*/
#endif
while (running)
{
......@@ -139,9 +156,15 @@ int main(void)
nk_end(ctx);
/* -------------- EXAMPLES ---------------- */
/*calculator(ctx);*/
/*overview(ctx);*/
/*node_editor(ctx);*/
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(ctx);
#endif
/* ----------------------------------------- */
/* Draw */
......
......@@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS = -std=c99 -pedantic -O2
CFLAGS += -std=c99 -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)
......
......@@ -27,23 +27,38 @@
#define WINDOW_WIDTH 1200
#define WINDOW_HEIGHT 800
#define UNUSED(a) (void)a
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])
/* ===============================================================
*
* EXAMPLE
*
* ===============================================================*/
/* 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