bindbc-raylib3 0.4.0
Dynamic and static bindings to Raylib, compatible with -betterC, @nogc, and nothrow.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
bindbc-raylib3
This project provides both static and dynamic bindings to the raylib a simple and easy-to-use library to enjoy videogames programming.
Versioning
bindbc-raylib3 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.
Compile raylib source code
See raylib wiki and bindbc wiki
Usage
By default, bindbc-raylib3
is configured to compile as a dynamic binding that is not -betterC
compatible.
The dynamic binding has no link-time dependency on the raylib library, so the raylib shared library must be manually loaded at run time.
To use raylib, add bindbc-raylib3
as a dependency to your project's package config file. For example, the following is configured to compile raylib as a dynamic binding that is not -betterC
compatible:
dub.json
dependencies {
"bindbc-raylib3": "~>0.1.0",
}
dub.sdl
dependency "bindbc-raylib3" version="~>0.1.0"
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
}
}
For static binding see wiki
Raylib version
Following are the supported versions of raylib, the corresponding version IDs to pass to the compiler, and the corresponding RaylibSupport
members.
Raylib version | Version ID | RaylibSupport Member |
---|---|---|
4.0.0 | Raylib_400 (Default) | RaylibSupport.raylib400 |
3.7.0 | Raylib_370 | RaylibSupport.raylib370 |
For bind-raylib3 version see wiki
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();
}
}
Dependencies
- 0.4.0 released 3 years ago
- o3o/bindbc-raylib3
- Boost
- Authors:
- Dependencies:
- none
- Versions:
-
5.0.1 2023-Dec-24 5.0.0 2023-Dec-22 4.5.0 2023-Jul-03 2.0.0 2022-Sep-02 1.0.0 2022-May-10 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
1 downloads this month
-
301 downloads total
-
- Score:
- 1.4
- Short URL:
- bindbc-raylib3.dub.pm