All Projects → RobLoach → raylib-nuklear

RobLoach / raylib-nuklear

Licence: Zlib license
Nuklear immediate mode GUI for raylib

Programming Languages

c
50402 projects - #5 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to raylib-nuklear

Terri-Fried
A multi-platform C++ game made for Ludum Dare 46
Stars: ✭ 140 (+197.87%)
Mutual labels:  raylib
raylib-php
PHP 8 Bindings to raylib
Stars: ✭ 112 (+138.3%)
Mutual labels:  raylib
FNode
Tool based in nodes to build GLSL shaders without any programming knowledge written in C using OpenGL and GLFW.
Stars: ✭ 81 (+72.34%)
Mutual labels:  raylib
cl-raylib
Common Lisp binding of raylib
Stars: ✭ 72 (+53.19%)
Mutual labels:  raylib
nelua-game2048
Clone of the 2048 game in Nelua using Raylib
Stars: ✭ 16 (-65.96%)
Mutual labels:  raylib
Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+17280.85%)
Mutual labels:  raylib
raylib-libretro
👾 libretro frontend using raylib.
Stars: ✭ 19 (-59.57%)
Mutual labels:  raylib
ecs
Build your own Game-Engine based on the Entity Component System concept in Golang.
Stars: ✭ 68 (+44.68%)
Mutual labels:  raylib
awesome-raylib
Curated list of awesome stuff for raylib.
Stars: ✭ 208 (+342.55%)
Mutual labels:  raylib
rPBR
Physically based rendering (PBR) for raylib
Stars: ✭ 72 (+53.19%)
Mutual labels:  raylib
raylib-nelua
Raylib wrapper to nelua language
Stars: ✭ 27 (-42.55%)
Mutual labels:  raylib
tbag
Tea-bag is Third party extension utility project
Stars: ✭ 13 (-72.34%)
Mutual labels:  raylib
raster-master
Raster Master Sprite/Icon/Map editor for Windows 10/11 that generates RayLib code / Put image and map code for Open Watcom, gcc, AmigaBASIC, Amiga C, Amiga Pascal ,QuickBasic, QB64, Quick C, Turbo Pascal, freepascal, Turbo C, Turbo Basic, Power Basic, FreeBASIC, GWBASIC, BASICA, PC-BASIC,, DOS XLIB LBM/PBM
Stars: ✭ 40 (-14.89%)
Mutual labels:  raylib
raylib-odin
Odin bindings for the raylib gamedev library
Stars: ✭ 29 (-38.3%)
Mutual labels:  raylib
raylua
Cross-Platform, Modern, And updated LuaJIT bindings for raylib library.
Stars: ✭ 77 (+63.83%)
Mutual labels:  raylib
raylib-zig
Manually tweaked, auto generated raylib bindings for zig. https://github.com/raysan5/raylib
Stars: ✭ 122 (+159.57%)
Mutual labels:  raylib
raylib-cpp-starter
A portable, automated template for raylib projects with C++ bindings
Stars: ✭ 32 (-31.91%)
Mutual labels:  raylib
nuklear-glfw-vulkan
A nuklear adapter that does Vulkan rendering
Stars: ✭ 52 (+10.64%)
Mutual labels:  nuklear
nelua-tetris
Tetris game clone made in Nelua with Raylib
Stars: ✭ 16 (-65.96%)
Mutual labels:  raylib
ruck
🧬 Modularised Evolutionary Algorithms For Python with Optional JIT and Multiprocessing (Ray) support. Inspired by PyTorch Lightning
Stars: ✭ 50 (+6.38%)
Mutual labels:  raylib

raylib-nuklear

Use the Nuklear immediate mode cross-platform GUI library in raylib.

raylib-nuklear-example Screenshot

Usage

  1. Since this is a header-only library, you must first define RAYLIB_NUKLEAR_IMPLEMENTATION in one of your .c files...
    #define RAYLIB_NUKLEAR_IMPLEMENTATION
  2. Include the raylib-nuklear.h file...
    #include "path/to/raylib-nuklear.h"
  3. Use InitNuklear(fontSize) or InitNuklearEx(font, fontSize) to create the nuklear context...
    struct nk_context *ctx = InitNuklear(10);
  4. Build your Nuklear GUI through the standard Nuklear API
  5. Update the input for the GUI using UpdateNuklear(ctx)
  6. Render the context using DrawNuklear(ctx)
  7. Destroy the nuklear context with UnloadNuklear(ctx)

