Skip to content

nk_begin no window #5

Description

@William-Baker
/*
#define NK_IMPLEMENTATION
#define NK_INCLUDE_DEFAULT_ALLOCATOR //prevents having to manage memory allows us of nk_init_default
#define NK_INCLUDE_FONT_BAKING//allows for use of custom fonts with high level API
#define NK_INCLUDE_DEFAULT_FONT//to allow loading default fon
#define NK_INCLUDE_STANDARD_IO//to allowloading custom fonts
#define _CRT_SECURE_NO_WARNINGS allows importing fonts without errors
*/

#include "Resource.h"
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <string>
#include <stdio.h>
#include <iostream>

#include <nuklear.h>





int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
	_In_opt_ HINSTANCE hPrevInstance,
	_In_ LPWSTR    lpCmdLine,
	_In_ int       nCmdShow)
{
	struct nk_context ctx;
	nk_font_atlas atlas;
	struct nk_font_config cfg = nk_font_config(0);
	struct nk_font* font_14;
	cfg.oversample_h = 3;
	cfg.oversample_v = 2;
	cfg.coord_type = NK_COORD_PIXEL;
	const void* image;
	void* image2;
	int w, h;
	nk_font_atlas_init_default(&atlas);
	nk_font_atlas_begin(&atlas);
	//font_14 = nk_font_atlas_add_default(&atlas, 14, &cfg);
	font_14 = nk_font_atlas_add_from_file(&atlas, "Roboto-Light.ttf", 12, &cfg);
	image = nk_font_atlas_bake(&atlas, &w, &h, NK_FONT_ATLAS_ALPHA8);
	image2 = new char[w * h];
	memcpy(image2, image, w * h);
	nk_font_atlas_end(&atlas, nk_handle_id(30), NULL); //30 means nothing?
	nk_init_default(&ctx, &font_14->handle);



	if (nk_begin(&ctx, "Window 1", nk_rect(10, 10, 400, 600), NK_WINDOW_BORDER | NK_WINDOW_MOVABLE)) {
	}
	nk_end(&ctx);
}

The definitions commented at the start have been added within the pre-compiler settings

Am I mistaken in that the above is the minimum required code to create a window? Since it doesn't work :( Are there minimalized examples for simple things like this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions