Skip to content
Martín Dias edited this page Nov 14, 2025 · 14 revisions

Welcome to the pharo-sdl-experiments wiki.

This repository has a collection of experiments around "layer composition" in Pharo FFI bindings to SDL2 library. The 'SDLExperiments-FFI' package contains improvements to regular Pharo 11's SDL2 bindings.

History

As a reference, members of "lse-openbloc" mailing-list can read "Tests with SDL2 atlas" thread (beginning of 2023), as well as "Drag and drop between OS windows" thread. Some videos from those threads:

Running

First, you should use the README's snippet to load the code in a fresh Pharo image. Then follow next subsections.

Demos with benchmarks

Browse subclasses of BenchmarkingDemo and evaluate scripts in both instance- and class-side. Open Transcript to check printed benchmark outputs.

Demos with focus on interaction

In a bash-like command-line, do any of:

SceneDragAndDropDemo: ./pharo Pharo.image eval --no-quit "SceneDragAndDropDemo new open" and draw with your mouse cursor the square from a window to another. They key of this demo is doing a proof-of-concept of custom cursors in a drag&drop scenario between OS windows, multi-platform.

DragDropCursorsDemo

SceneResizingDemo: ./pharo Pharo.image eval --no-quit "SceneResizingDemo new open" and drag the window border.

WinFixed

ScenePositionDemo: ./pharo Pharo.image eval --no-quit "ScenePositionDemo new open" and use the arrow keys and mouse wheel to move the square with sub-pixel precision. There are extra options to start the window with a non-default SDL2 backend, to see variations in your system. The key of this demo is doing a proof-of-concept of how do look of SDL_Textures on sub-pixel copy (it can look bad).

PositionDemo

You can use control+q to quit the process.

Headless benchmark

Evaluate SDL2TextureUpdateBench run and watch output in terminal. Alternatively you can do it headless, from terminal: ./pharo Pharo.image eval "SDL2TextureUpdateBench run".

The output consists of a table with rows such as this:

opengl      STREAM  512.00 MB  4096@4096    sum:  5.85  4.88 32.59    pre:  0.02  0.01  0.06    cairo:  5.82  4.86 32.57    update:  0.01  0.00  0.04

Where:

  • STREAM indicates that the SDL_Texture was created with as a SDL2 STREAMING texture (it could be STATIC, too)
  • sum: 5.85 4.88 32.59 corresponds to average, min and max number of milliseconds measured to update a SDL_Texture with the specified size. The mentioned sum is broken down by the next grouped values (pre, cairo and update are the 3 steps to update the texture).

Tip: Follow the instructions in this wiki page to create a vm with other libraries.

Clone this wiki locally