Skip to content

GoaLitiuM/bindbc-bgfx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bindbc-bgfx

Dynamic and static D bindings for bgfx.

These bindings target bgfx API version 115 (commit 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

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 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.

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.

About

Dynamic and static D bindings for bgfx

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages