1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
[[!meta title="El-gpu and pix-el: GNU Emacs 2D and 3D game programming"]]
[[!meta copyright="Copyright © 2026 Emanuel Berg"]]
[[!inline pages="internal(2026/info/el-gpu-nav)" raw="yes"]]
<!-- Initially generated with emacsconf-publish-talk-page and then left alone for manual editing -->
<!-- You can manually edit this file to update the abstract, add links, etc. --->
# El-gpu and pix-el: GNU Emacs 2D and 3D game programming
Emanuel Berg (he/him) - Pronunciation: Swenglish, IRC: lacni, incal@dataswamp.org
[[!inline pages="internal(2026/info/el-gpu-before)" raw="yes"]]
In this project, prepared especially for EmacsConf 2026, the two
packages - `el-gpu` and `pix-el` - for graphics on the GPU as well as
the CPU - have joined forces and been adapted to the CANVAS ARGB32
format, an exciting feature recently added to vanilla GNU Emacs.
We show no less than three games in this video:
1. a snake clone, which operates on a per-pixel basis;
2. a Tetris clone which loads its tiles on the fly from an arbitrary texture, even as that only exists in the drawing program as a dynamic, still editable object; and
3. a Descent-like space game, powered-up by SDL (input, system glue) and OpenGL (3D graphics), executing part CPU-side Emacs Lisp (Elisp), part CPU-side dynamic-module C, and part all-GPU GLSL vertex and fragment shaders.
Like its predecessor, known simply as "the studio" [1] `pix-el` comes
with an interactive environment offering a touch-key graphic
manipulation/control interface, inside an Emacs buffer, not to produce
graphics necessarily, but to make it come alive. Features are
1. OOP-style drawing moving around parameter-defined boxed data;
2. but also explicit pixel-plotting;
3. with independent layers;
4. with procedural shaders for generative/glitch-style graphics, but also for effects, mood lighting, or the illusions of metal and other realistic materials;
5. with alpha masks, expressed with familiar Elisp `lambda` and `defun`;
6. with RGB bitwise and color channel wise blenders, to produce pleasant colors in general, or do specific things e.g. transparency;
7. also with animated sprites and custom blitting to scale, flip, rotate, and transform any graphical object;
8. `pix-el`, being optimized in many ways big and small primarily to be able to iterate a 1920x1080 pixel monitor, in both Elisp and C, for this purpose relies on a C dynamic module, for example to implement `emacs_gpu_array`, which is very similar to the Elisp `cl-replace`, i.e. to do bounded array manipulation between indexes, however being in C and not by all means native compiled Elisp, `emacs_gpu_array` is often 150 times faster;
9. meanwhile, with new idiomatic GNU Emacs Lisp constructs, e.g. the `with-pixels` macro, as-fast-as-it-gets Elisp-side iteration and pixel access;
10. `el-gpu` and `pix-el` have new, interesting ways of drawing text, and images, to the point drawing can happen exclusively on the GPU, drawing platonic polyhedra (from the theory of 3D drawing), to Minecraft adventure lands, or random web PNGs, to a usable, running instance of GNU Emacs itself.
By Emanuel Berg <incal@dataswamp.org>
<https://dataswamp.org/~incal/emacsconf2026/glsl-old-tiles.png>
<https://dataswamp.org/~incal/emacsconf2026/ui-elements.png>
<https://dataswamp.org/~incal/el-gpu>
[[!inline pages="internal(2026/info/el-gpu-after)" raw="yes"]]
[[!inline pages="internal(2026/info/el-gpu-nav)" raw="yes"]]
|