Examples

Most of the examples require shader/texture/mesh data to be loaded. When running examples your current directory should be examples/runtime.

<bgfx_path>/examples/runtime $ ../../.build/<config>/bin/example-00-helloworldDebug

00-helloworld

Initialization and debug text.

example-00-helloworld

01-cubes

Rendering simple static mesh.

example-01-cubes

02-metaballs

Rendering with transient buffers and embedding shaders.

Downloading...

03-raymarch

Updating shader uniforms.

example-03-raymarch

04-mesh

Loading meshes.

example-04-mesh

05-instancing

Geometry instancing.

example-05-instancing

06-bump

Loading textures.

example-06-bump

07-callback

Implementing application specific callbacks for taking screen shots, caching OpenGL binary shaders, and video capture.

08-update

Updating textures.

09-hdr

Using multiple views with frame buffers, and view order remapping.

example-09-hdr

10-font

Use the font system to display text and styled text.

example-10-font

11-fontsdf

Use a single distance field font to render text of various size.

example-11-fontsdf

12-lod

Mesh LOD transitions.

example-12-lod

13-stencil

Stencil reflections and shadows.

example-13-stencil

14-shadowvolumes

Shadow volumes.

example-14-shadowvolumes

17-drawstress

60Hz

Draw stress is CPU stress test to show what is the maximimum number of draw calls while maintaining 60Hz frame rate. bgfx currently has default limit of 64K draw calls per frame. You can increase this limit by changing BGFX_CONFIG_MAX_DRAW_CALLS.

CPU

Renderer

GPU

Arch/Compiler/OS

Dim

Calls

i7-4770K 4.2

GL2.1

2xGTX780

x64/VS2013/Win 8.1

51

132651

i7-4770K 4.2

DX11

2xGTX780

x64/VS2013/Win 8.1

50

125000

i7-4790K 4.0

GL2.1

GTX970

x64/VS2015/Win 10

47

103823

i7-4790K 4.0

DX11

GTX970

x64/VS2015/Win 10

45

91125

i7-4790K 4.0

DX9

GTX970

x64/VS2013/Win 10

40

64000

i5-3570 3.8

NV 331.49

GTX560Ti

x64/GCC/Linux

40

64000+

i7-920 2.66

GL2.1

GTX650Ti

x64/VS2008/Win 7

38

54872

i7-920 2.66

GL2.1

GTX650Ti

x86/VS2008/Win 7

38

54872

i7-6700K 4.0

GL2.1

Skylake GT2

x64/GCC/Win 10

38

54872

i7-4790K 4.0

DX11

R7 240

x64/VS2015/Win 10

36

46656

i7-920 2.66

NV 331.113

GTX650Ti

x64/GCC/Linux

34

39304

i7-6700K 4.0

DX11

Skylake GT2

x64/GCC/Win 10

34

39304

i7-4790K 4.0

DX9

R7 240

x64/VS2015/Win 10

32

32768

i7-920 2.66

DX9

GTX650Ti

x64/GCC/Win 7

32

32768

i7-920 2.66

DX9

GTX650Ti

x64/VS2008/Win 7

32

32768

i7-920 2.66

DX9

GTX650Ti

x86/GCC/Win 7

30

27000

i7-920 2.66

DX9

GTX650Ti

x86/VS2008/Win 7

30

27000

i5-6200U 2.3

DX11

Intel 520

x64/GCC/Win 10

30

27000

i5-4250U 1.3

GL2.1

HD5000

x64/Clang/OSX 10.9

28

21852

Q8200 2.33

NV 319.32

GTX260

x64/GCC/Linux

27

19683

i7-6700K 4.0

GL2.1

Skylake GT2

x64/GCC/Linux

27

19683

i7-2600K 3.4

DX9

AMD6800

x64/VS2012/Win 7

27

19683

i7-2600K 3.4

GL2.1

AMD6800

x64/VS2012/Win 7

26

17576

i7-4770R 3.2

Mesa 10.5.9

HD5200

x64/GCC/Linux

26

17576

i5-6200U 2.3

GL

Intel 520

x64/GCC/Win 10

26

17576

i7-920 2.66

DX9-Wine

GTX650Ti

x64/GCC/Linux

24

13824

i5-6200U 2.3

Mesa 10.5.9

Intel 520

x64/GCC/Linux

23

12167

i7-4750HQ 2.0

Mesa 10.0.1

HD5200

x64/GCC/Linux

22

10648

i7-4750HQ 2.0

Mesa 10.1.3

HD5200

x64/GCC/Linux

21

9261

i7-920 2.66

ES2-ANGLE

GTX650Ti

x86/VS2008/Win 7

21

9261

Q8200 2.33

Gallium 0.4

AMD5770

x64/GCC/Linux

21

9261

i5-4250U 1.3

ES2

HD5000

JIT/Clang/PNaCl 31

21

9261

i5-4250U 1.3

ES2

HD5000

x86/GCC/NaCl 31

20

8000

Q8200 2.33

Gallium 0.4

GTX260

x64/GCC/Linux

19

6859

i5-2450M 2.5

Mesa 10.2.0

HD3000

x64/GCC/Linux

19

6859

i7-920 2.66

ES2-PowerVR

GTX650Ti

x86/VS2008/Win 7

18

5832

i7-920 2.66

FF27-GL

GTX650Ti

JIT/Clang/W7-asm.js

17

4913

i7-6700K 4.0

DX9

Skylake GT2

x64/GCC/Win 10

16

4096

i7-4750HQ 2.0

Mesa 8.0.5

LLVMPIPE

x64/GCC/Linux

16

4096

i5-6200U 2.3

DX9

Intel 520

x64/GCC/Win 10

16

4096

i7-920 2.66

ES2-Qualcomm

GTX650Ti

