Skip to content

A configurable dynamic and static D binding to the raylib (and raygui) library

License

Notifications You must be signed in to change notification settings

o3o/bindbc-raylib

Repository files navigation

bindbc-raylib

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.

Versioning

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.

Compile raylib source code

You can just compile raylib or also include support for raygui.

Usage

Add bindbc-raylib to your project

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();
   }
}

Dependencies

About

A configurable dynamic and static D binding to the raylib (and raygui) library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published