Rayex provides Elixir NIF bindings to Raylib
WIP: many of the functions on raylib are yet not implemented, check the contributing section to help
You need the following packages installed on your system:
- elixir (1.16)
- erlang (compat with elixir 1.16)
Steps to run:
- Add this project to your mix dependencies.
- Ensure that the project's git submodules are cloned; this means that Raylib should exist at the location (RayexRoot)/src/raylib.
- In (RayexRoot) in your deps folder (or if you've forked, just project root), you can run
make
. - If you have issues with the makefile, you simply need to run
make
inraylib/src/
with the build target ofPLATFORM=PLATFORM_DESKTOP
. Somake PLATFORM=PLATFORM_DESKTOP
within the Raylib folder. This will spit out alibraylib.a
file.libraylib.a
must exist within./c_src/rayex/lib/
, otherwise you'll get linker errors.raylib.h
must exist within./c_src/rayex/include
or you'll probably also get linker errors.
Once you have run the makefile which compiles raylib and copies the requirements libraylib.a
and raylib.h
to their respective folders under c_src/rayex/
, you can test to see if things are working.
Run mix run ./examples/test.exs
and if God is kind, they'll show a little test scene with a few GUI components. Be sure to look at the test.exs file for a code example of what the state of the project currently is.
A lot of the code that requires lists in lists is borked due to iterator redefinition; most if not all of this project will have to be rewritten once THIS is patched: membraneframework/membrane_core#719.
In the meantime, in mix.exs
, you can see that I have a fork of Unifex that fixes the issue in a pretty hacky way. It's a short term solution, so until Unifex patches it on main I'll be holding off making insane changes to the codebase. Thank you for understanding, I love you.
There are a few things that you need to know about the code:
- This project aims to run each one of those functions with elixir
- To do so, we are using Unifex to create NIFs
- On
c_src/rayex/rayex.spec.exs
you can find the definitions that will be generated by Unifex - On
c_src/rayex/rayex.cpp
you can find how they are implemented - On
c_src/rayex/rayex.h
andlib/unifex/code_generator/base_types/...
you can find custom types - On
lib/rayex/unifex/raylib.ex
is where the generated functions will be stored and used for each module underlib/rayex
, the public API
Any contributions are appreciated
Copyright 2021 Shiryel
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.