Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GoaLitiuM/bindbc-bgfx
Dynamic and static D bindings for bgfx
https://github.com/GoaLitiuM/bindbc-bgfx
Last synced: about 1 hour ago
JSON representation
Dynamic and static D bindings for bgfx
- Host: GitHub
- URL: https://github.com/GoaLitiuM/bindbc-bgfx
- Owner: GoaLitiuM
- License: bsl-1.0
- Created: 2019-09-29T04:21:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-17T14:51:48.000Z (almost 2 years ago)
- Last Synced: 2024-08-04T01:04:58.970Z (4 months ago)
- Language: D
- Size: 86.9 KB
- Stars: 21
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-d - bindbc-bgfx
README
# bindbc-bgfx
Dynamic and static D bindings for [bgfx](https://github.com/bkaradzic/bgfx).These bindings target bgfx API version **115** (commit [d95a643603e5b1dbe847d622ffb5860765ee7f62](https://github.com/bkaradzic/bgfx/tree/d95a643603e5b1dbe847d622ffb5860765ee7f62)).
## Usage (DUB)
To install this library with DUB, simply run the following command:
```
dub add bindbc-bgfx
```The library is configured to `dynamic` configuration by default, and should work out of box if you have the dynamic library installed properly (e.g. on Windows, the .DLL files are accessible by the application).
## Static bindings
For static linking, `static` configuration must be enabled:
__dub.json__
```
"subConfigurations": {
"bindbc-bgfx": "static"
},"libs": [
"bgfxRelease", "bxRelease", "bimgRelease"
]
```Make sure to link against all the necessary system libraries needed by bgfx, and setup the library paths for linker:
```
"libs-windows": [
"User32", "Gdi32"
],
"lflags-windows": [
"/LIBPATH:example\\path\\to\\bgfx\\.build\\win64_vs2019\\bin\\"
],"libs-linux": [
"stdc++", "GL", "X11"
],
"lflags-linux": [
"-L/example/path/to/bgfx/bgfx/.build/linux64_gcc/bin"
]
```The bindings also support `-betterC`, which can be enabled with `staticBC` and `dynamicBC` configurations.
## Usage
```d
import bindbc.bgfx;loadBgfx(); // required with dynamically linked bgfx
bgfx_init_t init;
bgfx_init_ctor(&init);bgfx_init(&init);
bgfx_reset(1280, 720, BGFX_RESET_NONE, init.resolution.format);bgfx_shutdown();
unloadBgfx(); // optional, only needed with dynamically linked bgfx
```This is a very simple sample of how to use these bindings with bgfx. The sample code does not render or output anything but merely demonstrates how the bindings are initialized for proper use. To setup a window, libraries like SDL2 are often used with bgfx to provide the window for bgfx to use with rendering. Please see [this C++ example](https://github.com/bkaradzic/bgfx/blob/master/examples/common/entry/entry_sdl.cpp#L75) on how to setup bgfx with SDL2.
If you need more in-depth tutorial of how to use bgfx, please see the [bgfx examples here.](https://bkaradzic.github.io/bgfx/examples.html)
## Generating bindings
The main bgfx repository already contains the latest generated binding definitions for D, so these files can be copied from `bgfx/bindings/d/` over the files in `bindbc-bgfx/source/bindbc/bgfx` when pairing these bindings with custom versions of bgfx. If you need to regenerate the bindings, you can run `genie idl` in bgfx project folder, and copy the regenerated files to previously mentioned location.