• Stars
    star
    175
  • Rank 211,148 (Top 5 %)
  • Language
    C#
  • License
    Other
  • Created over 6 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

.NET binding for the Nuklear immediate mode GUI

NuklearDotNet

LICENSE: Dual-licensed under MIT and The Unlicense. Your choice.

.NET binding for the Nuklear immediate mode GUI https://github.com/vurtun/nuklear

NuklearSharp ( https://github.com/leafi/NuklearSharp ) was my original inspiration for this.

No original nuklear source files were modified. A project was created with some support code to build Nuklear.dll (x64) with all API functions exported and ready to be used from .NET

Updating should be as easy as updating the submodule and rebuilding the project.

Currently this binding is used in my game engine project, so i implement stuff as i need it. https://github.com/sbarisic/libTech

Contributions welcome.

Implemented devices

Screenshots

alt text

Code samples

The custom device class implements actual drawing functions, it has to inherit from at least NuklearDevice. NuklearDeviceTex allows you to specify your custom texture class which replaces the internal texture handle integers, just for convenience. You can return your own texture handle integers in NuklearDevice and handle textures manually.

Optionally it can implement the IFrameBuffered interface which calls the Render function only when the GUI actually changes. It it supposed to be rendered to a framebuffer which is in turn rendered to the screen every frame in RenderFinal

class Device : NuklearDeviceTex<Texture>, IFrameBuffered {
	public override Texture CreateTexture(int W, int H, IntPtr Data) {
		// Create a texture from raw image data
		return null;
	}

	void IFrameBuffered.BeginBuffering() {
		// Begin rendering to framebuffer
	}
	
	public override void SetBuffer(NkVertex[] VertexBuffer, ushort[] IndexBuffer) {
		// Called once before Render, upload your vertex buffer and index buffer here
	}

	public override void Render(NkHandle Userdata, Texture Texture, NkRect ClipRect, uint Offset, uint Count) {
		// Render to either framebuffer or screen
		// If IFrameBuffered isn't implemented, it's called every frame, else only when the GUI actually changes
		// Called multiple times per frame, uses the vertex and index buffer that has been sent to SetBuffer
	}

	void IFrameBuffered.EndBuffering() {
		// End rendering to frame buffer
	}

	void IFrameBuffered.RenderFinal() {
		// Called each frame, render to screen finally
	}
}

Sending events; just call these when you capture the events from your input API. It's irrelevant when they're called. They are internally queued and dispatched to Nuklear on every frame.

	Device.OnMouseButton(Button, X, Y, Down)
	Device.OnMouseMove(X, Y)
	Device.OnScroll(X, Y)
	Device.OnText(Text)
	Device.OnKey(Key, Down)

Using the GUI, note that the while loop represents an OnRender function in your renderer code. At the end of the Frame call, the actual rendering functions are dispatched.

NuklearAPI.Init(Device);

while (true) {

	// Optional
	NuklearAPI.SetDeltaTime(Dt);
	
	NuklearAPI.Frame(() => {
		NuklearAPI.Window("Test Window", 100, 100, 200, 200, Flags, () => {
			NuklearAPI.LayoutRowDynamic(35);
			
			if (NuklearAPI.ButtonLabel("Some Button"))
				Console.WriteLine("You pressed Some Button!");
		});
	});

}

TODO

  • Demo application
  • Higher level binding
  • Support for multiple contexts, want to draw a GUI and some example on a 3D in-game screen at the same time?

More Repositories

1

libTech

Game engine inspired by id Tech and Source written in C#
C#
56
star
2

nanovg_dotnet

.NET binding for nanovg
C#
25
star
3

RuntimePInvoke

PInvoke at runtime for .NET
C#
17
star
4

Hackery

Making the .NET runtime do stuff it's not even supposed to do!
C#
14
star
5

gluac

GMod lua equivalent of luac
C#
13
star
6

SFMLTextBuffer

TextBuffers for SFML
C#
12
star
7

Libraria

.NET God Library
C
12
star
8

CatiaNET

Catia V5R20 programming interface tools for .NET
C#
11
star
9

bspconv

Quake bsp map converter tool
C#
10
star
10

Peeper

A screen recording software that doesn't spy on you (probably)!
C#
9
star
11

Squirrel.NET

Managed Squirrel programming language
C++
8
star
12

gmsv_gsharp_win32

Garry's Mod pure C# binary module proof of concept.
C#
8
star
13

GMOD-NET-API

Deprecated in favor of gsharp
C++
7
star
14

GCODE

Using C# as a domain specific language that emits g-code
C#
7
star
15

KerNET

Kernel mode .NET code
C#
6
star
16

Lua.NET

Lua(JIT) for .NET using P/Invoke
C#
6
star
17

Wren.NET

.NET binding for the Wren scripting language
C#
5
star
18

CarpECS

ECU R&D
C#
5
star
19

Flib

Font Libray - Freetype font rendering for .NET (OpenTK, OpenGL, or any other rendering engine)
C#
4
star
20

CarpOS

OS written in VC++
C
4
star
21

TCC.NET

.NET bindings for Tiny C Compiler
C
4
star
22

M68K

VM running the Motorola 68000 instruction set
C#
4
star
23

NotFuckingMinecraft

Voxel engine thingy done in C# and OpenTK and stuff.
C#
4
star
24

PointerHook

Hooking raw pointer read and write operations. Why? Because you can.
C#
4
star
25

FishGfx

SFML but better.
C#
4
star
26

ISO9660

.NET library for creating normal or bootable .iso images
C#
3
star
27

Gravity.NET

.NET bindings for the Gravity programming language
C#
2
star
28

LuaBintils

Utility library for loading and saving lua precompiled chunk files for .NET
C#
2
star
29

E78_14T

Delphi E78 ECU and GM/Opel 1.4T engine A14NET LUJ LUV information
C++
2
star
30

Habitat

A space video game
HTML
2
star
31

NetScript

Windows only .NET scripting for native applications proof of concept
C#
2
star
32

Kernel

x64 kernel operating system thing
C
2
star
33

FileUpload

ASP.NET file hosting, uploading and tagging web site
JavaScript
1
star
34

Asteroids2017

Asteroids (2017)
Python
1
star
35

q3vm_csharp

C# port of the Quake 3 virtual machine
C
1
star
36

Chatnet

Telnet chat
C#
1
star
37

VeldridTest

Sample thing using the Veldrid renderer
C#
1
star
38

Plync

Youtube playlist synchroniser
C#
1
star
39

Neutron

NeutronVM
C#
1
star
40

mini_kernel

Programming project for the class "C programming language"
C
1
star
41

RaylibGame

Game example using Raylib and C#
C
1
star
42

FishGL

A software renderer thingie
C#
1
star
43

Netwreck

.NET networking library
C#
1
star
44

ijs_projekt

C#
1
star
45

WiFiDirect

WiFi API thing
C#
1
star
46

binarylua_win32

Garry's Mod module that adds a function to load precompiled glua chunks
C#
1
star
47

Tetraquark

Space game
C#
1
star
48

CRTMachine

It's supposed to be some kind of CRT monitor/computer simulator.
C#
1
star
49

TurboMapCalculator

Calculates the curve on the compressor map for a specified engine
C#
1
star
50

Kawnsole

SDL2 Console renderer for .NET
C#
1
star
51

QuakeLiveSDK

.NET SDK for Quake Live
C#
1
star
52

Pinevoke

P/Invoke generator for Visual C++ dlls
C#
1
star
53

Harvesturr

Harvest Massive Encounter clone, but in 2D, and crappy
C#
1
star
54

V

.NET scripting language
C#
1
star
55

lemonade

.NET binding for the Lemon programming language
C#
1
star
56

string_utf8

A string type which defaults to the UTF-8 encoding for .NET for use in marshalling
C#
1
star
57

ImageToAscii

.NET ascii art generator thing
C#
1
star
58

Internetz

The networking library
C#
1
star
59

ArbitraryPictureFormat

APF - Arbitrary Picture Format
C#
1
star