What is nux and what's it used for?

This question mentions that Unity will use nux as the toolkit.

What exactly is nux?


Nux is a OpenGL based widget toolkit and canvas used to create user interfaces, similar to GTK+. At a high level, nux is broken down into 3 libraries.

  • NuxCore
  • NuxGraphics
  • Nux

NuxCore is responsible for basic things like a type system, math functions, color definitions, etc. It basically provides all the primitive types for a widget system (color, rectangle, point). Very little logic is present here, this is a foundational library.

NuxGraphics is a thin OpenGL abstraction layer. It provides simplifications of common OpenGL patterns (pushing and popping clipping rectangles, changing render targets, state setting, etc), however it does not directly forbid users from making raw OpenGL calls themselves. NuxGraphics provides abstractions for textures and loading/unloading data.

Nux is a widget library implemented on top of NuxCore and NuxGraphics. Nux contains a duplicate for almost every major widget in the GTK stack as well as several composition widgets (color picker, graphs, 3d views). The Nux widgets are not yet at the same level of complexity as GTK widgets, lacking advanced text rendering (being fixed) and clear theming support.

Rendering inside of nux could be described as “canvas style”. Nux provides a painter to perform basic drawing primitives which can be used in addition to embedding other widgets. So rather than embedding an hbar to create a horizontal line, a widget author may, at their choice, use the painter to draw the bar directly. Images may also be rendered in this fashion, rather the embedding an additional widget simply to render a static non-reactive image. This does not however rule out simply embedding widgets.

In Unity nux is used in what we call “Embedded Mode”. Essentially nux provides a function for painting itself in a foreign open gl context. We call the paint function and nux blits itself onto the backbuffer. We can then continue to paint on top of it if we desire (sometimes we allow compiz to do this). There are functions provided to do opengl state management in embedded mode.