Uderzo

Uderzo is mostly an idea at the moment, a work in progress. Maybe some code will follow. Needless to say, named after the Asterix creator, the half from the genius duo that made the images (if I ever write a Elixir-based wordprocessor, it'll be called Goscinny. Promise).

The idea is to have an Elixir GUI in the following way:

The reason to separate the vector graphics and the GUI are multiple:

Steps:

Setup

Note: I'm doing nothing yet to make this work on non-linux envs, but also nothing to make that hard. Nanovg is portable, and the wrapper executable should be minimal. It already works on Linux OpenGL under Xorg and Broadcom's VideoCore.

Protocol

To get started, we KISS and just use erlang term format. Later on we can have some hand-optimized RPC going on.

Messages are fully async, so if you want a response, you need to send a pid to receive the response along. By convention, we send that pid as the last argument on a call and return responses as {pid, response} - the graphics genserver then simply dispatches that with send(pid, response) and we're in Elixir-land from there.

We use the direct names of the GLFW/OpenGL/NanoVG libraries, uncamelcased. Pointers to hold return values are converted to return tuples. E.g.

  double mx, my;
  GLFWwindow *window;

  glfwGetCursorPos(window, &mx, &my);

becomes

  glfw_get_cursor_pos(window, self())
  receive do
    {mx, my} -> ....
  end

There is ample room for crashing the graphics server - pointers to windows, etcetera, are directly returned as 64 bit numbers. As long as you just store and send them back as opaque handles, everything is fine. If you don't, you will have spectacular crashes.

Note that crashing the graphics server should be fine: processes can monitor the GenServer that will crash along, re-open the window, and simply resume the rendering loop. With a bit of luck, it should be just a flicker.

TBD: Keyboard, mouse callbacks. These will be sent to pre-registered processes that want them. On the other hand, for embedded setups, there's no thing like GLFW to do this and a separate process to process input would be just fine.