Nuklear
Nuklear copied to clipboard
Example included on Github page seems useless
I was expecting the supplied example to be easily runnable, but copying the code from:
https://github.com/Immediate-Mode-UI/Nuklear#example
into a main() like:
#include "Nuklear-master/nuklear.h"
#include "stdlib.h"
int main(int argc, char *argv[])
{
/* init gui state */
struct nk_context ctx;
nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
enum {EASY, HARD};
static int op = EASY;
static float value = 0.6f;
static int i = 20;
if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
/* fixed widget pixel width */
nk_layout_row_static(&ctx, 30, 80, 1);
if (nk_button_label(&ctx, "button")) {
/* event handling */
}
/* fixed widget window ratio width */
nk_layout_row_dynamic(&ctx, 30, 2);
if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;
/* custom widget pixel width */
nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
{
nk_layout_row_push(&ctx, 50);
nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
nk_layout_row_push(&ctx, 110);
nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
}
nk_layout_row_end(&ctx);
}
nk_end(&ctx);
}
has a bunch of stuff missing, like MAX_MEMORY and font.
While i agree that for those unfamiliar with immediate mode / backend agnostic ui's it might seem as though the example does not "work", I also think its hard to provide a "runnable, visual" example without going into backends and all the things "around" nuklear.
The example is in my eyes the perfect example of how to use the nuklear api. Not so much the perfect example of how to integrate it into something runnable, those are in the demo folder.
We could maybe emphasize / structure the readme more towards "Please take a look at the demo folder for runnable, copy/pastable examples" to avoid confusion by those finding nuklear and wanting to try it out fast.
While i agree that for those unfamiliar with immediate mode / backend agnostic ui's it might seem as though the example does not "work", I also think its hard to provide a "runnable, visual" example without going into backends and all the things "around" nuklear.
The example is in my eyes the perfect example of how to use the nuklear api. Not so much the perfect example of how to integrate it into something runnable, those are in the demo folder.
We could maybe emphasize / structure the readme more towards "Please take a look at the demo folder for runnable, copy/pastable examples" to avoid confusion by those finding nuklear and wanting to try it out fast.
Yes, I started with demo/x11/main.c, which was much easier to understand.
We could maybe emphasize / structure the readme more towards "Please take a look at the demo folder for runnable, copy/pastable examples" to avoid confusion by those finding nuklear and wanting to try it out fast.
Good idea! PRs welcome!