This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Windows compiled executable error fix guide #73
Windows compiled executable error fix guide #73
Changes from all commits
4885cdc
27ad955
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
NimraylibNow! - The Ultimate Raylib wrapper for Nim
The most idiomatic and up-to-date wrapper for Raylib gaming C library. Use this library if you want to write games using Raylib in Nim.
This library is an effort to create an automatically generated wrapper which can be easily upgraded to any future version of Raylib. Anyone should be able to upgrade it with some effort and HACKING should be a guide on how to do it. Please file a bug report if any of that is too far from the reality.
Features
Automated generation of the wrapper using the power of (((Nim)))
Idiomatic Nim naming and conventions so you write Nim code, not C
60+ examples converted from C to Nim
Includes modules: raylib, raymath, rlgl, raygui, physac
Supports Windows, Linux, MacOS, Emscripten (see Emscripten example)
Supports static compilation, dynamic linking - you choose
Quickstart
$ nimble install nimraylib_now # wait 10 minutes for download, sorry
Explanation of flags:
-r
- run after compiling-d:release
- for speed, but also cuts away debugging information--gc:orc
- memory management without garbage collection and with better C interoperabilityCurrent version and upgrading from previous versions
NimraylibNow! v0.14 is a wrapper for Raylib v4.0.0 and Raygui v3.0.
See CHANGELOG for any tips on how to upgrade your code from previous versions.
Install NimraylibNow!
Install this library with nimble (takes 6-10(!) minutes because of huge original raylib repository):
Or put it into your
.nimble
file:How to use NimraylibNow!
Import any necessary modules and use it:
See examples for how to use it. You should generally be able to follow any tutorials for official C bindings, just mind the naming. Also see official cheatsheet and directly inspect the binding sources, e.g. for raylib.
Here is a long example to showcase most features (crown.nim).
Naming differences with C
Naming is converted to more Nim conventional style but in a predictable manner. Generally just omit any prefixes you see in official docs and use camelCase for procs, everything else stays the same:
to
Although some definitions may have names like
FULLSCREEN_MODE
, you can still use them (and encouraged to) asFullscreenMode
in code.Raymath
All prefixes specific to types were omitted where possible:
to
Passing values by addresses
BE VERY CAREFUL with values which are passed as addresses, always convert them to approapriate C-compatible types:
Tips and tricks
Tuple to object converters for geometry
Vector2, Vector3, Vector4 (Quaternion), Matrix, Rectangle, Color can be written as a tuple to save on typing as they have pretty much standard parameter sequence:
Require fully qualified procs
For functions operating on global scope it could be convenient to use fully qualified proc name:
which can be enforced by the compiler by importing
rlgl
module like this:Begin-End pairs sugar
There are pairs like
beginDrawing()
-endDrawing()
, each have helping templates to automatically insertend
-proc at the end:is same as
Reserved words
Be careful and use "stropping" when using fields or functions which are also reserved words in Nim:
`end`()
Enums
All enums are marked as
{.pure.}
which means they should be fully qualified when compiler can't guess their type:Raymath infix operators
You can use infix operators like
+
,-
,*
,/
for operations on vectors, matrices and quaternions:Raylib, the original C library
If you would like to know more about how this wrapper uses Raylib library and see all the different options, check USING_RAYLIB, it should help.
Contributing
Do you want to contribute but don't know how? Check out CONTRIBUTING!
How does wrapper work?
If you would like to know how this wrapper works or how to update it, check out HACKING.
Troubleshooting
Freezes on Wayland
Random freezes when everything stops being responsive can be caused by glfw compiled against Wayland library. Try X11 version of glfw.
GLFW is a raylib dependency that was installed by your package manager, you can uninstall raylib with clearing all of its dependencies and install it again choosing X11 version of glfw.
Windows error: The application was unable to start correctly (0x00000007b)
Or similar errors which point to missing
libwinpthread-1.dll
file mean that you do not have path set correctly and MinGW can't find correct library files.Make sure to include MinGW's bin folder in your PATH. The path to MinGW's bin folder looks something like this by default:
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
.Based on this answer in stack-overflow you can do the following to fix the problem:
pacman -S base-devel mingw-w64-x86_64-toolchain
to install the GCC toolchain (all components)c:\msys64\mingw64\bin
to the System PATHCommunity
Find us at
#raylib-nim
channel in the official Raylib discord server.Thanks
Many thanks to V.A. Guevara for the efforts on Raylib-Forever library which was the initial inspiration for this library.
Thanks to everyone who contributed to this project!
License
MIT licensed, see LICENSE.md.