Obsolete versions. Use bindbc-raylib3.
This project provides both static (WIP) and dynamic bindings to the raylib a simple and easy-to-use library to enjoy videogames programming and raygui a simple and easy-to-use immediate-mode-gui library. See Wiki for more information.
bindbc-raylib is being semantically versioned. Roughly described, major version changes will always represent backwards incompatible changes, minor version changes will always represent new features and will be backwards compatible, and patch ('tiny') version changes will always be bug fixes.
You can just compile raylib or also include support for raygui.
Add the package as a dependency in your dub.json
or dub.sdl
package description:
dub.json
"dependencies": {
"bindbc-raylib": "~>0.1.0"
}
dub.sdl
dependency "bindbc-raylib" version="~>0.1.0"
In order to use raylib version 3.0.0:
dub.json
"versions": [ "RAYLIB_300" ],
dub.sdl
versions "RAYLIB_300"
The loadRaylib
function is used to load all supported raylib functions.
The return value of loadRaylib
can be used to determine which version of raylib actually loaded.
import bindbc.raylib;
import loader = bindbc.loader.sharedlib;
void main(string[] args) {
RaylibSupport retVal = loadRaylib();
// raylibSupport is an enum with current raylib version
if (retVal != raylibSupport) {
// error
} else {
// successful
}
}
You can find original raylib examples ported to D inside examples directory.
A simple example:
import std.stdio;
import bindbc.raylib;
void main(string[] args) {
RaylibSupport retVal = loadRaylib();
if (retVal != raylibSupport) {
writeln("ERROR: ", retVal);
} else {
writeln("VERSION: ", retVal);
writeln("loaded : ", loadedRaylibVersion);
enum SCREEN_WIDTH = 800;
enum SCREEN_HEIGHT = 450;
// Initialization
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - basic window");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
// Main game loop
while (!WindowShouldClose()) {
// Draw
BeginDrawing();
ClearBackground(GOLD);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
}
}