Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This project provides Go bindings for nuklear.h — a small ANSI C GUI library.

License

NotificationsYou must be signed in to change notification settings

golang-ui/nuklear

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package nk provides Go bindings for nuklear.h — a small ANSI C gui library. Seegithub.com/vurtun/nuklear.
All the binding code has automatically been generated with rules defined innk.yml.

There is no idiomatic wrapper package that will make things easier to use, but the original API is pretty straightforward. Thenk package is fine for the start, then we'll figure out something better that just a wrapper.

Features (plain C version)

  • Immediate mode graphical user interface toolkit
  • Single header library
  • Written in C89 (ANSI C)
  • Small codebase (~15kLOC)
  • Focus on portability, efficiency and simplicity
  • No dependencies (not even the standard library if not wanted)
  • Fully skinnable and customizable
  • Low memory footprint with total memory control if needed or wanted
  • UTF-8 support
  • No global or hidden state
  • Customizable library modules (you can compile and use only what you need)
  • Optional font baker and vertex buffer output

About nuklear.h

This is a minimal state immediate mode graphical user interface single headertoolkit written in ANSI C and licensed under public domain.It was designed as a simple embeddable user interface for application and doesnot have any dependencies, a default render backend or OS window and input handlingbut instead provides a very modular library approach by using simple input statefor input and draw commands describing primitive shapes as output.So instead of providing a layered library that tries to abstract over a numberof platform and render backends it only focuses on the actual UI.

Overview

nuklear golang architecture

Your Go application runs a loop where it handles input from the platform and manages the rendering backend. It uses Nuklear API bindings (thenk package) to run UI commands for layout and event handling. Nuklear maintains a draw command list that is consumed by one of the rendering backends so the UI is displayed. In this case, a C program is being a middleman that does all the UI heavylifting for us, so we can focus on the application logic, event handling and drawing backends in Go.

Installation of nk

Supported platforms are:

  • Windows 32-bit
  • Windows 64-bit
  • OS X
  • Linux
  • Android

The desktop support is achieved usingGLFW and there are backends written in Go for OpenGL 2.1 and OpenGL 3.2. Thanks tostrangebroadcasts it also hasSDL2 support now.

Android support is added using theandroid-go project, there is a corresponding backend for OpenGL ES 2.0 or 3.0 surface and input handling logic. Sophisticated things like scroll gestures will be added later.

Desktop installation

Debian/Ubuntu dependencies: (Header files required for GLFW)

# apt install xorg-dev

Fedora(tested on 28):

# libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel libXi-devel

After that, standardgo get should work:

$ go get github.com/golang-ui/nuklear/nk

On desktop both OpenGL 2.1 and OpenGL 3.2 contexts are working fine, but by default OpenGL 3.2-core is used, to compile with OpenGL 2.1 support instead. The 2.1 backend is for legacy hardware or VMs like Parallels.

$ go get -tags opengl2 github.com/golang-ui/nuklear/nk

Additional steps for Windows users:

  1. Get MinGW compiler toolchain and MSYS viaMinGW installer;
  2. Open MSYS shell (usuallyC:\MinGW\msys\1.0\msys.bat);

Then everything should go smooth.

$ go versiongo version go1.6.2 windows/386$ gcc -vCOLLECT_GCC=C:\MinGW\bin\gcc.exeThread model: posixgcc version 5.3.0 (GCC)$ go install github.com/golang-ui/nuklear/nk

Hint: use-tags sdl2 to run with SDL2 instead of GLFW. SDL2 requires additional installation process, seeSDL2. Use GLFW if you want to stay go-get-able.

Android demo

In order run Android demo appnk-android make sure that you've prepared your environent as described in plainexample Android app. Namely you need to install Android SDK, tools and runmake toolchain:

$cd$GOPATH/src/github.com/golang-ui/nuklear/cmd/nk-android$ make toolchain# need to run once# the regular routine:$ make$ make install$ make listen

  

Click for video

Desktop demo

There is an example appnk-example that shows the usage of Nuklear GUI library, based on the official demos.

$ go get github.com/golang-ui/nuklear/cmd/nk-example$ nk-example2016/09/23 23:13:09 glfw: created window 400x5002016/09/23 23:13:10 [INFO] button pressed!2016/09/23 23:13:10 [INFO] button pressed!2016/09/23 23:13:10 [INFO] button pressed!

demo screenshot nuklear

Another more realistic Go application that uses Nuklear to do its GUI,a simple WebM player:

nuklear screenshot webm

Rebuilding the package

You will need to get thec-for-go tool installed first.

$ git clone https://github.com/golang-ui/nuklear && cd nuklear$ make clean$ make

Building nuklear - Using vcpkg

You can download and install nuklear using thevcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.gitcd vcpkg./bootstrap-vcpkg.sh./vcpkg integrate install./vcpkg install nuklear

The nuklear port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, pleasecreate an issue or pull request on the vcpkg repository.

License

All the code except when stated otherwise is licensed under theMIT license.Nuklear (ANSI C version) is in public domain, authored from 2015-2016 by Micha Mettke.

About

This project provides Go bindings for nuklear.h — a small ANSI C GUI library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors20


[8]ページ先頭

©2009-2025 Movatter.jp