bindbc-raylib
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.
Compile raylib source code
You can just compile raylib or also include support for raygui.
Usage
bindbc-raylib
to your project
Add 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"
Set raylib versions
In order to use raylib version 3.0.0:
dub.json
"versions": [ "RAYLIB_300" ],
dub.sdl
versions "RAYLIB_300"
Loading raylib
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
}
}
Examples
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();
}
}