raylibAPL is a library made to write cross-platform graphical applications using the Dyalog APL programming language.
- Supports platforms Windows and Linux.
- Input-methods: Keyboard, Mouse, Controler and Touchscreen.
- Graphics: 2D, 3D, Sound, Text, Vector graphics, Images/Textures and shaders.
- Multiple Fonts formats supported (TTF, OTF, Image fonts, AngelCode fonts).
- Multiple texture formats supported, including compressed formats (DXT, ETC, ASTC).
- Full 3D support, including 3D Shapes, Models, Billboards, Heightmaps and more!
- Flexible Materials system, supporting classic maps and PBR maps.
- Animated 3D models supported (skeletal bones animation) (IQM, M3D, glTF).
- Shaders support, including model shaders and postprocessing shaders.
- Powerful math module for Vector, Matrix and Quaternion operations: raymath.
- Audio loading and playing with streaming support (WAV, QOA, OGG, MP3, FLAC, XM, MOD).
- VR stereo rendering support with configurable HMD device parameters.
Breaking changes to any feature in raylibAPL should be expected for now, as this library is very young and experimental. If you experience code 999, there was likely a "segfault"/error in raylibAPL, and so a bug report would be appreciated.
Currently raylibAPL provides 4 different libraries; raylib, raygui, physac, and rlgl. Currently only raylib is stable, due to a lack of testing for the other 3.
There are two ways to get started, with Tatin and without. Easiest is using Tatin, though it's less consistent in Dyalog 19.0.
Run the following to install temp-c-raylib into the raylibAPL/lib/ folder.
dyalogscript install-raylib.aplsInstead of running the above, you can manually download temp-c-raylib from it's releases page and move the binary into raylibAPL/lib/.
To import raylibAPL as a namespace, take the code below and replace ../ with the path to raylibAPL:
rlDir ← '../raylibAPL/link/',⍨⊃1⎕NPARTS''
rl ← 0⎕Fix rlDir,'raylib.apln'
rl.Init rlDirWhen making a script file like the raylibAPL's examples, I would recommend the .apls file extension and adding this line at the top of the script #!cd $dir && /usr/bin/dyalogscript $fileName. When running .apls files, remember to always be in their directory.
Tatin is a package manager for Dyalog APL.
-
Install Tatin (if not already installed):
]Activate tatin
-
Install raylibAPL:
]Tatin.InstallPackages raylibAPL
-
Use in your code:
rl ← raylibAPL.raylib rl.Init raylibAPL.TatinVars.HOME,'/link'
You may ]Link to the raylibAPL/link folder.
This imports raylib.apln, rlgl.apln, and raymath.apln, each of which are from raylib. A 2d physics library called physac is also included as physac.apln, and a GUI library called raygui as raygui.apln.
Example using raylibAPL with ]link is shown below:
]cd /home/brian/Persinal/Scripts/APL/raylibAPL/link
]link.create # .
raylib.Init ''
raylib.InitWindow 800 800 'Hello!!!'
:While ~raylib.WindowShouldClose⍬
raylib.BeginDrawing⍬
raylib.ClearBackground raylib.color.gray
raylib.EndDrawing⍬
:EndWhile
raylib.CloseWindow⍬Tatin is a package manager for Dyalog APL.
-
Install Tatin (if not already installed):
]Activate tatin
-
Install raylibAPL:
]Tatin.InstallPackages raylibAPL
-
Use in your code:
rl ← raylibAPL.raylib rl.Init raylibAPL.TatinVars.HOME,'/link'
Developing an application with raylibAPL is very low level. The entirety of raylibAPL is about 200 functions that take in a list of inputs and returns some outputs, and/or change the state of the application. An example of changing the state of the application is the following:
raylib.InitWindow 400 400 'Title'This function opens a new window, with width=400, height=400, and window title being "Title". This changes the state of the computer screen of course, but it also changes something very important, it creates a kind of scope.
# Begin scope where window is open
raylib.InitWindow 400 400 'Title'
# Inside this scope, I am allowed to use a lot more functions.
# End scope where window is open, meaning closing window
raylib.CloseWindowInside this scope, you are allowed a lot more. You can use functions like SetWindowIcon, GetScreenWidth, GetMonitorCount, LoadShader, GetMouseRay, and many more.
There are other functions that start and end scopes, like StartDrawing and EndDrawing. StartDrawing and EndDrawing require the InitWindow scope. Inside the StartDrawing scope you can use functions like ClearBackground, which sets the background of the window to a given color. An important note about EndDrawing is that it automatically delays to whatever frame-rate you choose, which by default is your monitor refresh rate. As an example, if your monitor has a refresh rate of 60 frames per second, EndDrawing will delay a maximum of ÷60. I say "maximum", because EndDrawing delays just enough to keep your :while loop running 60 times a second, so if your loop takes ÷60 seconds to run, EndDrawing wouldn't delay.
Applications made with raylibAPL have a common structure and style. As you can see by the below example, there's a :while loop used that draws the frame using BeginDrawing, where the frame being drawn is gray because of ClearBackground . This example is intentionally very simple, simply drawing a window with a black background.
rl.InitWindow 800 800 'abc' # Begin InitWindow scope
:While ~rl.WindowShouldClose⍬ # Run this loop per frame
rl.BeginDrawing⍬ # Begin a drawing scope to draw the current frame
rl.ClearBackground⍬ rl.color.gray # Set background to gray
rl.EndDrawing⍬ # End the Drawing scope
:EndWhile
rl.CloseWindow⍬ # End InitWindow scopeTo get a good start into raylibAPL, mess around with the examples and see what you can make!
For a proper list of functions and namespaces found in raylibAPL, consider having a look into what the raylib.apln file defines. Note that the function definitions there aren't final, so drop the RAYLIB suffix to use the proper function. An example is the value raylib.KeyboardKey.KEY_SLASH can be given as argument to raylib.IsKeyPressed to check if the slash key is pressed.
All raylibAPL examples support using dyalogscript, by having the following on the top of every example:
#!cd $dir && /usr/bin/dyalogscript $fileName
The auto-parsing isn't needed since the parser output is premade, though if you still need to parse, install CBQN to run bqn raylibAPL/parse-raylibAPL/parseAll.bqn.
raylibAPL has been financially supported by Dyalog Limited. Brian was hired as an intern by Dyalog Limited at about 7th of July 2024 to develop raylibAPL, alongside Asher. Brian has continued being funded for the development. The Dyalog team have helped a lot with the development of this library.
raylibAPL relies on the raylib C library. Lots of thanks to raysan5 and the raylib community for this great library.
The current version of raylibAPL has parsing that relies on json.bqn made by Marshall Lochbaum.bqn. Also the BQN programming language in general!