x86/VS2008/Win 7

15

3375

i7-920 2.66

ES2

GTX650Ti

x64/GCC/NaCl 31

15

3375

i7-920 2.66

ES2

GTX650Ti

JIT/Clang/PNaCl 31

15

3375

Q8200 2.33

NV 319.32

GTX260

x64/GCC/NaCl 31

15

3375

Q8200 2.33

NV 319.32

GTX260

x64/GCC/PNaCl 31

15

3375

‘12 Nexus 7

ES2

Tegra3

ARM/GCC/Android

15

3375

i5-4250U 1.3

ES2-FF27

HD5000

JIT/Clang/OSX-asm.js

15

3375

i5-4250U 1.3

Chrome33

HD5000

JIT/Clang/OSX-asm.js

15

3375

iPad mini 2

ES2

PVR G6430

ARM64/Clang/iOS7

15

3375

i7-920 2.66

Chrome33

GTX650Ti

JIT/Clang/W7-asm.js

14

2744

i7-920 2.66

FF27-ANGLE

GTX650Ti

JIT/Clang/W7-asm.js

14

2744

‘13 Nexus 10

ES2

Mali T604

ARM/GCC/Android

13

2197

iPhone 5

ES2

PVR SGX543

ARM/Clang/iOS7

13

2197

‘13 Nexus 7

ES2

S4 Pro

ARM/GCC/Android

12

1728

iPad 2

ES2

PVR SGX543

ARM/Clang/iOS6

12

1728

AMD A4-5000

Gallium 0.4

HD8330/Kabini

x64/GCC/Linux

12

1728

Xperia Z

ES2

Adreno320

ARM/GCC/Android

11

1331

iPod 4

ES2

PVR SGX535

ARM/Clang/iOS6

7

343

i7-920 2.66

ES2-Mali

GTX650Ti

x86/VS2008/Windows7

6

216

Creator CI20

ES2

PVR SGX540

MIPS/GCC/Debian8

7

343

i5-6200U 2.3

ES2

SwiftShader

x64/GCC/Linux

6

216

RaspberryPi

ES2

VC IV

ARM/GCC/Raspbian

6

216

To test browsers in 60Hz mode following changes were made:

  • Firefox 27 about:config adjustments: webgl.prefer-native-gl true (on Windows), and layout.frame_rate 500.

  • Chrome 33 command line option: --disable-gpu-vsync.

30Hz (test for browsers)

By default browsers are using vsync, and don’t have option to turn it off programatically.

CPU

Renderer

GPU

Arch/Compiler/OS

Dim

Calls

i7-920 2.66

GL2.1

GTX650Ti

x64/VS2008/Win7

38

64000+

i5-4250U 1.3

GL2.1

HD5000

x64/Clang/OSX 10.9

36

46656

i5-4250U 1.3

Chrome34

HD5000

JIT/Clang/OSX-PNaCl 31

28

21952

i5-4250U 1.3

Chrome33

HD5000

JIT/Clang/OSX-PNaCl 31

27

19683

i5-4250U 1.3

FF28

HD5000

JIT/Clang/OSX-asm.js

25

15625

i5-4250U 1.3

FF36

HD5000

JIT/Clang/OSX-asm.js

25

15625

i5-4250U 1.3

Chrome41

HD5000

x64/GCC/OSX-NaCl 41

24

13824

i5-4250U 1.3

FF37

HD5000

JIT/Clang/OSX-asm.js

23

12167

i5-4250U 1.3

FF27

HD5000

JIT/Clang/OSX-asm.js

20

8000

i7-920 2.66

Chrome33

GTX650Ti

JIT/Clang/W7-PNaCl 31

20

8000

i7-920 2.66

Chrome34

GTX650Ti

JIT/Clang/W7-asm.js

18

5832

i7-920 2.66

Chrome33

GTX650Ti

JIT/Clang/W7-asm.js

18

5832

i7-920 2.66

FF28

GTX650Ti

JIT/Clang/W7-asm.js

18

5832

i7-920 2.66

FF27

GTX650Ti

JIT/Clang/W7-asm.js

18

5832

i5-4250U 1.3

Safari7

HD5000

JIT/Clang/OSX-asm.js

15

3375

18-ibl

Image-based lighting.

example-18-ibl

19-oit

Weighted, Blended Order-Independent Transparency

example-19-oit

20-nanovg

NanoVG is small antialiased vector graphics rendering library.

example-20-nanovg

21-deferred

MRT rendering and deferred shading.

example-21-deferred

22-windows

Rendering into multiple windows.

23-vectordisplay

Rendering lines as oldschool vectors.

example-23-vectordisplay

24-nbody

N-body simulation with compute shaders using buffers.

example-24-nbody

25-c99

Initialization and debug text with C99 API.

26-occlusion

Using occlusion query for conditional rendering.

example-26-occlusion

27-terrain

Terrain painting example.

example-27-terrain

28-wireframe

Drawing wireframe mesh.

example-28-wireframe

29-debugdraw

Debug draw.

example-29-debugdraw

30-picking

Mouse picking via GPU readback.

example-30-picking

31-rsm

Global Illumination with Reflective Shadow Map.

example-31-rsm

32-particles

Particles.

example-32-particles

33-pom

Parallax occlusion mapping.

Reference(s):
example-33-pom

34-mvs

Multiple vertex streams.

example-34-mvs

35-dynamic

Dynamic buffers update.

example-35-dynamic

36-sky

Perez dynamic sky model.

example-36-sky

39-assao

Adaptive Screen Space Ambient Occlusion.

Reference(s):
example-39-assao

40-svt

Sparse Virtual Textures.

example-40-svt

44-sss

Screen-Space Shadows

example-44-sss

45-bokeh

Bokeh Depth of Field

Reference(s):
example-45-bokeh