examples.rst 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. Examples
  2. ========
  3. Most of the examples require shader/texture/mesh data to be loaded. When
  4. running examples your current directory should be examples/runtime.
  5. ::
  6. <bgfx_path>/examples/runtime $ ../../.build/<config>/bin/example-00-helloworldDebug
  7. `00-helloworld <https://github.com/bkaradzic/bgfx/blob/master/examples/00-helloworld>`__
  8. ----------------------------------------------------------------------------------------
  9. Initialization and debug text.
  10. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/00-helloworld/screenshot.png
  11. :alt: example-00-helloworld
  12. `01-cubes <https://github.com/bkaradzic/bgfx/blob/master/examples/01-cubes/cubes.cpp>`__
  13. ----------------------------------------------------------------------------------------
  14. Rendering simple static mesh.
  15. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/01-cubes/screenshot.png
  16. :alt: example-01-cubes
  17. `02-metaballs <https://github.com/bkaradzic/bgfx/blob/master/examples/02-metaballs>`__
  18. --------------------------------------------------------------------------------------
  19. Rendering with transient buffers and embedding shaders.
  20. .. raw:: html
  21. <div class="emscripten">
  22. <progress value="0" max="100" id="progress" hidden=1></progress>
  23. </div>
  24. <div class="spinner" id='spinner'></div>
  25. <div class="emscripten" id="status">Downloading...</div>
  26. <div class="emscripten_border">
  27. <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
  28. </div>
  29. <script type='text/javascript'>
  30. var statusElement = document.getElementById('status');
  31. var progressElement = document.getElementById('progress');
  32. var spinnerElement = document.getElementById('spinner');
  33. var Module = {
  34. preRun: [],
  35. postRun: [],
  36. print: (function() {
  37. var element = document.getElementById('output');
  38. if (element) element.value = ''; // clear browser cache
  39. return function(text) {
  40. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  41. // These replacements are necessary if you render to raw HTML
  42. //text = text.replace(/&/g, "&amp;");
  43. //text = text.replace(/</g, "&lt;");
  44. //text = text.replace(/>/g, "&gt;");
  45. //text = text.replace('\n', '<br>', 'g');
  46. console.log(text);
  47. if (element) {
  48. element.value += text + "\n";
  49. element.scrollTop = element.scrollHeight; // focus on bottom
  50. }
  51. };
  52. })(),
  53. printErr: function(text) {
  54. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  55. if (0) { // XXX disabled for safety typeof dump == 'function') {
  56. dump(text + '\n'); // fast, straight to the real console
  57. } else {
  58. console.error(text);
  59. }
  60. },
  61. canvas: (function() {
  62. var canvas = document.getElementById('canvas');
  63. // As a default initial behavior, pop up an alert when webgl context is lost. To make your
  64. // application robust, you may want to override this behavior before shipping!
  65. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  66. canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
  67. return canvas;
  68. })(),
  69. setStatus: function(text) {
  70. if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
  71. if (text === Module.setStatus.text) return;
  72. var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
  73. var now = Date.now();
  74. if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon
  75. if (m) {
  76. text = m[1];
  77. progressElement.value = parseInt(m[2])*100;
  78. progressElement.max = parseInt(m[4])*100;
  79. progressElement.hidden = false;
  80. spinnerElement.hidden = false;
  81. } else {
  82. progressElement.value = null;
  83. progressElement.max = null;
  84. progressElement.hidden = true;
  85. if (!text) spinnerElement.style.display = 'none';
  86. }
  87. statusElement.innerHTML = text;
  88. },
  89. totalDependencies: 0,
  90. monitorRunDependencies: function(left) {
  91. this.totalDependencies = Math.max(this.totalDependencies, left);
  92. Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
  93. }
  94. };
  95. Module.setStatus('Downloading...');
  96. window.onerror = function(event) {
  97. // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
  98. Module.setStatus('Exception thrown, see JavaScript console');
  99. spinnerElement.style.display = 'none';
  100. Module.setStatus = function(text) {
  101. if (text) Module.printErr('[post-exception status] ' + text);
  102. };
  103. };
  104. </script>
  105. <script async type="text/javascript" src="example-02-metaballsRelease.bc.js"></script>
  106. `03-raymarch <https://github.com/bkaradzic/bgfx/blob/master/examples/03-raymarch>`__
  107. ------------------------------------------------------------------------------------
  108. Updating shader uniforms.
  109. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/03-raymarch/screenshot.png
  110. :alt: example-03-raymarch
  111. `04-mesh <https://github.com/bkaradzic/bgfx/blob/master/examples/04-mesh>`__
  112. ----------------------------------------------------------------------------
  113. Loading meshes.
  114. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/04-mesh/screenshot.png
  115. :alt: example-04-mesh
  116. `05-instancing <https://github.com/bkaradzic/bgfx/blob/master/examples/05-instancing>`__
  117. ----------------------------------------------------------------------------------------
  118. Geometry instancing.
  119. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/05-instancing/screenshot.png
  120. :alt: example-05-instancing
  121. `06-bump <https://github.com/bkaradzic/bgfx/blob/master/examples/06-bump>`__
  122. ----------------------------------------------------------------------------
  123. Loading textures.
  124. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/06-bump/screenshot.png
  125. :alt: example-06-bump
  126. `07-callback <https://github.com/bkaradzic/bgfx/blob/master/examples/07-callback>`__
  127. ------------------------------------------------------------------------------------
  128. Implementing application specific callbacks for taking screen shots,
  129. caching OpenGL binary shaders, and video capture.
  130. `08-update <https://github.com/bkaradzic/bgfx/blob/master/examples/08-update>`__
  131. --------------------------------------------------------------------------------
  132. Updating textures.
  133. `09-hdr <https://github.com/bkaradzic/bgfx/tree/master/examples/09-hdr>`__
  134. --------------------------------------------------------------------------
  135. Using multiple views with frame buffers, and view order remapping.
  136. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/09-hdr/screenshot.png
  137. :alt: example-09-hdr
  138. `10-font <https://github.com/bkaradzic/bgfx/tree/master/examples/10-font>`__
  139. ----------------------------------------------------------------------------
  140. Use the font system to display text and styled text.
  141. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/10-font/screenshot.png
  142. :alt: example-10-font
  143. `11-fontsdf <https://github.com/bkaradzic/bgfx/tree/master/examples/11-fontsdf>`__
  144. ----------------------------------------------------------------------------------
  145. Use a single distance field font to render text of various size.
  146. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/11-fontsdf/screenshot.png
  147. :alt: example-11-fontsdf
  148. `12-lod <https://github.com/bkaradzic/bgfx/tree/master/examples/12-lod>`__
  149. --------------------------------------------------------------------------
  150. Mesh LOD transitions.
  151. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/12-lod/screenshot.png
  152. :alt: example-12-lod
  153. `13-stencil <https://github.com/bkaradzic/bgfx/tree/master/examples/13-stencil>`__
  154. ----------------------------------------------------------------------------------
  155. Stencil reflections and shadows.
  156. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/13-stencil/screenshot.png
  157. :alt: example-13-stencil
  158. `14-shadowvolumes <https://github.com/bkaradzic/bgfx/tree/master/examples/14-shadowvolumes>`__
  159. ----------------------------------------------------------------------------------------------
  160. Shadow volumes.
  161. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/14-shadowvolumes/screenshot.png
  162. :alt: example-14-shadowvolumes
  163. `15-shadowmaps-simple <https://github.com/bkaradzic/bgfx/tree/master/examples/15-shadowmaps-simple>`__
  164. ------------------------------------------------------------------------------------------------------
  165. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/15-shadowmaps-simple/screenshot.png
  166. :alt: example-15-shadowmaps-simple
  167. `16-shadowmaps <https://github.com/bkaradzic/bgfx/tree/master/examples/16-shadowmaps>`__
  168. ----------------------------------------------------------------------------------------
  169. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/16-shadowmaps/screenshot.png
  170. :alt: example-16-shadowmaps
  171. `17-drawstress <https://github.com/bkaradzic/bgfx/blob/master/examples/17-drawstress>`__
  172. ----------------------------------------------------------------------------------------
  173. 60Hz
  174. ^^^^
  175. Draw stress is CPU stress test to show what is the maximum number of
  176. draw calls while maintaining 60Hz frame rate. bgfx currently has default
  177. limit of 64K draw calls per frame. You can increase this limit by
  178. changing ``BGFX_CONFIG_MAX_DRAW_CALLS``.
  179. +-----------------+----------------+--------------+------------------------+-------+----------+
  180. | CPU | Renderer | GPU | Arch/Compiler/OS | Dim | Calls |
  181. +=================+================+==============+========================+=======+==========+
  182. | i7-4770K 4.2 | GL2.1 | 2xGTX780 | x64/VS2013/Win 8.1 | 51 | 132651 |
  183. +-----------------+----------------+--------------+------------------------+-------+----------+
  184. | i7-4770K 4.2 | DX11 | 2xGTX780 | x64/VS2013/Win 8.1 | 50 | 125000 |
  185. +-----------------+----------------+--------------+------------------------+-------+----------+
  186. | i7-4790K 4.0 | GL2.1 | GTX970 | x64/VS2015/Win 10 | 47 | 103823 |
  187. +-----------------+----------------+--------------+------------------------+-------+----------+
  188. | i7-4790K 4.0 | DX11 | GTX970 | x64/VS2015/Win 10 | 45 | 91125 |
  189. +-----------------+----------------+--------------+------------------------+-------+----------+
  190. | i7-4790K 4.0 | DX9 | GTX970 | x64/VS2013/Win 10 | 40 | 64000 |
  191. +-----------------+----------------+--------------+------------------------+-------+----------+
  192. | i5-3570 3.8 | NV 331.49 | GTX560Ti | x64/GCC/Linux | 40 | 64000+ |
  193. +-----------------+----------------+--------------+------------------------+-------+----------+
  194. | i7-920 2.66 | GL2.1 | GTX650Ti | x64/VS2008/Win 7 | 38 | 54872 |
  195. +-----------------+----------------+--------------+------------------------+-------+----------+
  196. | i7-920 2.66 | GL2.1 | GTX650Ti | x86/VS2008/Win 7 | 38 | 54872 |
  197. +-----------------+----------------+--------------+------------------------+-------+----------+
  198. | i7-6700K 4.0 | GL2.1 | Skylake GT2 | x64/GCC/Win 10 | 38 | 54872 |
  199. +-----------------+----------------+--------------+------------------------+-------+----------+
  200. | i7-4790K 4.0 | DX11 | R7 240 | x64/VS2015/Win 10 | 36 | 46656 |
  201. +-----------------+----------------+--------------+------------------------+-------+----------+
  202. | i7-920 2.66 | NV 331.113 | GTX650Ti | x64/GCC/Linux | 34 | 39304 |
  203. +-----------------+----------------+--------------+------------------------+-------+----------+
  204. | i7-6700K 4.0 | DX11 | Skylake GT2 | x64/GCC/Win 10 | 34 | 39304 |
  205. +-----------------+----------------+--------------+------------------------+-------+----------+
  206. | i7-4790K 4.0 | DX9 | R7 240 | x64/VS2015/Win 10 | 32 | 32768 |
  207. +-----------------+----------------+--------------+------------------------+-------+----------+
  208. | i7-920 2.66 | DX9 | GTX650Ti | x64/GCC/Win 7 | 32 | 32768 |
  209. +-----------------+----------------+--------------+------------------------+-------+----------+
  210. | i7-920 2.66 | DX9 | GTX650Ti | x64/VS2008/Win 7 | 32 | 32768 |
  211. +-----------------+----------------+--------------+------------------------+-------+----------+
  212. | i7-920 2.66 | DX9 | GTX650Ti | x86/GCC/Win 7 | 30 | 27000 |
  213. +-----------------+----------------+--------------+------------------------+-------+----------+
  214. | i7-920 2.66 | DX9 | GTX650Ti | x86/VS2008/Win 7 | 30 | 27000 |
  215. +-----------------+----------------+--------------+------------------------+-------+----------+
  216. | i5-6200U 2.3 | DX11 | Intel 520 | x64/GCC/Win 10 | 30 | 27000 |
  217. +-----------------+----------------+--------------+------------------------+-------+----------+
  218. | i5-4250U 1.3 | GL2.1 | HD5000 | x64/Clang/OSX 10.9 | 28 | 21852 |
  219. +-----------------+----------------+--------------+------------------------+-------+----------+
  220. | Q8200 2.33 | NV 319.32 | GTX260 | x64/GCC/Linux | 27 | 19683 |
  221. +-----------------+----------------+--------------+------------------------+-------+----------+
  222. | i7-6700K 4.0 | GL2.1 | Skylake GT2 | x64/GCC/Linux | 27 | 19683 |
  223. +-----------------+----------------+--------------+------------------------+-------+----------+
  224. | i7-2600K 3.4 | DX9 | AMD6800 | x64/VS2012/Win 7 | 27 | 19683 |
  225. +-----------------+----------------+--------------+------------------------+-------+----------+
  226. | i7-2600K 3.4 | GL2.1 | AMD6800 | x64/VS2012/Win 7 | 26 | 17576 |
  227. +-----------------+----------------+--------------+------------------------+-------+----------+
  228. | i7-4770R 3.2 | Mesa 10.5.9 | HD5200 | x64/GCC/Linux | 26 | 17576 |
  229. +-----------------+----------------+--------------+------------------------+-------+----------+
  230. | i5-6200U 2.3 | GL | Intel 520 | x64/GCC/Win 10 | 26 | 17576 |
  231. +-----------------+----------------+--------------+------------------------+-------+----------+
  232. | i7-920 2.66 | DX9-Wine | GTX650Ti | x64/GCC/Linux | 24 | 13824 |
  233. +-----------------+----------------+--------------+------------------------+-------+----------+
  234. | i5-6200U 2.3 | Mesa 10.5.9 | Intel 520 | x64/GCC/Linux | 23 | 12167 |
  235. +-----------------+----------------+--------------+------------------------+-------+----------+
  236. | i7-4750HQ 2.0 | Mesa 10.0.1 | HD5200 | x64/GCC/Linux | 22 | 10648 |
  237. +-----------------+----------------+--------------+------------------------+-------+----------+
  238. | i7-4750HQ 2.0 | Mesa 10.1.3 | HD5200 | x64/GCC/Linux | 21 | 9261 |
  239. +-----------------+----------------+--------------+------------------------+-------+----------+
  240. | i7-920 2.66 | ES2-ANGLE | GTX650Ti | x86/VS2008/Win 7 | 21 | 9261 |
  241. +-----------------+----------------+--------------+------------------------+-------+----------+
  242. | Q8200 2.33 | Gallium 0.4 | AMD5770 | x64/GCC/Linux | 21 | 9261 |
  243. +-----------------+----------------+--------------+------------------------+-------+----------+
  244. | i5-4250U 1.3 | ES2 | HD5000 | JIT/Clang/PNaCl 31 | 21 | 9261 |
  245. +-----------------+----------------+--------------+------------------------+-------+----------+
  246. | i5-4250U 1.3 | ES2 | HD5000 | x86/GCC/NaCl 31 | 20 | 8000 |
  247. +-----------------+----------------+--------------+------------------------+-------+----------+
  248. | Q8200 2.33 | Gallium 0.4 | GTX260 | x64/GCC/Linux | 19 | 6859 |
  249. +-----------------+----------------+--------------+------------------------+-------+----------+
  250. | i5-2450M 2.5 | Mesa 10.2.0 | HD3000 | x64/GCC/Linux | 19 | 6859 |
  251. +-----------------+----------------+--------------+------------------------+-------+----------+
  252. | i7-920 2.66 | ES2-PowerVR | GTX650Ti | x86/VS2008/Win 7 | 18 | 5832 |
  253. +-----------------+----------------+--------------+------------------------+-------+----------+
  254. | i7-920 2.66 | FF27-GL | GTX650Ti | JIT/Clang/W7-asm.js | 17 | 4913 |
  255. +-----------------+----------------+--------------+------------------------+-------+----------+
  256. | i7-6700K 4.0 | DX9 | Skylake GT2 | x64/GCC/Win 10 | 16 | 4096 |
  257. +-----------------+----------------+--------------+------------------------+-------+----------+
  258. | i7-4750HQ 2.0 | Mesa 8.0.5 | LLVMPIPE | x64/GCC/Linux | 16 | 4096 |
  259. +-----------------+----------------+--------------+------------------------+-------+----------+
  260. | i5-6200U 2.3 | DX9 | Intel 520 | x64/GCC/Win 10 | 16 | 4096 |
  261. +-----------------+----------------+--------------+------------------------+-------+----------+
  262. | i7-920 2.66 | ES2-Qualcomm | GTX650Ti | x86/VS2008/Win 7 | 15 | 3375 |
  263. +-----------------+----------------+--------------+------------------------+-------+----------+
  264. | i7-920 2.66 | ES2 | GTX650Ti | x64/GCC/NaCl 31 | 15 | 3375 |
  265. +-----------------+----------------+--------------+------------------------+-------+----------+
  266. | i7-920 2.66 | ES2 | GTX650Ti | JIT/Clang/PNaCl 31 | 15 | 3375 |
  267. +-----------------+----------------+--------------+------------------------+-------+----------+
  268. | Q8200 2.33 | NV 319.32 | GTX260 | x64/GCC/NaCl 31 | 15 | 3375 |
  269. +-----------------+----------------+--------------+------------------------+-------+----------+
  270. | Q8200 2.33 | NV 319.32 | GTX260 | x64/GCC/PNaCl 31 | 15 | 3375 |
  271. +-----------------+----------------+--------------+------------------------+-------+----------+
  272. | '12 Nexus 7 | ES2 | Tegra3 | ARM/GCC/Android | 15 | 3375 |
  273. +-----------------+----------------+--------------+------------------------+-------+----------+
  274. | i5-4250U 1.3 | ES2-FF27 | HD5000 | JIT/Clang/OSX-asm.js | 15 | 3375 |
  275. +-----------------+----------------+--------------+------------------------+-------+----------+
  276. | i5-4250U 1.3 | Chrome33 | HD5000 | JIT/Clang/OSX-asm.js | 15 | 3375 |
  277. +-----------------+----------------+--------------+------------------------+-------+----------+
  278. | iPad mini 2 | ES2 | PVR G6430 | ARM64/Clang/iOS7 | 15 | 3375 |
  279. +-----------------+----------------+--------------+------------------------+-------+----------+
  280. | i7-920 2.66 | Chrome33 | GTX650Ti | JIT/Clang/W7-asm.js | 14 | 2744 |
  281. +-----------------+----------------+--------------+------------------------+-------+----------+
  282. | i7-920 2.66 | FF27-ANGLE | GTX650Ti | JIT/Clang/W7-asm.js | 14 | 2744 |
  283. +-----------------+----------------+--------------+------------------------+-------+----------+
  284. | '13 Nexus 10 | ES2 | Mali T604 | ARM/GCC/Android | 13 | 2197 |
  285. +-----------------+----------------+--------------+------------------------+-------+----------+
  286. | iPhone 5 | ES2 | PVR SGX543 | ARM/Clang/iOS7 | 13 | 2197 |
  287. +-----------------+----------------+--------------+------------------------+-------+----------+
  288. | '13 Nexus 7 | ES2 | S4 Pro | ARM/GCC/Android | 12 | 1728 |
  289. +-----------------+----------------+--------------+------------------------+-------+----------+
  290. | iPad 2 | ES2 | PVR SGX543 | ARM/Clang/iOS6 | 12 | 1728 |
  291. +-----------------+----------------+--------------+------------------------+-------+----------+
  292. | AMD A4-5000 | Gallium 0.4 | HD8330/Kabini| x64/GCC/Linux | 12 | 1728 |
  293. +-----------------+----------------+--------------+------------------------+-------+----------+
  294. | Xperia Z | ES2 | Adreno320 | ARM/GCC/Android | 11 | 1331 |
  295. +-----------------+----------------+--------------+------------------------+-------+----------+
  296. | iPod 4 | ES2 | PVR SGX535 | ARM/Clang/iOS6 | 7 | 343 |
  297. +-----------------+----------------+--------------+------------------------+-------+----------+
  298. | i7-920 2.66 | ES2-Mali | GTX650Ti | x86/VS2008/Windows7 | 6 | 216 |
  299. +-----------------+----------------+--------------+------------------------+-------+----------+
  300. | Creator CI20 | ES2 | PVR SGX540 | MIPS/GCC/Debian8 | 7 | 343 |
  301. +-----------------+----------------+--------------+------------------------+-------+----------+
  302. | i5-6200U 2.3 | ES2 | SwiftShader | x64/GCC/Linux | 6 | 216 |
  303. +-----------------+----------------+--------------+------------------------+-------+----------+
  304. | RaspberryPi | ES2 | VC IV | ARM/GCC/Raspbian | 6 | 216 |
  305. +-----------------+----------------+--------------+------------------------+-------+----------+
  306. To test browsers in 60Hz mode following changes were made:
  307. - Firefox 27 about:config adjustments: ``webgl.prefer-native-gl true``
  308. (on Windows), and ``layout.frame_rate 500``.
  309. - Chrome 33 command line option: ``--disable-gpu-vsync``.
  310. 30Hz (test for browsers)
  311. ^^^^^^^^^^^^^^^^^^^^^^^^
  312. By default browsers are using vsync, and don't have option to turn it
  313. off programmatically.
  314. +----------------+------------+------------+--------------------------+-------+----------+
  315. | CPU | Renderer | GPU | Arch/Compiler/OS | Dim | Calls |
  316. +================+============+============+==========================+=======+==========+
  317. | i7-920 2.66 | GL2.1 | GTX650Ti | x64/VS2008/Win7 | 38 | 64000+ |
  318. +----------------+------------+------------+--------------------------+-------+----------+
  319. | i5-4250U 1.3 | GL2.1 | HD5000 | x64/Clang/OSX 10.9 | 36 | 46656 |
  320. +----------------+------------+------------+--------------------------+-------+----------+
  321. | i5-4250U 1.3 | Chrome34 | HD5000 | JIT/Clang/OSX-PNaCl 31 | 28 | 21952 |
  322. +----------------+------------+------------+--------------------------+-------+----------+
  323. | i5-4250U 1.3 | Chrome33 | HD5000 | JIT/Clang/OSX-PNaCl 31 | 27 | 19683 |
  324. +----------------+------------+------------+--------------------------+-------+----------+
  325. | i5-4250U 1.3 | FF28 | HD5000 | JIT/Clang/OSX-asm.js | 25 | 15625 |
  326. +----------------+------------+------------+--------------------------+-------+----------+
  327. | i5-4250U 1.3 | FF36 | HD5000 | JIT/Clang/OSX-asm.js | 25 | 15625 |
  328. +----------------+------------+------------+--------------------------+-------+----------+
  329. | i5-4250U 1.3 | Chrome41 | HD5000 | x64/GCC/OSX-NaCl 41 | 24 | 13824 |
  330. +----------------+------------+------------+--------------------------+-------+----------+
  331. | i5-4250U 1.3 | FF37 | HD5000 | JIT/Clang/OSX-asm.js | 23 | 12167 |
  332. +----------------+------------+------------+--------------------------+-------+----------+
  333. | i5-4250U 1.3 | FF27 | HD5000 | JIT/Clang/OSX-asm.js | 20 | 8000 |
  334. +----------------+------------+------------+--------------------------+-------+----------+
  335. | i7-920 2.66 | Chrome33 | GTX650Ti | JIT/Clang/W7-PNaCl 31 | 20 | 8000 |
  336. +----------------+------------+------------+--------------------------+-------+----------+
  337. | i7-920 2.66 | Chrome34 | GTX650Ti | JIT/Clang/W7-asm.js | 18 | 5832 |
  338. +----------------+------------+------------+--------------------------+-------+----------+
  339. | i7-920 2.66 | Chrome33 | GTX650Ti | JIT/Clang/W7-asm.js | 18 | 5832 |
  340. +----------------+------------+------------+--------------------------+-------+----------+
  341. | i7-920 2.66 | FF28 | GTX650Ti | JIT/Clang/W7-asm.js | 18 | 5832 |
  342. +----------------+------------+------------+--------------------------+-------+----------+
  343. | i7-920 2.66 | FF27 | GTX650Ti | JIT/Clang/W7-asm.js | 18 | 5832 |
  344. +----------------+------------+------------+--------------------------+-------+----------+
  345. | i5-4250U 1.3 | Safari7 | HD5000 | JIT/Clang/OSX-asm.js | 15 | 3375 |
  346. +----------------+------------+------------+--------------------------+-------+----------+
  347. `18-ibl <https://github.com/bkaradzic/bgfx/tree/master/examples/18-ibl>`__
  348. --------------------------------------------------------------------------
  349. Image-based lighting.
  350. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/18-ibl/screenshot.png
  351. :alt: example-18-ibl
  352. `19-oit <https://github.com/bkaradzic/bgfx/tree/master/examples/19-oit>`__
  353. --------------------------------------------------------------------------
  354. Weighted, Blended Order-Independent Transparency
  355. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/19-oit/screenshot.png
  356. :alt: example-19-oit
  357. `20-nanovg <https://github.com/bkaradzic/bgfx/tree/master/examples/20-nanovg>`__
  358. --------------------------------------------------------------------------------
  359. NanoVG is small antialiased vector graphics rendering library.
  360. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/20-nanovg/screenshot.png
  361. :alt: example-20-nanovg
  362. `21-deferred <https://github.com/bkaradzic/bgfx/tree/master/examples/21-deferred>`__
  363. ------------------------------------------------------------------------------------
  364. MRT rendering and deferred shading.
  365. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/21-deferred/screenshot.png
  366. :alt: example-21-deferred
  367. `22-windows <https://github.com/bkaradzic/bgfx/tree/master/examples/22-windows>`__
  368. ----------------------------------------------------------------------------------
  369. Rendering into multiple windows.
  370. `23-vectordisplay <https://github.com/bkaradzic/bgfx/tree/master/examples/23-vectordisplay>`__
  371. ----------------------------------------------------------------------------------------------
  372. Rendering lines as oldschool vectors.
  373. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/23-vectordisplay/screenshot.png
  374. :alt: example-23-vectordisplay
  375. `24-nbody <https://github.com/bkaradzic/bgfx/tree/master/examples/24-nbody>`__
  376. ------------------------------------------------------------------------------
  377. N-body simulation with compute shaders using buffers.
  378. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/24-nbody/screenshot.png
  379. :alt: example-24-nbody
  380. `25-c99 <https://github.com/bkaradzic/bgfx/tree/master/examples/25-c99>`__
  381. --------------------------------------------------------------------------
  382. Initialization and debug text with C99 API.
  383. `26-occlusion <https://github.com/bkaradzic/bgfx/tree/master/examples/26-occlusion>`__
  384. --------------------------------------------------------------------------------------
  385. Using occlusion query for conditional rendering.
  386. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/26-occlusion/screenshot.png
  387. :alt: example-26-occlusion
  388. `27-terrain <https://github.com/bkaradzic/bgfx/tree/master/examples/27-terrain>`__
  389. ----------------------------------------------------------------------------------
  390. Terrain painting example.
  391. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/27-terrain/screenshot.png
  392. :alt: example-27-terrain
  393. `28-wireframe <https://github.com/bkaradzic/bgfx/tree/master/examples/28-wireframe>`__
  394. --------------------------------------------------------------------------------------
  395. Drawing wireframe mesh.
  396. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/28-wireframe/screenshot.png
  397. :alt: example-28-wireframe
  398. `29-debugdraw <https://github.com/bkaradzic/bgfx/tree/master/examples/29-debugdraw>`__
  399. --------------------------------------------------------------------------------------
  400. Debug draw.
  401. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/29-debugdraw/screenshot.png
  402. :alt: example-29-debugdraw
  403. `30-picking <https://github.com/bkaradzic/bgfx/tree/master/examples/30-picking>`__
  404. --------------------------------------------------------------------------------------
  405. Mouse picking via GPU readback.
  406. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/30-picking/screenshot.png
  407. :alt: example-30-picking
  408. `31-rsm <https://github.com/bkaradzic/bgfx/tree/master/examples/31-rsm>`__
  409. --------------------------------------------------------------------------------------
  410. Global Illumination with Reflective Shadow Map.
  411. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/31-rsm/screenshot.png
  412. :alt: example-31-rsm
  413. `32-particles <https://github.com/bkaradzic/bgfx/tree/master/examples/32-particles>`__
  414. --------------------------------------------------------------------------------------
  415. Particles.
  416. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/32-particles/screenshot.png
  417. :alt: example-32-particles
  418. `33-pom <https://github.com/bkaradzic/bgfx/tree/master/examples/33-pom>`__
  419. --------------------------------------------------------------------------
  420. Parallax occlusion mapping.
  421. Reference(s):
  422. - `Exploring bump mapping with WebGL <http://apoorvaj.io/exploring-bump-mapping-with-webgl.html>`__
  423. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/33-pom/screenshot.png
  424. :alt: example-33-pom
  425. `34-mvs <https://github.com/bkaradzic/bgfx/tree/master/examples/34-mvs>`__
  426. --------------------------------------------------------------------------
  427. Multiple vertex streams.
  428. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/34-mvs/screenshot.png
  429. :alt: example-34-mvs
  430. `35-dynamic <https://github.com/bkaradzic/bgfx/tree/master/examples/35-dynamic>`__
  431. ----------------------------------------------------------------------------------
  432. Dynamic buffers update.
  433. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/35-dynamic/screenshot.png
  434. :alt: example-35-dynamic
  435. `36-sky <https://github.com/bkaradzic/bgfx/tree/master/examples/36-sky>`__
  436. --------------------------------------------------------------------------
  437. Perez dynamic sky model.
  438. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/36-sky/screenshot.png
  439. :alt: example-36-sky
  440. `37-gpudrivenrendering <https://github.com/bkaradzic/bgfx/tree/master/examples/37-gpudrivenrendering>`__
  441. --------------------------------------------------------------------------------------------------------
  442. GPU-Driven Rendering.
  443. Reference(s):
  444. - `Experiments in GPU-based occlusion culling <https://interplayoflight.wordpress.com/2017/11/15/experiments-in-gpu-based-occlusion-culling/>`__,
  445. - `Experiments in GPU-based occlusion culling part 2: MultiDrawIndirect and mesh lodding <https://interplayoflight.wordpress.com/2018/01/15/experiments-in-gpu-based-occlusion-culling-part-2-multidrawindirect-and-mesh-lodding/>`__,
  446. - `Porting GPU driven occlusion culling to bgfx <https://interplayoflight.wordpress.com/2018/03/05/porting-gpu-driven-occlusion-culling-to-bgfx/>`__.
  447. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/37-gpudrivenrendering/screenshot.png
  448. :alt: example-37-gpudrivenrendering
  449. `38-bloom <https://github.com/bkaradzic/bgfx/tree/master/examples/38-bloom>`__
  450. ------------------------------------------------------------------------------
  451. Bloom.
  452. Reference(s):
  453. - `Next Generation Post Processing in Call of Duty: Advanced Warfare <http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare>`__.
  454. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/38-bloom/screenshot.png
  455. :alt: example-38-bloom
  456. `39-assao <https://github.com/bkaradzic/bgfx/tree/master/examples/39-assao>`__
  457. ------------------------------------------------------------------------------
  458. Adaptive Screen Space Ambient Occlusion.
  459. Reference(s):
  460. - `Adaptive Screen Space Ambient Occlusion <https://software.intel.com/en-us/articles/adaptive-screen-space-ambient-occlusion>`__.
  461. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/39-assao/screenshot.png
  462. :alt: example-39-assao
  463. `40-svt <https://github.com/bkaradzic/bgfx/tree/master/examples/40-svt>`__
  464. --------------------------------------------------------------------------
  465. Sparse Virtual Textures.
  466. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/40-svt/screenshot.png
  467. :alt: example-40-svt
  468. `41-tess <https://github.com/bkaradzic/bgfx/tree/master/examples/41-tess>`__
  469. ----------------------------------------------------------------------------
  470. Adaptive GPU Tessellation with Compute Shaders
  471. Reference(s):
  472. - `Adaptive GPU Tessellation with Compute Shaders by Jad Khoury, Jonathan Dupuy, and Christophe Riccio <http://onrendering.com/data/papers/isubd/isubd.pdf>`__.
  473. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/41-tess/screenshot.png
  474. :alt: example-41-tess
  475. `42-bunnylod <https://github.com/bkaradzic/bgfx/tree/master/examples/42-bunnylod>`__
  476. ------------------------------------------------------------------------------------
  477. Simple Polygon Reduction
  478. Reference(s):
  479. - `Simple Polygon Reduction <https://web.archive.org/web/20020114194131/http://www.melax.com/polychop/>`__.
  480. - `A Simple, Fast,and Effective Polygon Reduction Algorithm <https://web.archive.org/web/20031204035320/http://www.melax.com/polychop/gdmag.pdf>`__.
  481. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/42-bunnylod/screenshot.png
  482. :alt: example-42-bunnylod
  483. `43-denoise <https://github.com/bkaradzic/bgfx/tree/master/examples/43-denoise>`__
  484. ----------------------------------------------------------------------------------
  485. Denoise
  486. Reference(s):
  487. - `Spatiotemporal Variance-Guided Filtering: Real-Time Reconstruction for Path-Traced Global Illumination. <https://web.archive.org/web/20170720213354/https://research.nvidia.com/sites/default/files/pubs/2017-07_Spatiotemporal-Variance-Guided-Filtering%3A/svgf_preprint.pdf>`__.
  488. - `Streaming G-Buffer Compression for Multi-Sample Anti-Aliasing <https://web.archive.org/web/20200807211002/https://software.intel.com/content/www/us/en/develop/articles/streaming-g-buffer-compression-for-multi-sample-anti-aliasing.html>`__.
  489. - `Edge-Avoiding À-Trous Wavelet Transform for fast Global Illumination Filtering <https://web.archive.org/web/20130412085423/https://www.uni-ulm.de/fileadmin/website_uni_ulm/iui.inst.100/institut/Papers/atrousGIfilter.pdf>`__.
  490. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/43-denoise/screenshot.png
  491. :alt: example-43-denoise
  492. `44-sss <https://github.com/bkaradzic/bgfx/tree/master/examples/44-sss>`__
  493. --------------------------------------------------------------------------
  494. Screen-Space Shadows
  495. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/44-sss/screenshot.png
  496. :alt: example-44-sss
  497. `45-bokeh <https://github.com/bkaradzic/bgfx/tree/master/examples/45-bokeh>`__
  498. ------------------------------------------------------------------------------
  499. Bokeh Depth of Field
  500. Reference(s):
  501. - `Bokeh depth of field in a single pass <https://web.archive.org/web/20201215123940/https://blog.tuxedolabs.com/2018/05/04/bokeh-depth-of-field-in-single-pass.html>`__.
  502. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/45-bokeh/screenshot.png
  503. :alt: example-45-bokeh
  504. `46-fsr <https://github.com/bkaradzic/bgfx/tree/master/examples/46-fsr>`__
  505. --------------------------------------------------------------------------
  506. AMD FidelityFX Super Resolution - high-quality solution for producing high resolution frames
  507. from lower resolution inputs.
  508. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/46-fsr/screenshot.png
  509. :alt: example-46-fsr
  510. `47-pixelformats <https://github.com/bkaradzic/bgfx/tree/master/examples/47-pixelformats>`__
  511. --------------------------------------------------------------------------------------------
  512. Pixel Formats
  513. View and test texture formats
  514. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/47-pixelformats/screenshot.png
  515. :alt: example-47-pixelformats
  516. `48-drawindirect <https://github.com/bkaradzic/bgfx/tree/master/examples/48-drawindirect>`__
  517. ---------------------------------------------------------------------------------------------
  518. Draw Indirect
  519. Simple example of indirect rendering + an implementation of multidraw indirect
  520. Reference(s):
  521. - `OpenGL MultiDrawIndirect with per-instance textures <https://web.archive.org/web/20201109155619/https://litasa.github.io/blog/2017/09/04/OpenGL-MultiDrawIndirect-with-Individual-Textures>`__.
  522. - `Indirect Rendering - A way to a million draw calls <https://web.archive.org/web/20210926073337/https://cpp-rendering.io/indirect-rendering>`__.
  523. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/48-drawindirect/screenshot.png
  524. :alt: example-48-drawindirect
  525. `49-hextile <https://github.com/bkaradzic/bgfx/tree/master/examples/49-hextile>`__
  526. -----------------------------------------------------------------------------------
  527. Realtime Hex-Tiling
  528. Simple example of how to use Hex-tiling in real time, ported from https://github.com/mmikk/hextile-demo
  529. Reference(s):
  530. - `Hex-Tiling demo <https://github.com/mmikk/hextile-demo>`__.
  531. - `Paper explaining concepts - <https://github.com/mmikk/mmikk.github.io/blob/master/papers3d/mm_hex_compressed.pdf>`__.
  532. .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/49-hextile/screenshot.png
  533. :alt: example-49-hextile
  534. `50-headless <https://github.com/bkaradzic/bgfx/tree/master/examples/50-headless>`__
  535. ------------------------------------------------------------------------------------
  536. Demonstrate running bgfx in headless mode. Initialize bgfx without window, render into frame buffer,
  537. and output result into an image.