Example

#define RAYLIB_NUKLEAR_IMPLEMENTATION
#include "raylib-nuklear.h"

int main() {
    InitWindow(640, 480, "raylib-nuklear example");

    // Create the Nuklear Context
    int fontSize = 10;
    struct nk_context *ctx = InitNuklear(fontSize);

    while (!WindowShouldClose()) {
        // Update the Nuklear context, along with input
        UpdateNuklear(ctx);

        // Nuklear GUI Code
        // https://github.com/Immediate-Mode-UI/Nuklear/wiki/Window
        if (nk_begin(ctx, "Nuklear", nk_rect(100, 100, 220, 220),
                NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
            if (nk_button_label(ctx, "Button")) {
                // Button was clicked!
            }
        }
        nk_end(ctx);

        // Render
        BeginDrawing();
            ClearBackground(RAYWHITE);

            // Render the Nuklear GUI
            DrawNuklear(ctx);

        EndDrawing();
    }

    // De-initialize the Nuklear GUI
    UnloadNuklear(ctx);

    CloseWindow();
    return 0;
}

API

struct nk_context* InitNuklear(int fontSize);                // Initialize the Nuklear GUI context
struct nk_context* InitNuklearEx(Font font, float fontSize); // Initialize the Nuklear GUI context, with a custom font
void UpdateNuklear(struct nk_context * ctx);                 // Update the input state and internal components for Nuklear
void DrawNuklear(struct nk_context * ctx);                   // Render the Nuklear GUI on the screen
void UnloadNuklear(struct nk_context * ctx);                 // Deinitialize the Nuklear context
struct nk_color ColorToNuklear(Color color);                 // Convert a raylib Color to a Nuklear color object
struct nk_colorf ColorToNuklearF(Color color);               // Convert a raylib Color to a Nuklear floating color
struct Color ColorFromNuklear(struct nk_color color);        // Convert a Nuklear color to a raylib Color
struct Color ColorFromNuklearF(struct nk_colorf color);      // Convert a Nuklear floating color to a raylib Color
struct Rectangle RectangleFromNuklear(struct nk_context * ctx, struct nk_rect rect); // Convert a Nuklear rectangle to a raylib Rectangle
struct nk_rect RectangleToNuklear(struct nk_context * ctx, Rectangle rect); // Convert a raylib Rectangle to a Nuklear Rectangle
struct nk_image TextureToNuklear(Texture tex);               // Convert a raylib Texture to A Nuklear image
struct Texture TextureFromNuklear(struct nk_image img);      // Convert a Nuklear image to a raylib Texture
struct nk_image LoadNuklearImage(const char* path);          // Load a Nuklear image
void UnloadNuklearImage(struct nk_image img);                // Unload a Nuklear image. And free its data
void CleanupNuklearImage(struct nk_image img);               // Frees the data stored by the Nuklear image
void SetNuklearScaling(struct nk_context * ctx, float scaling); // Scale the graphical user interface larger or smaller (1 is the default)
float GetNuklearScaling(struct nk_context * ctx);            // Retrieves the scale of the given Nuklear contextgit

See the Nuklear API documenation for more how to use Nuklear.

Comparision

There are a few other graphical user interface solutions out there for use with raylib. While every project's needs differ, this aims to compare and contrast each one. In general, however, if you're unsure which GUI to use, use raygui.

Nuklear

Nuklear is a fully fledged immediate mode GUI library, providing a full set of controls and widgets.

Pros

  • Portability, as it's written in C99
  • Automatic layouts
  • Lots of controls
  • Documentation
  • Stable API

Cons

  • Larger code size, which can result in slower compile time
  • Slightly more complex API than raygui

raygui

raygui is a companion library for raylib, and is a tiny, lightweight immediate mode GUI.

Pros

  • Targets the same platforms as raylib
  • Tiny code size
  • Minimal API
  • Easy to use
  • Matches the coding conventions of raylib

Cons

  • No automatic layouts
  • No documentation
  • Not many advanced controls

ImGui

ImGui, used in raylib with rlImGui, is a very powerful graphical user interface for C++.

Pros

  • Pretty much an industry standard
  • Lots of advanced controls
  • Automatic layouts

Cons

  • Requires C++

Development

While this project uses CMake, CMake is not required in order to use raylib-nuklear.

git submodule update --init
mkdir build
cd build
cmake ..
make
./example/raylib-nuklear-example
make test

License

raylib-nuklear is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check LICENSE for further details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].