Hi I wrote this simple example with nuklear gui toolkit but window is not shown? What do I do?
#define NK_IMPLEMENTATION
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_STANDARD_IO
#include <nuklear.h>
int main(int argc, char **argv) {
struct nk_font_atlas font_atlas;
nk_font_atlas_init_default(&font_atlas);
nk_font_atlas_begin(&font_atlas);
int img_width, img_height;
// struct nk_font_config font_config;
const char *font_path = "/home/.../font/file.ttf";
struct nk_font *font = nk_font_atlas_add_from_file(&font_atlas, font_path, 13, NULL);
const void* img = nk_font_atlas_bake(&font_atlas, &img_width, &img_height, NK_FONT_ATLAS_RGBA32);
// char *img_two[img_width * img_height];
// memcpy(img_two, img, img_width * img_height);
nk_font_atlas_end(&font_atlas, nk_handle_id(0), NULL);
int running = 1;
struct nk_context ctx;
nk_init_default(&ctx, &font->handle);
enum {EASY, HARD};
static int op = EASY;
static float value = 0.6f;
static int i = 20;
while (running) {
struct nk_rect window_bound = { 50, 50, 220, 220 };
nk_flags window_flag = NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_CLOSABLE;
int window_status = nk_begin(&ctx, "show", window_bound, window_flag);
if (window_status) {
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);
nk_clear(&ctx);
}
nk_font_atlas_clear(&font_atlas);
nk_free(&ctx);
return 0;
}
The problem is that Nuklear can't do much on it's own. You need to use some rendering API in order to actually draw your window, such as SDL, OpenGL, DirectX or something else.