Repository navigation
Releases
OpenECS-examples 0.8.0
OpenECS-examples 0.8.0 adds two examples: c15_board, a board of blocks and wires, and s26_history, undo and redo with the History panel. Every example now runs on LuaJIT 2.1, and its Lua panels are objects of a class. The release has the examples built for Linux and Windows.
It comes out with OpenECS 0.8.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.8.0, whose plugins they use.
Run an example from OpenECS's folder:
./OpenECS --fresh --preset examples/c15_board/preset.luaWhat you can learn
A board. c15_board is a board of blocks and wires, built with ui's board, in Lua and in C. A click, Ctrl and a rectangle choose blocks; a drag and the arrows move them; a drag from an output's pin to an input's wires them. The wheel zooms, and the middle button moves the view. A Show block has a picture made in memory, whose grey follows its value.
History. s26_history keeps a tally's changes in a history, in Lua and in C. Ctrl+Z undoes, Ctrl+Y and Ctrl+Shift+Z redo, and a drag is one record. The History panel goes to a record at a click, and follows the focused panel. A panel without a history of its own uses the tool's default one.
LuaJIT. The examples give FFI arrays to C as buffers, without copying them: s2_media's samples, s4_model's and s10_cglm's points, s8_gpu's pixels and s9_gpu_model's vertices. sketch_lua builds its image in a string.buffer. c13_workers sends its messages as string.buffer's bytes. c14_structs and s10_cglm use a C plugin's structs as cdata, with fields, methods and operators. s24_profiler finds a Lua function, wave, in the profile.
Classes. Each example's Lua panel keeps its state in an object of its class, with its functions as methods. c1_hello explains the class.
Drawing again on events. A panel type names the events that draw it again. c7_events and c5_services show it from Lua and from C, and s3_network, s5_files, s6_web, s14_gamepad, s17_notify and s25_keys keep no table of their panels.
The GPU. s8_gpu draws gpu's rounded rectangles, circles, rings, clips inside clips and bold text, in Lua and in C. c3_ui and s22_viewer draw on the GPU; their preset_pixels.lua draws them into pixels.
ui. c3_ui shows, in Lua and in C:
- icons, and labels of words and icons, such as a Lock button;
- marks in a tree, such as a lock that a click turns;
- a tree and a list of many rows that build only the rows in view;
- a dropdown of 40 items, and text cut at two lines;
- tooltips, also on each choice of a selector;
- a menu of the panel, with a heading, a line, a dimmed entry and a submenu;
- a finder of ui's elements in a popup, whose rows drag onto the panel;
- a tree that refuses a drop inside itself, and marks where a drop lands;
- an image of draw beside a title, made again for each tint.
Its callbacks follow their meaning: a selector, tabs and dropdowns call onChange only when the choice changes.
Popups. c11_popups opens a submenu beside its menu, and a finder from a field in the title bar, in Lua and in C. A menu at the window's edge stays inside it.
Drag and drop. c9_drag_drop marks where a dragged colour will land, in Lua and in C, and its palette moves its own colours.
Files. s5_files shows a tree of folders beside the grid. It copies a file dropped from a file manager into the folder, and Show in Files shows a note in the panel. watcher and watcher_c watch a folder and the folders inside it, in Lua and in C. The notes use fs in place of io and os, and delete to the trash.
A whole tool. c12_sketch binds Ctrl+H for each plugin, in all its panels. Its highlight is yellow for one run only, through the settings' run layer. Each canvas counts its unsaved changes in a badge. showCanvas focuses an open canvas or opens one. useBrush takes nil to go back to the settings' brush.
Keys. c6_keys binds keys for a plugin, and its panel type's key wins over the plugin's. s25_keys binds a key after the prefix, Alt+W then C, and adds an entry to the menu Tools.
The console. s23_console's entries name their source, which a checkbox hides. The Show dropdown chooses the levels, and Sort the order. A hidden console shows a badge in the colour of its worst entry.
Logs and sessions. c7_events and c4_settings hear the log through ecs.logged. c8_state opens a saved session that names its preset, and takes the preset's menus, keys and settings again.
The viewer. s22_viewer puts Previous, Next and Slideshow in the title bar. Its text shows line numbers, and a mark on the rows that a long line wraps into.
First-party plugins. s7_first_party shows that a manifest that is not valid is left out of the plugin list, and why. It opens the settings window at a setting with settings.show, and walks every theme.
Small fixes
s6_webserves on port 47210, so its test runs besides3_network's.s3_networklistens on 127.0.0.1 with a free port, ands13_processgives programs variables.c10_text_input's field shows an italic hint while it is empty.s17_notify's tray icon is its ownicon.png.c13_workersstops its workers when its plugin is disabled, and counts again when it is enabled.shuild.cprints its flags with--help.
What will break
Plugin API 4. Every example's plugin says api = 4, and needs OpenECS 0.8.0. Code copied from 0.7.0 must change as OpenECS's and OpenECS-std's releases say: Lua is LuaJIT 2.1, so buffers are FFI arrays and string.pack is gone; structs, such as cglm's vectors, are cdata; workers' messages cannot hold functions; and ui's callbacks follow their meaning.
Downloads
openecs-examples-0.8.0-linux-x86_64.tar.gzandopenecs-examples-0.8.0-windows-x86_64.zip: the examples built. Unpack one into an OpenECS 0.8.0 folder.openecs-examples-0.8.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as its README.md says.SHA256SUMS: checksums of the archives.
The examples are under the 0BSD license.
OpenECS-examples 0.7.0
OpenECS-examples 0.7.0 adds eight examples, s18_regex to s25_keys, for the new standard plugins, the profiler and the key list. c8_state and c2_native reload their plugins while the tool runs, and c3_ui shows ui's new elements. The release has the examples built for Linux and Windows.
It comes out with OpenECS 0.7.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.7.0, whose plugins they use.
Run an example from OpenECS's folder:
./OpenECS --fresh --preset examples/s24_profiler/preset.luaWhat you can learn
Regular expressions. s18_regex is a log filter: a typed pattern filters the lines, and a pattern with named groups reads each one.
Markdown. s19_markdown shows a help file with ui's elements, with its headings as a tree. A click on a link, or Tab and Return, opens it.
Syntax. s20_syntax shows a C, a Lua and a JSON file with their code coloured.
Video. s21_video plays a clip with its sound; Space plays and pauses, and Left and Right seek.
Files, the viewer and the console. s5_files is a notes tool on the files panel: its menu makes, renames and deletes notes, and its grid shows them as tiles. s22_viewer shows text, images and sounds. s23_console runs a program and shows its output; a click on an entry's place opens it in the code editor.
The profiler. s24_profiler has a panel that draws every frame through draw, beside the profiler. The panel reads ecs.profile.get(), so its own time and draw's show apart.
Keys. s25_keys has a function that Ctrl+J runs, beside the key list, which gives it another key, resets it, removes it and adds one.
Reloading plugins. c8_state reloads its Lua plugin when its files change, and keeps its panels' state. c2_native reloads a native plugin from a new build of its library.
ui. c3_ui shows sections, colour pickers, a path field, a graph, a menu at a right click, a row that wraps, a tree that chooses many nodes and drags them, a number field that takes sums and drags sideways, and a slider that submits at its release, in Lua and in C where C has them.
Errors. c5_services fails with ECS_Fail and ecs.fail, and checks arguments with ECS_Check and ecs.check.
Drawing only what changed. c12_sketch's canvases paint only the new part of a stroke, and tell OpenECS the rectangle they changed.
Small fixes
s14_gamepaddraws each gamepad's sticks, triggers and buttons.s12_compressmakes a.tar.gzand reads it back.s1_terminalgivestextgrid.fitthe surface's scale.
What will break
Plugin API 3. Every example's plugin says api = 3, and needs OpenECS 0.7.0. Code copied from 0.6.0 must change as OpenECS-std's release says: ui's props last, selected and onSelect, and registrations without assert.
Downloads
openecs-examples-0.7.0-linux-x86_64.tar.gzandopenecs-examples-0.7.0-windows-x86_64.zip: the examples built. Unpack one into an OpenECS 0.7.0 folder.openecs-examples-0.7.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as README.md says.SHA256SUMS: checksums of the archives.
The examples are under the zlib license.
OpenECS-examples 0.6.0
OpenECS-examples 0.6.0 adds eight examples: c14_structs for the plugin interface's structs, and s11_parse to s17_notify for the new standard plugins. s7_first_party enables and disables plugins while the tool runs. The release has the examples built for Linux and Windows.
It comes out with OpenECS 0.6.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.6.0, whose plugins they use.
Run an example from OpenECS's folder:
./OpenECS --fresh --preset examples/s16_sqlite/preset.luaWhat you can learn
Structs. c14_structs has a C plugin's vec2 struct, with methods and operators, which a Lua panel uses as a table: it measures a clicked path with a - b and v:length().
Data formats. s11_parse writes a table in JSON, TOML, INI, .env and CSV, reads each text back, and shows that it reads back the same.
Compression. s12_compress packs its own file with gzip, zlib, deflate and zstd and unpacks it, then writes a zip archive, lists it and reads a file back.
Programs. s13_process runs sort with an input, then starts the shell beside the tool and reads its output and errors from a timer.
Gamepads. s14_gamepad shows every gamepad that is plugged in, from gamepad's events. Space plugs in a virtual gamepad that the keyboard drives.
Hashes. s15_hash hashes a text with each algorithm, and its own file whole and in parts, which give the same hash.
SQLite. s16_sqlite keeps a table in a database in memory: it creates it, adds and updates rows with parameters, and shows a query. Return adds a row.
Notifications and tray icons. s17_notify sends notifications with buttons and shows a tray icon with a menu; the panel lists what the user clicks. Return sends one.
Enabling and disabling plugins. In s7_first_party, the plugin list disables and enables plugins while the tool runs. A new plugin, badges, needs shapes: disabling shapes disables badges too, and enabling badges enables shapes. Its test also opens the tool's menu.
cglm's structs. s10_cglm's cube multiplies its matrices with * and reads a projected point's x and y. The C cube passes CglmVec3 and CglmMat4 by pointer. s9_gpu_model joins the bytes of its matrices and vectors into uniforms.
Small fixes
c12_sketch's Lua panel paints each row of a dab with one fill, and makes each colour's text once, as each call from Lua to the core has a cost.s6_websays that web uses HTTP/2 and asks for compressed answers.
What will break
cglm. s9_gpu_model and s10_cglm use cglm's structs, so they need OpenECS-std 0.6.0. Code copied from their 0.5.0 versions must change as OpenECS-std's release says.
Plugin API. The examples' plugins use plugin API version 2, and need OpenECS 0.6.0.
Downloads
openecs-examples-0.6.0-linux-x86_64.tar.gzandopenecs-examples-0.6.0-windows-x86_64.zip: the examples built. Unpack one into an OpenECS 0.6.0 folder.openecs-examples-0.6.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as README.md says.SHA256SUMS: checksums of the archives.
The examples are under the zlib license.
OpenECS-examples 0.5.0
OpenECS-examples 0.5.0 names its examples by what they teach: c1_hello to c13_workers the plugin interface, and s1_terminal to s10_cglm the standard plugins. s10_cglm is new, and s9_gpu_model's shaders are GLSL. The release has the examples built for Linux and Windows.
It comes out with OpenECS 0.5.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.5.0, whose plugins they use.
Run an example from OpenECS's folder:
./OpenECS --fresh --preset examples/s10_cglm/preset.luaWhat you can learn
3D math. s10_cglm turns a cube and shows it in perspective with the cglm plugin's vectors and matrices, and draws its edges with draw. Its second workspace has the same cube in C, with the same functions. Drag to turn it.
Shaders in GLSL. s9_gpu_model gives gpu its shaders as GLSL source, which gpu compiles on every system, and makes its matrices with cglm. Its test checks gpu.compile's SPIR-V and its error message too.
GPU panels without SDL. In s8_gpu, the C plugin draws with the gpu plugin's functions, as the Lua one does.
ui in C. In c3_ui, the C panel on the second workspace shows the same controls as the Lua one, and one test checks both.
Following a setting. c4_settings follows its settings with ecs.settingChanged.
Plugins that see only the interface. The examples' C plugins include only OpenECS's include/: OpenECS.h and the plugins' headers.
Small fixes
- A test checks that Shift+1, after the prefix, moves a panel to workspace 1.
- The comments follow OpenECS's folders, named
OpenECS, and the theme's colour names,ecs.Color.
What will break
Names. The examples have new names. Update a command or a preset that names one:
| 0.4.0 | 0.5.0 |
|---|---|
1_hello … 12_sketch |
c1_hello … c12_sketch |
20_workers |
c13_workers |
13_terminal |
s1_terminal |
14_media |
s2_media |
15_network |
s3_network |
16_model |
s4_model |
17_files |
s5_files |
18_web |
s6_web |
19_first_party |
s7_first_party |
21_gpu |
s8_gpu |
22_gpu_model |
s9_gpu_model |
Plugin API. The examples' plugins use plugin API version 2, and need OpenECS 0.5.0.
Downloads
openecs-examples-0.5.0-linux-x86_64.tar.gzandopenecs-examples-0.5.0-windows-x86_64.zip: the examples built. Unpack one into an OpenECS 0.5.0 folder.openecs-examples-0.5.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as README.md says.SHA256SUMS: checksums of the archives.
The examples are under the zlib license.
OpenECS-examples 0.4.0
OpenECS-examples 0.4.0 runs on Windows, and its tests run on Wayland too. 22_gpu_model labels its model with text from its own shaders.
It comes out with OpenECS 0.4.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.4.0, whose plugins they use.
Run an example from OpenECS's folder:
./OpenECS --fresh --preset examples/22_gpu_model/preset.luaWhat you can learn
Shaders for Windows. 22_gpu_model gives its shaders in DXIL too, for Direct3D 12, which Windows uses. They are HLSL, compiled with DXC to DXIL and to SPIR-V; gpu takes the code that the GPU's driver takes.
Text in a 3D scene. 22_gpu_model draws a label beside a point of its ring, with the glyphs that gpu.glyphs gives and shaders of its own. The ring hides the label as it passes behind it.
Pop-out windows. 12_sketch's new test pops a canvas out into a window of its own, and drags it back into the main window.
Small fixes
- The examples build on Windows, with LLVM-MinGW or MinGW's gcc, and their tests run there.
- The tests pass on Wayland in a tiling compositor, where the window fills the screen:
3_uiand13_terminalno longer depend on the window's width. 18_webknows that its WebSocket connection is open once a message arrives, also when the server's greeting comes before it saw the connection open.
What will break
Nothing.
Downloads
openecs-examples-0.4.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as README.md says.SHA256SUMS: the checksum of the archive.
The examples are under the zlib license.
OpenECS-examples 0.3.0
OpenECS-examples 0.3.0 adds four examples: web requests and WebSockets, workers on threads of their own, and two that draw on the GPU. The examples of 0.2.0 show the new functions of OpenECS and its standard plugins, and each of their tests checks them.
It comes out with OpenECS 0.3.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.3.0, whose plugins they use.
Every preset has a hint now, which the title bar shows after the tool's name: what to try first, and the keys to press. Run an example from OpenECS's folder:
./OpenECS --fresh --preset examples/21_gpu/preset.luaWhat you can learn
New examples.
18_web: a panel that fetches each typed URL with web, and shows the answer's status, type and first line. Aws://URL opens a WebSocket connection, and each typed line is a message. The plugin serves its own pages and an echo server with net, so the example needs no internet.20_workers: four workers, Lua scripts on threads of their own, count primes in chunks while the panel stays free to use.21_gpu: two GPU panels with the same picture: one in Lua, with the gpu plugin, and one in C, with SDL's GPU API. The Lua one draws its title withgpu.text. Both keep drawing after they pop out into a window of their own.22_gpu_model: a glTF torus, lit and turning on the GPU, drawn with its own shaders and a depth texture. Drag turns it, and the wheel moves it nearer. Its shaders are GLSL, compiled to SPIR-V with glslang.
New in the examples of 0.2.0.
3_ui: a name field to type and select in, a note that wraps, a number field, a tooltip, tabs, a tree and a sortable table. Tab moves between the controls.button_cshows the same controls in C, with ui's macros.5_services:counter.watchkeeps a function and calls it at each change, so both tally panels show the total in their titles.7_events: an event carries a panel's handle and bytes, and a handle has a method of its own.8_state: closing a panel with unsaved work asks in OpenECS's own dialog.10_text_input: a key that an input method repeats types once for each press.13_terminal: bold, underlined and wide characters, and Ctrl with + or - changes the font size; the lines wrap again at each size.14_media: a frame with rounded corners, a picture that turns, fades and is written to a PNG file, an animated GIF, a streamed tune, a tone made in Lua and panned, and a low-pass filter, an echo and a reverb.15_network: a TLS server with a certificate made for the example, and a client that trusts it.16_model: a texture from inside a.glb, a badge that its animation turns and moves, and a skinned arm that bends.17_files: the list follows the folder's changes withfs.watch.19_first_party, which was18_first_party: the launcher opens in the tool itself, with Alt+W, then/.
What will break
18_first_partyis now19_first_party, so the examples of the standard plugins stay together.
Downloads
openecs-examples-0.3.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as README.md says.SHA256SUMS: the checksum of the archive.
The examples are under the zlib license.
OpenECS-examples 0.2.0
This is the first release of OpenECS-examples, the examples for writing OpenECS plugins. It comes out with OpenECS 0.2.0, which ships these examples, built, in its examples/ folder, and OpenECS-std 0.2.0, whose plugins the later examples use.
Read the examples in the order of their numbers. Each explains the parts it is the first to use, and each has a test that shows what it does. Run one from OpenECS's folder:
./OpenECS --fresh --preset examples/1_hello/preset.luaWhat you can learn
OpenECS, from 1 to 12.
1_hello: a Lua plugin with a panel, and when OpenECS calls its functions.2_native: the same panel as a native plugin in C.3_ui: a button that counts clicks, and ui's other controls: a toggle, a switch, a slider, a selector, a dropdown and a list, and how drawing on demand works.4_settings: settings of each type, and the three layers they come from.5_services: a plugin in C that offers functions, and panels in Lua that call them withrequire.6_keys: key bindings for a plugin and for one panel type.7_events: events between plugins, and timers.8_state: a panel's and a plugin's saved state.9_drag_drop: dragging data between panels, and files from other programs.10_text_input: typed text, with input methods.11_popups: a menu drawn next to a panel.12_sketch: a whole drawing tool, twice, in C and in Lua, and resetting its layout.
The standard plugins, from 13.
13_terminal: a terminal with a few commands, on textgrid.14_media: a picture that plays a sound when it is clicked: image and audio read the files, and draw and mixer use them.15_network: a server and a client that send each other lines, with net, over TCP and over UDP.16_model: a glTF model that turns, read with gltf and drawn as lines with draw.17_files: a file browser, with fs, ui and Lua'sio.18_first_party: a tool with the settings window, the panel list and the launcher, and its themes.
Downloads
openecs-examples-0.2.0-source.tar.gz: the examples' source. Build them inside a checkout of OpenECS, as README.md says.SHA256SUMS: the checksum of the archive.
The examples are under the zlib license.