Skip to content
forked from shiryel/rayex

Raylib binds to elixir for games programming

License

Notifications You must be signed in to change notification settings

FatigueDev/rayex

 
 

Repository files navigation

Rayex

Hex.pm API Docs Run Tests

OG creator twitter: Twitter

Rayex provides Elixir NIF bindings to Raylib

WIP: many of the functions on raylib are yet not implemented, check the contributing section to help

Running from source

You need the following packages installed on your system:

  • elixir (1.16)
  • erlang (compat with elixir 1.16)

Steps to run:

  1. Add this project to your mix dependencies.
  2. Ensure that the project's git submodules are cloned; this means that Raylib should exist at the location (RayexRoot)/src/raylib.
  3. In (RayexRoot) in your deps folder (or if you've forked, just project root), you can run make.
  4. If you have issues with the makefile, you simply need to run make in raylib/src/ with the build target of PLATFORM=PLATFORM_DESKTOP. So make PLATFORM=PLATFORM_DESKTOP within the Raylib folder. This will spit out a libraylib.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.

! Stuff that is busted !

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.

Contributing

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 and lib/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 under lib/rayex, the public API

Any contributions are appreciated

License

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.

About

Raylib binds to elixir for games programming

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.0%
  • Elixir 2.0%
  • Other 1.0%