Integrate nuklear into engine
This commit is contained in:
@@ -19,13 +19,19 @@ typedef struct BzAppDesc {
|
||||
BzAppRenderFunc render;
|
||||
BzAppDeinitFunc deinit;
|
||||
|
||||
bool useNuklear;
|
||||
|
||||
void *userData;
|
||||
} BzAppDesc;
|
||||
|
||||
extern struct nk_context *NK;
|
||||
|
||||
extern bool bzMain(BzAppDesc *appDesc, int argc, const char **argv);
|
||||
|
||||
#ifdef BZ_ENTRYPOINT
|
||||
#include <raylib.h>
|
||||
#include <raylib-nuklear.h>
|
||||
|
||||
struct nk_context *NK = NULL;
|
||||
|
||||
// https://www.raylib.com/examples/core/loader.html?name=core_custom_logging
|
||||
static void bzRaylibLogger(int msgType, const char *text, va_list args) {
|
||||
@@ -85,16 +91,27 @@ int main(int argc, const char **argv) {
|
||||
SetTargetFPS(appDesc.fps);
|
||||
// Initialize modules
|
||||
|
||||
if (appDesc.useNuklear) {
|
||||
NK = InitNuklear(16);
|
||||
}
|
||||
|
||||
// User initialize
|
||||
if (appDesc.init && !appDesc.init(appDesc.userData)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (!WindowShouldClose()) {
|
||||
if (NK)
|
||||
UpdateNuklear(NK);
|
||||
if (appDesc.update)
|
||||
appDesc.update(0.0f, appDesc.userData);
|
||||
|
||||
BeginDrawing();
|
||||
if (appDesc.render)
|
||||
appDesc.render(0.0f, appDesc.userData);
|
||||
if (NK)
|
||||
DrawNuklear(NK);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
// User deinitialize
|
||||
@@ -102,6 +119,10 @@ int main(int argc, const char **argv) {
|
||||
appDesc.deinit(appDesc.userData);
|
||||
|
||||
// Deinitialize modules
|
||||
if (NK) {
|
||||
UnloadNuklear(NK);
|
||||
NK = NULL;
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
bzLoggerDeinit();
|
||||
|
||||
Reference in New Issue
Block a user