Building

Getting Source

git clone https://github.com/bkaradzic/bx.git
git clone https://github.com/bkaradzic/bimg.git
git clone https://github.com/bkaradzic/bgfx.git

Quick Start

These are step for users who use Windows with Visual Studio.

Enter bgfx directory:

cd bgfx

Generate Visual Studio 2017 project files:

..\bx\tools\bin\windows\genie --with-examples vs2017

Open bgfx solution in Visual Studio 2017:

start .build\projects\vs2017\bgfx.sln

Note

For more detailed prerequisites and build steps on other platforms see below.

Prerequisites

Android

Download AndroidNDK:

Set following environment variables:

setx ANDROID_NDK_ROOT <path to AndroidNDK directory>
setx ANDROID_NDK_ARM <path to AndroidNDK directory>\toolchains\arm-linux-androideabi-4.7\prebuilt\windows-x86_64
setx ANDROID_NDK_MIPS <path to AndroidNDK directory>\toolchains\mipsel-linux-android-4.7\prebuilt\windows-x86_64
setx ANDROID_NDK_X86 <path to AndroidNDK directory>\toolchains\x86-4.7\prebuilt\windows-x86_64

To deploy on Android you can use bgfx android activity:

Linux

sudo apt-get install libgl1-mesa-dev x11proto-core-dev libx11-dev

Build

bgfx uses GENie - Project generator tool to generate project files for various platform. Binaries for Linux, OSX, and Windows are included in bx repository.

General

cd bgfx
make

After calling make, .build/projects/* directory will be generated. All intermediate files generated by compiler will be inside .build directory structure. Deleting .build directory at any time is safe.

make <configuration>

Configuration is <platform>-<debug/release>[32/64]. For example:

linux-release64, wasm-debug, wasm-release, osx-debug, osx-release, android-arm64-release, etc.

Windows

Visual Studio 2017 command line:

make vs2017-release64

Visual Studio 2017 IDE:

start .build/projects/vs2017/bgfx.sln

Xcode

Xcode command line:

make osx-release
cd examples/runtime
../../.build/osx64_clang/bin/examples.app/Contents/MacOS/examplesRelease

Xcode IDE:

../bx/tools/bin/darwin/genie --with-combined-examples --xcode=osx xcode9
open .build/projects/xcode9-osx/bgfx.xcworkspace

Due to inability to set working directory for an Xcode project from GENie configuration file, it has to be set manually for each example project:

  1. Open “Edit scheme…” dialog for a given project.

  2. Select “Run” settings.

  3. Check “Use custom working directory” and enter following path: ${PROJECT_DIR}/../../../examples/runtime.

Linux

make linux-release64

WinRT / UWP

..\bx\tools\bin\windows\genie --vs=winstore100 vs2017

Build the resulting solution and deploy to device.

Note

Shaders will need to be compiled with the appropriate target profile for your platform.

Amalgamated Build

For ease of integration to other build system bgfx library can be built with single .cpp file. It’s only necessary to build src/amalgamated.cpp (for OSX/iOS use src/amalgamated.mm instead) inside different build system.

Tools

To build bgfx project files for tools, use --with-tools option:

..\bx\tools\bin\windows\genie --with-tools vs2017

Minimal example without bgfx’s example harness

This project demonstrates minimal amount of code needed to integrate bgfx with GLFW, but without any of existing bgfx example harness. It also demonstrates how to build bgfx with alternative build system.

https://github.com/jpcy/bgfx-minimal-example