Coder Social home page Coder Social logo

bindbc-raylib3's Introduction

bindbc-raylib3

This project provides both static and dynamic bindings to the raylib a simple and easy-to-use library to enjoy videogames programming.

See wiki and API.

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:

dub.json

dependencies {
    "bindbc-raylib3": "~>0.1.0",
}

dub.sdl

dependency "bindbc-raylib3" version="~>0.1.0"

For static binding:

dub.sdl

dependency "bindbc-raylib3" version="~>0.1.0"
subConfiguration "bindbc-raylib3" "static"

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 bindbc-raylib3 versions, the supported versions of raylib and the corresponding RaylibSupport members.

Raylib version RaylibSupport Member bindbc-raylib3 version
4.2.0 RaylibSupport.raylib420 2.0.0
4.0.0 RaylibSupport.raylib400 1.0.0
3.7.0 RaylibSupport.raylib370 0.3.0

For bind-raylib3 version see wiki.

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.

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

bindbc-raylib3's People

Contributors

o3o avatar webfreak001 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.