2
0
Эх сурвалжийг харах

Delete BGFX examples folder

Daniele Bartolini 9 жил өмнө
parent
commit
fe355a8c89
100 өөрчлөгдсөн 0 нэмэгдсэн , 8350 устгасан
  1. 0 84
      third/bgfx/examples/00-helloworld/helloworld.cpp
  2. 0 253
      third/bgfx/examples/00-helloworld/logo.h
  3. BIN
      third/bgfx/examples/00-helloworld/screenshot.png
  4. 0 217
      third/bgfx/examples/01-cubes/cubes.cpp
  5. 0 13
      third/bgfx/examples/01-cubes/fs_cubes.sc
  6. 0 18
      third/bgfx/examples/01-cubes/makefile
  7. BIN
      third/bgfx/examples/01-cubes/screenshot.png
  8. 0 4
      third/bgfx/examples/01-cubes/varying.def.sc
  9. 0 15
      third/bgfx/examples/01-cubes/vs_cubes.sc
  10. 0 151
      third/bgfx/examples/02-metaballs/fs_metaballs.bin.h
  11. 0 16
      third/bgfx/examples/02-metaballs/fs_metaballs.sc
  12. 0 9
      third/bgfx/examples/02-metaballs/makefile
  13. 0 779
      third/bgfx/examples/02-metaballs/metaballs.cpp
  14. BIN
      third/bgfx/examples/02-metaballs/screenshot.png
  15. 0 6
      third/bgfx/examples/02-metaballs/varying.def.sc
  16. 0 175
      third/bgfx/examples/02-metaballs/vs_metaballs.bin.h
  17. 0 16
      third/bgfx/examples/02-metaballs/vs_metaballs.sc
  18. 0 133
      third/bgfx/examples/03-raymarch/fs_raymarching.sc
  19. 0 82
      third/bgfx/examples/03-raymarch/iq_sdf.sh
  20. 0 18
      third/bgfx/examples/03-raymarch/makefile
  21. 0 254
      third/bgfx/examples/03-raymarch/raymarch.cpp
  22. BIN
      third/bgfx/examples/03-raymarch/screenshot.png
  23. 0 6
      third/bgfx/examples/03-raymarch/varying.def.sc
  24. 0 16
      third/bgfx/examples/03-raymarch/vs_raymarching.sc
  25. 0 54
      third/bgfx/examples/04-mesh/fs_mesh.sc
  26. 0 18
      third/bgfx/examples/04-mesh/makefile
  27. 0 144
      third/bgfx/examples/04-mesh/mesh.cpp
  28. BIN
      third/bgfx/examples/04-mesh/screenshot.png
  29. 0 10
      third/bgfx/examples/04-mesh/varying.def.sc
  30. 0 32
      third/bgfx/examples/04-mesh/vs_mesh.sc
  31. 0 13
      third/bgfx/examples/05-instancing/fs_instancing.sc
  32. 0 246
      third/bgfx/examples/05-instancing/instancing.cpp
  33. 0 18
      third/bgfx/examples/05-instancing/makefile
  34. BIN
      third/bgfx/examples/05-instancing/screenshot.png
  35. 0 9
      third/bgfx/examples/05-instancing/varying.def.sc
  36. 0 22
      third/bgfx/examples/05-instancing/vs_instancing.sc
  37. 0 386
      third/bgfx/examples/06-bump/bump.cpp
  38. BIN
      third/bgfx/examples/06-bump/fieldstone-n.tga
  39. BIN
      third/bgfx/examples/06-bump/fieldstone-rgba.tga
  40. 0 79
      third/bgfx/examples/06-bump/fs_bump.sc
  41. 0 18
      third/bgfx/examples/06-bump/makefile
  42. BIN
      third/bgfx/examples/06-bump/screenshot.png
  43. 0 15
      third/bgfx/examples/06-bump/varying.def.sc
  44. 0 37
      third/bgfx/examples/06-bump/vs_bump.sc
  45. 0 43
      third/bgfx/examples/06-bump/vs_bump_instanced.sc
  46. 0 516
      third/bgfx/examples/07-callback/callback.cpp
  47. 0 17
      third/bgfx/examples/07-callback/fs_callback.sc
  48. 0 18
      third/bgfx/examples/07-callback/makefile
  49. 0 5
      third/bgfx/examples/07-callback/varying.def.sc
  50. 0 16
      third/bgfx/examples/07-callback/vs_callback.sc
  51. 0 15
      third/bgfx/examples/08-update/fs_update.sc
  52. 0 17
      third/bgfx/examples/08-update/fs_update_3d.sc
  53. 0 15
      third/bgfx/examples/08-update/fs_update_cmp.sc
  54. 0 18
      third/bgfx/examples/08-update/makefile
  55. 0 578
      third/bgfx/examples/08-update/update.cpp
  56. 0 4
      third/bgfx/examples/08-update/varying.def.sc
  57. 0 15
      third/bgfx/examples/08-update/vs_update.sc
  58. 0 53
      third/bgfx/examples/09-hdr/common.sh
  59. 0 15
      third/bgfx/examples/09-hdr/fs_hdr_blur.sc
  60. 0 39
      third/bgfx/examples/09-hdr/fs_hdr_bright.sc
  61. 0 38
      third/bgfx/examples/09-hdr/fs_hdr_lum.sc
  62. 0 33
      third/bgfx/examples/09-hdr/fs_hdr_lumavg.sc
  63. 0 55
      third/bgfx/examples/09-hdr/fs_hdr_mesh.sc
  64. 0 18
      third/bgfx/examples/09-hdr/fs_hdr_skybox.sc
  65. 0 42
      third/bgfx/examples/09-hdr/fs_hdr_tonemap.sc
  66. 0 563
      third/bgfx/examples/09-hdr/hdr.cpp
  67. 0 18
      third/bgfx/examples/09-hdr/makefile
  68. BIN
      third/bgfx/examples/09-hdr/screenshot.png
  69. 0 14
      third/bgfx/examples/09-hdr/varying.def.sc
  70. 0 27
      third/bgfx/examples/09-hdr/vs_hdr_blur.sc
  71. 0 15
      third/bgfx/examples/09-hdr/vs_hdr_bright.sc
  72. 0 15
      third/bgfx/examples/09-hdr/vs_hdr_lum.sc
  73. 0 15
      third/bgfx/examples/09-hdr/vs_hdr_lumavg.sc
  74. 0 22
      third/bgfx/examples/09-hdr/vs_hdr_mesh.sc
  75. 0 15
      third/bgfx/examples/09-hdr/vs_hdr_skybox.sc
  76. 0 29
      third/bgfx/examples/09-hdr/vs_hdr_tonemap.sc
  77. 0 290
      third/bgfx/examples/10-font/font.cpp
  78. BIN
      third/bgfx/examples/10-font/screenshot.png
  79. 0 286
      third/bgfx/examples/11-fontsdf/fontsdf.cpp
  80. BIN
      third/bgfx/examples/11-fontsdf/screenshot.png
  81. 0 42
      third/bgfx/examples/12-lod/fs_tree.sc
  82. 0 315
      third/bgfx/examples/12-lod/lod.cpp
  83. 0 18
      third/bgfx/examples/12-lod/makefile
  84. BIN
      third/bgfx/examples/12-lod/screenshot.png
  85. 0 8
      third/bgfx/examples/12-lod/varying.def.sc
  86. 0 23
      third/bgfx/examples/12-lod/vs_tree.sc
  87. BIN
      third/bgfx/examples/13-stencil/figure-rgba.tga
  88. BIN
      third/bgfx/examples/13-stencil/flare.tga
  89. 0 11
      third/bgfx/examples/13-stencil/fs_stencil_color_black.sc
  90. 0 88
      third/bgfx/examples/13-stencil/fs_stencil_color_lighting.sc
  91. 0 22
      third/bgfx/examples/13-stencil/fs_stencil_color_texture.sc
  92. 0 14
      third/bgfx/examples/13-stencil/fs_stencil_texture.sc
  93. 0 90
      third/bgfx/examples/13-stencil/fs_stencil_texture_lighting.sc
  94. 0 18
      third/bgfx/examples/13-stencil/makefile
  95. BIN
      third/bgfx/examples/13-stencil/screenshot.png
  96. 0 1402
      third/bgfx/examples/13-stencil/stencil.cpp
  97. 0 7
      third/bgfx/examples/13-stencil/varying.def.sc
  98. 0 13
      third/bgfx/examples/13-stencil/vs_stencil_color.sc
  99. 0 18
      third/bgfx/examples/13-stencil/vs_stencil_color_lighting.sc
  100. 0 16
      third/bgfx/examples/13-stencil/vs_stencil_color_texture.sc

+ 0 - 84
third/bgfx/examples/00-helloworld/helloworld.cpp

@@ -1,84 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include <bx/uint32_t.h>
-#include "common.h"
-#include "bgfx_utils.h"
-#include "logo.h"
-
-class ExampleHelloWorld : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-				, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-				, 0x303030ff
-				, 1.0f
-				, 0
-				);
-	}
-
-	virtual int shutdown() BX_OVERRIDE
-	{
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			// Set view 0 default viewport.
-			bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextImage(bx::uint16_max(uint16_t(m_width /2/8 ), 20)-20
-							 , bx::uint16_max(uint16_t(m_height/2/16), 6)-6
-							 , 40
-							 , 12
-							 , s_logo
-							 , 160
-							 );
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld);

+ 0 - 253
third/bgfx/examples/00-helloworld/logo.h

@@ -1,253 +0,0 @@
-static const uint8_t s_logo[4000] =
-{
-	0xdc, 0x03, 0xdc, 0x03, 0xdc, 0x03, 0xdc, 0x03, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, // ........ . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xdc, 0x08, //  . . . . . . ...
-	0xdc, 0x03, 0xdc, 0x07, 0xdc, 0x07, 0xdc, 0x08, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, // ........ . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0xde, 0x03, 0xb0, 0x3b, 0xb1, 0x3b, 0xb2, 0x3b, 0xdb, 0x3b, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, // ...;.;.;.; . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xdc, 0x03, 0xb1, 0x3b, 0xb2, 0x3b, //  . . . . ....;.;
-	0xdb, 0x3b, 0xdf, 0x03, 0xdf, 0x3b, 0xb2, 0x3f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, // .;...;.? . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0xb1, 0x3b, 0xb1, 0x3b, 0xb2, 0x3b, 0xb2, 0x3f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  ..;.;.;.? . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xb1, 0x3b, 0xb1, 0x3b, 0xb2, 0x3b, //  . . . . ..;.;.;
-	0xb2, 0x3f, 0x20, 0x0f, 0x20, 0x0f, 0xdf, 0x03, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, // .? . ... . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0xb1, 0x3b, 0xb1, 0x3b, 0xb1, 0x3b, 0xb1, 0x3f, 0xdc, 0x0b, 0xdc, 0x03, 0xdc, 0x03, //  ..;.;.;.?......
-	0xdc, 0x03, 0xdc, 0x03, 0x20, 0x0f, 0x20, 0x0f, 0xdc, 0x08, 0xdc, 0x03, 0xdc, 0x03, 0xdc, 0x03, // .... . .........
-	0xdc, 0x03, 0xdc, 0x03, 0xdc, 0x03, 0xdc, 0x08, 0x20, 0x0f, 0xb1, 0x3b, 0xb1, 0x3b, 0xb1, 0x3b, // ........ ..;.;.;
-	0xb1, 0x3f, 0xb1, 0x3f, 0xb2, 0x0b, 0x20, 0x0f, 0x20, 0x0f, 0xdc, 0x03, 0xdc, 0x03, 0xdc, 0x03, // .?.?.. . .......
-	0x20, 0x0f, 0x20, 0x0f, 0xdc, 0x03, 0xdc, 0x03, 0xdc, 0x03, 0x20, 0x0f, 0x20, 0x01, 0x20, 0x0f, //  . ....... . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0xb2, 0x3b, 0xb1, 0x3b, 0xb0, 0x3b, 0xb0, 0x3f, 0x20, 0x0f, 0xde, 0x03, 0xb0, 0x3f, //  ..;.;.;.? ....?
-	0xb1, 0x3f, 0xb2, 0x3f, 0xdd, 0x03, 0xde, 0x03, 0xdb, 0x03, 0xdb, 0x03, 0xb2, 0x3f, 0x20, 0x0f, // .?.?.........? .
-	0x20, 0x0f, 0xb0, 0x3f, 0xb1, 0x3f, 0xb2, 0x3f, 0xde, 0x38, 0xb2, 0x3b, 0xb1, 0x3b, 0xb0, 0x3b, //  ..?.?.?.8.;.;.;
-	0xb0, 0x3f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xb0, 0x3b, 0xb1, 0x3b, 0xb2, 0x3b, 0xb2, 0x3f, // .? . . ..;.;.;.?
-	0xdd, 0x03, 0xde, 0x03, 0xb0, 0x3f, 0xb1, 0x3f, 0xb2, 0x3f, 0xdd, 0x03, 0x20, 0x01, 0x20, 0x0f, // .....?.?.?.. . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0xb2, 0x3b, 0xb1, 0x3b, 0xb0, 0x3b, 0xb0, 0x3f, 0x20, 0x0f, 0x20, 0x0f, 0xdb, 0x03, //  ..;.;.;.? . ...
-	0xb0, 0x3f, 0xb1, 0x3f, 0xdd, 0x03, 0xb1, 0x3b, 0xb0, 0x3b, 0xdb, 0x03, 0xb1, 0x3f, 0x20, 0x0f, // .?.?...;.;...? .
-	0x20, 0x0f, 0x20, 0x3f, 0xb0, 0x3f, 0xb1, 0x3f, 0xb0, 0x3b, 0xb2, 0x3b, 0xb1, 0x3b, 0xb0, 0x3b, //  . ?.?.?.;.;.;.;
-	0xb0, 0x3f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xdc, 0x08, 0xdc, 0x3b, 0xb1, 0x3b, 0xb1, 0x3f, // .? . . ....;.;.?
-	0xb1, 0x3b, 0xb0, 0x3b, 0xb2, 0x3b, 0xb0, 0x3f, 0xdc, 0x03, 0x20, 0x0f, 0x20, 0x01, 0x20, 0x0f, // .;.;.;.?.. . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0xb2, 0x3b, 0xb1, 0x3b, 0xb0, 0x3b, 0xb0, 0x3f, 0xdc, 0x0b, 0xdc, 0x07, 0xdb, 0x03, //  ..;.;.;.?......
-	0xdb, 0x03, 0xdc, 0x38, 0x20, 0x0f, 0xdf, 0x03, 0xb1, 0x3b, 0xb0, 0x3b, 0xb0, 0x3f, 0xdc, 0x03, // ...8 ....;.;.?..
-	0xdc, 0x07, 0xb0, 0x3f, 0xb1, 0x3f, 0xb2, 0x3f, 0xdd, 0x3b, 0xb2, 0x3b, 0xb1, 0x3b, 0xdc, 0x78, // ...?.?.?.;.;.;.x
-	0xdf, 0x08, 0x20, 0x0f, 0x20, 0x0f, 0xde, 0x08, 0xb2, 0x3b, 0xb1, 0x3b, 0xb0, 0x3b, 0xb0, 0x3f, // .. . ....;.;.;.?
-	0x20, 0x0f, 0xdf, 0x03, 0xb1, 0x3b, 0xb2, 0x3b, 0xdb, 0x03, 0xdd, 0x03, 0x20, 0x01, 0x20, 0x0f, //  ....;.;.... . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xdc, 0x08, 0xdc, 0x08, 0xdc, 0x08, 0x20, 0x0f, //  . . . ....... .
-	0x20, 0x0f, 0xb0, 0x3f, 0xb0, 0x3f, 0xb1, 0x3f, 0xdd, 0x3b, 0xdb, 0x0b, 0xdf, 0x03, 0x20, 0x0f, //  ..?.?.?.;.... .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xdf, 0x08, 0xdf, 0x03, 0xdf, 0x03, 0xdf, 0x08, //  . . . .........
-	0x20, 0x0f, 0x20, 0x0f, 0xdf, 0x08, 0xdf, 0x03, 0xdf, 0x03, 0x20, 0x0f, 0x20, 0x01, 0x20, 0x0f, //  . ....... . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0xdb, 0x08, 0xb2, 0x38, 0xb1, 0x38, 0xdc, 0x03, //  . . . ....8.8..
-	0xdc, 0x07, 0xb0, 0x3b, 0xb1, 0x3b, 0xdf, 0x3b, 0xdf, 0x08, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, // ...;.;.;.. . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, //  . . . . . . . .
-	0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0b, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x2d, 0x08, 0x3d, 0x08, 0x20, 0x0a, 0x43, 0x0b, 0x72, 0x0b, 0x6f, 0x0b, 0x73, 0x0b, 0x73, 0x0b, // -.=. .C.r.o.s.s.
-	0x2d, 0x0b, 0x70, 0x0b, 0x6c, 0x0b, 0x61, 0x0b, 0x74, 0x0b, 0x66, 0x0b, 0x6f, 0x0b, 0x72, 0x0b, // -.p.l.a.t.f.o.r.
-	0x6d, 0x0b, 0x20, 0x0b, 0x72, 0x0b, 0x65, 0x0b, 0x6e, 0x0b, 0x64, 0x0b, 0x65, 0x0b, 0x72, 0x0b, // m. .r.e.n.d.e.r.
-	0x69, 0x0b, 0x6e, 0x0b, 0x67, 0x0b, 0x20, 0x0b, 0x6c, 0x0b, 0x69, 0x0b, 0x62, 0x0b, 0x72, 0x0b, // i.n.g. .l.i.b.r.
-	0x61, 0x0b, 0x72, 0x0b, 0x79, 0x0b, 0x20, 0x0f, 0x3d, 0x08, 0x2d, 0x08, 0x20, 0x01, 0x20, 0x0f, // a.r.y. .=.-. . .
-	0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, //  . . . . . . . .
-	0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, //  . . . . . . . .
-	0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, //  . . . . . . . .
-	0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, //  . . . . . . . .
-	0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, 0x20, 0x0a, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-	0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, 0x20, 0x0f, //  . . . . . . . .
-};

BIN
third/bgfx/examples/00-helloworld/screenshot.png


+ 0 - 217
third/bgfx/examples/01-cubes/cubes.cpp

@@ -1,217 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-struct PosColorVertex
-{
-	float m_x;
-	float m_y;
-	float m_z;
-	uint32_t m_abgr;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Color0,   4, bgfx::AttribType::Uint8, true)
-			.end();
-	};
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosColorVertex::ms_decl;
-
-static PosColorVertex s_cubeVertices[8] =
-{
-	{-1.0f,  1.0f,  1.0f, 0xff000000 },
-	{ 1.0f,  1.0f,  1.0f, 0xff0000ff },
-	{-1.0f, -1.0f,  1.0f, 0xff00ff00 },
-	{ 1.0f, -1.0f,  1.0f, 0xff00ffff },
-	{-1.0f,  1.0f, -1.0f, 0xffff0000 },
-	{ 1.0f,  1.0f, -1.0f, 0xffff00ff },
-	{-1.0f, -1.0f, -1.0f, 0xffffff00 },
-	{ 1.0f, -1.0f, -1.0f, 0xffffffff },
-};
-
-static const uint16_t s_cubeIndices[36] =
-{
-	0, 1, 2, // 0
-	1, 3, 2,
-	4, 6, 5, // 2
-	5, 6, 7,
-	0, 2, 4, // 4
-	4, 2, 6,
-	1, 5, 3, // 6
-	5, 7, 3,
-	0, 4, 1, // 8
-	4, 5, 1,
-	2, 3, 6, // 10
-	6, 3, 7,
-};
-
-class ExampleCubes : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-				, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-				, 0x303030ff
-				, 1.0f
-				, 0
-				);
-
-		// Create vertex stream declaration.
-		PosColorVertex::init();
-
-		// Create static vertex buffer.
-		m_vbh = bgfx::createVertexBuffer(
-				// Static data can be passed with bgfx::makeRef
-				bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
-				, PosColorVertex::ms_decl
-				);
-
-		// Create static index buffer.
-		m_ibh = bgfx::createIndexBuffer(
-				// Static data can be passed with bgfx::makeRef
-				bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) )
-				);
-
-		// Create program from shaders.
-		m_program = loadProgram("vs_cubes", "fs_cubes");
-
-		m_timeOffset = bx::getHPCounter();
-	}
-
-	virtual int shutdown() BX_OVERRIDE
-	{
-		// Cleanup.
-		bgfx::destroyIndexBuffer(m_ibh);
-		bgfx::destroyVertexBuffer(m_vbh);
-		bgfx::destroyProgram(m_program);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-
-			float time = (float)( (now-m_timeOffset)/double(bx::getHPFrequency() ) );
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/01-cube");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Rendering simple static mesh.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			float at[3]  = { 0.0f, 0.0f,   0.0f };
-			float eye[3] = { 0.0f, 0.0f, -35.0f };
-
-			// Set view and projection matrix for view 0.
-			const bgfx::HMD* hmd = bgfx::getHMD();
-			if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-			{
-				float view[16];
-				bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
-				bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
-
-				// Set view 0 default viewport.
-				//
-				// Use HMD's width/height since HMD's internal frame buffer size
-				// might be much larger than window size.
-				bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-			}
-			else
-			{
-				float view[16];
-				bx::mtxLookAt(view, eye, at);
-
-				float proj[16];
-				bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-				bgfx::setViewTransform(0, view, proj);
-
-				// Set view 0 default viewport.
-				bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-			}
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			// Submit 11x11 cubes.
-			for (uint32_t yy = 0; yy < 11; ++yy)
-			{
-				for (uint32_t xx = 0; xx < 11; ++xx)
-				{
-					float mtx[16];
-					bx::mtxRotateXY(mtx, time + xx*0.21f, time + yy*0.37f);
-					mtx[12] = -15.0f + float(xx)*3.0f;
-					mtx[13] = -15.0f + float(yy)*3.0f;
-					mtx[14] = 0.0f;
-
-					// Set model matrix for rendering.
-					bgfx::setTransform(mtx);
-
-					// Set vertex and index buffer.
-					bgfx::setVertexBuffer(m_vbh);
-					bgfx::setIndexBuffer(m_ibh);
-
-					// Set render states.
-					bgfx::setState(BGFX_STATE_DEFAULT);
-
-					// Submit primitive for rendering to view 0.
-					bgfx::submit(0, m_program);
-				}
-			}
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-	bgfx::VertexBufferHandle m_vbh;
-	bgfx::IndexBufferHandle m_ibh;
-	bgfx::ProgramHandle m_program;
-	int64_t m_timeOffset;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleCubes);

+ 0 - 13
third/bgfx/examples/01-cubes/fs_cubes.sc

@@ -1,13 +0,0 @@
-$input v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_FragColor = v_color0;
-}

+ 0 - 18
third/bgfx/examples/01-cubes/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

BIN
third/bgfx/examples/01-cubes/screenshot.png


+ 0 - 4
third/bgfx/examples/01-cubes/varying.def.sc

@@ -1,4 +0,0 @@
-vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
-
-vec3 a_position  : POSITION;
-vec4 a_color0    : COLOR0;

+ 0 - 15
third/bgfx/examples/01-cubes/vs_cubes.sc

@@ -1,15 +0,0 @@
-$input a_position, a_color0
-$output v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_color0 = a_color0;
-}

+ 0 - 151
third/bgfx/examples/02-metaballs/fs_metaballs.bin.h

@@ -1,151 +0,0 @@
-static const uint8_t fs_metaballs_glsl[398] =
-{
-	0x46, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x00, 0x00, 0x7f, 0x01, 0x00, 0x00, 0x76, 0x61, // FSH..,.?......va
-	0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, // rying highp vec4
-	0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, //  v_color0;.varyi
-	0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x76, 0x5f, // ng highp vec3 v_
-	0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, // normal;.void mai
-	0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x66, // n ().{.  highp f
-	0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, // loat tmpvar_1;. 
-	0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x20, //  tmpvar_1 = dot 
-	0x28, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x28, 0x76, 0x5f, 0x6e, 0x6f, 0x72, // (normalize(v_nor
-	0x6d, 0x61, 0x6c, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, // mal), vec3(0.0, 
-	0x30, 0x2e, 0x30, 0x2c, 0x20, 0x2d, 0x31, 0x2e, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x6d, // 0.0, -1.0));.  m
-	0x65, 0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, // ediump vec4 tmpv
-	0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // ar_2;.  tmpvar_2
-	0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // .w = 1.0;.  tmpv
-	0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x70, 0x6f, 0x77, 0x20, 0x28, // ar_2.xyz = pow (
-	0x28, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x6f, 0x77, 0x20, 0x28, 0x76, 0x5f, 0x63, 0x6f, // ((.    pow (v_co
-	0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x28, 0x32, // lor0.xyz, vec3(2
-	0x2e, 0x32, 0x2c, 0x20, 0x32, 0x2e, 0x32, 0x2c, 0x20, 0x32, 0x2e, 0x32, 0x29, 0x29, 0x0a, 0x20, // .2, 2.2, 2.2)). 
-	0x20, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x20, 0x2b, 0x20, //   * tmpvar_1) + 
-	0x70, 0x6f, 0x77, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2c, 0x20, 0x33, // pow (tmpvar_1, 3
-	0x30, 0x2e, 0x30, 0x29, 0x29, 0x2c, 0x20, 0x76, 0x65, 0x63, 0x33, 0x28, 0x30, 0x2e, 0x34, 0x35, // 0.0)), vec3(0.45
-	0x34, 0x35, 0x34, 0x35, 0x34, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x35, 0x34, 0x35, 0x34, 0x35, 0x34, // 45454, 0.4545454
-	0x2c, 0x20, 0x30, 0x2e, 0x34, 0x35, 0x34, 0x35, 0x34, 0x35, 0x34, 0x29, 0x29, 0x3b, 0x0a, 0x20, // , 0.4545454));. 
-	0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, //  gl_FragColor = 
-	0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00,             // tmpvar_2;.}...
-};
-static const uint8_t fs_metaballs_dx9[433] =
-{
-	0x46, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x00, 0x00, 0xa4, 0x01, 0x00, 0x03, 0xff, 0xff, // FSH..,.?........
-	0xfe, 0xff, 0x17, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, // ....CTAB....#...
-	0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, // ................
-	0x1c, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, // ....ps_3_0.Micro
-	0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, // soft (R) HLSL Sh
-	0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, // ader Compiler 10
-	0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, // .0.10011.16384..
-	0x51, 0x00, 0x00, 0x05, 0x00, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0xf0, 0x41, 0xcd, 0xcc, 0x0c, 0x40, // Q..........A...@
-	0x2f, 0xba, 0xe8, 0x3e, 0x00, 0x00, 0x80, 0x3f, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, // /..>...?........
-	0x00, 0x00, 0x07, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x01, 0x80, 0x01, 0x00, 0x07, 0x90, // ................
-	0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x01, 0x00, 0xe4, 0x90, // ................
-	0x07, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x03, // ................
-	0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xaa, 0x90, 0x20, 0x00, 0x00, 0x03, // ............ ...
-	0x01, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0xa0, 0x0f, 0x00, 0x00, 0x02, // ................
-	0x02, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x90, 0x0f, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x80, // ................
-	0x00, 0x00, 0x55, 0x90, 0x0f, 0x00, 0x00, 0x02, 0x02, 0x00, 0x04, 0x80, 0x00, 0x00, 0xaa, 0x90, // ..U.............
-	0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0e, 0x80, 0x02, 0x00, 0x90, 0x80, 0x00, 0x00, 0x55, 0xa0, // ..............U.
-	0x0e, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x80, 0x00, 0x00, 0x55, 0x80, 0x0e, 0x00, 0x00, 0x02, // ..........U.....
-	0x02, 0x00, 0x02, 0x80, 0x00, 0x00, 0xaa, 0x80, 0x0e, 0x00, 0x00, 0x02, 0x02, 0x00, 0x04, 0x80, // ................
-	0x00, 0x00, 0xff, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x02, 0x00, 0xe4, 0x80, // ................
-	0x00, 0x00, 0x00, 0x81, 0x01, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x80, // ................
-	0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x02, 0x01, 0x00, 0x02, 0x80, 0x00, 0x00, 0x55, 0x80, // ..............U.
-	0x0f, 0x00, 0x00, 0x02, 0x01, 0x00, 0x04, 0x80, 0x00, 0x00, 0xaa, 0x80, 0x05, 0x00, 0x00, 0x03, // ................
-	0x00, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xaa, 0xa0, 0x0e, 0x00, 0x00, 0x02, // ................
-	0x00, 0x08, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, 0x0e, 0x00, 0x00, 0x02, 0x00, 0x08, 0x02, 0x80, // ................
-	0x00, 0x00, 0x55, 0x80, 0x0e, 0x00, 0x00, 0x02, 0x00, 0x08, 0x04, 0x80, 0x00, 0x00, 0xaa, 0x80, // ..U.............
-	0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x80, 0x00, 0x00, 0xff, 0xa0, 0xff, 0xff, 0x00, 0x00, // ................
-	0x00,                                                                                           // .
-};
-static const uint8_t fs_metaballs_dx11[660] =
-{
-	0x46, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x00, 0x00, 0x84, 0x02, 0x44, 0x58, 0x42, 0x43, // FSH..,.?....DXBC
-	0x71, 0x00, 0x85, 0x0b, 0x80, 0xfd, 0x1e, 0xdf, 0x09, 0x21, 0xdf, 0xe6, 0x3a, 0xef, 0x53, 0xf8, // q........!..:.S.
-	0x01, 0x00, 0x00, 0x00, 0x84, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, // ............,...
-	0xa0, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00, // ........ISGNl...
-	0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........P.......
-	0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, // ................
-	0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // ................
-	0x01, 0x00, 0x00, 0x00, 0x0f, 0x07, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // ........b.......
-	0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, // ................
-	0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, // SV_POSITION.COLO
-	0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e, // R.TEXCOORD..OSGN
-	0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, // ,........... ...
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, // ....SV_TARGET...
-	0x53, 0x48, 0x44, 0x52, 0xa8, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, // [email protected]...
-	0x62, 0x10, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, // b...r.......b...
-	0x72, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, // r.......e.... ..
-	0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x05, // ....h......./...
-	0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // r.......F.......
-	0x38, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, // 8...r.......F...
-	0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0x0c, 0x40, 0xcd, 0xcc, 0x0c, 0x40, // .....@.....@...@
-	0xcd, 0xcc, 0x0c, 0x40, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x05, 0x72, 0x00, 0x10, 0x00, // [email protected]...
-	0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x07, // ....F...........
-	0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x12, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, // ........F.......
-	0x46, 0x12, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, // F.......D.......
-	0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, // ....:.......8...
-	0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........:.......
-	0x2a, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x06, 0x12, 0x00, 0x10, 0x00, // *......./.......
-	0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....:...A.......
-	0x38, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, // 8...............
-	0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x41, 0x19, 0x00, 0x00, 0x05, // [email protected]....
-	0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
-	0x32, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, // 2...r.......F...
-	0x00, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........A.......
-	0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x05, 0x72, 0x00, 0x10, 0x00, // ......../...r...
-	0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, // ....F.......8...
-	0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // r.......F.......
-	0x02, 0x40, 0x00, 0x00, 0x2f, 0xba, 0xe8, 0x3e, 0x2f, 0xba, 0xe8, 0x3e, 0x2f, 0xba, 0xe8, 0x3e, // .@../..>/..>/..>
-	0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x05, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........r ......
-	0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, // F.......6.... ..
-	0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, // .....@.....?>...
-	0x00, 0x00, 0x00, 0x00,                                                                         // ....
-};
-static const uint8_t fs_metaballs_mtl[704] =
-{
-	0x46, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x00, 0x00, 0xb1, 0x02, 0x00, 0x00, 0x75, 0x73, // FSH..,.?......us
-	0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
-	0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
-	0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
-	0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // .  float4 v_colo
-	0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x76, 0x5f, 0x6e, // r0;.  float3 v_n
-	0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, // ormal;.};.struct
-	0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, //  xlatMtlShaderOu
-	0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, // tput {.  float4 
-	0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x7d, 0x3b, // gl_FragColor;.};
-	0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, // .struct xlatMtlS
-	0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x7d, // haderUniform {.}
-	0x3b, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, // ;.fragment xlatM
-	0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, // tlShaderOutput x
-	0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, // latMtlMain (xlat
-	0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, // MtlShaderInput _
-	0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, // mtl_i [[stage_in
-	0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, // ]], constant xla
-	0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, // tMtlShaderUnifor
-	0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, // m& _mtl_u [[buff
-	0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, // er(0)]]).{.  xla
-	0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, // tMtlShaderOutput
-	0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, //  _mtl_o;.  float
-	0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, //  tmpvar_1;.  tmp
-	0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x64, 0x6f, 0x74, 0x20, 0x28, 0x6e, 0x6f, 0x72, // var_1 = dot (nor
-	0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, // malize(_mtl_i.v_
-	0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x29, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x28, // normal), float3(
-	0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x2d, 0x31, 0x2e, 0x30, 0x29, 0x29, // 0.0, 0.0, -1.0))
-	0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // ;.  float4 tmpva
-	0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, // r_2;.  tmpvar_2.
-	0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // w = 1.0;.  tmpva
-	0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x70, 0x6f, 0x77, 0x20, 0x28, 0x28, // r_2.xyz = pow ((
-	0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x6f, 0x77, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // (.    pow (_mtl_
-	0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x2e, 0x78, 0x79, 0x7a, 0x2c, 0x20, // i.v_color0.xyz, 
-	0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x28, 0x32, 0x2e, 0x32, 0x2c, 0x20, 0x32, 0x2e, 0x32, 0x2c, // float3(2.2, 2.2,
-	0x20, 0x32, 0x2e, 0x32, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, //  2.2)).   * tmpv
-	0x61, 0x72, 0x5f, 0x31, 0x29, 0x20, 0x2b, 0x20, 0x70, 0x6f, 0x77, 0x20, 0x28, 0x74, 0x6d, 0x70, // ar_1) + pow (tmp
-	0x76, 0x61, 0x72, 0x5f, 0x31, 0x2c, 0x20, 0x33, 0x30, 0x2e, 0x30, 0x29, 0x29, 0x2c, 0x20, 0x66, // var_1, 30.0)), f
-	0x6c, 0x6f, 0x61, 0x74, 0x33, 0x28, 0x30, 0x2e, 0x34, 0x35, 0x34, 0x35, 0x34, 0x35, 0x34, 0x2c, // loat3(0.4545454,
-	0x20, 0x30, 0x2e, 0x34, 0x35, 0x34, 0x35, 0x34, 0x35, 0x34, 0x2c, 0x20, 0x30, 0x2e, 0x34, 0x35, //  0.4545454, 0.45
-	0x34, 0x35, 0x34, 0x35, 0x34, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // 45454));.  _mtl_
-	0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, // o.gl_FragColor =
-	0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, //  tmpvar_2;.  ret
-	0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // urn _mtl_o;.}...
-};

+ 0 - 16
third/bgfx/examples/02-metaballs/fs_metaballs.sc

@@ -1,16 +0,0 @@
-$input v_normal, v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	vec3 lightDir = vec3(0.0, 0.0, -1.0);
-	float ndotl = dot(normalize(v_normal), lightDir);
-	float spec = pow(ndotl, 30.0);
-	gl_FragColor = vec4(pow(pow(v_color0.xyz, vec3_splat(2.2) ) * ndotl + spec, vec3_splat(1.0/2.2) ), 1.0);
-}

+ 0 - 9
third/bgfx/examples/02-metaballs/makefile

@@ -1,9 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-include ../../scripts/shader-embeded.mk
-
-rebuild:
-	@make -s --no-print-directory clean all

+ 0 - 779
third/bgfx/examples/02-metaballs/metaballs.cpp

@@ -1,779 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-// embedded shaders
-#include "vs_metaballs.bin.h"
-#include "fs_metaballs.bin.h"
-
-struct PosNormalColorVertex
-{
-	float m_pos[3];
-	float m_normal[3];
-	uint32_t m_abgr;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Normal,   3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Color0,   4, bgfx::AttribType::Uint8, true)
-			.end();
-	};
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosNormalColorVertex::ms_decl;
-
-struct Grid
-{
-	Grid()
-		: m_val(0.0f)
-	{
-		m_normal[0] = 0.0f;
-		m_normal[1] = 0.0f;
-		m_normal[2] = 0.0f;
-	}
-
-	float m_val;
-	float m_normal[3];
-};
-
-// Triangulation tables taken from:
-// http://paulbourke.net/geometry/polygonise/
-
-static const uint16_t s_edges[256] =
-{
-	0x000, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
-	0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
-	0x190, 0x099, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
-	0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
-	0x230, 0x339, 0x033, 0x13a, 0x636, 0x73f, 0x435, 0x53c,
-	0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
-	0x3a0, 0x2a9, 0x1a3, 0x0aa, 0x7a6, 0x6af, 0x5a5, 0x4ac,
-	0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
-	0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
-	0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
-	0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0x0ff, 0x3f5, 0x2fc,
-	0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
-	0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x055, 0x15c,
-	0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
-	0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0x0cc,
-	0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
-	0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
-	0x0cc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
-	0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
-	0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
-	0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
-	0x2fc, 0x3f5, 0x0ff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
-	0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
-	0x36c, 0x265, 0x16f, 0x066, 0x76a, 0x663, 0x569, 0x460,
-	0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
-	0x4ac, 0x5a5, 0x6af, 0x7a6, 0x0aa, 0x1a3, 0x2a9, 0x3a0,
-	0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
-	0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x033, 0x339, 0x230,
-	0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
-	0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x099, 0x190,
-	0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
-	0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x000,
-};
-
-static const int8_t s_indices[256][16] =
-{
-	{  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  1,  9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  8,  3,  9,  8,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  3,  1,  2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  2, 10,  0,  2,  9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  8,  3,  2, 10,  8, 10,  9,  8, -1, -1, -1, -1, -1, -1, -1 },
-	{   3, 11,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0, 11,  2,  8, 11,  0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  9,  0,  2,  3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1, 11,  2,  1,  9, 11,  9,  8, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{   3, 10,  1, 11, 10,  3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0, 10,  1,  0,  8, 10,  8, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  9,  0,  3, 11,  9, 11, 10,  9, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  8, 10, 10,  8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  7,  8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  3,  0,  7,  3,  4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  1,  9,  8,  4,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  1,  9,  4,  7,  1,  7,  3,  1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2, 10,  8,  4,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  4,  7,  3,  0,  4,  1,  2, 10, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  2, 10,  9,  0,  2,  8,  4,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{   2, 10,  9,  2,  9,  7,  2,  7,  3,  7,  9,  4, -1, -1, -1, -1 },
-	{   8,  4,  7,  3, 11,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{  11,  4,  7, 11,  2,  4,  2,  0,  4, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  0,  1,  8,  4,  7,  2,  3, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  7, 11,  9,  4, 11,  9, 11,  2,  9,  2,  1, -1, -1, -1, -1 },
-	{   3, 10,  1,  3, 11, 10,  7,  8,  4, -1, -1, -1, -1, -1, -1, -1 },
-	{   1, 11, 10,  1,  4, 11,  1,  0,  4,  7, 11,  4, -1, -1, -1, -1 },
-	{   4,  7,  8,  9,  0, 11,  9, 11, 10, 11,  0,  3, -1, -1, -1, -1 },
-	{   4,  7, 11,  4, 11,  9,  9, 11, 10, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  5,  4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  5,  4,  0,  8,  3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  5,  4,  1,  5,  0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  5,  4,  8,  3,  5,  3,  1,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2, 10,  9,  5,  4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  0,  8,  1,  2, 10,  4,  9,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   5,  2, 10,  5,  4,  2,  4,  0,  2, -1, -1, -1, -1, -1, -1, -1 },
-	{   2, 10,  5,  3,  2,  5,  3,  5,  4,  3,  4,  8, -1, -1, -1, -1 },
-	{   9,  5,  4,  2,  3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0, 11,  2,  0,  8, 11,  4,  9,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  5,  4,  0,  1,  5,  2,  3, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  1,  5,  2,  5,  8,  2,  8, 11,  4,  8,  5, -1, -1, -1, -1 },
-	{  10,  3, 11, 10,  1,  3,  9,  5,  4, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  9,  5,  0,  8,  1,  8, 10,  1,  8, 11, 10, -1, -1, -1, -1 },
-	{   5,  4,  0,  5,  0, 11,  5, 11, 10, 11,  0,  3, -1, -1, -1, -1 },
-	{   5,  4,  8,  5,  8, 10, 10,  8, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  7,  8,  5,  7,  9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  3,  0,  9,  5,  3,  5,  7,  3, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  7,  8,  0,  1,  7,  1,  5,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  5,  3,  3,  5,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  7,  8,  9,  5,  7, 10,  1,  2, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  1,  2,  9,  5,  0,  5,  3,  0,  5,  7,  3, -1, -1, -1, -1 },
-	{   8,  0,  2,  8,  2,  5,  8,  5,  7, 10,  5,  2, -1, -1, -1, -1 },
-	{   2, 10,  5,  2,  5,  3,  3,  5,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{   7,  9,  5,  7,  8,  9,  3, 11,  2, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  5,  7,  9,  7,  2,  9,  2,  0,  2,  7, 11, -1, -1, -1, -1 },
-	{   2,  3, 11,  0,  1,  8,  1,  7,  8,  1,  5,  7, -1, -1, -1, -1 },
-	{  11,  2,  1, 11,  1,  7,  7,  1,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  5,  8,  8,  5,  7, 10,  1,  3, 10,  3, 11, -1, -1, -1, -1 },
-	{   5,  7,  0,  5,  0,  9,  7, 11,  0,  1,  0, 10, 11, 10,  0, -1 },
-	{  11, 10,  0, 11,  0,  3, 10,  5,  0,  8,  0,  7,  5,  7,  0, -1 },
-	{  11, 10,  5,  7, 11,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  6,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  3,  5, 10,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  0,  1,  5, 10,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  8,  3,  1,  9,  8,  5, 10,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  6,  5,  2,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  6,  5,  1,  2,  6,  3,  0,  8, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  6,  5,  9,  0,  6,  0,  2,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{   5,  9,  8,  5,  8,  2,  5,  2,  6,  3,  2,  8, -1, -1, -1, -1 },
-	{   2,  3, 11, 10,  6,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{  11,  0,  8, 11,  2,  0, 10,  6,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  1,  9,  2,  3, 11,  5, 10,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{   5, 10,  6,  1,  9,  2,  9, 11,  2,  9,  8, 11, -1, -1, -1, -1 },
-	{   6,  3, 11,  6,  5,  3,  5,  1,  3, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8, 11,  0, 11,  5,  0,  5,  1,  5, 11,  6, -1, -1, -1, -1 },
-	{   3, 11,  6,  0,  3,  6,  0,  6,  5,  0,  5,  9, -1, -1, -1, -1 },
-	{   6,  5,  9,  6,  9, 11, 11,  9,  8, -1, -1, -1, -1, -1, -1, -1 },
-	{   5, 10,  6,  4,  7,  8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  3,  0,  4,  7,  3,  6,  5, 10, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  9,  0,  5, 10,  6,  8,  4,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  6,  5,  1,  9,  7,  1,  7,  3,  7,  9,  4, -1, -1, -1, -1 },
-	{   6,  1,  2,  6,  5,  1,  4,  7,  8, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2,  5,  5,  2,  6,  3,  0,  4,  3,  4,  7, -1, -1, -1, -1 },
-	{   8,  4,  7,  9,  0,  5,  0,  6,  5,  0,  2,  6, -1, -1, -1, -1 },
-	{   7,  3,  9,  7,  9,  4,  3,  2,  9,  5,  9,  6,  2,  6,  9, -1 },
-	{   3, 11,  2,  7,  8,  4, 10,  6,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   5, 10,  6,  4,  7,  2,  4,  2,  0,  2,  7, 11, -1, -1, -1, -1 },
-	{   0,  1,  9,  4,  7,  8,  2,  3, 11,  5, 10,  6, -1, -1, -1, -1 },
-	{   9,  2,  1,  9, 11,  2,  9,  4, 11,  7, 11,  4,  5, 10,  6, -1 },
-	{   8,  4,  7,  3, 11,  5,  3,  5,  1,  5, 11,  6, -1, -1, -1, -1 },
-	{   5,  1, 11,  5, 11,  6,  1,  0, 11,  7, 11,  4,  0,  4, 11, -1 },
-	{   0,  5,  9,  0,  6,  5,  0,  3,  6, 11,  6,  3,  8,  4,  7, -1 },
-	{   6,  5,  9,  6,  9, 11,  4,  7,  9,  7, 11,  9, -1, -1, -1, -1 },
-	{  10,  4,  9,  6,  4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4, 10,  6,  4,  9, 10,  0,  8,  3, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  0,  1, 10,  6,  0,  6,  4,  0, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  3,  1,  8,  1,  6,  8,  6,  4,  6,  1, 10, -1, -1, -1, -1 },
-	{   1,  4,  9,  1,  2,  4,  2,  6,  4, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  0,  8,  1,  2,  9,  2,  4,  9,  2,  6,  4, -1, -1, -1, -1 },
-	{   0,  2,  4,  4,  2,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  3,  2,  8,  2,  4,  4,  2,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  4,  9, 10,  6,  4, 11,  2,  3, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  2,  2,  8, 11,  4,  9, 10,  4, 10,  6, -1, -1, -1, -1 },
-	{   3, 11,  2,  0,  1,  6,  0,  6,  4,  6,  1, 10, -1, -1, -1, -1 },
-	{   6,  4,  1,  6,  1, 10,  4,  8,  1,  2,  1, 11,  8, 11,  1, -1 },
-	{   9,  6,  4,  9,  3,  6,  9,  1,  3, 11,  6,  3, -1, -1, -1, -1 },
-	{   8, 11,  1,  8,  1,  0, 11,  6,  1,  9,  1,  4,  6,  4,  1, -1 },
-	{   3, 11,  6,  3,  6,  0,  0,  6,  4, -1, -1, -1, -1, -1, -1, -1 },
-	{   6,  4,  8, 11,  6,  8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   7, 10,  6,  7,  8, 10,  8,  9, 10, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  7,  3,  0, 10,  7,  0,  9, 10,  6,  7, 10, -1, -1, -1, -1 },
-	{  10,  6,  7,  1, 10,  7,  1,  7,  8,  1,  8,  0, -1, -1, -1, -1 },
-	{  10,  6,  7, 10,  7,  1,  1,  7,  3, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2,  6,  1,  6,  8,  1,  8,  9,  8,  6,  7, -1, -1, -1, -1 },
-	{   2,  6,  9,  2,  9,  1,  6,  7,  9,  0,  9,  3,  7,  3,  9, -1 },
-	{   7,  8,  0,  7,  0,  6,  6,  0,  2, -1, -1, -1, -1, -1, -1, -1 },
-	{   7,  3,  2,  6,  7,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  3, 11, 10,  6,  8, 10,  8,  9,  8,  6,  7, -1, -1, -1, -1 },
-	{   2,  0,  7,  2,  7, 11,  0,  9,  7,  6,  7, 10,  9, 10,  7, -1 },
-	{   1,  8,  0,  1,  7,  8,  1, 10,  7,  6,  7, 10,  2,  3, 11, -1 },
-	{  11,  2,  1, 11,  1,  7, 10,  6,  1,  6,  7,  1, -1, -1, -1, -1 },
-	{   8,  9,  6,  8,  6,  7,  9,  1,  6, 11,  6,  3,  1,  3,  6, -1 },
-	{   0,  9,  1, 11,  6,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   7,  8,  0,  7,  0,  6,  3, 11,  0, 11,  6,  0, -1, -1, -1, -1 },
-	{   7, 11,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   7,  6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  0,  8, 11,  7,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  1,  9, 11,  7,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  1,  9,  8,  3,  1, 11,  7,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  1,  2,  6, 11,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2, 10,  3,  0,  8,  6, 11,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  9,  0,  2, 10,  9,  6, 11,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{   6, 11,  7,  2, 10,  3, 10,  8,  3, 10,  9,  8, -1, -1, -1, -1 },
-	{   7,  2,  3,  6,  2,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   7,  0,  8,  7,  6,  0,  6,  2,  0, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  7,  6,  2,  3,  7,  0,  1,  9, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  6,  2,  1,  8,  6,  1,  9,  8,  8,  7,  6, -1, -1, -1, -1 },
-	{  10,  7,  6, 10,  1,  7,  1,  3,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  7,  6,  1,  7, 10,  1,  8,  7,  1,  0,  8, -1, -1, -1, -1 },
-	{   0,  3,  7,  0,  7, 10,  0, 10,  9,  6, 10,  7, -1, -1, -1, -1 },
-	{   7,  6, 10,  7, 10,  8,  8, 10,  9, -1, -1, -1, -1, -1, -1, -1 },
-	{   6,  8,  4, 11,  8,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  6, 11,  3,  0,  6,  0,  4,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  6, 11,  8,  4,  6,  9,  0,  1, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  4,  6,  9,  6,  3,  9,  3,  1, 11,  3,  6, -1, -1, -1, -1 },
-	{   6,  8,  4,  6, 11,  8,  2, 10,  1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2, 10,  3,  0, 11,  0,  6, 11,  0,  4,  6, -1, -1, -1, -1 },
-	{   4, 11,  8,  4,  6, 11,  0,  2,  9,  2, 10,  9, -1, -1, -1, -1 },
-	{  10,  9,  3, 10,  3,  2,  9,  4,  3, 11,  3,  6,  4,  6,  3, -1 },
-	{   8,  2,  3,  8,  4,  2,  4,  6,  2, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  4,  2,  4,  6,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  9,  0,  2,  3,  4,  2,  4,  6,  4,  3,  8, -1, -1, -1, -1 },
-	{   1,  9,  4,  1,  4,  2,  2,  4,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  1,  3,  8,  6,  1,  8,  4,  6,  6, 10,  1, -1, -1, -1, -1 },
-	{  10,  1,  0, 10,  0,  6,  6,  0,  4, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  6,  3,  4,  3,  8,  6, 10,  3,  0,  3,  9, 10,  9,  3, -1 },
-	{  10,  9,  4,  6, 10,  4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  9,  5,  7,  6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  3,  4,  9,  5, 11,  7,  6, -1, -1, -1, -1, -1, -1, -1 },
-	{   5,  0,  1,  5,  4,  0,  7,  6, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{  11,  7,  6,  8,  3,  4,  3,  5,  4,  3,  1,  5, -1, -1, -1, -1 },
-	{   9,  5,  4, 10,  1,  2,  7,  6, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{   6, 11,  7,  1,  2, 10,  0,  8,  3,  4,  9,  5, -1, -1, -1, -1 },
-	{   7,  6, 11,  5,  4, 10,  4,  2, 10,  4,  0,  2, -1, -1, -1, -1 },
-	{   3,  4,  8,  3,  5,  4,  3,  2,  5, 10,  5,  2, 11,  7,  6, -1 },
-	{   7,  2,  3,  7,  6,  2,  5,  4,  9, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  5,  4,  0,  8,  6,  0,  6,  2,  6,  8,  7, -1, -1, -1, -1 },
-	{   3,  6,  2,  3,  7,  6,  1,  5,  0,  5,  4,  0, -1, -1, -1, -1 },
-	{   6,  2,  8,  6,  8,  7,  2,  1,  8,  4,  8,  5,  1,  5,  8, -1 },
-	{   9,  5,  4, 10,  1,  6,  1,  7,  6,  1,  3,  7, -1, -1, -1, -1 },
-	{   1,  6, 10,  1,  7,  6,  1,  0,  7,  8,  7,  0,  9,  5,  4, -1 },
-	{   4,  0, 10,  4, 10,  5,  0,  3, 10,  6, 10,  7,  3,  7, 10, -1 },
-	{   7,  6, 10,  7, 10,  8,  5,  4, 10,  4,  8, 10, -1, -1, -1, -1 },
-	{   6,  9,  5,  6, 11,  9, 11,  8,  9, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  6, 11,  0,  6,  3,  0,  5,  6,  0,  9,  5, -1, -1, -1, -1 },
-	{   0, 11,  8,  0,  5, 11,  0,  1,  5,  5,  6, 11, -1, -1, -1, -1 },
-	{   6, 11,  3,  6,  3,  5,  5,  3,  1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2, 10,  9,  5, 11,  9, 11,  8, 11,  5,  6, -1, -1, -1, -1 },
-	{   0, 11,  3,  0,  6, 11,  0,  9,  6,  5,  6,  9,  1,  2, 10, -1 },
-	{  11,  8,  5, 11,  5,  6,  8,  0,  5, 10,  5,  2,  0,  2,  5, -1 },
-	{   6, 11,  3,  6,  3,  5,  2, 10,  3, 10,  5,  3, -1, -1, -1, -1 },
-	{   5,  8,  9,  5,  2,  8,  5,  6,  2,  3,  8,  2, -1, -1, -1, -1 },
-	{   9,  5,  6,  9,  6,  0,  0,  6,  2, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  5,  8,  1,  8,  0,  5,  6,  8,  3,  8,  2,  6,  2,  8, -1 },
-	{   1,  5,  6,  2,  1,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  3,  6,  1,  6, 10,  3,  8,  6,  5,  6,  9,  8,  9,  6, -1 },
-	{  10,  1,  0, 10,  0,  6,  9,  5,  0,  5,  6,  0, -1, -1, -1, -1 },
-	{   0,  3,  8,  5,  6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  5,  6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{  11,  5, 10,  7,  5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{  11,  5, 10, 11,  7,  5,  8,  3,  0, -1, -1, -1, -1, -1, -1, -1 },
-	{   5, 11,  7,  5, 10, 11,  1,  9,  0, -1, -1, -1, -1, -1, -1, -1 },
-	{  10,  7,  5, 10, 11,  7,  9,  8,  1,  8,  3,  1, -1, -1, -1, -1 },
-	{  11,  1,  2, 11,  7,  1,  7,  5,  1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  3,  1,  2,  7,  1,  7,  5,  7,  2, 11, -1, -1, -1, -1 },
-	{   9,  7,  5,  9,  2,  7,  9,  0,  2,  2, 11,  7, -1, -1, -1, -1 },
-	{   7,  5,  2,  7,  2, 11,  5,  9,  2,  3,  2,  8,  9,  8,  2, -1 },
-	{   2,  5, 10,  2,  3,  5,  3,  7,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  2,  0,  8,  5,  2,  8,  7,  5, 10,  2,  5, -1, -1, -1, -1 },
-	{   9,  0,  1,  5, 10,  3,  5,  3,  7,  3, 10,  2, -1, -1, -1, -1 },
-	{   9,  8,  2,  9,  2,  1,  8,  7,  2, 10,  2,  5,  7,  5,  2, -1 },
-	{   1,  3,  5,  3,  7,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  7,  0,  7,  1,  1,  7,  5, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  0,  3,  9,  3,  5,  5,  3,  7, -1, -1, -1, -1, -1, -1, -1 },
-	{   9,  8,  7,  5,  9,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   5,  8,  4,  5, 10,  8, 10, 11,  8, -1, -1, -1, -1, -1, -1, -1 },
-	{   5,  0,  4,  5, 11,  0,  5, 10, 11, 11,  3,  0, -1, -1, -1, -1 },
-	{   0,  1,  9,  8,  4, 10,  8, 10, 11, 10,  4,  5, -1, -1, -1, -1 },
-	{  10, 11,  4, 10,  4,  5, 11,  3,  4,  9,  4,  1,  3,  1,  4, -1 },
-	{   2,  5,  1,  2,  8,  5,  2, 11,  8,  4,  5,  8, -1, -1, -1, -1 },
-	{   0,  4, 11,  0, 11,  3,  4,  5, 11,  2, 11,  1,  5,  1, 11, -1 },
-	{   0,  2,  5,  0,  5,  9,  2, 11,  5,  4,  5,  8, 11,  8,  5, -1 },
-	{   9,  4,  5,  2, 11,  3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  5, 10,  3,  5,  2,  3,  4,  5,  3,  8,  4, -1, -1, -1, -1 },
-	{   5, 10,  2,  5,  2,  4,  4,  2,  0, -1, -1, -1, -1, -1, -1, -1 },
-	{   3, 10,  2,  3,  5, 10,  3,  8,  5,  4,  5,  8,  0,  1,  9, -1 },
-	{   5, 10,  2,  5,  2,  4,  1,  9,  2,  9,  4,  2, -1, -1, -1, -1 },
-	{   8,  4,  5,  8,  5,  3,  3,  5,  1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  4,  5,  1,  0,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   8,  4,  5,  8,  5,  3,  9,  0,  5,  0,  3,  5, -1, -1, -1, -1 },
-	{   9,  4,  5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4, 11,  7,  4,  9, 11,  9, 10, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  8,  3,  4,  9,  7,  9, 11,  7,  9, 10, 11, -1, -1, -1, -1 },
-	{   1, 10, 11,  1, 11,  4,  1,  4,  0,  7,  4, 11, -1, -1, -1, -1 },
-	{   3,  1,  4,  3,  4,  8,  1, 10,  4,  7,  4, 11, 10, 11,  4, -1 },
-	{   4, 11,  7,  9, 11,  4,  9,  2, 11,  9,  1,  2, -1, -1, -1, -1 },
-	{   9,  7,  4,  9, 11,  7,  9,  1, 11,  2, 11,  1,  0,  8,  3, -1 },
-	{  11,  7,  4, 11,  4,  2,  2,  4,  0, -1, -1, -1, -1, -1, -1, -1 },
-	{  11,  7,  4, 11,  4,  2,  8,  3,  4,  3,  2,  4, -1, -1, -1, -1 },
-	{   2,  9, 10,  2,  7,  9,  2,  3,  7,  7,  4,  9, -1, -1, -1, -1 },
-	{   9, 10,  7,  9,  7,  4, 10,  2,  7,  8,  7,  0,  2,  0,  7, -1 },
-	{   3,  7, 10,  3, 10,  2,  7,  4, 10,  1, 10,  0,  4,  0, 10, -1 },
-	{   1, 10,  2,  8,  7,  4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  9,  1,  4,  1,  7,  7,  1,  3, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  9,  1,  4,  1,  7,  0,  8,  1,  8,  7,  1, -1, -1, -1, -1 },
-	{   4,  0,  3,  7,  4,  3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   4,  8,  7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   9, 10,  8, 10, 11,  8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  0,  9,  3,  9, 11, 11,  9, 10, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  1, 10,  0, 10,  8,  8, 10, 11, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  1, 10, 11,  3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  2, 11,  1, 11,  9,  9, 11,  8, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  0,  9,  3,  9, 11,  1,  2,  9,  2, 11,  9, -1, -1, -1, -1 },
-	{   0,  2, 11,  8,  0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   3,  2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  3,  8,  2,  8, 10, 10,  8,  9, -1, -1, -1, -1, -1, -1, -1 },
-	{   9, 10,  2,  0,  9,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   2,  3,  8,  2,  8, 10,  0,  1,  8,  1, 10,  8, -1, -1, -1, -1 },
-	{   1, 10,  2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   1,  3,  8,  9,  1,  8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  9,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{   0,  3,  8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-	{  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
-};
-
-static const float s_cube[8][3] =
-{
-	{ 0.0f, 1.0f, 1.0f }, // 0
-	{ 1.0f, 1.0f, 1.0f }, // 1
-	{ 1.0f, 1.0f, 0.0f }, // 2
-	{ 0.0f, 1.0f, 0.0f }, // 3
-	{ 0.0f, 0.0f, 1.0f }, // 4
-	{ 1.0f, 0.0f, 1.0f }, // 5
-	{ 1.0f, 0.0f, 0.0f }, // 6
-	{ 0.0f, 0.0f, 0.0f }, // 7
-};
-
-float vertLerp(float* __restrict _result, float _iso, uint32_t _idx0, float _v0, uint32_t _idx1, float _v1)
-{
-	const float* __restrict edge0 = s_cube[_idx0];
-	const float* __restrict edge1 = s_cube[_idx1];
-
-	if (fabsf(_iso-_v1) < 0.00001f)
-	{
-		_result[0] = edge1[0];
-		_result[1] = edge1[1];
-		_result[2] = edge1[2];
-		return 1.0f;
-	}
-
-	if (fabsf(_iso-_v0) < 0.00001f
-	||  fabsf(_v0-_v1) < 0.00001f)
-	{
-		_result[0] = edge0[0];
-		_result[1] = edge0[1];
-		_result[2] = edge0[2];
-		return 0.0f;
-	}
-
-	float lerp = (_iso - _v0) / (_v1 - _v0);
-	_result[0] = edge0[0] + lerp * (edge1[0] - edge0[0]);
-	_result[1] = edge0[1] + lerp * (edge1[1] - edge0[1]);
-	_result[2] = edge0[2] + lerp * (edge1[2] - edge0[2]);
-
-	return lerp;
-}
-
-uint32_t triangulate(uint8_t* _result, uint32_t _stride, const float* __restrict _rgb, const float* __restrict _xyz, const Grid* _val[8], float _iso)
-{
-	uint8_t cubeindex = 0;
-	cubeindex |= (_val[0]->m_val < _iso) ? 0x01 : 0;
-	cubeindex |= (_val[1]->m_val < _iso) ? 0x02 : 0;
-	cubeindex |= (_val[2]->m_val < _iso) ? 0x04 : 0;
-	cubeindex |= (_val[3]->m_val < _iso) ? 0x08 : 0;
-	cubeindex |= (_val[4]->m_val < _iso) ? 0x10 : 0;
-	cubeindex |= (_val[5]->m_val < _iso) ? 0x20 : 0;
-	cubeindex |= (_val[6]->m_val < _iso) ? 0x40 : 0;
-	cubeindex |= (_val[7]->m_val < _iso) ? 0x80 : 0;
-
-	if (0 == s_edges[cubeindex])
-	{
-		return 0;
-	}
-
-	float verts[12][6];
-	uint16_t flags = s_edges[cubeindex];
-
-	for (uint32_t ii = 0; ii < 12; ++ii)
-	{
-		if (flags & (1<<ii) )
-		{
-			uint32_t idx0 = ii&7;
-			uint32_t idx1 = "\x1\x2\x3\x0\x5\x6\x7\x4\x4\x5\x6\x7"[ii];
-			float* vertex = verts[ii];
-			float lerp = vertLerp(vertex, _iso, idx0, _val[idx0]->m_val, idx1, _val[idx1]->m_val);
-
-			const float* na = _val[idx0]->m_normal;
-			const float* nb = _val[idx1]->m_normal;
-			vertex[3] = na[0] + lerp * (nb[0] - na[0]);
-			vertex[4] = na[1] + lerp * (nb[1] - na[1]);
-			vertex[5] = na[2] + lerp * (nb[2] - na[2]);
-		}
-	}
-
-	float dr = _rgb[3] - _rgb[0];
-	float dg = _rgb[4] - _rgb[1];
-	float db = _rgb[5] - _rgb[2];
-
-	uint32_t num = 0;
-	const int8_t* indices = s_indices[cubeindex];
-	for (uint32_t ii = 0; indices[ii] != -1; ++ii)
-	{
-		const float* vertex = verts[uint8_t(indices[ii])];
-
-		float* xyz = (float*)_result;
-		xyz[0] = _xyz[0] + vertex[0];
-		xyz[1] = _xyz[1] + vertex[1];
-		xyz[2] = _xyz[2] + vertex[2];
-
-		xyz[3] = vertex[3];
-		xyz[4] = vertex[4];
-		xyz[5] = vertex[5];
-
-		uint32_t rr = uint8_t( (_rgb[0] + vertex[0]*dr)*255.0f);
-		uint32_t gg = uint8_t( (_rgb[1] + vertex[1]*dg)*255.0f);
-		uint32_t bb = uint8_t( (_rgb[2] + vertex[2]*db)*255.0f);
-
-		uint32_t* abgr = (uint32_t*)&_result[24];
-		*abgr = 0xff000000
-			  | (bb<<16)
-			  | (gg<<8)
-			  | rr
-			  ;
-
-		_result += _stride;
-		++num;
-	}
-
-	return num;
-}
-
-#define DIMS 32
-
-class ExampleMetaballs : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-				, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-				, 0x303030ff
-				, 1.0f
-				, 0
-				);
-
-		// Create vertex stream declaration.
-		PosNormalColorVertex::init();
-
-		const bgfx::Memory* vs_metaballs;
-		const bgfx::Memory* fs_metaballs;
-
-		switch (bgfx::getRendererType() )
-		{
-			case bgfx::RendererType::Direct3D9:
-				vs_metaballs = bgfx::makeRef(vs_metaballs_dx9, sizeof(vs_metaballs_dx9) );
-				fs_metaballs = bgfx::makeRef(fs_metaballs_dx9, sizeof(fs_metaballs_dx9) );
-				break;
-
-			case bgfx::RendererType::Direct3D11:
-			case bgfx::RendererType::Direct3D12:
-				vs_metaballs = bgfx::makeRef(vs_metaballs_dx11, sizeof(vs_metaballs_dx11) );
-				fs_metaballs = bgfx::makeRef(fs_metaballs_dx11, sizeof(fs_metaballs_dx11) );
-				break;
-
-			case bgfx::RendererType::Metal:
-				vs_metaballs = bgfx::makeRef(vs_metaballs_mtl, sizeof(vs_metaballs_mtl) );
-				fs_metaballs = bgfx::makeRef(fs_metaballs_mtl, sizeof(fs_metaballs_mtl) );
-				break;
-
-			default:
-				vs_metaballs = bgfx::makeRef(vs_metaballs_glsl, sizeof(vs_metaballs_glsl) );
-				fs_metaballs = bgfx::makeRef(fs_metaballs_glsl, sizeof(fs_metaballs_glsl) );
-				break;
-		}
-
-		bgfx::ShaderHandle vsh = bgfx::createShader(vs_metaballs);
-		bgfx::ShaderHandle fsh = bgfx::createShader(fs_metaballs);
-
-		// Create program from shaders.
-		m_program = bgfx::createProgram(vsh, fsh, true /* destroy shaders when program is destroyed */);
-
-		m_grid = new Grid[DIMS*DIMS*DIMS];
-		m_timeOffset = bx::getHPCounter();
-	}
-
-	int shutdown() BX_OVERRIDE
-	{
-		delete [] m_grid;
-
-		// Cleanup.
-		bgfx::destroyProgram(m_program);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		const uint32_t ypitch = DIMS;
-		const uint32_t zpitch = DIMS*DIMS;
-		const float invdim = 1.0f/float(DIMS-1);
-
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			// Set view 0 default viewport.
-			bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-			float time = (float)( (now - m_timeOffset)/double(bx::getHPFrequency() ) );
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/02-metaball");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Rendering with transient buffers and embedding shaders.");
-
-			float at[3]  = { 0.0f, 0.0f,   0.0f };
-			float eye[3] = { 0.0f, 0.0f, -50.0f };
-
-			// Set view and projection matrix for view 0.
-			const bgfx::HMD* hmd = bgfx::getHMD();
-			if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-			{
-				float view[16];
-				bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
-				bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
-
-				// Set view 0 default viewport.
-				//
-				// Use HMD's width/height since HMD's internal frame buffer size
-				// might be much larger than window size.
-				bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-			}
-			else
-			{
-				float view[16];
-				bx::mtxLookAt(view, eye, at);
-
-				float proj[16];
-				bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-				bgfx::setViewTransform(0, view, proj);
-
-				// Set view 0 default viewport.
-				bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-			}
-
-			// Stats.
-			uint32_t numVertices = 0;
-			int64_t profUpdate = 0;
-			int64_t profNormal = 0;
-			int64_t profTriangulate = 0;
-
-			// Allocate 32K vertices in transient vertex buffer.
-			uint32_t maxVertices = (32<<10);
-			bgfx::TransientVertexBuffer tvb;
-			bgfx::allocTransientVertexBuffer(&tvb, maxVertices, PosNormalColorVertex::ms_decl);
-
-			const uint32_t numSpheres = 16;
-			float sphere[numSpheres][4];
-			for (uint32_t ii = 0; ii < numSpheres; ++ii)
-			{
-				sphere[ii][0] = sinf(time*(ii*0.21f)+ii*0.37f) * (DIMS * 0.5f - 8.0f);
-				sphere[ii][1] = sinf(time*(ii*0.37f)+ii*0.67f) * (DIMS * 0.5f - 8.0f);
-				sphere[ii][2] = cosf(time*(ii*0.11f)+ii*0.13f) * (DIMS * 0.5f - 8.0f);
-				sphere[ii][3] = 1.0f/(2.0f + (sinf(time*(ii*0.13f) )*0.5f+0.5f)*2.0f);
-			}
-
-			profUpdate = bx::getHPCounter();
-
-			for (uint32_t zz = 0; zz < DIMS; ++zz)
-			{
-				for (uint32_t yy = 0; yy < DIMS; ++yy)
-				{
-					uint32_t offset = (zz*DIMS+yy)*DIMS;
-
-					for (uint32_t xx = 0; xx < DIMS; ++xx)
-					{
-						uint32_t xoffset = offset + xx;
-
-						float dist = 0.0f;
-						float prod = 1.0f;
-						for (uint32_t ii = 0; ii < numSpheres; ++ii)
-						{
-							const float* pos = sphere[ii];
-							float dx = pos[0] - (-DIMS*0.5f + float(xx) );
-							float dy = pos[1] - (-DIMS*0.5f + float(yy) );
-							float dz = pos[2] - (-DIMS*0.5f + float(zz) );
-							float invr = pos[3];
-							float dot = dx*dx + dy*dy + dz*dz;
-							dot *= invr*invr;
-
-							dist *= dot;
-							dist += prod;
-							prod *= dot;
-						}
-
-						m_grid[xoffset].m_val = dist / prod - 1.0f;
-					}
-				}
-			}
-
-			profUpdate = bx::getHPCounter() - profUpdate;
-
-			profNormal = bx::getHPCounter();
-
-			for (uint32_t zz = 1; zz < DIMS-1; ++zz)
-			{
-				for (uint32_t yy = 1; yy < DIMS-1; ++yy)
-				{
-					uint32_t offset = (zz*DIMS+yy)*DIMS;
-
-					for (uint32_t xx = 1; xx < DIMS-1; ++xx)
-					{
-						uint32_t xoffset = offset + xx;
-
-						Grid* grid = m_grid;
-						float normal[3] =
-						{
-							grid[xoffset-1     ].m_val - grid[xoffset+1     ].m_val,
-							grid[xoffset-ypitch].m_val - grid[xoffset+ypitch].m_val,
-							grid[xoffset-zpitch].m_val - grid[xoffset+zpitch].m_val,
-						};
-
-						bx::vec3Norm(grid[xoffset].m_normal, normal);
-					}
-				}
-			}
-
-			profNormal = bx::getHPCounter() - profNormal;
-
-			profTriangulate = bx::getHPCounter();
-
-			PosNormalColorVertex* vertex = (PosNormalColorVertex*)tvb.data;
-
-			for (uint32_t zz = 0; zz < DIMS-1 && numVertices+12 < maxVertices; ++zz)
-			{
-				float rgb[6];
-				rgb[2] = zz*invdim;
-				rgb[5] = (zz+1)*invdim;
-
-				for (uint32_t yy = 0; yy < DIMS-1 && numVertices+12 < maxVertices; ++yy)
-				{
-					uint32_t offset = (zz*DIMS+yy)*DIMS;
-
-					rgb[1] = yy*invdim;
-					rgb[4] = (yy+1)*invdim;
-
-					for (uint32_t xx = 0; xx < DIMS-1 && numVertices+12 < maxVertices; ++xx)
-					{
-						uint32_t xoffset = offset + xx;
-
-						rgb[0] = xx*invdim;
-						rgb[3] = (xx+1)*invdim;
-
-						float pos[3] =
-						{
-							-DIMS*0.5f + float(xx),
-							-DIMS*0.5f + float(yy),
-							-DIMS*0.5f + float(zz)
-						};
-
-						const Grid* grid = m_grid;
-						const Grid* val[8] = {
-							&grid[xoffset+zpitch+ypitch  ],
-							&grid[xoffset+zpitch+ypitch+1],
-							&grid[xoffset+ypitch+1       ],
-							&grid[xoffset+ypitch         ],
-							&grid[xoffset+zpitch         ],
-							&grid[xoffset+zpitch+1       ],
-							&grid[xoffset+1              ],
-							&grid[xoffset                ],
-						};
-
-						uint32_t num = triangulate( (uint8_t*)vertex, PosNormalColorVertex::ms_decl.getStride(), rgb, pos, val, 0.5f);
-						vertex += num;
-						numVertices += num;
-					}
-				}
-			}
-
-			profTriangulate = bx::getHPCounter() - profTriangulate;
-
-			float mtx[16];
-			bx::mtxRotateXY(mtx, time*0.67f, time);
-
-			// Set model matrix for rendering.
-			bgfx::setTransform(mtx);
-
-			// Set vertex and index buffer.
-			bgfx::setVertexBuffer(&tvb, 0, numVertices);
-
-			// Set render states.
-			bgfx::setState(BGFX_STATE_DEFAULT);
-
-			// Submit primitive for rendering to view 0.
-			bgfx::submit(0, m_program);
-
-			// Display stats.
-			bgfx::dbgTextPrintf(1, 4, 0x0f, "Num vertices: %5d (%6.4f%%)", numVertices, float(numVertices)/maxVertices * 100);
-			bgfx::dbgTextPrintf(1, 5, 0x0f, "      Update: % 7.3f[ms]", double(profUpdate)*toMs);
-			bgfx::dbgTextPrintf(1, 6, 0x0f, "Calc normals: % 7.3f[ms]", double(profNormal)*toMs);
-			bgfx::dbgTextPrintf(1, 7, 0x0f, " Triangulate: % 7.3f[ms]", double(profTriangulate)*toMs);
-			bgfx::dbgTextPrintf(1, 8, 0x0f, "       Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-	bgfx::ProgramHandle m_program;
-
-	Grid* m_grid;
-	int64_t m_timeOffset;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleMetaballs);

BIN
third/bgfx/examples/02-metaballs/screenshot.png


+ 0 - 6
third/bgfx/examples/02-metaballs/varying.def.sc

@@ -1,6 +0,0 @@
-vec3 v_normal    : TEXCOORD1 = vec3(0.0, 0.0, 1.0);
-vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
-
-vec3 a_position  : POSITION;
-vec3 a_normal    : NORMAL;
-vec4 a_color0    : COLOR0;

+ 0 - 175
third/bgfx/examples/02-metaballs/vs_metaballs.bin.h

@@ -1,175 +0,0 @@
-static const uint8_t vs_metaballs_glsl[537] =
-{
-	0x56, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x02, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH..,.?...u_mod
-	0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x20, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // el. .. ..u_model
-	0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0xe6, 0x01, // ViewProj........
-	0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, // ..attribute high
-	0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, // p vec4 a_color0;
-	0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // .attribute highp
-	0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0a, //  vec3 a_normal;.
-	0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, // attribute highp 
-	0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, // vec3 a_position;
-	0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, // .varying highp v
-	0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x61, // ec4 v_color0;.va
-	0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, // rying highp vec3
-	0x20, 0x76, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, //  v_normal;.unifo
-	0x72, 0x6d, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, // rm mat4 u_model[
-	0x33, 0x32, 0x5d, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, // 32];.uniform hig
-	0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, // hp mat4 u_modelV
-	0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, // iewProj;.void ma
-	0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, // in ().{.  highp 
-	0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, // vec4 tmpvar_1;. 
-	0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, //  tmpvar_1.w = 1.
-	0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, // 0;.  tmpvar_1.xy
-	0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, // z = a_position;.
-	0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, //   gl_Position = 
-	0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, // (u_modelViewProj
-	0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, //  * tmpvar_1);.  
-	0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // highp vec4 tmpva
-	0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, // r_2;.  tmpvar_2.
-	0x77, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // w = 0.0;.  tmpva
-	0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, // r_2.xyz = a_norm
-	0x61, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x20, 0x3d, // al;.  v_normal =
-	0x20, 0x28, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x30, 0x5d, 0x20, 0x2a, 0x20, 0x74, //  (u_model[0] * t
-	0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, // mpvar_2).xyz;.  
-	0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, // v_color0 = a_col
-	0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00,                                           // or0;.}...
-};
-static const uint8_t vs_metaballs_dx9[461] =
-{
-	0x56, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x02, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH..,.?...u_mod
-	0x65, 0x6c, 0x04, 0x20, 0x04, 0x00, 0x03, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // el. .....u_model
-	0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, 0x9c, 0x01, // ViewProj........
-	0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x2f, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, // ....../.CTAB....
-	0x83, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, // ................
-	0x00, 0x91, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x00, // ....|...D.......
-	0x03, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, // ....L...........
-	0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........l.......
-	0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, // u_model.........
-	0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, //  .......u_modelV
-	0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, // iewProj.........
-	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, // ........vs_3_0.M
-	0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, // icrosoft (R) HLS
-	0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, // L Shader Compile
-	0x72, 0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, // r 10.0.10011.163
-	0x38, 0x34, 0x00, 0xab, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, // 84..............
-	0x1f, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, // ................
-	0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, // ................
-	0x00, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0xe0, // ................
-	0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x01, 0x80, 0x02, 0x00, 0x07, 0xe0, 0x05, 0x00, 0x00, 0x03, // ................
-	0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, // ..........U.....
-	0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, // ................
-	0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, // ................
-	0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, // ................
-	0x03, 0x00, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80, 0x05, 0x00, 0xe4, 0xa0, // ................
-	0x01, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x04, 0x00, 0xe4, 0xa0, // ..U.............
-	0x01, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x07, 0xe0, // ................
-	0x06, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, // ................
-	0x01, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00,                   // .............
-};
-static const uint8_t vs_metaballs_dx11[726] =
-{
-	0x56, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x02, 0x00, 0x07, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH..,.?...u_mod
-	0x65, 0x6c, 0x04, 0x20, 0x00, 0x00, 0x80, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, // el. .....u_model
-	0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x00, 0x00, 0x08, 0x04, 0x00, 0x9c, 0x02, // ViewProj........
-	0x44, 0x58, 0x42, 0x43, 0xc6, 0x4d, 0x04, 0x38, 0x93, 0x20, 0x89, 0x1c, 0xbe, 0x68, 0xbc, 0xd4, // DXBC.M.8. ...h..
-	0xee, 0x2f, 0x8a, 0xe9, 0x01, 0x00, 0x00, 0x00, 0x9c, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // ./..............
-	0x2c, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, // ,...........ISGN
-	0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // h...........P...
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x0f, 0x0f, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....V...........
-	0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, // ............]...
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ................
-	0x07, 0x07, 0x00, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, // ....COLOR.NORMAL
-	0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, // .POSITION...OSGN
-	0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, // l...........P...
-	0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
-	0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, // ............b...
-	0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ................
-	0x07, 0x08, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, // ....SV_POSITION.
-	0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, // COLOR.TEXCOORD..
-	0x53, 0x48, 0x44, 0x52, 0x84, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x61, 0x00, 0x00, 0x00, // [email protected]...
-	0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, // Y...F. .........
-	0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, // _..........._...
-	0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, // r......._...r...
-	0x02, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....g.... ......
-	0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ....e.... ......
-	0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, // e...r ......h...
-	0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....8...........
-	0x56, 0x15, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // V.......F. .....
-	0x81, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....2...........
-	0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, // F. .............
-	0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, // ....F.......2...
-	0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // ........F. .....
-	0x82, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, // ............F...
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ......... ......
-	0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // F.......F. .....
-	0x83, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ....6.... ......
-	0x46, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, // F.......8...r...
-	0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, // ....V.......F. .
-	0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, // ........2...r...
-	0x00, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....F. .........
-	0x06, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........F.......
-	0x32, 0x00, 0x00, 0x0a, 0x72, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, // 2...r ......F. .
-	0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
-	0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x03, 0x05, 0x00, // F.......>.......
-	0x02, 0x00, 0x01, 0x00, 0x40, 0x08,                                                             // ....@.
-};
-static const uint8_t vs_metaballs_mtl[855] =
-{
-	0x56, 0x53, 0x48, 0x04, 0x03, 0x2c, 0xf5, 0x3f, 0x00, 0x00, 0x48, 0x03, 0x00, 0x00, 0x75, 0x73, // VSH..,.?..H...us
-	0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
-	0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
-	0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
-	0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // .  float4 a_colo
-	0x72, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, // r0 [[attribute(0
-	0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, // )]];.  float3 a_
-	0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, // normal [[attribu
-	0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // te(1)]];.  float
-	0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, // 3 a_position [[a
-	0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x32, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, // ttribute(2)]];.}
-	0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // ;.struct xlatMtl
-	0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, // ShaderOutput {. 
-	0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, //  float4 gl_Posit
-	0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, // ion [[position]]
-	0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, // ;.  float4 v_col
-	0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x76, 0x5f, // or0;.  float3 v_
-	0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, // normal;.};.struc
-	0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, // t xlatMtlShaderU
-	0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // niform {.  float
-	0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x33, 0x32, 0x5d, 0x3b, // 4x4 u_model[32];
-	0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, // .  float4x4 u_mo
-	0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, // delViewProj;.};.
-	0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // vertex xlatMtlSh
-	0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, // aderOutput xlatM
-	0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, // tlMain (xlatMtlS
-	0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // haderInput _mtl_
-	0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, // i [[stage_in]], 
-	0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // constant xlatMtl
-	0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, // ShaderUniform& _
-	0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, // mtl_u [[buffer(0
-	0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // )]]).{.  xlatMtl
-	0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, // ShaderOutput _mt
-	0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, // l_o;.  float4 tm
-	0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // pvar_1;.  tmpvar
-	0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // _1.w = 1.0;.  tm
-	0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, // pvar_1.xyz = _mt
-	0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, // l_i.a_position;.
-	0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, //   _mtl_o.gl_Posi
-	0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, // tion = (_mtl_u.u
-	0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, // _modelViewProj *
-	0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, //  tmpvar_1);.  fl
-	0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, // oat4 tmpvar_2;. 
-	0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x30, 0x2e, //  tmpvar_2.w = 0.
-	0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, // 0;.  tmpvar_2.xy
-	0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x6e, 0x6f, 0x72, // z = _mtl_i.a_nor
-	0x6d, 0x61, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, // mal;.  _mtl_o.v_
-	0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, // normal = (_mtl_u
-	0x2e, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5b, 0x30, 0x5d, 0x20, 0x2a, 0x20, 0x74, 0x6d, // .u_model[0] * tm
-	0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x5f, // pvar_2).xyz;.  _
-	0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, // mtl_o.v_color0 =
-	0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, //  _mtl_i.a_color0
-	0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // ;.  return _mtl_
-	0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00,                                                       // o;.}...
-};

+ 0 - 16
third/bgfx/examples/02-metaballs/vs_metaballs.sc

@@ -1,16 +0,0 @@
-$input a_position, a_normal, a_color0
-$output v_normal, v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_normal = mul(u_model[0], vec4(a_normal, 0.0) ).xyz;
-	v_color0 = a_color0;
-}

+ 0 - 133
third/bgfx/examples/03-raymarch/fs_raymarching.sc

@@ -1,133 +0,0 @@
-$input v_color0, v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-// References:
-// Sphere tracing: a geometric method for the antialiased ray tracing of implicit surfaces - John C. Hart
-// http://web.archive.org/web/20110331200546/http://graphics.cs.uiuc.edu/~jch/papers/zeno.pdf
-//
-// Modeling with distance functions
-// http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
-
-#include "../common/common.sh"
-#include "iq_sdf.sh"
-
-uniform mat4 u_mtx;
-uniform vec4 u_lightDirTime;
-
-#define u_lightDir u_lightDirTime.xyz
-#define u_time     u_lightDirTime.w
-
-float sceneDist(vec3 _pos)
-{
-	float d1 = udRoundBox(_pos, vec3(2.5, 2.5, 2.5), 0.5);
-	float d2 = sdSphere(_pos + vec3( 4.0, 0.0, 0.0), 1.0);
-	float d3 = sdSphere(_pos + vec3(-4.0, 0.0, 0.0), 1.0);
-	float d4 = sdSphere(_pos + vec3( 0.0, 4.0, 0.0), 1.0);
-	float d5 = sdSphere(_pos + vec3( 0.0,-4.0, 0.0), 1.0);
-	float d6 = sdSphere(_pos + vec3( 0.0, 0.0, 4.0), 1.0);
-	float d7 = sdSphere(_pos + vec3( 0.0, 0.0,-4.0), 1.0);
-	float dist = min(min(min(min(min(min(d1, d2), d3), d4), d5), d6), d7);
-	return dist;
-}
-
-vec3 calcNormal(vec3 _pos)
-{
-	const vec2 delta = vec2(0.002, 0.0);
-	float nx = sceneDist(_pos + delta.xyy) - sceneDist(_pos - delta.xyy);
-	float ny = sceneDist(_pos + delta.yxy) - sceneDist(_pos - delta.yxy);
-	float nz = sceneDist(_pos + delta.yyx) - sceneDist(_pos - delta.yyx);
-	return normalize(vec3(nx, ny, nz) );
-}
-
-float calcAmbOcc(vec3 _pos, vec3 _normal)
-{
-	float occ = 0.0;
-	float aostep = 0.2;
-	for (int ii = 1; ii < 4; ii++)
-	{
-		float fi = float(ii);
-		float dist = sceneDist(_pos + _normal * fi * aostep);
-		occ += (fi * aostep - dist) / pow(2.0, fi);
-	}
-
-	return 1.0 - occ;
-}
-
-float trace(vec3 _ray, vec3 _dir, float _maxd)
-{
-	float tt = 0.0;
-	float epsilon = 0.001;
-
-	for (int ii = 0; ii < 64; ii++)
-	{
-		float dist = sceneDist(_ray + _dir*tt);
-		if (dist > epsilon)
-		{
-			tt += dist;
-		}
-	}
-
-	return tt < _maxd ? tt : 0.0;
-}
-
-vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
-{
-	float ndotl = dot(_normal, _lightDir);
-	vec3 reflected = _lightDir - 2.0*ndotl*_normal; // reflect(_lightDir, _normal);
-	float rdotv = dot(reflected, _viewDir);
-	return vec2(ndotl, rdotv);
-}
-
-float fresnel(float _ndotl, float _bias, float _pow)
-{
-	float facing = (1.0 - _ndotl);
-	return max(_bias + (1.0 - _bias) * pow(facing, _pow), 0.0);
-}
-
-vec4 lit(float _ndotl, float _rdotv, float _m)
-{
-	float diff = max(0.0, _ndotl);
-	float spec = step(0.0, _ndotl) * max(0.0, _rdotv * _m);
-	return vec4(1.0, diff, spec, 1.0);
-}
-
-void main()
-{
-	vec4 tmp;
-	tmp = mul(u_mtx, vec4(v_texcoord0.xy, 0.0, 1.0) );
-	vec3 eye = tmp.xyz/tmp.w;
-
-	tmp = mul(u_mtx, vec4(v_texcoord0.xy, 1.0, 1.0) );
-	vec3 at = tmp.xyz/tmp.w;
-
-	float maxd = length(at - eye);
-	vec3 dir = normalize(at - eye);
-
-	float dist = trace(eye, dir, maxd);
-
-	if (dist > 0.5)
-	{
-		vec3 pos = eye + dir*dist;
-		vec3 normal = calcNormal(pos);
-
-		vec2 bln = blinn(u_lightDir, normal, dir);
-		vec4 lc = lit(bln.x, bln.y, 1.0);
-		float fres = fresnel(bln.x, 0.2, 5.0);
-
-		float val = 0.9*lc.y + pow(lc.z, 128.0)*fres;
-		val *= calcAmbOcc(pos, normal);
-		val = pow(val, 1.0/2.2);
-
-		gl_FragColor = vec4(val, val, val, 1.0);
-		gl_FragDepth = dist/maxd;
-	}
-	else
-	{
-		gl_FragColor = v_color0;
-		gl_FragDepth = 1.0;
-	}
-}

+ 0 - 82
third/bgfx/examples/03-raymarch/iq_sdf.sh

@@ -1,82 +0,0 @@
-//
-// References:
-// Modeling with distance functions
-// http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
-//
-
-// primitives
-
-float sdSphere(vec3 _pos, float _radius)
-{
-	return length(_pos) - _radius;
-}
-
-float udBox(vec3 _pos, vec3 _extents)
-{
-	return length(max(abs(_pos) - _extents, 0.0) );
-}
-
-float udRoundBox(vec3 _pos, vec3 _extents, float r)
-{
-	return length(max(abs(_pos) - _extents, 0.0) ) - r;
-}
-
-float sdBox(vec3 _pos, vec3 _extents)
-{
-	vec3 d = abs(_pos) - _extents;
-	return min(max(d.x, max(d.y, d.z) ), 0.0) +
-	       length(max(d, 0.0) );
-}
-
-float sdTorus(vec3 _pos, vec2 t)
-{
-	vec2 q = vec2(length(_pos.xz) - t.x, _pos.y);
-	return length(q) - t.y;
-}
-
-float sdCylinder(vec3 _pos, vec3 c)
-{
-	return length(_pos.xz - c.xy) - c.z;
-}
-
-float sdCone(vec3 _pos, vec2 c)
-{
-	// c must be normalized
-	float q = length(_pos.xy);
-	return dot(c, vec2(q, _pos.z) );
-}
-
-float sdPlane(vec3 _pos, vec4 n)
-{
-	// n must be normalized
-	return dot(_pos, n.xyz) + n.w;
-}
-
-float sdHexPrism(vec3 _pos, vec2 h)
-{
-	vec3 q = abs(_pos);
-	return max(q.z - h.y, max(q.x + q.y * 0.57735, q.y * 1.1547) - h.x);
-}
-
-float sdTriPrism(vec3 _pos, vec2 h)
-{
-	vec3 q = abs(_pos);
-	return max(q.z - h.y, max(q.x * 0.866025 + _pos.y * 0.5, -_pos.y) - h.x * 0.5);
-}
-
-// domain operations
-
-float opUnion(float d1, float d2)
-{
-	return min(d1, d2);
-}
-
-float opSubtract(float d1, float d2)
-{
-	return max(-d1, d2);
-}
-
-float opIntersect(float d1, float d2)
-{
-	return max(d1, d2);
-}

+ 0 - 18
third/bgfx/examples/03-raymarch/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

+ 0 - 254
third/bgfx/examples/03-raymarch/raymarch.cpp

@@ -1,254 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-struct PosColorTexCoord0Vertex
-{
-	float m_x;
-	float m_y;
-	float m_z;
-	uint32_t m_abgr;
-	float m_u;
-	float m_v;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position,  3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Color0,    4, bgfx::AttribType::Uint8, true)
-			.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
-			.end();
-	}
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
-
-static bool s_oglNdc = false;
-
-inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far)
-{
-	bx::mtxProj(_result, _fovy, _aspect, _near, _far, s_oglNdc);
-}
-
-void renderScreenSpaceQuad(uint8_t _view, bgfx::ProgramHandle _program, float _x, float _y, float _width, float _height)
-{
-	bgfx::TransientVertexBuffer tvb;
-	bgfx::TransientIndexBuffer tib;
-
-	if (bgfx::allocTransientBuffers(&tvb, PosColorTexCoord0Vertex::ms_decl, 4, &tib, 6) )
-	{
-		PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)tvb.data;
-
-		float zz = 0.0f;
-
-		const float minx = _x;
-		const float maxx = _x + _width;
-		const float miny = _y;
-		const float maxy = _y + _height;
-
-		float minu = -1.0f;
-		float minv = -1.0f;
-		float maxu =  1.0f;
-		float maxv =  1.0f;
-
-		vertex[0].m_x = minx;
-		vertex[0].m_y = miny;
-		vertex[0].m_z = zz;
-		vertex[0].m_abgr = 0xff0000ff;
-		vertex[0].m_u = minu;
-		vertex[0].m_v = minv;
-
-		vertex[1].m_x = maxx;
-		vertex[1].m_y = miny;
-		vertex[1].m_z = zz;
-		vertex[1].m_abgr = 0xff00ff00;
-		vertex[1].m_u = maxu;
-		vertex[1].m_v = minv;
-
-		vertex[2].m_x = maxx;
-		vertex[2].m_y = maxy;
-		vertex[2].m_z = zz;
-		vertex[2].m_abgr = 0xffff0000;
-		vertex[2].m_u = maxu;
-		vertex[2].m_v = maxv;
-
-		vertex[3].m_x = minx;
-		vertex[3].m_y = maxy;
-		vertex[3].m_z = zz;
-		vertex[3].m_abgr = 0xffffffff;
-		vertex[3].m_u = minu;
-		vertex[3].m_v = maxv;
-
-		uint16_t* indices = (uint16_t*)tib.data;
-
-		indices[0] = 0;
-		indices[1] = 2;
-		indices[2] = 1;
-		indices[3] = 0;
-		indices[4] = 3;
-		indices[5] = 2;
-
-		bgfx::setState(BGFX_STATE_DEFAULT);
-		bgfx::setIndexBuffer(&tib);
-		bgfx::setVertexBuffer(&tvb);
-		bgfx::submit(_view, _program);
-	}
-}
-
-class ExampleRaymarch : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-				, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-				, 0x303030ff
-				, 1.0f
-				, 0
-				);
-
-		const bgfx::Caps* caps = bgfx::getCaps();
-		s_oglNdc = caps->homogeneousDepth;
-
-		// Create vertex stream declaration.
-		PosColorTexCoord0Vertex::init();
-
-		u_mtx          = bgfx::createUniform("u_mtx",      bgfx::UniformType::Mat4);
-		u_lightDirTime = bgfx::createUniform("u_lightDirTime", bgfx::UniformType::Vec4);
-
-		// Create program from shaders.
-		m_program = loadProgram("vs_raymarching", "fs_raymarching");
-
-		m_timeOffset = bx::getHPCounter();
-	}
-
-	int shutdown() BX_OVERRIDE
-	{
-		// Cleanup.
-		bgfx::destroyProgram(m_program);
-
-		bgfx::destroyUniform(u_mtx);
-		bgfx::destroyUniform(u_lightDirTime);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			// Set view 0 default viewport.
-			bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-
-			// Set view 1 default viewport.
-			bgfx::setViewRect(1, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to viewZ 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/03-raymarch");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Updating shader uniforms.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			float at[3]  = { 0.0f, 0.0f,   0.0f };
-			float eye[3] = { 0.0f, 0.0f, -15.0f };
-
-			float view[16];
-			float proj[16];
-			bx::mtxLookAt(view, eye, at);
-			mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-
-			// Set view and projection matrix for view 1.
-			bgfx::setViewTransform(0, view, proj);
-
-			float ortho[16];
-			bx::mtxOrtho(ortho, 0.0f, 1280.0f, 720.0f, 0.0f, 0.0f, 100.0f);
-
-			// Set view and projection matrix for view 0.
-			bgfx::setViewTransform(1, NULL, ortho);
-
-			float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) );
-
-			float vp[16];
-			bx::mtxMul(vp, view, proj);
-
-			float mtx[16];
-			bx::mtxRotateXY(mtx
-				, time
-				, time*0.37f
-				);
-
-			float mtxInv[16];
-			bx::mtxInverse(mtxInv, mtx);
-			float lightDirModel[4] = { -0.4f, -0.5f, -1.0f, 0.0f };
-			float lightDirModelN[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-			bx::vec3Norm(lightDirModelN, lightDirModel);
-			float lightDirTime[4];
-			bx::vec4MulMtx(lightDirTime, lightDirModelN, mtxInv);
-			lightDirTime[3] = time;
-			bgfx::setUniform(u_lightDirTime, lightDirTime);
-
-			float mvp[16];
-			bx::mtxMul(mvp, mtx, vp);
-
-			float invMvp[16];
-			bx::mtxInverse(invMvp, mvp);
-			bgfx::setUniform(u_mtx, invMvp);
-
-			renderScreenSpaceQuad(1, m_program, 0.0f, 0.0f, 1280.0f, 720.0f);
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-
-	int64_t m_timeOffset;
-	bgfx::UniformHandle u_mtx;
-	bgfx::UniformHandle u_lightDirTime;
-	bgfx::ProgramHandle m_program;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleRaymarch);

BIN
third/bgfx/examples/03-raymarch/screenshot.png


+ 0 - 6
third/bgfx/examples/03-raymarch/varying.def.sc

@@ -1,6 +0,0 @@
-vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
-vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
-
-vec3 a_position  : POSITION;
-vec4 a_color0    : COLOR0;
-vec2 a_texcoord0 : TEXCOORD0;

+ 0 - 16
third/bgfx/examples/03-raymarch/vs_raymarching.sc

@@ -1,16 +0,0 @@
-$input a_position, a_color0, a_texcoord0
-$output v_color0, v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_color0 = a_color0;
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 54
third/bgfx/examples/04-mesh/fs_mesh.sc

@@ -1,54 +0,0 @@
-$input v_pos, v_view, v_normal, v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-uniform vec4 u_time;
-
-vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
-{
-	float ndotl = dot(_normal, _lightDir);
-	vec3 reflected = _lightDir - 2.0*ndotl*_normal; // reflect(_lightDir, _normal);
-	float rdotv = dot(reflected, _viewDir);
-	return vec2(ndotl, rdotv);
-}
-
-float fresnel(float _ndotl, float _bias, float _pow)
-{
-	float facing = (1.0 - _ndotl);
-	return max(_bias + (1.0 - _bias) * pow(facing, _pow), 0.0);
-}
-
-vec4 lit(float _ndotl, float _rdotv, float _m)
-{
-	float diff = max(0.0, _ndotl);
-	float spec = step(0.0, _ndotl) * max(0.0, _rdotv * _m);
-	return vec4(1.0, diff, spec, 1.0);
-}
-
-void main()
-{
-	vec3 lightDir = vec3(0.0, 0.0, -1.0);
-	vec3 normal = normalize(v_normal);
-	vec3 view = normalize(v_view);
-	vec2 bln = blinn(lightDir, normal, view);
-	vec4 lc = lit(bln.x, bln.y, 1.0);
-	float fres = fresnel(bln.x, 0.2, 5.0);
-
-	float index = ( (sin(v_pos.x*3.0+u_time.x)*0.3+0.7)
-				+ (  cos(v_pos.y*3.0+u_time.x)*0.4+0.6)
-				+ (  cos(v_pos.z*3.0+u_time.x)*0.2+0.8)
-				)*M_PI;
-
-	vec3 color = vec3(sin(index*8.0)*0.4 + 0.6
-					, sin(index*4.0)*0.4 + 0.6
-					, sin(index*2.0)*0.4 + 0.6
-					) * v_color0.xyz;
-
-	gl_FragColor.xyz = pow(vec3(0.07, 0.06, 0.08) + color*lc.y + fres*pow(lc.z, 128.0), vec3_splat(1.0/2.2) );
-	gl_FragColor.w = 1.0;
-}

+ 0 - 18
third/bgfx/examples/04-mesh/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

+ 0 - 144
third/bgfx/examples/04-mesh/mesh.cpp

@@ -1,144 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-class ExampleMesh : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-				, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-				, 0x303030ff
-				, 1.0f
-				, 0
-				);
-
-		u_time = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
-
-		// Create program from shaders.
-		m_program = loadProgram("vs_mesh", "fs_mesh");
-
-		m_mesh = meshLoad("meshes/bunny.bin");
-
-		m_timeOffset = bx::getHPCounter();
-	}
-
-	int shutdown() BX_OVERRIDE
-	{
-		meshUnload(m_mesh);
-
-		// Cleanup.
-		bgfx::destroyProgram(m_program);
-
-		bgfx::destroyUniform(u_time);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			// Set view 0 default viewport.
-			bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-			float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) );
-			bgfx::setUniform(u_time, &time);
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/04-mesh");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Loading meshes.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			float at[3]  = { 0.0f, 1.0f,  0.0f };
-			float eye[3] = { 0.0f, 1.0f, -2.5f };
-
-			// Set view and projection matrix for view 0.
-			const bgfx::HMD* hmd = bgfx::getHMD();
-			if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-			{
-				float view[16];
-				bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
-				bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
-
-				// Set view 0 default viewport.
-				//
-				// Use HMD's width/height since HMD's internal frame buffer size
-				// might be much larger than window size.
-				bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-			}
-			else
-			{
-				float view[16];
-				bx::mtxLookAt(view, eye, at);
-
-				float proj[16];
-				bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-				bgfx::setViewTransform(0, view, proj);
-
-				// Set view 0 default viewport.
-				bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-			}
-
-			float mtx[16];
-			bx::mtxRotateXY(mtx
-				, 0.0f
-				, time*0.37f
-				);
-
-			meshSubmit(m_mesh, 0, m_program, mtx);
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-
-	int64_t m_timeOffset;
-	Mesh* m_mesh;
-	bgfx::ProgramHandle m_program;
-	bgfx::UniformHandle u_time;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleMesh);

BIN
third/bgfx/examples/04-mesh/screenshot.png


+ 0 - 10
third/bgfx/examples/04-mesh/varying.def.sc

@@ -1,10 +0,0 @@
-vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
-vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
-vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
-vec3 v_pos       : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
-vec3 v_view      : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
-
-vec3 a_position  : POSITION;
-vec4 a_color0    : COLOR0;
-vec2 a_texcoord0 : TEXCOORD0;
-vec3 a_normal    : NORMAL;

+ 0 - 32
third/bgfx/examples/04-mesh/vs_mesh.sc

@@ -1,32 +0,0 @@
-$input a_position, a_normal
-$output v_pos, v_view, v_normal, v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-uniform vec4 u_time;
-
-void main()
-{
-	vec3 pos = a_position;
-
-	float sx = sin(pos.x*32.0+u_time.x*4.0)*0.5+0.5;
-	float cy = cos(pos.y*32.0+u_time.x*4.0)*0.5+0.5;
-	vec3 displacement = vec3(sx, cy, sx*cy);
-	vec3 normal = a_normal.xyz*2.0 - 1.0;
-
-	pos = pos + normal*displacement*vec3(0.06, 0.06, 0.06);
-
-	gl_Position = mul(u_modelViewProj, vec4(pos, 1.0) );
-	v_pos = gl_Position.xyz;
-	v_view = mul(u_modelView, vec4(pos, 1.0) ).xyz;
-
-	v_normal = mul(u_modelView, vec4(normal, 0.0) ).xyz;
-
-	float len = length(displacement)*0.4+0.6;
-	v_color0 = vec4(len, len, len, 1.0);
-}

+ 0 - 13
third/bgfx/examples/05-instancing/fs_instancing.sc

@@ -1,13 +0,0 @@
-$input v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_FragColor = v_color0;
-}

+ 0 - 246
third/bgfx/examples/05-instancing/instancing.cpp

@@ -1,246 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-struct PosColorVertex
-{
-	float m_x;
-	float m_y;
-	float m_z;
-	uint32_t m_abgr;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Color0,   4, bgfx::AttribType::Uint8, true)
-			.end();
-	};
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosColorVertex::ms_decl;
-
-static PosColorVertex s_cubeVertices[8] =
-{
-	{-1.0f,  1.0f,  1.0f, 0xff000000 },
-	{ 1.0f,  1.0f,  1.0f, 0xff0000ff },
-	{-1.0f, -1.0f,  1.0f, 0xff00ff00 },
-	{ 1.0f, -1.0f,  1.0f, 0xff00ffff },
-	{-1.0f,  1.0f, -1.0f, 0xffff0000 },
-	{ 1.0f,  1.0f, -1.0f, 0xffff00ff },
-	{-1.0f, -1.0f, -1.0f, 0xffffff00 },
-	{ 1.0f, -1.0f, -1.0f, 0xffffffff },
-};
-
-static const uint16_t s_cubeIndices[36] =
-{
-	0, 1, 2, // 0
-	1, 3, 2,
-	4, 6, 5, // 2
-	5, 6, 7,
-	0, 2, 4, // 4
-	4, 2, 6,
-	1, 5, 3, // 6
-	5, 7, 3,
-	0, 4, 1, // 8
-	4, 5, 1,
-	2, 3, 6, // 10
-	6, 3, 7,
-};
-
-class ExampleInstancing : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-			, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-			, 0x303030ff
-			, 1.0f
-			, 0
-			);
-
-		// Create vertex stream declaration.
-		PosColorVertex::init();
-
-		// Create static vertex buffer.
-		m_vbh = bgfx::createVertexBuffer(
-					  bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
-					, PosColorVertex::ms_decl
-					);
-
-		// Create static index buffer.
-		m_ibh = bgfx::createIndexBuffer(
-					bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) )
-					);
-
-		// Create program from shaders.
-		m_program = loadProgram("vs_instancing", "fs_instancing");
-
-		m_timeOffset = bx::getHPCounter();
-	}
-
-	int shutdown() BX_OVERRIDE
-	{
-		// Cleanup.
-		bgfx::destroyIndexBuffer(m_ibh);
-		bgfx::destroyVertexBuffer(m_vbh);
-		bgfx::destroyProgram(m_program);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			// Set view 0 default viewport.
-			bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-			float time = (float)( (now - m_timeOffset)/double(bx::getHPFrequency() ) );
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/05-instancing");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Geometry instancing.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			// Get renderer capabilities info.
-			const bgfx::Caps* caps = bgfx::getCaps();
-
-			// Check if instancing is supported.
-			if (0 == (BGFX_CAPS_INSTANCING & caps->supported) )
-			{
-				// When instancing is not supported by GPU, implement alternative
-				// code path that doesn't use instancing.
-				bool blink = uint32_t(time*3.0f)&1;
-				bgfx::dbgTextPrintf(0, 5, blink ? 0x1f : 0x01, " Instancing is not supported by GPU. ");
-			}
-			else
-			{
-				float at[3]  = { 0.0f, 0.0f,   0.0f };
-				float eye[3] = { 0.0f, 0.0f, -35.0f };
-
-				// Set view and projection matrix for view 0.
-				const bgfx::HMD* hmd = bgfx::getHMD();
-				if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-				{
-					float view[16];
-					bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
-					bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
-
-					// Set view 0 default viewport.
-					//
-					// Use HMD's width/height since HMD's internal frame buffer size
-					// might be much larger than window size.
-					bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-				}
-				else
-				{
-					float view[16];
-					bx::mtxLookAt(view, eye, at);
-
-					float proj[16];
-					bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-					bgfx::setViewTransform(0, view, proj);
-
-					// Set view 0 default viewport.
-					bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-				}
-
-				const uint16_t instanceStride = 80;
-				const bgfx::InstanceDataBuffer* idb = bgfx::allocInstanceDataBuffer(121, instanceStride);
-				if (NULL != idb)
-				{
-					uint8_t* data = idb->data;
-
-					// Write instance data for 11x11 cubes.
-					for (uint32_t yy = 0, numInstances = 0; yy < 11 && numInstances < idb->num; ++yy)
-					{
-						for (uint32_t xx = 0; xx < 11 && numInstances < idb->num; ++xx, ++numInstances)
-						{
-							float* mtx = (float*)data;
-							bx::mtxRotateXY(mtx, time + xx*0.21f, time + yy*0.37f);
-							mtx[12] = -15.0f + float(xx)*3.0f;
-							mtx[13] = -15.0f + float(yy)*3.0f;
-							mtx[14] = 0.0f;
-
-							float* color = (float*)&data[64];
-							color[0] = sinf(time+float(xx)/11.0f)*0.5f+0.5f;
-							color[1] = cosf(time+float(yy)/11.0f)*0.5f+0.5f;
-							color[2] = sinf(time*3.0f)*0.5f+0.5f;
-							color[3] = 1.0f;
-
-							data += instanceStride;
-						}
-					}
-
-					// Set vertex and index buffer.
-					bgfx::setVertexBuffer(m_vbh);
-					bgfx::setIndexBuffer(m_ibh);
-
-					// Set instance data buffer.
-					bgfx::setInstanceDataBuffer(idb);
-
-					// Set render states.
-					bgfx::setState(BGFX_STATE_DEFAULT);
-
-					// Submit primitive for rendering to view 0.
-					bgfx::submit(0, m_program);
-				}
-			}
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-			return true;
-		}
-
-		return false;
-	}
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-	bgfx::VertexBufferHandle m_vbh;
-	bgfx::IndexBufferHandle  m_ibh;
-	bgfx::ProgramHandle m_program;
-
-	int64_t m_timeOffset;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleInstancing);

+ 0 - 18
third/bgfx/examples/05-instancing/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

BIN
third/bgfx/examples/05-instancing/screenshot.png


+ 0 - 9
third/bgfx/examples/05-instancing/varying.def.sc

@@ -1,9 +0,0 @@
-vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
-
-vec3 a_position  : POSITION;
-vec4 a_color0    : COLOR0;
-vec4 i_data0     : TEXCOORD7;
-vec4 i_data1     : TEXCOORD6;
-vec4 i_data2     : TEXCOORD5;
-vec4 i_data3     : TEXCOORD4;
-vec4 i_data4     : TEXCOORD3;

+ 0 - 22
third/bgfx/examples/05-instancing/vs_instancing.sc

@@ -1,22 +0,0 @@
-$input a_position, a_color0, i_data0, i_data1, i_data2, i_data3, i_data4
-$output v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	mat4 model;
-	model[0] = i_data0;
-	model[1] = i_data1;
-	model[2] = i_data2;
-	model[3] = i_data3;
-
-	vec4 worldPos = instMul(model, vec4(a_position, 1.0) );
-	gl_Position = mul(u_viewProj, worldPos);
-	v_color0 = a_color0*i_data4;
-}

+ 0 - 386
third/bgfx/examples/06-bump/bump.cpp

@@ -1,386 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-struct PosNormalTangentTexcoordVertex
-{
-	float m_x;
-	float m_y;
-	float m_z;
-	uint32_t m_normal;
-	uint32_t m_tangent;
-	int16_t m_u;
-	int16_t m_v;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position,  3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Normal,    4, bgfx::AttribType::Uint8, true, true)
-			.add(bgfx::Attrib::Tangent,   4, bgfx::AttribType::Uint8, true, true)
-			.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Int16, true, true)
-			.end();
-	}
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosNormalTangentTexcoordVertex::ms_decl;
-
-uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
-{
-	union
-	{
-		uint32_t ui32;
-		uint8_t arr[4];
-	} un;
-
-	un.arr[0] = _x;
-	un.arr[1] = _y;
-	un.arr[2] = _z;
-	un.arr[3] = _w;
-
-	return un.ui32;
-}
-
-uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
-{
-	const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
-	const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
-	const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
-	const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
-	return packUint32(xx, yy, zz, ww);
-}
-
-static PosNormalTangentTexcoordVertex s_cubeVertices[24] =
-{
-	{-1.0f,  1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 0,      0,      0 },
-	{ 1.0f,  1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 0, 0x7fff,      0 },
-	{-1.0f, -1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 0,      0, 0x7fff },
-	{ 1.0f, -1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 0, 0x7fff, 0x7fff },
-	{-1.0f,  1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 0,      0,      0 },
-	{ 1.0f,  1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 0, 0x7fff,      0 },
-	{-1.0f, -1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 0,      0, 0x7fff },
-	{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 0, 0x7fff, 0x7fff },
-	{-1.0f,  1.0f,  1.0f, packF4u( 0.0f,  1.0f,  0.0f), 0,      0,      0 },
-	{ 1.0f,  1.0f,  1.0f, packF4u( 0.0f,  1.0f,  0.0f), 0, 0x7fff,      0 },
-	{-1.0f,  1.0f, -1.0f, packF4u( 0.0f,  1.0f,  0.0f), 0,      0, 0x7fff },
-	{ 1.0f,  1.0f, -1.0f, packF4u( 0.0f,  1.0f,  0.0f), 0, 0x7fff, 0x7fff },
-	{-1.0f, -1.0f,  1.0f, packF4u( 0.0f, -1.0f,  0.0f), 0,      0,      0 },
-	{ 1.0f, -1.0f,  1.0f, packF4u( 0.0f, -1.0f,  0.0f), 0, 0x7fff,      0 },
-	{-1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f,  0.0f), 0,      0, 0x7fff },
-	{ 1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f,  0.0f), 0, 0x7fff, 0x7fff },
-	{ 1.0f, -1.0f,  1.0f, packF4u( 1.0f,  0.0f,  0.0f), 0,      0,      0 },
-	{ 1.0f,  1.0f,  1.0f, packF4u( 1.0f,  0.0f,  0.0f), 0, 0x7fff,      0 },
-	{ 1.0f, -1.0f, -1.0f, packF4u( 1.0f,  0.0f,  0.0f), 0,      0, 0x7fff },
-	{ 1.0f,  1.0f, -1.0f, packF4u( 1.0f,  0.0f,  0.0f), 0, 0x7fff, 0x7fff },
-	{-1.0f, -1.0f,  1.0f, packF4u(-1.0f,  0.0f,  0.0f), 0,      0,      0 },
-	{-1.0f,  1.0f,  1.0f, packF4u(-1.0f,  0.0f,  0.0f), 0, 0x7fff,      0 },
-	{-1.0f, -1.0f, -1.0f, packF4u(-1.0f,  0.0f,  0.0f), 0,      0, 0x7fff },
-	{-1.0f,  1.0f, -1.0f, packF4u(-1.0f,  0.0f,  0.0f), 0, 0x7fff, 0x7fff },
-};
-
-static const uint16_t s_cubeIndices[36] =
-{
-	 0,  2,  1,
-	 1,  2,  3,
-	 4,  5,  6,
-	 5,  7,  6,
-
-	 8, 10,  9,
-	 9, 10, 11,
-	12, 13, 14,
-	13, 15, 14,
-
-	16, 18, 17,
-	17, 18, 19,
-	20, 21, 22,
-	21, 23, 22,
-};
-
-class ExampleBump : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-				, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-				, 0x303030ff
-				, 1.0f
-				, 0
-				);
-
-		// Get renderer capabilities info.
-		const bgfx::Caps* caps = bgfx::getCaps();
-		m_instancingSupported = 0 != (caps->supported & BGFX_CAPS_INSTANCING);
-
-		// Create vertex stream declaration.
-		PosNormalTangentTexcoordVertex::init();
-
-		calcTangents(s_cubeVertices
-				, BX_COUNTOF(s_cubeVertices)
-				, PosNormalTangentTexcoordVertex::ms_decl
-				, s_cubeIndices
-				, BX_COUNTOF(s_cubeIndices)
-				);
-
-		// Create static vertex buffer.
-		m_vbh = bgfx::createVertexBuffer(
-					  bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
-					, PosNormalTangentTexcoordVertex::ms_decl
-					);
-
-		// Create static index buffer.
-		m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );
-
-		// Create texture sampler uniforms.
-		s_texColor  = bgfx::createUniform("s_texColor",  bgfx::UniformType::Int1);
-		s_texNormal = bgfx::createUniform("s_texNormal", bgfx::UniformType::Int1);
-
-		m_numLights = 4;
-		u_lightPosRadius = bgfx::createUniform("u_lightPosRadius", bgfx::UniformType::Vec4, m_numLights);
-		u_lightRgbInnerR = bgfx::createUniform("u_lightRgbInnerR", bgfx::UniformType::Vec4, m_numLights);
-
-		// Create program from shaders.
-		m_program = loadProgram(m_instancingSupported ? "vs_bump_instanced" : "vs_bump", "fs_bump");
-
-		// Load diffuse texture.
-		m_textureColor = loadTexture("textures/fieldstone-rgba.dds");
-
-		// Load normal texture.
-		m_textureNormal = loadTexture("textures/fieldstone-n.dds");
-
-		m_timeOffset = bx::getHPCounter();
-	}
-
-	virtual int shutdown() BX_OVERRIDE
-	{
-		// Cleanup.
-		bgfx::destroyIndexBuffer(m_ibh);
-		bgfx::destroyVertexBuffer(m_vbh);
-		bgfx::destroyProgram(m_program);
-		bgfx::destroyTexture(m_textureColor);
-		bgfx::destroyTexture(m_textureNormal);
-		bgfx::destroyUniform(s_texColor);
-		bgfx::destroyUniform(s_texNormal);
-		bgfx::destroyUniform(u_lightPosRadius);
-		bgfx::destroyUniform(u_lightRgbInnerR);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			// Set view 0 default viewport.
-			bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-
-			float time = (float)( (now-m_timeOffset)/freq);
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/06-bump");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Loading textures.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			float at[3]  = { 0.0f, 0.0f,  0.0f };
-			float eye[3] = { 0.0f, 0.0f, -7.0f };
-
-			// Set view and projection matrix for view 0.
-			const bgfx::HMD* hmd = bgfx::getHMD();
-			if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-			{
-				float view[16];
-				bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
-				bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
-
-				// Set view 0 default viewport.
-				//
-				// Use HMD's width/height since HMD's internal frame buffer size
-				// might be much larger than window size.
-				bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-			}
-			else
-			{
-				float view[16];
-				bx::mtxLookAt(view, eye, at);
-
-				float proj[16];
-				bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-				bgfx::setViewTransform(0, view, proj);
-
-				// Set view 0 default viewport.
-				bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
-			}
-
-			float lightPosRadius[4][4];
-			for (uint32_t ii = 0; ii < m_numLights; ++ii)
-			{
-				lightPosRadius[ii][0] = sinf( (time*(0.1f + ii*0.17f) + ii*bx::piHalf*1.37f ) )*3.0f;
-				lightPosRadius[ii][1] = cosf( (time*(0.2f + ii*0.29f) + ii*bx::piHalf*1.49f ) )*3.0f;
-				lightPosRadius[ii][2] = -2.5f;
-				lightPosRadius[ii][3] = 3.0f;
-			}
-
-			bgfx::setUniform(u_lightPosRadius, lightPosRadius, m_numLights);
-
-			float lightRgbInnerR[4][4] =
-			{
-				{ 1.0f, 0.7f, 0.2f, 0.8f },
-				{ 0.7f, 0.2f, 1.0f, 0.8f },
-				{ 0.2f, 1.0f, 0.7f, 0.8f },
-				{ 1.0f, 0.4f, 0.2f, 0.8f },
-			};
-
-			bgfx::setUniform(u_lightRgbInnerR, lightRgbInnerR, m_numLights);
-
-			const uint16_t instanceStride = 64;
-			const uint16_t numInstances = 3;
-
-			if (m_instancingSupported)
-			{
-				// Write instance data for 3x3 cubes.
-				for (uint32_t yy = 0; yy < 3; ++yy)
-				{
-					const bgfx::InstanceDataBuffer* idb = bgfx::allocInstanceDataBuffer(numInstances, instanceStride);
-					if (NULL != idb)
-					{
-						uint8_t* data = idb->data;
-
-						for (uint32_t xx = 0; xx < 3; ++xx)
-						{
-							float* mtx = (float*)data;
-							bx::mtxRotateXY(mtx, time*0.023f + xx*0.21f, time*0.03f + yy*0.37f);
-							mtx[12] = -3.0f + float(xx)*3.0f;
-							mtx[13] = -3.0f + float(yy)*3.0f;
-							mtx[14] = 0.0f;
-
-							data += instanceStride;
-						}
-
-						// Set instance data buffer.
-						bgfx::setInstanceDataBuffer(idb, numInstances);
-
-						// Set vertex and index buffer.
-						bgfx::setVertexBuffer(m_vbh);
-						bgfx::setIndexBuffer(m_ibh);
-
-						// Bind textures.
-						bgfx::setTexture(0, s_texColor,  m_textureColor);
-						bgfx::setTexture(1, s_texNormal, m_textureNormal);
-
-						// Set render states.
-						bgfx::setState(0
-								| BGFX_STATE_RGB_WRITE
-								| BGFX_STATE_ALPHA_WRITE
-								| BGFX_STATE_DEPTH_WRITE
-								| BGFX_STATE_DEPTH_TEST_LESS
-								| BGFX_STATE_MSAA
-								);
-
-						// Submit primitive for rendering to view 0.
-						bgfx::submit(0, m_program);
-					}
-				}
-			}
-			else
-			{
-				for (uint32_t yy = 0; yy < 3; ++yy)
-				{
-					for (uint32_t xx = 0; xx < 3; ++xx)
-					{
-						float mtx[16];
-						bx::mtxRotateXY(mtx, time*0.023f + xx*0.21f, time*0.03f + yy*0.37f);
-						mtx[12] = -3.0f + float(xx)*3.0f;
-						mtx[13] = -3.0f + float(yy)*3.0f;
-						mtx[14] = 0.0f;
-
-						// Set transform for draw call.
-						bgfx::setTransform(mtx);
-
-						// Set vertex and index buffer.
-						bgfx::setVertexBuffer(m_vbh);
-						bgfx::setIndexBuffer(m_ibh);
-
-						// Bind textures.
-						bgfx::setTexture(0, s_texColor,  m_textureColor);
-						bgfx::setTexture(1, s_texNormal, m_textureNormal);
-
-						// Set render states.
-						bgfx::setState(0
-								| BGFX_STATE_RGB_WRITE
-								| BGFX_STATE_ALPHA_WRITE
-								| BGFX_STATE_DEPTH_WRITE
-								| BGFX_STATE_DEPTH_TEST_LESS
-								| BGFX_STATE_MSAA
-								);
-
-						// Submit primitive for rendering to view 0.
-						bgfx::submit(0, m_program);
-					}
-				}
-			}
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	bgfx::VertexBufferHandle m_vbh;
-	bgfx::IndexBufferHandle  m_ibh;
-	bgfx::UniformHandle s_texColor;
-	bgfx::UniformHandle s_texNormal;
-	bgfx::UniformHandle u_lightPosRadius;
-	bgfx::UniformHandle u_lightRgbInnerR;
-	bgfx::ProgramHandle m_program;
-	bgfx::TextureHandle m_textureColor;
-	bgfx::TextureHandle m_textureNormal;
-	uint16_t m_numLights;
-	bool m_instancingSupported;
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-	int64_t m_timeOffset;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleBump);

BIN
third/bgfx/examples/06-bump/fieldstone-n.tga


BIN
third/bgfx/examples/06-bump/fieldstone-rgba.tga


+ 0 - 79
third/bgfx/examples/06-bump/fs_bump.sc

@@ -1,79 +0,0 @@
-$input v_wpos, v_view, v_normal, v_tangent, v_bitangent, v_texcoord0 // in...
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-SAMPLER2D(s_texColor,  0);
-SAMPLER2D(s_texNormal, 1);
-uniform vec4 u_lightPosRadius[4];
-uniform vec4 u_lightRgbInnerR[4];
-
-vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
-{
-	float ndotl = dot(_normal, _lightDir);
-	vec3 reflected = _lightDir - 2.0*ndotl*_normal; // reflect(_lightDir, _normal);
-	float rdotv = dot(reflected, _viewDir);
-	return vec2(ndotl, rdotv);
-}
-
-float fresnel(float _ndotl, float _bias, float _pow)
-{
-	float facing = (1.0 - _ndotl);
-	return max(_bias + (1.0 - _bias) * pow(facing, _pow), 0.0);
-}
-
-vec4 lit(float _ndotl, float _rdotv, float _m)
-{
-	float diff = max(0.0, _ndotl);
-	float spec = step(0.0, _ndotl) * max(0.0, _rdotv * _m);
-	return vec4(1.0, diff, spec, 1.0);
-}
-
-vec4 powRgba(vec4 _rgba, float _pow)
-{
-	vec4 result;
-	result.xyz = pow(_rgba.xyz, vec3_splat(_pow) );
-	result.w = _rgba.w;
-	return result;
-}
-
-vec3 calcLight(int _idx, mat3 _tbn, vec3 _wpos, vec3 _normal, vec3 _view)
-{
-	vec3 lp = u_lightPosRadius[_idx].xyz - _wpos;
-	float attn = 1.0 - smoothstep(u_lightRgbInnerR[_idx].w, 1.0, length(lp) / u_lightPosRadius[_idx].w);
-	vec3 lightDir = mul(_tbn, normalize(lp) );
-	vec2 bln = blinn(lightDir, _normal, _view);
-	vec4 lc = lit(bln.x, bln.y, 1.0);
-	vec3 rgb = u_lightRgbInnerR[_idx].xyz * saturate(lc.y) * attn;
-	return rgb;
-}
-
-void main()
-{
-	mat3 tbn = mat3(
-				normalize(v_tangent),
-				normalize(v_bitangent),
-				normalize(v_normal)
-				);
-
-	vec3 normal;
-	normal.xy = texture2D(s_texNormal, v_texcoord0).xy * 2.0 - 1.0;
-	normal.z = sqrt(1.0 - dot(normal.xy, normal.xy) );
-	vec3 view = -normalize(v_view);
-
-	vec3 lightColor;
-	lightColor =  calcLight(0, tbn, v_wpos, normal, view);
-	lightColor += calcLight(1, tbn, v_wpos, normal, view);
-	lightColor += calcLight(2, tbn, v_wpos, normal, view);
-	lightColor += calcLight(3, tbn, v_wpos, normal, view);
-
-	vec4 color = toLinear(texture2D(s_texColor, v_texcoord0) );
-
-	gl_FragColor.xyz = max(vec3_splat(0.05), lightColor.xyz)*color.xyz;
-	gl_FragColor.w = 1.0;
-	gl_FragColor = toGamma(gl_FragColor);
-}

+ 0 - 18
third/bgfx/examples/06-bump/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

BIN
third/bgfx/examples/06-bump/screenshot.png


+ 0 - 15
third/bgfx/examples/06-bump/varying.def.sc

@@ -1,15 +0,0 @@
-vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
-vec3 v_wpos      : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
-vec3 v_view      : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
-vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
-vec3 v_tangent   : TANGENT   = vec3(1.0, 0.0, 0.0);
-vec3 v_bitangent : BINORMAL  = vec3(0.0, 1.0, 0.0);
-
-vec3 a_position  : POSITION;
-vec4 a_normal    : NORMAL;
-vec4 a_tangent   : TANGENT;
-vec2 a_texcoord0 : TEXCOORD0;
-vec4 i_data0     : TEXCOORD7;
-vec4 i_data1     : TEXCOORD6;
-vec4 i_data2     : TEXCOORD5;
-vec4 i_data3     : TEXCOORD4;

+ 0 - 37
third/bgfx/examples/06-bump/vs_bump.sc

@@ -1,37 +0,0 @@
-$input a_position, a_normal, a_tangent, a_texcoord0
-$output v_wpos, v_view, v_normal, v_tangent, v_bitangent, v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	vec3 wpos = mul(u_model[0], vec4(a_position, 1.0) ).xyz;
-	gl_Position = mul(u_viewProj, vec4(wpos, 1.0) );
-	
-	vec4 normal = a_normal * 2.0 - 1.0;
-	vec3 wnormal = mul(u_model[0], vec4(normal.xyz, 0.0) ).xyz;
-
-	vec4 tangent = a_tangent * 2.0 - 1.0;
-	vec3 wtangent = mul(u_model[0], vec4(tangent.xyz, 0.0) ).xyz;
-
-	vec3 viewNormal = normalize(mul(u_view, vec4(wnormal, 0.0) ).xyz);
-	vec3 viewTangent = normalize(mul(u_view, vec4(wtangent, 0.0) ).xyz);
-	vec3 viewBitangent = cross(viewNormal, viewTangent) * tangent.w;
-	mat3 tbn = mat3(viewTangent, viewBitangent, viewNormal);
-
-	v_wpos = wpos;
-
-	vec3 view = mul(u_view, vec4(wpos, 0.0) ).xyz;
-	v_view = mul(view, tbn);
-
-	v_normal = viewNormal;
-	v_tangent = viewTangent;
-	v_bitangent = viewBitangent;
-
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 43
third/bgfx/examples/06-bump/vs_bump_instanced.sc

@@ -1,43 +0,0 @@
-$input a_position, a_normal, a_tangent, a_texcoord0, i_data0, i_data1, i_data2, i_data3
-$output v_wpos, v_view, v_normal, v_tangent, v_bitangent, v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	mat4 model;
-	model[0] = i_data0;
-	model[1] = i_data1;
-	model[2] = i_data2;
-	model[3] = i_data3;
-
-	vec3 wpos = instMul(model, vec4(a_position, 1.0) ).xyz;
-	gl_Position = mul(u_viewProj, vec4(wpos, 1.0) );
-	
-	vec4 normal = a_normal * 2.0 - 1.0;
-	vec3 wnormal = instMul(model, vec4(normal.xyz, 0.0) ).xyz;
-
-	vec4 tangent = a_tangent * 2.0 - 1.0;
-	vec3 wtangent = instMul(model, vec4(tangent.xyz, 0.0) ).xyz;
-
-	vec3 viewNormal = normalize(mul(u_view, vec4(wnormal, 0.0) ).xyz);
-	vec3 viewTangent = normalize(mul(u_view, vec4(wtangent, 0.0) ).xyz);
-	vec3 viewBitangent = cross(viewNormal, viewTangent) * tangent.w;
-	mat3 tbn = mat3(viewTangent, viewBitangent, viewNormal);
-
-	v_wpos = wpos;
-
-	vec3 view = mul(u_view, vec4(wpos, 0.0) ).xyz;
-	v_view = instMul(view, tbn);
-
-	v_normal = viewNormal;
-	v_tangent = viewTangent;
-	v_bitangent = viewBitangent;
-
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 516
third/bgfx/examples/07-callback/callback.cpp

@@ -1,516 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-#include <bx/allocator.h>
-#include <bx/string.h>
-#include "aviwriter.h"
-
-#include <inttypes.h>
-
-struct PosColorVertex
-{
-	float m_x;
-	float m_y;
-	float m_z;
-	uint32_t m_abgr;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Color0,   4, bgfx::AttribType::Uint8, true)
-			.end();
-	};
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosColorVertex::ms_decl;
-
-static PosColorVertex s_cubeVertices[8] =
-{
-	{-1.0f,  1.0f,  1.0f, 0xff000000 },
-	{ 1.0f,  1.0f,  1.0f, 0xff0000ff },
-	{-1.0f, -1.0f,  1.0f, 0xff00ff00 },
-	{ 1.0f, -1.0f,  1.0f, 0xff00ffff },
-	{-1.0f,  1.0f, -1.0f, 0xffff0000 },
-	{ 1.0f,  1.0f, -1.0f, 0xffff00ff },
-	{-1.0f, -1.0f, -1.0f, 0xffffff00 },
-	{ 1.0f, -1.0f, -1.0f, 0xffffffff },
-};
-
-static const uint16_t s_cubeIndices[36] =
-{
-	0, 1, 2, // 0
-	1, 3, 2,
-	4, 6, 5, // 2
-	5, 6, 7,
-	0, 2, 4, // 4
-	4, 2, 6,
-	1, 5, 3, // 6
-	5, 7, 3,
-	0, 4, 1, // 8
-	4, 5, 1,
-	2, 3, 6, // 10
-	6, 3, 7,
-};
-
-void saveTga(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale, bool _yflip)
-{
-	FILE* file = fopen(_filePath, "wb");
-	if (NULL != file)
-	{
-		uint8_t type = _grayscale ? 3 : 2;
-		uint8_t bpp = _grayscale ? 8 : 32;
-
-		putc(0, file);
-		putc(0, file);
-		putc(type, file);
-		putc(0, file);
-		putc(0, file);
-		putc(0, file);
-		putc(0, file);
-		putc(0, file);
-		putc(0, file);
-		putc(0, file);
-		putc(0, file);
-		putc(0, file);
-		putc(_width&0xff, file);
-		putc( (_width>>8)&0xff, file);
-		putc(_height&0xff, file);
-		putc( (_height>>8)&0xff, file);
-		putc(bpp, file);
-		putc(32, file);
-
-		uint32_t dstPitch = _width*bpp/8;
-		if (_yflip)
-		{
-			uint8_t* data = (uint8_t*)_src + _srcPitch*_height - _srcPitch;
-			for (uint32_t yy = 0; yy < _height; ++yy)
-			{
-				fwrite(data, dstPitch, 1, file);
-				data -= _srcPitch;
-			}
-		}
-		else
-		{
-			uint8_t* data = (uint8_t*)_src;
-			for (uint32_t yy = 0; yy < _height; ++yy)
-			{
-				fwrite(data, dstPitch, 1, file);
-				data += _srcPitch;
-			}
-		}
-
-		fclose(file);
-	}
-}
-
-long int fsize(FILE* _file)
-{
-	long int pos = ftell(_file);
-	fseek(_file, 0L, SEEK_END);
-	long int size = ftell(_file);
-	fseek(_file, pos, SEEK_SET);
-	return size;
-}
-
-struct BgfxCallback : public bgfx::CallbackI
-{
-	virtual ~BgfxCallback()
-	{
-	}
-
-	virtual void fatal(bgfx::Fatal::Enum _code, const char* _str) BX_OVERRIDE
-	{
-		// Something unexpected happened, inform user and bail out.
-		dbgPrintf("Fatal error: 0x%08x: %s", _code, _str);
-
-		// Must terminate, continuing will cause crash anyway.
-		abort();
-	}
-
-	virtual void traceVargs(const char* _filePath, uint16_t _line, const char* _format, va_list _argList) BX_OVERRIDE
-	{
-		dbgPrintf("%s (%d): ", _filePath, _line);
-		dbgPrintfVargs(_format, _argList);
-	}
-
-	virtual uint32_t cacheReadSize(uint64_t _id) BX_OVERRIDE
-	{
-		char filePath[256];
-		bx::snprintf(filePath, sizeof(filePath), "temp/%016" PRIx64, _id);
-
-		// Use cache id as filename.
-		FILE* file = fopen(filePath, "rb");
-		if (NULL != file)
-		{
-			uint32_t size = fsize(file);
-			fclose(file);
-			// Return size of shader file.
-			return size;
-		}
-
-		// Return 0 if shader is not found.
-		return 0;
-	}
-
-	virtual bool cacheRead(uint64_t _id, void* _data, uint32_t _size) BX_OVERRIDE
-	{
-		char filePath[256];
-		bx::snprintf(filePath, sizeof(filePath), "temp/%016" PRIx64, _id);
-
-		// Use cache id as filename.
-		FILE* file = fopen(filePath, "rb");
-		if (NULL != file)
-		{
-			// Read shader.
-			size_t result = fread(_data, 1, _size, file);
-			fclose(file);
-
-			// Make sure that read size matches requested size.
-			return result == _size;
-		}
-
-		// Shader is not found in cache, needs to be rebuilt.
-		return false;
-	}
-
-	virtual void cacheWrite(uint64_t _id, const void* _data, uint32_t _size) BX_OVERRIDE
-	{
-		char filePath[256];
-		bx::snprintf(filePath, sizeof(filePath), "temp/%016" PRIx64, _id);
-
-		// Use cache id as filename.
-		FILE* file = fopen(filePath, "wb");
-		if (NULL != file)
-		{
-			// Write shader to cache location.
-			fwrite(_data, 1, _size, file);
-			fclose(file);
-		}
-	}
-
-	virtual void screenShot(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data, uint32_t /*_size*/, bool _yflip) BX_OVERRIDE
-	{
-		char temp[1024];
-
-		// Save screen shot as TGA.
-		bx::snprintf(temp, BX_COUNTOF(temp), "%s.mip0.tga", _filePath);
-		saveTga(temp, _width, _height, _pitch, _data, false, _yflip);
-
-		uint32_t width = _width;
-		uint32_t height = _height;
-		uint32_t pitch = _pitch;
-
-		uint8_t* data = (uint8_t*)_data;
-
-		// Generate mip maps.
-		uint32_t mip = 1;
-		for (; 2 <= width && 2 <= height; ++mip)
-		{
-			bx::snprintf(temp, BX_COUNTOF(temp), "%s.mip%d.tga", _filePath, mip);
-			bgfx::imageRgba8Downsample2x2(width, height, pitch, data, data);
-
-			width >>= 1;
-			height >>= 1;
-			pitch = width*4;
-
-			saveTga(temp, width, height, pitch, _data, false, _yflip);
-		}
-
-		if (width > height)
-		{
-			for (; 2 <= width; ++mip)
-			{
-				memcpy(&data[width*4], data, width*4);
-
-				bx::snprintf(temp, BX_COUNTOF(temp), "%s.mip%d.tga", _filePath, mip);
-				bgfx::imageRgba8Downsample2x2(width, 2, pitch, data, data);
-
-				width >>= 1;
-				pitch = width*4;
-
-				saveTga(temp, width, 2, pitch, _data, false, _yflip);
-			}
-		}
-		else
-		{
-			for (; 2 <= height; ++mip)
-			{
-				uint32_t* src = (uint32_t*)data;
-				for (uint32_t ii = 0; ii < height; ++ii, src += 2)
-				{
-					src[1] = src[0];
-				}
-
-				bx::snprintf(temp, BX_COUNTOF(temp), "%s.mip%d.tga", _filePath, mip);
-				bgfx::imageRgba8Downsample2x2(2, height, 8, data, data);
-
-				height >>= 1;
-
-				saveTga(temp, 2, height, 8, _data, false, _yflip);
-			}
-		}
-	}
-
-	virtual void captureBegin(uint32_t _width, uint32_t _height, uint32_t /*_pitch*/, bgfx::TextureFormat::Enum /*_format*/, bool _yflip) BX_OVERRIDE
-	{
-		m_writer = new AviWriter(entry::getFileWriter() );
-		if (!m_writer->open("temp/capture.avi", _width, _height, 60, _yflip) )
-		{
-			delete m_writer;
-			m_writer = NULL;
-		}
-	}
-
-	virtual void captureEnd() BX_OVERRIDE
-	{
-		if (NULL != m_writer)
-		{
-			m_writer->close();
-			delete m_writer;
-			m_writer = NULL;
-		}
-	}
-
-	virtual void captureFrame(const void* _data, uint32_t /*_size*/) BX_OVERRIDE
-	{
-		if (NULL != m_writer)
-		{
-			m_writer->frame(_data);
-		}
-	}
-
-	AviWriter* m_writer;
-};
-
-class BgfxAllocator : public bx::AllocatorI
-{
-public:
-	BgfxAllocator()
-		: m_numBlocks(0)
-		, m_maxBlocks(0)
-	{
-	}
-
-	virtual ~BgfxAllocator()
-	{
-	}
-
-	virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE
-	{
-		if (0 == _size)
-		{
-			if (NULL != _ptr)
-			{
-				if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
-				{
-					dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr);
-					::free(_ptr);
-					--m_numBlocks;
-				}
-				else
-				{
-					bx::alignedFree(this, _ptr, _align, _file, _line);
-				}
-			}
-
-			return NULL;
-		}
-		else if (NULL == _ptr)
-		{
-			if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
-			{
-				void* ptr = ::malloc(_size);
-				dbgPrintf("%s(%d): ALLOC %p of %d byte(s)\n", _file, _line, ptr, _size);
-				++m_numBlocks;
-				m_maxBlocks = bx::uint32_max(m_maxBlocks, m_numBlocks);
-				return ptr;
-			}
-
-			return bx::alignedAlloc(this, _size, _align, _file, _line);
-		}
-
-		if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
-		{
-			void* ptr = ::realloc(_ptr, _size);
-			dbgPrintf("%s(%d): REALLOC %p (old %p) of %d byte(s)\n", _file, _line, ptr, _ptr, _size);
-
-			if (NULL == _ptr)
-			{
-				++m_numBlocks;
-				m_maxBlocks = bx::uint32_max(m_maxBlocks, m_numBlocks);
-			}
-
-			return ptr;
-		}
-
-		return bx::alignedRealloc(this, _ptr, _size, _align, _file, _line);
-	}
-
-	void dumpStats() const
-	{
-		dbgPrintf("Allocator stats: num blocks %d (peak: %d)\n", m_numBlocks, m_maxBlocks);
-	}
-
-private:
-	uint32_t m_numBlocks;
-	uint32_t m_maxBlocks;
-};
-
-int _main_(int _argc, char** _argv)
-{
-	Args args(_argc, _argv);
-
-	BgfxCallback callback;
-	BgfxAllocator allocator;
-
-	uint32_t width = 1280;
-	uint32_t height = 720;
-
-	// Enumerate supported backend renderers.
-	bgfx::RendererType::Enum renderers[bgfx::RendererType::Count];
-	uint8_t numRenderers = bgfx::getSupportedRenderers(renderers);
-
-	bgfx::init(bgfx::RendererType::Count == args.m_type
-		? renderers[bx::getHPCounter() % numRenderers] /* randomize renderer */
-		: args.m_type
-		, args.m_pciId
-		, 0
-		, &callback  // custom callback handler
-		, &allocator // custom allocator
-		);
-	bgfx::reset(width, height, BGFX_RESET_CAPTURE|BGFX_RESET_MSAA_X16);
-
-	// Enable debug text.
-	bgfx::setDebug(BGFX_DEBUG_TEXT);
-
-	// Set view 0 default viewport.
-	bgfx::setViewRect(0, 0, 0, 1280, 720);
-
-	// Set view 0 clear state.
-	bgfx::setViewClear(0
-		, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-		, 0x303030ff
-		, 1.0f
-		, 0
-		);
-
-	// Create vertex stream declaration.
-	PosColorVertex::init();
-
-	// Create static vertex buffer.
-	bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(
-		  bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
-		, PosColorVertex::ms_decl
-		);
-
-	// Create static index buffer.
-	bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );
-
-	// Create program from shaders.
-	bgfx::ProgramHandle program = loadProgram("vs_callback", "fs_callback");
-
-	float time = 0.0f;
-
-	const bgfx::RendererType::Enum rendererType = bgfx::getRendererType();
-
-	// 5 second 60Hz video
-	for (uint32_t frame = 0; frame < 300; ++frame)
-	{
-		// This dummy draw call is here to make sure that view 0 is cleared
-		// if no other draw calls are submitted to view 0.
-		bgfx::touch(0);
-
-		int64_t now = bx::getHPCounter();
-		static int64_t last = now;
-		const int64_t frameTime = now - last;
-		last = now;
-		const double freq = double(bx::getHPFrequency() );
-		const double toMs = 1000.0/freq;
-
-		// Use debug font to print information about this example.
-		bgfx::dbgTextClear();
-		bgfx::dbgTextPrintf( 0, 1, 0x4f, "bgfx/examples/07-callback");
-		bgfx::dbgTextPrintf( 0, 2, 0x6f, "Description: Implementing application specific callbacks for taking screen shots,");
-		bgfx::dbgTextPrintf(13, 3, 0x6f, "caching OpenGL binary shaders, and video capture.");
-		bgfx::dbgTextPrintf( 0, 4, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-		bgfx::dbgTextPrintf( 2, 6, 0x0e, "Supported renderers:");
-		for (uint8_t ii = 0; ii < numRenderers; ++ii)
-		{
-			bgfx::dbgTextPrintf( 2, 7+ii, 0x0c, "[%c] %s"
-				, renderers[ii] == rendererType ? '\xfe' : ' '
-				, bgfx::getRendererName(renderers[ii])
-				);
-		}
-
-		float at[3] = { 0.0f, 0.0f, 0.0f };
-		float eye[3] = { 0.0f, 0.0f, -35.0f };
-
-		float view[16];
-		float proj[16];
-		bx::mtxLookAt(view, eye, at);
-		bx::mtxProj(proj, 60.0f, float(width)/float(height), 0.1f, 100.0f);
-
-		// Set view and projection matrix for view 0.
-		bgfx::setViewTransform(0, view, proj);
-
-		time += 1.0f/60.0f;
-
-		// Submit 11x11 cubes.
-		for (uint32_t yy = 0; yy < 11; ++yy)
-		{
-			for (uint32_t xx = 0; xx < 11-yy; ++xx)
-			{
-				float mtx[16];
-				bx::mtxRotateXY(mtx, time + xx*0.21f, time + yy*0.37f);
-				mtx[12] = -15.0f + float(xx)*3.0f;
-				mtx[13] = -15.0f + float(yy)*3.0f;
-				mtx[14] = 0.0f;
-
-				// Set model matrix for rendering.
-				bgfx::setTransform(mtx);
-
-				// Set vertex and index buffer.
-				bgfx::setVertexBuffer(vbh);
-				bgfx::setIndexBuffer(ibh);
-
-				// Set render states.
-				bgfx::setState(BGFX_STATE_DEFAULT);
-
-				// Submit primitive for rendering to view 0.
-				bgfx::submit(0, program);
-			}
-		}
-
-		// Take screen shot at frame 150.
-		if (150 == frame)
-		{
-			bgfx::saveScreenShot("temp/frame150");
-		}
-
-		// Advance to next frame. Rendering thread will be kicked to
-		// process submitted rendering primitives.
-		bgfx::frame();
-	}
-
-	// Cleanup.
-	bgfx::destroyIndexBuffer(ibh);
-	bgfx::destroyVertexBuffer(vbh);
-	bgfx::destroyProgram(program);
-
-	// Shutdown bgfx.
-	bgfx::shutdown();
-
-	allocator.dumpStats();
-
-	return 0;
-}

+ 0 - 17
third/bgfx/examples/07-callback/fs_callback.sc

@@ -1,17 +0,0 @@
-$input v_world, v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	vec3 normal = normalize(cross(dFdx(v_world), dFdy(v_world) ) );
-	vec3 lightDir = vec3(0.0, 0.0, 1.0);
-	float ndotl = max(dot(normal, lightDir), 0.0);
-	float spec = pow(ndotl, 30.0);
-	gl_FragColor = pow(pow(v_color0, vec4_splat(2.2) ) * ndotl + spec, vec4_splat(1.0/2.2) );
-}

+ 0 - 18
third/bgfx/examples/07-callback/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

+ 0 - 5
third/bgfx/examples/07-callback/varying.def.sc

@@ -1,5 +0,0 @@
-vec3 v_world     : TEXCOORD0 = vec3(0.0, 0.0, 0.0);
-vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
-
-vec3 a_position  : POSITION;
-vec4 a_color0    : COLOR0;

+ 0 - 16
third/bgfx/examples/07-callback/vs_callback.sc

@@ -1,16 +0,0 @@
-$input a_position, a_color0
-$output v_world, v_color0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_world = mul(u_model[0], vec4(a_position, 1.0) ).xyz;
-	v_color0 = a_color0;
-}

+ 0 - 15
third/bgfx/examples/08-update/fs_update.sc

@@ -1,15 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-SAMPLERCUBE(s_texCube, 0);
-
-void main()
-{
-	gl_FragColor = textureCube(s_texCube, v_texcoord0);
-}

+ 0 - 17
third/bgfx/examples/08-update/fs_update_3d.sc

@@ -1,17 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-SAMPLER3D(s_texColor, 0);
-uniform vec4 u_time;
-
-void main()
-{
-	vec3 uvw = vec3(v_texcoord0.xy*0.5+0.5,	sin(u_time.x)*0.5+0.5);
-	gl_FragColor = vec4_splat(texture3D(s_texColor, uvw).x);
-}

+ 0 - 15
third/bgfx/examples/08-update/fs_update_cmp.sc

@@ -1,15 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-SAMPLER2D(s_texColor, 0);
-
-void main()
-{
-	gl_FragColor = texture2D(s_texColor, v_texcoord0.xy*0.5+0.5);
-}

+ 0 - 18
third/bgfx/examples/08-update/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

+ 0 - 578
third/bgfx/examples/08-update/update.cpp

@@ -1,578 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-#include <bx/uint32_t.h>
-#include "packrect.h"
-
-#include <list>
-
-struct PosTexcoordVertex
-{
-	float m_x;
-	float m_y;
-	float m_z;
-	float m_u;
-	float m_v;
-	float m_w;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position,  3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::TexCoord0, 3, bgfx::AttribType::Float)
-			.end();
-	};
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosTexcoordVertex::ms_decl;
-
-static PosTexcoordVertex s_m_cubeVertices[28] =
-{
-	{-1.0f,  1.0f,  1.0f, -1.0f,  1.0f,  1.0f },
-	{ 1.0f,  1.0f,  1.0f,  1.0f,  1.0f,  1.0f },
-	{-1.0f, -1.0f,  1.0f, -1.0f, -1.0f,  1.0f },
-	{ 1.0f, -1.0f,  1.0f,  1.0f, -1.0f,  1.0f },
-
-	{-1.0f,  1.0f, -1.0f, -1.0f,  1.0f, -1.0f },
-	{ 1.0f,  1.0f, -1.0f,  1.0f,  1.0f, -1.0f },
-	{-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f },
-	{ 1.0f, -1.0f, -1.0f,  1.0f, -1.0f, -1.0f },
-
-	{-1.0f,  1.0f,  1.0f, -1.0f,  1.0f,  1.0f },
-	{-1.0f,  1.0f, -1.0f, -1.0f,  1.0f, -1.0f },
-	{-1.0f, -1.0f,  1.0f, -1.0f, -1.0f,  1.0f },
-	{-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f },
-
-	{ 1.0f,  1.0f,  1.0f,  1.0f,  1.0f,  1.0f },
-	{ 1.0f, -1.0f,  1.0f,  1.0f, -1.0f,  1.0f },
-	{ 1.0f,  1.0f, -1.0f,  1.0f,  1.0f, -1.0f },
-	{ 1.0f, -1.0f, -1.0f,  1.0f, -1.0f, -1.0f },
-
-	{-1.0f,  1.0f,  1.0f, -1.0f,  1.0f,  1.0f },
-	{ 1.0f,  1.0f,  1.0f,  1.0f,  1.0f,  1.0f },
-	{-1.0f,  1.0f, -1.0f, -1.0f,  1.0f, -1.0f },
-	{ 1.0f,  1.0f, -1.0f,  1.0f,  1.0f, -1.0f },
-
-	{-1.0f, -1.0f,  1.0f, -1.0f, -1.0f,  1.0f },
-	{-1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f },
-	{ 1.0f, -1.0f,  1.0f,  1.0f, -1.0f,  1.0f },
-	{ 1.0f, -1.0f, -1.0f,  1.0f, -1.0f, -1.0f },
-
-	{-1.0f,  1.0f,  1.0f, -2.0f,  2.0f,  2.0f },
-	{ 1.0f,  1.0f,  1.0f,  2.0f,  2.0f,  2.0f },
-	{-1.0f, -1.0f,  1.0f, -2.0f, -2.0f,  2.0f },
-	{ 1.0f, -1.0f,  1.0f,  2.0f, -2.0f,  2.0f },
-};
-
-static const uint16_t s_m_cubeIndices[36] =
-{
-	 0,  1,  2, // 0
-	 1,  3,  2,
-
-	 4,  6,  5, // 2
-	 5,  6,  7,
-
-	 8, 10,  9, // 4
-	 9, 10, 11,
-
-	12, 14, 13, // 6
-	14, 15, 13,
-
-	16, 18, 17, // 8
-	18, 19, 17,
-
-	20, 22, 21, // 10
-	21, 22, 23,
-};
-
-static void updateTextureCubeRectBgra8(bgfx::TextureHandle _handle, uint8_t _side, uint32_t _x, uint32_t _y, uint32_t _width, uint32_t _height, uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 0xff)
-{
-	bgfx::TextureInfo ti;
-	bgfx::calcTextureSize(ti, _width, _height, 1, 1, false, bgfx::TextureFormat::BGRA8);
-
-	const bgfx::Memory* mem = bgfx::alloc(ti.storageSize);
-	uint8_t* data = (uint8_t*)mem->data;
-	for (uint32_t ii = 0, num = ti.storageSize*8/ti.bitsPerPixel; ii < num; ++ii)
-	{
-		data[0] = _b;
-		data[1] = _g;
-		data[2] = _r;
-		data[3] = _a;
-		data += 4;
-	}
-
-	bgfx::updateTextureCube(_handle, _side, 0, _x, _y, _width, _height, mem);
-}
-
-static const uint32_t m_textureside   = 512;
-static const uint32_t m_texture2dSize = 256;
-
-class ExampleUpdate : public entry::AppI
-{
-public:
-	ExampleUpdate()
-		: m_cube(m_textureside)
-	{
-	}
-
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-			, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-			, 0x303030ff
-			, 1.0f
-			, 0
-			);
-
-		// Create vertex stream declaration.
-		PosTexcoordVertex::init();
-
-		m_textures[0] = loadTexture("textures/texture_compression_bc1.ktx",  BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
-		m_textures[1] = loadTexture("textures/texture_compression_bc2.ktx",  BGFX_TEXTURE_U_CLAMP);
-		m_textures[2] = loadTexture("textures/texture_compression_bc3.ktx",  BGFX_TEXTURE_V_CLAMP);
-		m_textures[3] = loadTexture("textures/texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER|BGFX_TEXTURE_V_BORDER|BGFX_TEXTURE_BORDER_COLOR(1) );
-		m_textures[4] = loadTexture("textures/texture_compression_etc2.ktx");
-		m_textures[5] = loadTexture("textures/texture_compression_ptc12.pvr");
-		m_textures[6] = loadTexture("textures/texture_compression_ptc14.pvr");
-		m_textures[7] = loadTexture("textures/texture_compression_ptc22.pvr");
-		m_textures[8] = loadTexture("textures/texture_compression_ptc24.pvr");
-
-		const bgfx::Caps* caps = bgfx::getCaps();
-		m_texture3DSupported = !!(caps->supported & BGFX_CAPS_TEXTURE_3D);
-		m_blitSupported      = !!(caps->supported & BGFX_CAPS_TEXTURE_BLIT);
-		m_numm_textures3d      = 0;
-
-		if (m_texture3DSupported)
-		{
-			const bgfx::Memory* mem8   = bgfx::alloc(32*32*32);
-			const bgfx::Memory* mem16f = bgfx::alloc(32*32*32*2);
-			const bgfx::Memory* mem32f = bgfx::alloc(32*32*32*4);
-			for (uint8_t zz = 0; zz < 32; ++zz)
-			{
-				for (uint8_t yy = 0; yy < 32; ++yy)
-				{
-					for (uint8_t xx = 0; xx < 32; ++xx)
-					{
-						const uint32_t offset = ( (zz*32+yy)*32+xx);
-						const uint32_t val = xx ^ yy ^ zz;
-						mem8->data[offset] = val<<3;
-						*(uint16_t*)&mem16f->data[offset*2] = bx::halfFromFloat( (float)val/32.0f);
-						*(float*)&mem32f->data[offset*4] = (float)val/32.0f;
-					}
-				}
-			}
-
-			if (0 != (BGFX_CAPS_FORMAT_TEXTURE_2D & caps->formats[bgfx::TextureFormat::R8]) )
-			{
-				m_textures3d[m_numm_textures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8,   BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8);
-			}
-
-			if (0 != (BGFX_CAPS_FORMAT_TEXTURE_2D & caps->formats[bgfx::TextureFormat::R16F]) )
-			{
-				m_textures3d[m_numm_textures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f);
-			}
-
-			if (0 != (BGFX_CAPS_FORMAT_TEXTURE_2D & caps->formats[bgfx::TextureFormat::R32F]) )
-			{
-				m_textures3d[m_numm_textures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f);
-			}
-		}
-
-		// Create static vertex buffer.
-		m_vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_m_cubeVertices, sizeof(s_m_cubeVertices) ), PosTexcoordVertex::ms_decl);
-
-		// Create static index buffer.
-		m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_m_cubeIndices, sizeof(s_m_cubeIndices) ) );
-
-		// Create programs.
-		m_program    = loadProgram("vs_update", "fs_update");
-		m_programCmp = loadProgram("vs_update", "fs_update_cmp");
-		m_program3d.idx = bgfx::invalidHandle;
-		if (m_texture3DSupported)
-		{
-			m_program3d = loadProgram("vs_update", "fs_update_3d");
-		}
-
-		// Create texture sampler uniforms.
-		s_texCube  = bgfx::createUniform("s_texCube",  bgfx::UniformType::Int1);
-		s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
-
-		// Create time uniform.
-		u_time = bgfx::createUniform("u_time", bgfx::UniformType::Vec4);
-
-		m_textureCube[0] = bgfx::createTextureCube(m_textureside, 1
-				, bgfx::TextureFormat::BGRA8
-				, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT
-				);
-
-		if (m_blitSupported)
-		{
-			m_textureCube[1] = bgfx::createTextureCube(m_textureside, 1
-					, bgfx::TextureFormat::BGRA8
-					, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT|BGFX_TEXTURE_BLIT_DST
-					);
-		}
-
-		m_texture2d = bgfx::createTexture2D(m_texture2dSize, m_texture2dSize, 1
-				, bgfx::TextureFormat::BGRA8
-				, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT
-				);
-
-		m_texture2dData = (uint8_t*)malloc(m_texture2dSize*m_texture2dSize*4);
-
-		m_rr = rand()%255;
-		m_gg = rand()%255;
-		m_bb = rand()%255;
-
-		m_hit  = 0;
-		m_miss = 0;
-
-		m_updateTime = 0;
-		m_timeOffset = bx::getHPCounter();
-	}
-
-	virtual int shutdown() BX_OVERRIDE
-	{
-		// m_texture2dData is managed from main thread, and it's passed to renderer
-		// just as MemoryRef. At this point render might be using it. We must wait
-		// previous frame to finish before we can free it.
-		bgfx::frame();
-
-		// Cleanup.
-		free(m_texture2dData);
-
-		for (uint32_t ii = 0; ii < BX_COUNTOF(m_textures); ++ii)
-		{
-			bgfx::destroyTexture(m_textures[ii]);
-		}
-
-		for (uint32_t ii = 0; ii < m_numm_textures3d; ++ii)
-		{
-			bgfx::destroyTexture(m_textures3d[ii]);
-		}
-
-		bgfx::destroyTexture(m_texture2d);
-		bgfx::destroyTexture(m_textureCube[0]);
-		if (m_blitSupported)
-		{
-			bgfx::destroyTexture(m_textureCube[1]);
-		}
-		bgfx::destroyIndexBuffer(m_ibh);
-		bgfx::destroyVertexBuffer(m_vbh);
-		if (bgfx::isValid(m_program3d) )
-		{
-			bgfx::destroyProgram(m_program3d);
-		}
-		bgfx::destroyProgram(m_programCmp);
-		bgfx::destroyProgram(m_program);
-		bgfx::destroyUniform(u_time);
-		bgfx::destroyUniform(s_texColor);
-		bgfx::destroyUniform(s_texCube);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
-		{
-			float borderColor[4] = { float(rand()%255)/255.0f, float(rand()%255)/255.0f, float(rand()%255)/255.0f, float(rand()%255)/255.0f };
-			bgfx::setPaletteColor(1, borderColor);
-
-			// Set view 0 and 1 viewport.
-			bgfx::setViewRect(0, 0, 0, m_width, m_height);
-			bgfx::setViewRect(1, 0, 0, m_width, m_height);
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const int64_t freq = bx::getHPFrequency();
-			const double toMs = 1000.0/double(freq);
-			float time = (float)( (now - m_timeOffset)/double(bx::getHPFrequency() ) );
-			bgfx::setUniform(u_time, &time);
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/08-update");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Updating m_textures.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			if (now > m_updateTime)
-			{
-				PackCube face;
-
-				uint32_t bw = bx::uint16_max(1, rand()%(m_textureside/4) );
-				uint32_t bh = bx::uint16_max(1, rand()%(m_textureside/4) );
-
-				if (m_cube.find(bw, bh, face) )
-				{
-					m_quads.push_back(face);
-
-					++m_hit;
-					const Pack2D& rect = face.m_rect;
-
-					updateTextureCubeRectBgra8(m_textureCube[0], face.m_side, rect.m_x, rect.m_y, rect.m_width, rect.m_height, m_rr, m_gg, m_bb);
-					if (m_blitSupported)
-					{
-						bgfx::blit(0, m_textureCube[1], 0, rect.m_x, rect.m_y, face.m_side, m_textureCube[0], 0, rect.m_x, rect.m_y, face.m_side, rect.m_width, rect.m_height);
-					}
-
-					m_rr = rand()%255;
-					m_gg = rand()%255;
-					m_bb = rand()%255;
-				}
-				else
-				{
-					++m_miss;
-
-					for (uint32_t ii = 0, num = bx::uint32_min(10, (uint32_t)m_quads.size() ); ii < num; ++ii)
-					{
-						face = m_quads.front();
-						const Pack2D& rect = face.m_rect;
-
-						updateTextureCubeRectBgra8(m_textureCube[0], face.m_side, rect.m_x, rect.m_y, rect.m_width, rect.m_height, 0, 0, 0);
-						if (m_blitSupported)
-						{
-							bgfx::blit(0, m_textureCube[1], 0, rect.m_x, rect.m_y, face.m_side, m_textureCube[0], 0, rect.m_x, rect.m_y, face.m_side, rect.m_width, rect.m_height);
-						}
-
-						m_cube.clear(face);
-						m_quads.pop_front();
-					}
-				}
-
-				{
-					// Fill rect.
-					const uint32_t pitch = m_texture2dSize*4;
-
-					const uint16_t tw = rand()%m_texture2dSize;
-					const uint16_t th = rand()%m_texture2dSize;
-					const uint16_t tx = rand()%(m_texture2dSize-tw);
-					const uint16_t ty = rand()%(m_texture2dSize-th);
-
-					uint8_t* dst = &m_texture2dData[(ty*m_texture2dSize+tx)*4];
-					uint8_t* next = dst + pitch;
-
-					// Using makeRef to pass texture memory without copying.
-					const bgfx::Memory* mem = bgfx::makeRef(dst, tw*th*4);
-
-					for (uint32_t yy = 0; yy < th; ++yy, dst = next, next += pitch)
-					{
-						for (uint32_t xx = 0; xx < tw; ++xx, dst += 4)
-						{
-							dst[0] = m_bb;
-							dst[1] = m_gg;
-							dst[2] = m_rr;
-							dst[3] = 255;
-						}
-					}
-
-					// Pitch here makes possible to pass data from source to destination
-					// without need for m_textures and allocated memory to be the same size.
-					bgfx::updateTexture2D(m_texture2d, 0, tx, ty, tw, th, mem, pitch);
-				}
-			}
-
-			bgfx::dbgTextPrintf(0, 4, 0x0f, "m_hit: %d, m_miss %d", m_hit, m_miss);
-
-			float at[3] = { 0.0f, 0.0f, 0.0f };
-			float eye[3] = { 0.0f, 0.0f, -5.0f };
-
-			float view[16];
-			float proj[16];
-			bx::mtxLookAt(view, eye, at);
-			bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-
-			// Set view and projection matrix for view 0.
-			bgfx::setViewTransform(0, view, proj);
-
-			for (uint32_t ii = 0; ii < 1 + uint32_t(m_blitSupported); ++ii)
-			{
-				float mtx[16];
-				bx::mtxSRT(mtx, 1.0f, 1.0f, 1.0f, time, time*0.37f, 0.0f, -1.5f*m_blitSupported + ii*3.0f, 0.0f, 0.0f);
-
-				// Set model matrix for rendering.
-				bgfx::setTransform(mtx);
-
-				// Set vertex and index buffer.
-				bgfx::setVertexBuffer(m_vbh);
-				bgfx::setIndexBuffer(m_ibh);
-
-				// Bind texture.
-				bgfx::setTexture(0, s_texCube, m_textureCube[ii]);
-
-				// Set render states.
-				bgfx::setState(BGFX_STATE_DEFAULT);
-
-				// Submit primitive for rendering to view 0.
-				bgfx::submit(0, m_program);
-			}
-
-			// Set view and projection matrix for view 1.
-			const float aspectRatio = float(m_height)/float(m_width);
-			const float size = 11.0f;
-			bx::mtxOrtho(proj, -size, size, size*aspectRatio, -size*aspectRatio, 0.0f, 1000.0f);
-			bgfx::setViewTransform(1, NULL, proj);
-
-			float mtx[16];
-			bx::mtxTranslate(mtx, -size+2.0f - BX_COUNTOF(m_textures)*0.1f*0.5f, 1.9f, 0.0f);
-
-			// Set model matrix for rendering.
-			bgfx::setTransform(mtx);
-
-			// Set vertex and index buffer.
-			bgfx::setVertexBuffer(m_vbh);
-			bgfx::setIndexBuffer(m_ibh);
-
-			// Bind texture.
-			bgfx::setTexture(0, s_texColor, m_texture2d);
-
-			// Set render states.
-			bgfx::setState(BGFX_STATE_DEFAULT);
-
-			// Submit primitive for rendering to view 1.
-			bgfx::submit(1, m_programCmp);
-
-			const float xpos = -size+2.0f - BX_COUNTOF(m_textures)*0.1f*0.5f;
-
-			for (uint32_t ii = 0; ii < BX_COUNTOF(m_textures); ++ii)
-			{
-				bx::mtxTranslate(mtx, xpos + ii*2.1f, size-6.5f, 0.0f);
-
-				// Set model matrix for rendering.
-				bgfx::setTransform(mtx);
-
-				// Set vertex and index buffer.
-				bgfx::setVertexBuffer(m_vbh);
-				bgfx::setIndexBuffer(m_ibh, 0, 6);
-
-				// Bind texture.
-				bgfx::setTexture(0, s_texColor, m_textures[ii]);
-
-				// Set render states.
-				bgfx::setState(BGFX_STATE_DEFAULT);
-
-				// Submit primitive for rendering to view 1.
-				bgfx::submit(1, m_programCmp);
-			}
-
-			for (uint32_t ii = 0; ii < m_numm_textures3d; ++ii)
-			{
-				bx::mtxTranslate(mtx, xpos + ii*2.1f, -size+6.5f, 0.0f);
-
-				// Set model matrix for rendering.
-				bgfx::setTransform(mtx);
-
-				// Set vertex and index buffer.
-				bgfx::setVertexBuffer(m_vbh);
-				bgfx::setIndexBuffer(m_ibh, 0, 6);
-
-				// Bind texture.
-				bgfx::setTexture(0, s_texColor, m_textures3d[ii]);
-
-				// Set render states.
-				bgfx::setState(BGFX_STATE_DEFAULT);
-
-				// Submit primitive for rendering to view 1.
-				bgfx::submit(1, m_program3d);
-			}
-
-			for (uint32_t ii = 0; ii < 4; ++ii)
-			{
-				bx::mtxTranslate(mtx, xpos + (size-2.0f)*2.1f, -size+6.5f + ii*2.1f, 0.0f);
-
-				// Set model matrix for rendering.
-				bgfx::setTransform(mtx);
-
-				// Set vertex and index buffer.
-				bgfx::setVertexBuffer(m_vbh, 24, 4);
-				bgfx::setIndexBuffer(m_ibh, 0, 6);
-
-				// Bind texture.
-				bgfx::setTexture(0, s_texColor, m_textures[ii]);
-
-				// Set render states.
-				bgfx::setState(BGFX_STATE_DEFAULT);
-
-				// Submit primitive for rendering to view 1.
-				bgfx::submit(1, m_programCmp);
-			}
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-			return true;
-		}
-
-		return false;
-	}
-
-	uint8_t* m_texture2dData;
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-
-	uint32_t m_numm_textures3d;
-	bool m_texture3DSupported;
-	bool m_blitSupported;
-
-	std::list<PackCube> m_quads;
-	RectPackCubeT<256> m_cube;
-	int64_t m_updateTime;
-	int64_t m_timeOffset;
-
-	uint32_t m_hit;
-	uint32_t m_miss;
-
-	uint8_t m_rr;
-	uint8_t m_gg;
-	uint8_t m_bb;
-
-	bgfx::TextureHandle m_textures[9];
-	bgfx::TextureHandle m_textures3d[3];
-	bgfx::TextureHandle m_texture2d;
-	bgfx::TextureHandle m_textureCube[2];
-	bgfx::IndexBufferHandle m_ibh;
-	bgfx::VertexBufferHandle m_vbh;
-	bgfx::ProgramHandle m_program3d;
-	bgfx::ProgramHandle m_programCmp;
-	bgfx::ProgramHandle m_program;
-	bgfx::UniformHandle u_time;
-	bgfx::UniformHandle s_texColor;
-	bgfx::UniformHandle s_texCube;
-
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleUpdate);

+ 0 - 4
third/bgfx/examples/08-update/varying.def.sc

@@ -1,4 +0,0 @@
-vec3 v_texcoord0    : TEXCOORD0 = vec3(9.0, 0.0, 0.0);
-
-vec3 a_position  : POSITION;
-vec3 a_texcoord0 : TEXCOORD0;

+ 0 - 15
third/bgfx/examples/08-update/vs_update.sc

@@ -1,15 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 53
third/bgfx/examples/09-hdr/common.sh

@@ -1,53 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-uniform vec4 u_offset[16];
-uniform vec4 u_tonemap;
-#define u_time u_tonemap.w
-
-float reinhard(float _x)
-{
-	return _x / (_x + 1.0);
-}
-
-vec3 reinhard(vec3 _x)
-{
-	return _x / (_x + 1.0);
-}
-
-float reinhard2(float _x, float _whiteSqr)
-{
-	return (_x * (1.0 + _x/_whiteSqr) ) / (1.0 + _x);
-}
-
-vec3 reinhard2(vec3 _x, float _whiteSqr)
-{
-	return (_x * (1.0 + _x/_whiteSqr) ) / (1.0 + _x);
-}
-
-vec4 blur9(sampler2D _sampler, vec2 _uv0, vec4 _uv1, vec4 _uv2, vec4 _uv3, vec4 _uv4)
-{
-#define _BLUR9_WEIGHT_0 1.0
-#define _BLUR9_WEIGHT_1 0.9
-#define _BLUR9_WEIGHT_2 0.55
-#define _BLUR9_WEIGHT_3 0.18
-#define _BLUR9_WEIGHT_4 0.1
-#define _BLUR9_NORMALIZE (_BLUR9_WEIGHT_0+2.0*(_BLUR9_WEIGHT_1+_BLUR9_WEIGHT_2+_BLUR9_WEIGHT_3+_BLUR9_WEIGHT_4) )
-#define BLUR9_WEIGHT(_x) (_BLUR9_WEIGHT_##_x/_BLUR9_NORMALIZE)
-
-	vec4 blur;
-	blur  = texture2D(_sampler, _uv0)*BLUR9_WEIGHT(0);
-	blur += texture2D(_sampler, _uv1.xy)*BLUR9_WEIGHT(1);
-	blur += texture2D(_sampler, _uv1.zw)*BLUR9_WEIGHT(1);
-	blur += texture2D(_sampler, _uv2.xy)*BLUR9_WEIGHT(2);
-	blur += texture2D(_sampler, _uv2.zw)*BLUR9_WEIGHT(2);
-	blur += texture2D(_sampler, _uv3.xy)*BLUR9_WEIGHT(3);
-	blur += texture2D(_sampler, _uv3.zw)*BLUR9_WEIGHT(3);
-	blur += texture2D(_sampler, _uv4.xy)*BLUR9_WEIGHT(4);
-	blur += texture2D(_sampler, _uv4.zw)*BLUR9_WEIGHT(4);
-	return blur;
-}

+ 0 - 15
third/bgfx/examples/09-hdr/fs_hdr_blur.sc

@@ -1,15 +0,0 @@
-$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.sh"
-
-SAMPLER2D(s_texColor, 0);
-
-void main()
-{
-	gl_FragColor = blur9(s_texColor, v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4);
-}

+ 0 - 39
third/bgfx/examples/09-hdr/fs_hdr_bright.sc

@@ -1,39 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.sh"
-
-SAMPLER2D(s_texColor, 0);
-SAMPLER2D(s_texLum, 1);
-
-void main()
-{
-	float lum = clamp(decodeRE8(texture2D(s_texLum, v_texcoord0) ), 0.1, 0.7);
-
-	vec3 rgb = vec3(0.0, 0.0, 0.0);
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[0].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[1].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[2].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[3].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[4].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[5].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[6].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[7].xy) );
-	rgb += decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[8].xy) );
-
-	rgb *= 1.0/9.0;
-
-	float middleGray = u_tonemap.x;
-	float whiteSqr   = u_tonemap.y;
-	float treshold   = u_tonemap.z;
-	float offset     = u_tonemap.w;
-
-	rgb = max(vec3_splat(0.0), rgb - treshold) * middleGray / (lum + 0.0001);
-	rgb = reinhard2(rgb, whiteSqr);
-
-	gl_FragColor = toGamma(vec4(rgb, 1.0) );
-}

+ 0 - 38
third/bgfx/examples/09-hdr/fs_hdr_lum.sc

@@ -1,38 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.sh"
-
-SAMPLER2D(s_texColor, 0);
-
-void main()
-{
-	float delta = 0.0001;
-
-	vec3 rgb0 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[0].xy) );
-	vec3 rgb1 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[1].xy) );
-	vec3 rgb2 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[2].xy) );
-	vec3 rgb3 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[3].xy) );
-	vec3 rgb4 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[4].xy) );
-	vec3 rgb5 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[5].xy) );
-	vec3 rgb6 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[6].xy) );
-	vec3 rgb7 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[7].xy) );
-	vec3 rgb8 = decodeRGBE8(texture2D(s_texColor, v_texcoord0+u_offset[8].xy) );
-	float avg = luma(rgb0).x
-			  + luma(rgb1).x
-			  + luma(rgb2).x
-			  + luma(rgb3).x
-			  + luma(rgb4).x
-			  + luma(rgb5).x
-			  + luma(rgb6).x
-			  + luma(rgb7).x
-			  + luma(rgb8).x
-			  ;
-	avg *= 1.0/9.0;
-
-	gl_FragColor = encodeRE8(avg);
-}

+ 0 - 33
third/bgfx/examples/09-hdr/fs_hdr_lumavg.sc

@@ -1,33 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.sh"
-
-SAMPLER2D(s_texColor, 0);
-
-void main()
-{
-	float sum;
-	sum  = decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 0].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 1].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 2].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 3].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 4].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 5].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 6].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 7].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 8].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[ 9].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[10].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[11].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[12].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[13].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[14].xy) );
-	sum += decodeRE8(texture2D(s_texColor, v_texcoord0+u_offset[15].xy) );
-	float avg = sum/16.0;
-	gl_FragColor = encodeRE8(avg);
-}

+ 0 - 55
third/bgfx/examples/09-hdr/fs_hdr_mesh.sc

@@ -1,55 +0,0 @@
-$input v_pos, v_view, v_normal
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.sh"
-
-SAMPLERCUBE(s_texCube, 0);
-
-vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
-{
-	float ndotl = dot(_normal, _lightDir);
-	vec3 reflected = _lightDir - 2.0*ndotl*_normal; // reflect(_lightDir, _normal);
-	float rdotv = dot(reflected, _viewDir);
-	return vec2(ndotl, rdotv);
-}
-
-float fresnel(float _ndotl, float _bias, float _pow)
-{
-	float facing = (1.0 - _ndotl);
-	return max(_bias + (1.0 - _bias) * pow(facing, _pow), 0.0);
-}
-
-vec4 lit(float _ndotl, float _rdotv, float _m)
-{
-	float diff = max(0.0, _ndotl);
-	float spec = step(0.0, _ndotl) * max(0.0, _rdotv * _m);
-	return vec4(1.0, diff, spec, 1.0);
-}
-
-void main()
-{
-	vec3 lightDir = vec3(0.0, 0.0, -1.0);
-	vec3 normal = normalize(v_normal);
-	vec3 view = normalize(v_view);
-	vec2 bln = blinn(lightDir, normal, view);
-	vec4 lc = lit(bln.x, bln.y, 1.0);
-	float fres = fresnel(bln.x, 0.2, 5.0);
-
-	float index = ( (sin(v_pos.x*3.0+u_time)*0.3+0.7)
-				+ (  cos(v_pos.y*3.0+u_time)*0.4+0.6)
-				+ (  cos(v_pos.z*3.0+u_time)*0.2+0.8)
-				)*M_PI;
-
-	vec3 color = vec3(sin(index*8.0)*0.4 + 0.6
-					, sin(index*4.0)*0.4 + 0.6
-					, sin(index*2.0)*0.4 + 0.6
-					);
-
-	color *= textureCube(s_texCube, reflect(view, -normal) ).xyz;
-
-	gl_FragColor = encodeRGBE8(color.xyz*lc.y + fres*pow(lc.z, 128.0) );
-}

+ 0 - 18
third/bgfx/examples/09-hdr/fs_hdr_skybox.sc

@@ -1,18 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.sh"
-
-SAMPLERCUBE(s_texCube, 0);
-uniform mat4 u_mtx;
-
-void main()
-{
-	vec3 dir = vec3(v_texcoord0*2.0 - 1.0, 1.0);
-	dir = normalize(mul(u_mtx, vec4(dir, 0.0) ).xyz);
-	gl_FragColor = encodeRGBE8(textureCube(s_texCube, dir).xyz);
-}

+ 0 - 42
third/bgfx/examples/09-hdr/fs_hdr_tonemap.sc

@@ -1,42 +0,0 @@
-$input v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.sh"
-
-SAMPLER2D(s_texColor, 0);
-SAMPLER2D(s_texLum, 1);
-SAMPLER2D(s_texBlur, 2);
-
-void main()
-{
-	vec3 rgb = decodeRGBE8(texture2D(s_texColor, v_texcoord0) );
-	float lum = clamp(decodeRE8(texture2D(s_texLum, v_texcoord0) ), 0.1, 0.7);
-
-	vec3 Yxy = convertRGB2Yxy(rgb);
-
-	float middleGray = u_tonemap.x;
-	float whiteSqr   = u_tonemap.y;
-	float treshold   = u_tonemap.z;
-	float offset     = u_tonemap.w;
-
-	float lp = Yxy.x * middleGray / (lum + 0.0001);
-	Yxy.x = reinhard2(lp, whiteSqr);
-
-	rgb = convertYxy2RGB(Yxy);
-
-	vec4 blur = blur9(s_texBlur
-					, v_texcoord0
-					, v_texcoord1
-					, v_texcoord2
-					, v_texcoord3
-					, v_texcoord4
-					);
-
-	rgb += 0.6 * blur.xyz;
-
-	gl_FragColor = toGamma(vec4(rgb, 1.0) );
-}

+ 0 - 563
third/bgfx/examples/09-hdr/hdr.cpp

@@ -1,563 +0,0 @@
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-#include "imgui/imgui.h"
-
-static float s_texelHalf = 0.0f;
-
-struct PosColorTexCoord0Vertex
-{
-	float m_x;
-	float m_y;
-	float m_z;
-	uint32_t m_rgba;
-	float m_u;
-	float m_v;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position,  3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Color0,    4, bgfx::AttribType::Uint8, true)
-			.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
-			.end();
-	}
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosColorTexCoord0Vertex::ms_decl;
-
-void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBottomLeft = false, float _width = 1.0f, float _height = 1.0f)
-{
-	if (bgfx::checkAvailTransientVertexBuffer(3, PosColorTexCoord0Vertex::ms_decl) )
-	{
-		bgfx::TransientVertexBuffer vb;
-		bgfx::allocTransientVertexBuffer(&vb, 3, PosColorTexCoord0Vertex::ms_decl);
-		PosColorTexCoord0Vertex* vertex = (PosColorTexCoord0Vertex*)vb.data;
-
-		const float zz = 0.0f;
-
-		const float minx = -_width;
-		const float maxx =  _width;
-		const float miny = 0.0f;
-		const float maxy = _height*2.0f;
-
-		const float texelHalfW = s_texelHalf/_textureWidth;
-		const float texelHalfH = s_texelHalf/_textureHeight;
-		const float minu = -1.0f + texelHalfW;
-		const float maxu =  1.0f + texelHalfW;
-
-		float minv = texelHalfH;
-		float maxv = 2.0f + texelHalfH;
-
-		if (_originBottomLeft)
-		{
-			float temp = minv;
-			minv = maxv;
-			maxv = temp;
-
-			minv -= 1.0f;
-			maxv -= 1.0f;
-		}
-
-		vertex[0].m_x = minx;
-		vertex[0].m_y = miny;
-		vertex[0].m_z = zz;
-		vertex[0].m_rgba = 0xffffffff;
-		vertex[0].m_u = minu;
-		vertex[0].m_v = minv;
-
-		vertex[1].m_x = maxx;
-		vertex[1].m_y = miny;
-		vertex[1].m_z = zz;
-		vertex[1].m_rgba = 0xffffffff;
-		vertex[1].m_u = maxu;
-		vertex[1].m_v = minv;
-
-		vertex[2].m_x = maxx;
-		vertex[2].m_y = maxy;
-		vertex[2].m_z = zz;
-		vertex[2].m_rgba = 0xffffffff;
-		vertex[2].m_u = maxu;
-		vertex[2].m_v = maxv;
-
-		bgfx::setVertexBuffer(&vb);
-	}
-}
-
-void setOffsets2x2Lum(bgfx::UniformHandle _handle, uint32_t _width, uint32_t _height)
-{
-	float offsets[16][4];
-
-	float du = 1.0f/_width;
-	float dv = 1.0f/_height;
-
-	uint32_t num = 0;
-	for (uint32_t yy = 0; yy < 3; ++yy)
-	{
-		for (uint32_t xx = 0; xx < 3; ++xx)
-		{
-			offsets[num][0] = (xx - s_texelHalf) * du;
-			offsets[num][1] = (yy - s_texelHalf) * dv;
-			++num;
-		}
-	}
-
-	bgfx::setUniform(_handle, offsets, num);
-}
-
-void setOffsets4x4Lum(bgfx::UniformHandle _handle, uint32_t _width, uint32_t _height)
-{
-	float offsets[16][4];
-
-	float du = 1.0f/_width;
-	float dv = 1.0f/_height;
-
-	uint32_t num = 0;
-	for (uint32_t yy = 0; yy < 4; ++yy)
-	{
-		for (uint32_t xx = 0; xx < 4; ++xx)
-		{
-			offsets[num][0] = (xx - 1.0f - s_texelHalf) * du;
-			offsets[num][1] = (yy - 1.0f - s_texelHalf) * dv;
-			++num;
-		}
-	}
-
-	bgfx::setUniform(_handle, offsets, num);
-}
-
-inline float square(float _x)
-{
-	return _x*_x;
-}
-
-class ExampleHDR : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable m_debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-				, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-				, 0x303030ff
-				, 1.0f
-				, 0
-				);
-
-		// Create vertex stream declaration.
-		PosColorTexCoord0Vertex::init();
-
-		// Set view m_debug names.
-		bgfx::setViewName(0, "Skybox");
-		bgfx::setViewName(1, "Mesh");
-		bgfx::setViewName(2, "Luminance");
-		bgfx::setViewName(3, "Downscale luminance 0");
-		bgfx::setViewName(4, "Downscale luminance 1");
-		bgfx::setViewName(5, "Downscale luminance 2");
-		bgfx::setViewName(6, "Downscale luminance 3");
-		bgfx::setViewName(7, "Brightness");
-		bgfx::setViewName(8, "Blur vertical");
-		bgfx::setViewName(9, "Blur horizontal + tonemap");
-
-		m_uffizi = loadTexture("textures/uffizi.dds"
-				, 0
-				| BGFX_TEXTURE_U_CLAMP
-				| BGFX_TEXTURE_V_CLAMP
-				| BGFX_TEXTURE_W_CLAMP
-				);
-
-		m_skyProgram     = loadProgram("vs_hdr_skybox",  "fs_hdr_skybox");
-		m_lumProgram     = loadProgram("vs_hdr_lum",     "fs_hdr_lum");
-		m_lumAvgProgram  = loadProgram("vs_hdr_lumavg",  "fs_hdr_lumavg");
-		m_blurProgram    = loadProgram("vs_hdr_blur",    "fs_hdr_blur");
-		m_brightProgram  = loadProgram("vs_hdr_bright",  "fs_hdr_bright");
-		m_meshProgram    = loadProgram("vs_hdr_mesh",    "fs_hdr_mesh");
-		m_tonemapProgram = loadProgram("vs_hdr_tonemap", "fs_hdr_tonemap");
-
-		s_texCube   = bgfx::createUniform("s_texCube",  bgfx::UniformType::Int1);
-		s_texColor  = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
-		s_texLum    = bgfx::createUniform("s_texLum",   bgfx::UniformType::Int1);
-		s_texBlur   = bgfx::createUniform("s_texBlur",  bgfx::UniformType::Int1);
-		u_mtx       = bgfx::createUniform("u_mtx",      bgfx::UniformType::Mat4);
-		u_tonemap   = bgfx::createUniform("u_tonemap",  bgfx::UniformType::Vec4);
-		u_offset    = bgfx::createUniform("u_offset",   bgfx::UniformType::Vec4, 16);
-
-		m_mesh = meshLoad("meshes/bunny.bin");
-
-		m_fbtextures[0] = bgfx::createTexture2D(m_width, m_height, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_RT|BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
-		m_fbtextures[1] = bgfx::createTexture2D(m_width, m_height, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_WRITE_ONLY);
-		m_fbh = bgfx::createFrameBuffer(BX_COUNTOF(m_fbtextures), m_fbtextures, true);
-
-		m_lum[0] = bgfx::createFrameBuffer(128, 128, bgfx::TextureFormat::BGRA8);
-		m_lum[1] = bgfx::createFrameBuffer( 64,  64, bgfx::TextureFormat::BGRA8);
-		m_lum[2] = bgfx::createFrameBuffer( 16,  16, bgfx::TextureFormat::BGRA8);
-		m_lum[3] = bgfx::createFrameBuffer(  4,   4, bgfx::TextureFormat::BGRA8);
-		m_lum[4] = bgfx::createFrameBuffer(  1,   1, bgfx::TextureFormat::BGRA8);
-
-		m_bright = bgfx::createFrameBuffer(bgfx::BackbufferRatio::Half,   bgfx::TextureFormat::BGRA8);
-		m_blur   = bgfx::createFrameBuffer(bgfx::BackbufferRatio::Eighth, bgfx::TextureFormat::BGRA8);
-
-		m_lumBgra8 = 0;
-		if ( (BGFX_CAPS_TEXTURE_BLIT|BGFX_CAPS_TEXTURE_READ_BACK) == (bgfx::getCaps()->supported & (BGFX_CAPS_TEXTURE_BLIT|BGFX_CAPS_TEXTURE_READ_BACK) ) )
-		{
-			m_rb = bgfx::createTexture2D(1, 1, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_READ_BACK);
-		}
-		else
-		{
-			m_rb.idx = bgfx::invalidHandle;
-		}
-
-		// Imgui.
-		imguiCreate();
-
-		m_caps = bgfx::getCaps();
-		s_texelHalf = bgfx::RendererType::Direct3D9 == m_caps->rendererType ? 0.5f : 0.0f;
-
-		m_oldWidth  = 0;
-		m_oldHeight = 0;
-		m_oldReset  = m_reset;
-
-		m_speed      = 0.37f;
-		m_middleGray = 0.18f;
-		m_white      = 1.1f;
-		m_threshold  = 1.5f;
-
-		m_scrollArea = 0;
-
-		m_time = 0.0f;
-	}
-
-	virtual int shutdown() BX_OVERRIDE
-	{
-		// Cleanup.
-		imguiDestroy();
-
-		meshUnload(m_mesh);
-
-		for (uint32_t ii = 0; ii < BX_COUNTOF(m_lum); ++ii)
-		{
-			bgfx::destroyFrameBuffer(m_lum[ii]);
-		}
-		bgfx::destroyFrameBuffer(m_bright);
-		bgfx::destroyFrameBuffer(m_blur);
-		bgfx::destroyFrameBuffer(m_fbh);
-
-		bgfx::destroyProgram(m_meshProgram);
-		bgfx::destroyProgram(m_skyProgram);
-		bgfx::destroyProgram(m_tonemapProgram);
-		bgfx::destroyProgram(m_lumProgram);
-		bgfx::destroyProgram(m_lumAvgProgram);
-		bgfx::destroyProgram(m_blurProgram);
-		bgfx::destroyProgram(m_brightProgram);
-		bgfx::destroyTexture(m_uffizi);
-		if (bgfx::isValid(m_rb) )
-		{
-			bgfx::destroyTexture(m_rb);
-		}
-
-		bgfx::destroyUniform(s_texCube);
-		bgfx::destroyUniform(s_texColor);
-		bgfx::destroyUniform(s_texLum);
-		bgfx::destroyUniform(s_texBlur);
-		bgfx::destroyUniform(u_mtx);
-		bgfx::destroyUniform(u_tonemap);
-		bgfx::destroyUniform(u_offset);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
-		{
-			if (m_oldWidth  != m_width
-			||  m_oldHeight != m_height
-			||  m_oldReset  != m_reset)
-			{
-				// Recreate variable size render targets when resolution changes.
-				m_oldWidth  = m_width;
-				m_oldHeight = m_height;
-				m_oldReset  = m_reset;
-
-				uint32_t msaa = (m_reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
-
-				bgfx::destroyFrameBuffer(m_fbh);
-
-				m_fbtextures[0] = bgfx::createTexture2D(m_width, m_height, 1, bgfx::TextureFormat::BGRA8, ( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT)|BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
-				m_fbtextures[1] = bgfx::createTexture2D(m_width, m_height, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_WRITE_ONLY|( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT) );
-				m_fbh = bgfx::createFrameBuffer(BX_COUNTOF(m_fbtextures), m_fbtextures, true);
-			}
-
-			imguiBeginFrame(m_mouseState.m_mx
-					,  m_mouseState.m_my
-					, (m_mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT   : 0)
-					| (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT  : 0)
-					| (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
-					,  m_mouseState.m_mz
-					, m_width
-					, m_height
-					);
-
-			imguiBeginScrollArea("Settings", m_width - m_width / 5 - 10, 10, m_width / 5, m_height / 2, &m_scrollArea);
-			imguiSeparatorLine();
-
-			imguiSlider("Speed", m_speed, 0.0f, 1.0f, 0.01f);
-			imguiSeparator();
-
-			imguiSlider("Middle gray", m_middleGray, 0.1f, 1.0f, 0.01f);
-			imguiSlider("White point", m_white,      0.1f, 2.0f, 0.01f);
-			imguiSlider("Threshold",   m_threshold,  0.1f, 2.0f, 0.01f);
-
-			if (bgfx::isValid(m_rb) )
-			{
-				union { uint32_t color; uint8_t bgra[4]; } cast = { m_lumBgra8 };
-				float exponent = cast.bgra[3]/255.0f * 255.0f - 128.0f;
-				float lumAvg   = cast.bgra[2]/255.0f * bx::fexp2(exponent);
-				imguiSlider("Lum Avg", lumAvg, 0.0f, 1.0f, 0.01f, false);
-			}
-
-			imguiEndScrollArea();
-			imguiEndFrame();
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-
-			m_time += (float)(frameTime*m_speed/freq);
-
-			// Use m_debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/09-hdr");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Using multiple views and frame buffers.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			// Set views.
-			for (uint32_t ii = 0; ii < 6; ++ii)
-			{
-				bgfx::setViewRect(ii, 0, 0, bgfx::BackbufferRatio::Equal);
-			}
-			bgfx::setViewFrameBuffer(0, m_fbh);
-			bgfx::setViewFrameBuffer(1, m_fbh);
-			bgfx::setViewClear(1, BGFX_CLEAR_DISCARD_DEPTH|BGFX_CLEAR_DISCARD_STENCIL);
-
-			bgfx::setViewRect(2, 0, 0, 128, 128);
-			bgfx::setViewFrameBuffer(2, m_lum[0]);
-
-			bgfx::setViewRect(3, 0, 0, 64, 64);
-			bgfx::setViewFrameBuffer(3, m_lum[1]);
-
-			bgfx::setViewRect(4, 0, 0, 16, 16);
-			bgfx::setViewFrameBuffer(4, m_lum[2]);
-
-			bgfx::setViewRect(5, 0, 0, 4, 4);
-			bgfx::setViewFrameBuffer(5, m_lum[3]);
-
-			bgfx::setViewRect(6, 0, 0, 1, 1);
-			bgfx::setViewFrameBuffer(6, m_lum[4]);
-
-			bgfx::setViewRect(7, 0, 0, bgfx::BackbufferRatio::Half);
-			bgfx::setViewFrameBuffer(7, m_bright);
-
-			bgfx::setViewRect(8, 0, 0, bgfx::BackbufferRatio::Eighth);
-			bgfx::setViewFrameBuffer(8, m_blur);
-
-			bgfx::setViewRect(9, 0, 0, bgfx::BackbufferRatio::Equal);
-
-			float view[16];
-			float proj[16];
-
-			bx::mtxIdentity(view);
-			bx::mtxOrtho(proj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);
-
-			// Set view and projection matrix for view 0.
-			for (uint32_t ii = 0; ii < 10; ++ii)
-			{
-				bgfx::setViewTransform(ii, view, proj);
-			}
-
-			float at[3] = { 0.0f, 1.0f, 0.0f };
-			float eye[3] = { 0.0f, 1.0f, -2.5f };
-
-			float mtx[16];
-			bx::mtxRotateXY(mtx
-					, 0.0f
-					, m_time
-					);
-
-			float temp[4];
-			bx::vec3MulMtx(temp, eye, mtx);
-
-			bx::mtxLookAt(view, temp, at);
-			bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-
-			// Set view and projection matrix for view 1.
-			bgfx::setViewTransform(1, view, proj);
-
-			bgfx::setUniform(u_mtx, mtx);
-
-			// Render skybox into view 0.
-			bgfx::setTexture(0, s_texCube, m_uffizi);
-
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad( (float)m_width, (float)m_height, true);
-			bgfx::submit(0, m_skyProgram);
-
-			// Render m_mesh into view 1
-			bgfx::setTexture(0, s_texCube, m_uffizi);
-			meshSubmit(m_mesh, 1, m_meshProgram, NULL);
-
-			// Calculate luminance.
-			setOffsets2x2Lum(u_offset, 128, 128);
-			bgfx::setTexture(0, s_texColor, m_fbtextures[0]);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad(128.0f, 128.0f, m_caps->originBottomLeft);
-			bgfx::submit(2, m_lumProgram);
-
-			// Downscale luminance 0.
-			setOffsets4x4Lum(u_offset, 128, 128);
-			bgfx::setTexture(0, s_texColor, m_lum[0]);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad(64.0f, 64.0f, m_caps->originBottomLeft);
-			bgfx::submit(3, m_lumAvgProgram);
-
-			// Downscale luminance 1.
-			setOffsets4x4Lum(u_offset, 64, 64);
-			bgfx::setTexture(0, s_texColor, m_lum[1]);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad(16.0f, 16.0f, m_caps->originBottomLeft);
-			bgfx::submit(4, m_lumAvgProgram);
-
-			// Downscale luminance 2.
-			setOffsets4x4Lum(u_offset, 16, 16);
-			bgfx::setTexture(0, s_texColor, m_lum[2]);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad(4.0f, 4.0f, m_caps->originBottomLeft);
-			bgfx::submit(5, m_lumAvgProgram);
-
-			// Downscale luminance 3.
-			setOffsets4x4Lum(u_offset, 4, 4);
-			bgfx::setTexture(0, s_texColor, m_lum[3]);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad(1.0f, 1.0f, m_caps->originBottomLeft);
-			bgfx::submit(6, m_lumAvgProgram);
-
-			float tonemap[4] = { m_middleGray, square(m_white), m_threshold, m_time };
-			bgfx::setUniform(u_tonemap, tonemap);
-
-			// m_bright pass m_threshold is tonemap[3].
-			setOffsets4x4Lum(u_offset, m_width/2, m_height/2);
-			bgfx::setTexture(0, s_texColor, m_fbtextures[0]);
-			bgfx::setTexture(1, s_texLum, m_lum[4]);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad( (float)m_width/2.0f, (float)m_height/2.0f, m_caps->originBottomLeft);
-			bgfx::submit(7, m_brightProgram);
-
-			// m_blur m_bright pass vertically.
-			bgfx::setTexture(0, s_texColor, m_bright);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad( (float)m_width/8.0f, (float)m_height/8.0f, m_caps->originBottomLeft);
-			bgfx::submit(8, m_blurProgram);
-
-			// m_blur m_bright pass horizontally, do tonemaping and combine.
-			bgfx::setTexture(0, s_texColor, m_fbtextures[0]);
-			bgfx::setTexture(1, s_texLum, m_lum[4]);
-			bgfx::setTexture(2, s_texBlur, m_blur);
-			bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
-			screenSpaceQuad( (float)m_width, (float)m_height, m_caps->originBottomLeft);
-			bgfx::submit(9, m_tonemapProgram);
-
-			if (bgfx::isValid(m_rb) )
-			{
-				bgfx::blit(9, m_rb, 0, 0, m_lum[4]);
-				bgfx::readTexture(m_rb, &m_lumBgra8);
-			}
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	entry::MouseState m_mouseState;
-
-	bgfx::ProgramHandle m_skyProgram;
-	bgfx::ProgramHandle m_lumProgram;
-	bgfx::ProgramHandle m_lumAvgProgram;
-	bgfx::ProgramHandle m_blurProgram;
-	bgfx::ProgramHandle m_brightProgram;
-	bgfx::ProgramHandle m_meshProgram;
-	bgfx::ProgramHandle m_tonemapProgram;
-
-	bgfx::TextureHandle m_uffizi;
-	bgfx::UniformHandle s_texCube;
-	bgfx::UniformHandle s_texColor;
-	bgfx::UniformHandle s_texLum;
-	bgfx::UniformHandle s_texBlur;
-	bgfx::UniformHandle u_mtx;
-	bgfx::UniformHandle u_tonemap;
-	bgfx::UniformHandle u_offset;
-
-	Mesh* m_mesh;
-
-	bgfx::TextureHandle m_fbtextures[2];
-	bgfx::TextureHandle m_rb;
-	bgfx::FrameBufferHandle m_fbh;
-	bgfx::FrameBufferHandle m_lum[5];
-	bgfx::FrameBufferHandle m_bright;
-	bgfx::FrameBufferHandle m_blur;
-
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-	uint32_t m_lumBgra8;
-
-	uint32_t m_oldWidth;
-	uint32_t m_oldHeight;
-	uint32_t m_oldReset;
-
-	float m_speed;
-	float m_middleGray;
-	float m_white;
-	float m_threshold;
-
-	int32_t m_scrollArea;
-
-	const bgfx::Caps* m_caps;
-	float m_time;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleHDR);

+ 0 - 18
third/bgfx/examples/09-hdr/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

BIN
third/bgfx/examples/09-hdr/screenshot.png


+ 0 - 14
third/bgfx/examples/09-hdr/varying.def.sc

@@ -1,14 +0,0 @@
-vec4 v_color0    : COLOR0    = vec4(1.0, 0.0, 0.0, 1.0);
-vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
-vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
-vec4 v_texcoord1 : TEXCOORD1 = vec4(0.0, 0.0, 0.0, 0.0);
-vec4 v_texcoord2 : TEXCOORD2 = vec4(0.0, 0.0, 0.0, 0.0);
-vec4 v_texcoord3 : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0);
-vec4 v_texcoord4 : TEXCOORD4 = vec4(0.0, 0.0, 0.0, 0.0);
-vec3 v_pos       : TEXCOORD5 = vec3(0.0, 0.0, 0.0);
-vec3 v_view      : TEXCOORD6 = vec3(0.0, 0.0, 0.0);
-
-vec3 a_position  : POSITION;
-vec4 a_color0    : COLOR0;
-vec2 a_texcoord0 : TEXCOORD0;
-vec3 a_normal    : NORMAL;

+ 0 - 27
third/bgfx/examples/09-hdr/vs_hdr_blur.sc

@@ -1,27 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_texcoord0 = a_texcoord0;
-	v_texcoord1 = vec4(a_texcoord0.x, a_texcoord0.y - u_viewTexel.y*1.0,
-					   a_texcoord0.x, a_texcoord0.y + u_viewTexel.y*1.0
-					  );
-	v_texcoord2 = vec4(a_texcoord0.x, a_texcoord0.y - u_viewTexel.y*2.0,
-					   a_texcoord0.x, a_texcoord0.y + u_viewTexel.y*2.0
-					  );
-	v_texcoord3 = vec4(a_texcoord0.x, a_texcoord0.y - u_viewTexel.y*3.0,
-					   a_texcoord0.x, a_texcoord0.y + u_viewTexel.y*3.0
-					  );
-	v_texcoord4 = vec4(a_texcoord0.x, a_texcoord0.y - u_viewTexel.y*4.0,
-					   a_texcoord0.x, a_texcoord0.y + u_viewTexel.y*4.0
-					  );
-}

+ 0 - 15
third/bgfx/examples/09-hdr/vs_hdr_bright.sc

@@ -1,15 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 15
third/bgfx/examples/09-hdr/vs_hdr_lum.sc

@@ -1,15 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 15
third/bgfx/examples/09-hdr/vs_hdr_lumavg.sc

@@ -1,15 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 22
third/bgfx/examples/09-hdr/vs_hdr_mesh.sc

@@ -1,22 +0,0 @@
-$input a_position, a_normal
-$output v_pos, v_view, v_normal
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	vec3 pos = a_position;
-
-	vec3 normal = a_normal.xyz*2.0 - 1.0;
-
-	gl_Position = mul(u_modelViewProj, vec4(pos, 1.0) );
-	v_pos = gl_Position.xyz;
-	v_view = mul(u_modelView, vec4(pos, 1.0) ).xyz;
-
-	v_normal = mul(u_modelView, vec4(normal, 0.0) ).xyz;
-}

+ 0 - 15
third/bgfx/examples/09-hdr/vs_hdr_skybox.sc

@@ -1,15 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_texcoord0 = a_texcoord0;
-}

+ 0 - 29
third/bgfx/examples/09-hdr/vs_hdr_tonemap.sc

@@ -1,29 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0, v_texcoord1, v_texcoord2, v_texcoord3, v_texcoord4
-
-/*
- * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	float offset = u_viewTexel.x*8.0;
-
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-	v_texcoord0 = a_texcoord0;
-	v_texcoord1 = vec4(a_texcoord0.x - offset*1.0, a_texcoord0.y,
-					   a_texcoord0.x + offset*1.0, a_texcoord0.y
-					  );
-	v_texcoord2 = vec4(a_texcoord0.x - offset*2.0, a_texcoord0.y,
-					   a_texcoord0.x + offset*2.0, a_texcoord0.y
-					  );
-	v_texcoord3 = vec4(a_texcoord0.x - offset*3.0, a_texcoord0.y,
-					   a_texcoord0.x + offset*3.0, a_texcoord0.y
-					  );
-	v_texcoord4 = vec4(a_texcoord0.x - offset*4.0, a_texcoord0.y,
-					   a_texcoord0.x + offset*4.0, a_texcoord0.y
-					  );
-}

+ 0 - 290
third/bgfx/examples/10-font/font.cpp

@@ -1,290 +0,0 @@
-/*
- * Copyright 2013 Jeremie Roy. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-#include <bx/timer.h>
-#include <bx/string.h>
-#include <bx/fpumath.h>
-
-#include "font/font_manager.h"
-#include "font/text_buffer_manager.h"
-#include "entry/input.h"
-
-#include <iconfontheaders/icons_font_awesome.h>
-#include <iconfontheaders/icons_kenney.h>
-
-#include <stdio.h>
-#include <wchar.h>
-
-long int fsize(FILE* _file)
-{
-	long int pos = ftell(_file);
-	fseek(_file, 0L, SEEK_END);
-	long int size = ftell(_file);
-	fseek(_file, pos, SEEK_SET);
-	return size;
-}
-
-TrueTypeHandle loadTtf(FontManager* _fm, const char* _filePath)
-{
-	FILE* file = fopen(_filePath, "rb");
-	if (NULL != file)
-	{
-		uint32_t size = (uint32_t)fsize(file);
-		uint8_t* mem = (uint8_t*)malloc(size+1);
-		size_t ignore = fread(mem, 1, size, file);
-		BX_UNUSED(ignore);
-		fclose(file);
-		mem[size-1] = '\0';
-		TrueTypeHandle handle = _fm->createTtf(mem, size);
-		free(mem);
-		return handle;
-	}
-
-	TrueTypeHandle invalid = BGFX_INVALID_HANDLE;
-	return invalid;
-}
-
-int _main_(int _argc, char** _argv)
-{
-	Args args(_argc, _argv);
-
-	uint32_t width = 1280;
-	uint32_t height = 720;
-	uint32_t debug = BGFX_DEBUG_TEXT;
-	uint32_t reset = BGFX_RESET_VSYNC;
-
-	bgfx::init(args.m_type, args.m_pciId);
-	bgfx::reset(width, height, reset);
-
-	// Enable debug text.
-	bgfx::setDebug(debug);
-
-	// Set view 0 clear state.
-	bgfx::setViewClear(0
-		, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
-		, 0x303030ff
-		, 1.0f
-		, 0
-		);
-
-	// Init the text rendering system.
-	FontManager* fontManager = new FontManager(512);
-	TextBufferManager* textBufferManager = new TextBufferManager(fontManager);
-
-	// Load some TTF files.
-	const char* fontFilePath[7] =
-	{
-		"font/droidsans.ttf",
-		"font/chp-fire.ttf",
-		"font/bleeding_cowboys.ttf",
-		"font/mias_scribblings.ttf",
-		"font/ruritania.ttf",
-		"font/signika-regular.ttf",
-		"font/five_minutes.otf",
-	};
-
-	const uint32_t numFonts = BX_COUNTOF(fontFilePath);
-
-	TrueTypeHandle fontFiles[numFonts];
-	FontHandle fonts[numFonts];
-	for (uint32_t ii = 0; ii < numFonts; ++ii)
-	{
-		// Instantiate a usable font.
-		fontFiles[ii] = loadTtf(fontManager, fontFilePath[ii]);
-		fonts[ii] = fontManager->createFontByPixelSize(fontFiles[ii], 0, 32);
-
-		// Preload glyphs and blit them to atlas.
-		fontManager->preloadGlyph(fonts[ii], L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. \n");
-
-		// You can unload the truetype files at this stage, but in that
-		// case, the set of glyph's will be limited to the set of preloaded
-		// glyph.
-		fontManager->destroyTtf(fontFiles[ii]);
-	}
-
-	TrueTypeHandle fontAwesomeTtf = loadTtf(fontManager, "font/fontawesome-webfont.ttf");
-	TrueTypeHandle fontKenneyTtf  = loadTtf(fontManager, "font/kenney-icon-font.ttf");
-
-	// This font doesn't have any preloaded glyph's but the truetype file
-	// is loaded so glyph will be generated as needed.
-	FontHandle fontAwesome72 = fontManager->createFontByPixelSize(fontAwesomeTtf, 0, 72);
-	FontHandle fontKenney64  = fontManager->createFontByPixelSize(fontKenneyTtf,  0, 64);
-
-	TrueTypeHandle visitorTtf = loadTtf(fontManager, "font/visitor1.ttf");
-
-	// This font doesn't have any preloaded glyph's but the truetype file
-	// is loaded so glyph will be generated as needed.
-	FontHandle visitor10 = fontManager->createFontByPixelSize(visitorTtf, 0, 10);
-
-	//create a static text buffer compatible with alpha font
-	//a static text buffer content cannot be modified after its first submit.
-	TextBufferHandle staticText = textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Static);
-
-	// The pen position represent the top left of the box of the first line
-	// of text.
-	textBufferManager->setPenPosition(staticText, 24.0f, 100.0f);
-
-	for (uint32_t ii = 0; ii < numFonts; ++ii)
-	{
-		// Add some text to the buffer.
-		// The position of the pen is adjusted when there is an endline.
-		textBufferManager->appendText(staticText, fonts[ii], L"The quick brown fox jumps over the lazy dog\n");
-	}
-
-	// Now write some styled text.
-
-	// Setup style colors.
-	textBufferManager->setBackgroundColor(staticText, 0x551111ff);
-	textBufferManager->setUnderlineColor(staticText, 0xff2222ff);
-	textBufferManager->setOverlineColor(staticText, 0x2222ffff);
-	textBufferManager->setStrikeThroughColor(staticText, 0x22ff22ff);
-
-	// Background.
-	textBufferManager->setStyle(staticText, STYLE_BACKGROUND);
-	textBufferManager->appendText(staticText, fonts[0], L"The quick ");
-
-	// Strike-through.
-	textBufferManager->setStyle(staticText, STYLE_STRIKE_THROUGH);
-	textBufferManager->appendText(staticText, fonts[0], L"brown fox ");
-
-	// Overline.
-	textBufferManager->setStyle(staticText, STYLE_OVERLINE);
-	textBufferManager->appendText(staticText, fonts[0], L"jumps over ");
-
-	// Underline.
-	textBufferManager->setStyle(staticText, STYLE_UNDERLINE);
-	textBufferManager->appendText(staticText, fonts[0], L"the lazy ");
-
-	// Background + strike-through.
-	textBufferManager->setStyle(staticText, STYLE_BACKGROUND | STYLE_STRIKE_THROUGH);
-	textBufferManager->appendText(staticText, fonts[0], L"dog\n");
-
-	textBufferManager->setStyle(staticText, STYLE_NORMAL);
-	textBufferManager->appendText(staticText, fontAwesome72,
-			" " ICON_FA_POWER_OFF
-			" " ICON_FA_TWITTER_SQUARE
-			" " ICON_FA_CERTIFICATE
-			" " ICON_FA_FLOPPY_O
-			" " ICON_FA_GITHUB
-			" " ICON_FA_GITHUB_ALT
-			"\n"
-			);
-	textBufferManager->appendText(staticText, fontKenney64,
-			" " ICON_KI_COMPUTER
-			" " ICON_KI_JOYSTICK
-			" " ICON_KI_EXLAMATION
-			" " ICON_KI_STAR
-			" " ICON_KI_BUTTON_START
-			" " ICON_KI_DOWNLOAD
-			"\n"
-			);
-
-	// Create a transient buffer for real-time data.
-	TextBufferHandle transientText = textBufferManager->createTextBuffer(FONT_TYPE_ALPHA, BufferType::Transient);
-
-	while (!entry::processEvents(width, height, debug, reset) )
-	{
-		// This dummy draw call is here to make sure that view 0 is cleared
-		// if no other draw calls are submitted to view 0.
-		bgfx::touch(0);
-
-		int64_t now = bx::getHPCounter();
-		static int64_t last = now;
-		const int64_t frameTime = now - last;
-		last = now;
-		const double freq = double(bx::getHPFrequency() );
-		const double toMs = 1000.0 / freq;
-
-		// Use debug font to print information about this example.
-		bgfx::dbgTextClear();
-		bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/10-font");
-		bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Use the font system to display text and styled text.");
-		bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-		// Use transient text to display debug information.
-		wchar_t fpsText[64];
-		bx::swnprintf(fpsText, BX_COUNTOF(fpsText), L"Frame: % 7.3f[ms]", double(frameTime) * toMs);
-
-		textBufferManager->clearTextBuffer(transientText);
-		textBufferManager->setPenPosition(transientText, width - 150.0f, 10.0f);
-		textBufferManager->appendText(transientText, visitor10, L"Transient\n");
-		textBufferManager->appendText(transientText, visitor10, L"text buffer\n");
-		textBufferManager->appendText(transientText, visitor10, fpsText);
-
-		float at[3]  = { 0, 0,  0.0f };
-		float eye[3] = { 0, 0, -1.0f };
-
-		float view[16];
-		bx::mtxLookAt(view, eye, at);
-
-		const float centering = 0.5f;
-
-		// Setup a top-left ortho matrix for screen space drawing.
-		const bgfx::HMD* hmd = bgfx::getHMD();
-		if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-		{
-			float proj[16];
-			bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
-
-			static float time = 0.0f;
-			time += 0.05f;
-
-			const float dist = 10.0f;
-			const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]);
-			const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]);
-
-			float ortho[2][16];
-			const float offsetx = width/2.0f;
-			bx::mtxOrtho(ortho[0], centering, offsetx + centering, height + centering, centering, -1.0f, 1.0f, offset0);
-			bx::mtxOrtho(ortho[1], centering, offsetx + centering, height + centering, centering, -1.0f, 1.0f, offset1);
-			bgfx::setViewTransform(0, view, ortho[0], BGFX_VIEW_STEREO, ortho[1]);
-			bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-		}
-		else
-		{
-			float ortho[16];
-			bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f);
-			bgfx::setViewTransform(0, view, ortho);
-			bgfx::setViewRect(0, 0, 0, uint16_t(width), uint16_t(height) );
-		}
-
-		// Submit the debug text.
-		textBufferManager->submitTextBuffer(transientText, 0);
-
-		// Submit the static text.
-		textBufferManager->submitTextBuffer(staticText, 0);
-
-		// Advance to next frame. Rendering thread will be kicked to
-		// process submitted rendering primitives.
-		bgfx::frame();
-	}
-
-	fontManager->destroyTtf(fontKenneyTtf);
-	fontManager->destroyTtf(fontAwesomeTtf);
-	fontManager->destroyTtf(visitorTtf);
-
-	// Destroy the fonts.
-	fontManager->destroyFont(fontKenney64);
-	fontManager->destroyFont(fontAwesome72);
-	fontManager->destroyFont(visitor10);
-	for (uint32_t ii = 0; ii < numFonts; ++ii)
-	{
-		fontManager->destroyFont(fonts[ii]);
-	}
-
-	textBufferManager->destroyTextBuffer(staticText);
-	textBufferManager->destroyTextBuffer(transientText);
-
-	delete textBufferManager;
-	delete fontManager;
-
-	// Shutdown bgfx.
-	bgfx::shutdown();
-
-	return 0;
-}

BIN
third/bgfx/examples/10-font/screenshot.png


+ 0 - 286
third/bgfx/examples/11-fontsdf/fontsdf.cpp

@@ -1,286 +0,0 @@
-/*
- * Copyright 2013 Jeremie Roy. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-#include <bgfx/bgfx.h>
-#include <bx/timer.h>
-#include <bx/fpumath.h>
-
-#include "font/font_manager.h"
-#include "font/text_metrics.h"
-#include "font/text_buffer_manager.h"
-#include "imgui/imgui.h"
-
-#include <stdio.h>
-#include <string.h>
-
-long int fsize(FILE* _file)
-{
-	long int pos = ftell(_file);
-	fseek(_file, 0L, SEEK_END);
-	long int size = ftell(_file);
-	fseek(_file, pos, SEEK_SET);
-	return size;
-}
-
-static char* loadText(const char* _filePath)
-{
-	FILE* file = fopen(_filePath, "rb");
-	if (NULL != file)
-	{
-		uint32_t size = (uint32_t)fsize(file);
-		char* mem = (char*)malloc(size+1);
-		size_t ignore = fread(mem, 1, size, file);
-		BX_UNUSED(ignore);
-		fclose(file);
-		mem[size-1] = '\0';
-		return mem;
-	}
-
-	return NULL;
-}
-
-TrueTypeHandle loadTtf(FontManager* _fm, const char* _filePath)
-{
-	FILE* file = fopen(_filePath, "rb");
-	if (NULL != file)
-	{
-		uint32_t size = (uint32_t)fsize(file);
-		uint8_t* mem = (uint8_t*)malloc(size+1);
-		size_t ignore = fread(mem, 1, size, file);
-		BX_UNUSED(ignore);
-		fclose(file);
-		mem[size-1] = '\0';
-		TrueTypeHandle handle = _fm->createTtf(mem, size);
-		free(mem);
-		return handle;
-	}
-
-	TrueTypeHandle invalid = BGFX_INVALID_HANDLE;
-	return invalid;
-}
-
-int _main_(int _argc, char** _argv)
-{
-	Args args(_argc, _argv);
-
-	uint32_t width = 1280;
-	uint32_t height = 720;
-	uint32_t debug = BGFX_DEBUG_TEXT;
-	uint32_t reset = BGFX_RESET_VSYNC;
-
-	bgfx::init(args.m_type, args.m_pciId);
-	bgfx::reset(width, height, reset);
-
-	// Enable debug text.
-	bgfx::setDebug(debug);
-
-	// Set view 0 clear state.
-	bgfx::setViewClear(0
-		, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH
-		, 0x303030ff
-		, 1.0f
-		, 0
-		);
-
-	// Imgui.
-	imguiCreate();
-
-	char* bigText = loadText( "text/sherlock_holmes_a_scandal_in_bohemia_arthur_conan_doyle.txt");
-
-	// Init the text rendering system.
-	FontManager* fontManager = new FontManager(512);
-	TextBufferManager* textBufferManager = new TextBufferManager(fontManager);
-
-	TrueTypeHandle font = loadTtf(fontManager, "font/special_elite.ttf");
-
-	// Create a distance field font.
-	FontHandle fontSdf = fontManager->createFontByPixelSize(font, 0, 48, FONT_TYPE_DISTANCE);
-
-	// Create a scaled down version of the same font (without adding anything to the atlas).
-	FontHandle fontScaled = fontManager->createScaledFontToPixelSize(fontSdf, 14);
-
-	TextLineMetrics metrics(fontManager->getFontInfo(fontScaled) );
-	uint32_t lineCount = metrics.getLineCount(bigText);
-
-	float visibleLineCount = 20.0f;
-
-	const char* textBegin = 0;
-	const char* textEnd = 0;
-	metrics.getSubText(bigText, 0, (uint32_t)visibleLineCount, textBegin, textEnd);
-
-	TextBufferHandle scrollableBuffer = textBufferManager->createTextBuffer(FONT_TYPE_DISTANCE, BufferType::Transient);
-	textBufferManager->setTextColor(scrollableBuffer, 0xFFFFFFFF);
-
-	textBufferManager->appendText(scrollableBuffer, fontScaled, textBegin, textEnd);
-
-	entry::MouseState mouseState;
-	int32_t scrollArea = 0;
-	const int32_t guiPanelWidth = 250;
-	const int32_t guiPanelHeight = 200;
-	float textScroll = 0.0f;
-	float textRotation = 0.0f;
-	float textScale = 1.0f;
-	float textSize = 14.0f;
-
-	while (!entry::processEvents(width, height, debug, reset, &mouseState) )
-	{
-		imguiBeginFrame(mouseState.m_mx
-			, mouseState.m_my
-			, (mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT   : 0)
-			| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT  : 0)
-			| (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
-			, mouseState.m_mz
-			, width
-			, height
-			);
-
-		imguiBeginScrollArea("Text Area"
-			, width - guiPanelWidth - 10
-			, 10
-			, guiPanelWidth
-			, guiPanelHeight
-			, &scrollArea
-			);
-		imguiSeparatorLine();
-
-		bool recomputeVisibleText = false;
-		recomputeVisibleText |= imguiSlider("Number of lines", visibleLineCount, 1.0f, 177.0f , 1.0f);
-		if (imguiSlider("Font size", textSize, 6.0f, 64.0f , 1.0f) )
-		{
-			fontManager->destroyFont(fontScaled);
-			fontScaled = fontManager->createScaledFontToPixelSize(fontSdf, (uint32_t) textSize);
-			metrics = TextLineMetrics(fontManager->getFontInfo(fontScaled) );
-			recomputeVisibleText = true;
-		}
-
-		recomputeVisibleText |= imguiSlider("Scroll", textScroll, 0.0f, (lineCount-visibleLineCount) , 1.0f);
-		imguiSlider("Rotate", textRotation, 0.0f, bx::pi*2.0f , 0.1f);
-		recomputeVisibleText |= imguiSlider("Scale", textScale, 0.1f, 10.0f , 0.1f);
-
-		if (recomputeVisibleText)
-		{
-			textBufferManager->clearTextBuffer(scrollableBuffer);
-			metrics.getSubText(bigText,(uint32_t)textScroll, (uint32_t)(textScroll+visibleLineCount), textBegin, textEnd);
-			textBufferManager->appendText(scrollableBuffer, fontScaled, textBegin, textEnd);
-		}
-
-		imguiEndScrollArea();
-
-		imguiEndFrame();
-
-		// Set view 0 default viewport.
-		bgfx::setViewRect(0, 0, 0, width, height);
-
-		// This dummy draw call is here to make sure that view 0 is cleared
-		// if no other draw calls are submitted to view 0.
-		bgfx::touch(0);
-
-		int64_t now = bx::getHPCounter();
-		static int64_t last = now;
-		const int64_t frameTime = now - last;
-		last = now;
-		const double freq = double(bx::getHPFrequency() );
-		const double toMs = 1000.0 / freq;
-
-		// Use debug font to print32_t information about this example.
-		bgfx::dbgTextClear();
-		bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/11-fontsdf");
-		bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Use a single distance field font to render text of various size.");
-		bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime) * toMs);
-
-		float at[3]  = { 0, 0, 0.0f };
-		float eye[3] = {0, 0, -1.0f };
-
-		float view[16];
-		bx::mtxLookAt(view, eye, at);
-
-		const float centering = 0.5f;
-
-		// Setup a top-left ortho matrix for screen space drawing.
-		const bgfx::HMD* hmd = bgfx::getHMD();
-		if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-		{
-			float proj[16];
-			bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f);
-
-			static float time = 0.0f;
-			time += 0.05f;
-
-			const float dist = 10.0f;
-			const float offset0 = -proj[8] + (hmd->eye[0].viewOffset[0] / dist * proj[0]);
-			const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]);
-
-			float ortho[2][16];
-			const float viewOffset = width/4.0f;
-			const float viewWidth  = width/2.0f;
-			bx::mtxOrtho(ortho[0], centering + viewOffset, centering + viewOffset + viewWidth, height + centering, centering, -1.0f, 1.0f, offset0);
-			bx::mtxOrtho(ortho[1], centering + viewOffset, centering + viewOffset + viewWidth, height + centering, centering, -1.0f, 1.0f, offset1);
-			bgfx::setViewTransform(0, view, ortho[0], BGFX_VIEW_STEREO, ortho[1]);
-			bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-		}
-		else
-		{
-			float ortho[16];
-			bx::mtxOrtho(ortho, centering, width + centering, height + centering, centering, -1.0f, 1.0f);
-			bgfx::setViewTransform(0, view, ortho);
-			bgfx::setViewRect(0, 0, 0, width, height);
-		}
-
-		//very crude approximation :(
-		float textAreaWidth = 0.5f * 66.0f * fontManager->getFontInfo(fontScaled).maxAdvanceWidth;
-
-		float textRotMat[16];
-		float textCenterMat[16];
-		float textScaleMat[16];
-		float screenCenterMat[16];
-
-		bx::mtxRotateZ(textRotMat, textRotation);
-		bx::mtxTranslate(textCenterMat, -(textAreaWidth * 0.5f), (-visibleLineCount)*metrics.getLineHeight()*0.5f, 0);
-		bx::mtxScale(textScaleMat, textScale, textScale, 1.0f);
-		bx::mtxTranslate(screenCenterMat, ( (width) * 0.5f), ( (height) * 0.5f), 0);
-
-		//first translate to text center, then scale, then rotate
-		float tmpMat[16];
-		bx::mtxMul(tmpMat, textCenterMat, textRotMat);
-
-		float tmpMat2[16];
-		bx::mtxMul(tmpMat2, tmpMat, textScaleMat);
-
-		float tmpMat3[16];
-		bx::mtxMul(tmpMat3, tmpMat2, screenCenterMat);
-
-		// Set model matrix for rendering.
-		bgfx::setTransform(tmpMat3);
-
-		// Draw your text.
-		textBufferManager->submitTextBuffer(scrollableBuffer, 0);
-
-		// Advance to next frame. Rendering thread will be kicked to
-		// process submitted rendering primitives.
-		bgfx::frame();
-	}
-
-	imguiDestroy();
-
-	free(bigText);
-
-	fontManager->destroyTtf(font);
-	// Destroy the fonts.
-	fontManager->destroyFont(fontSdf);
-	fontManager->destroyFont(fontScaled);
-
-	textBufferManager->destroyTextBuffer(scrollableBuffer);
-
-	delete textBufferManager;
-	delete fontManager;
-
-	// Shutdown bgfx.
-	bgfx::shutdown();
-
-	return 0;
-}

BIN
third/bgfx/examples/11-fontsdf/screenshot.png


+ 0 - 42
third/bgfx/examples/12-lod/fs_tree.sc

@@ -1,42 +0,0 @@
-$input v_pos, v_view, v_normal, v_texcoord0
-
-/*
- * Copyright 2013 Milos Tosic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-SAMPLER2D(s_texColor, 0);
-SAMPLER2D(s_texStipple, 1);
-uniform vec4 u_stipple;
-
-vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
-{
-	float ndotl = dot(_normal, _lightDir);
-	vec3 reflected = _lightDir - 2.0*ndotl*_normal; // reflect(_lightDir, _normal);
-	float rdotv = dot(reflected, _viewDir);
-	return vec2(ndotl, rdotv);
-}
-
-void main()
-{
-	vec2 viewport = (u_viewRect.zw - u_viewRect.xy) * vec2(1.0/8.0, 1.0/4.0);
-	vec2 stippleUV = viewport*(v_pos.xy*0.5 + 0.5);
-	vec4 color = texture2D(s_texColor, v_texcoord0);
-	if ( (u_stipple.x - texture2D(s_texStipple, stippleUV).x)*u_stipple.y > u_stipple.z
-	||   color.w < 0.5)
-	{
-		discard;
-	}
-
-	vec3 lightDir = vec3(0.0, 0.0, -1.0);
-	vec3 normal = normalize(v_normal);
-	vec3 view = normalize(v_view);
-	vec2 bln = blinn(lightDir, normal, view);
-	float l = saturate(bln.y) + 0.12;
-
-	color.xyz = toLinear(color.xyz)*l;
-	gl_FragColor = toGamma(color);
-}
-

+ 0 - 315
third/bgfx/examples/12-lod/lod.cpp

@@ -1,315 +0,0 @@
-/*
- * Copyright 2013 Milos Tosic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "common.h"
-#include "bgfx_utils.h"
-#include "imgui/imgui.h"
-
-#include <bx/readerwriter.h>
-
-struct KnightPos
-{
-	int32_t m_x;
-	int32_t m_y;
-};
-
-static const KnightPos knightTour[8*4] =
-{
-	{0,0}, {1,2}, {3,3}, {4,1}, {5,3}, {7,2}, {6,0}, {5,2},
-	{7,3}, {6,1}, {4,0}, {3,2}, {2,0}, {0,1}, {1,3}, {2,1},
-	{0,2}, {1,0}, {2,2}, {0,3}, {1,1}, {3,0}, {4,2}, {5,0},
-	{7,1}, {6,3}, {5,1}, {7,0}, {6,2}, {4,3}, {3,1}, {2,3},
-};
-
-class ExampleLod : public entry::AppI
-{
-	void init(int _argc, char** _argv) BX_OVERRIDE
-	{
-		Args args(_argc, _argv);
-
-		m_width  = 1280;
-		m_height = 720;
-		m_debug  = BGFX_DEBUG_TEXT;
-		m_reset  = BGFX_RESET_VSYNC;
-
-		bgfx::init(args.m_type, args.m_pciId);
-		bgfx::reset(m_width, m_height, m_reset);
-
-		// Enable debug text.
-		bgfx::setDebug(m_debug);
-
-		// Set view 0 clear state.
-		bgfx::setViewClear(0
-			, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
-			, 0x303030ff
-			, 1.0f
-			, 0
-			);
-
-		s_texColor   = bgfx::createUniform("s_texColor",   bgfx::UniformType::Int1);
-		s_texStipple = bgfx::createUniform("s_texStipple", bgfx::UniformType::Int1);
-		u_stipple    = bgfx::createUniform("u_stipple",    bgfx::UniformType::Vec4);
-
-		m_program = loadProgram("vs_tree", "fs_tree");
-
-		m_textureLeafs = loadTexture("textures/leafs1.dds");
-		m_textureBark  = loadTexture("textures/bark1.dds");
-
-		const bgfx::Memory* stippleTex = bgfx::alloc(8*4);
-		memset(stippleTex->data, 0, stippleTex->size);
-
-		for (uint32_t ii = 0; ii < 32; ++ii)
-		{
-			stippleTex->data[knightTour[ii].m_y * 8 + knightTour[ii].m_x] = ii*4;
-		}
-
-		m_textureStipple = bgfx::createTexture2D(8, 4, 1
-			, bgfx::TextureFormat::R8
-			, BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIN_POINT
-			, stippleTex
-			);
-
-		m_meshTop[0] = meshLoad("meshes/tree1b_lod0_1.bin");
-		m_meshTop[1] = meshLoad("meshes/tree1b_lod1_1.bin");
-		m_meshTop[2] = meshLoad("meshes/tree1b_lod2_1.bin");
-
-		m_meshTrunk[0] = meshLoad("meshes/tree1b_lod0_2.bin");
-		m_meshTrunk[1] = meshLoad("meshes/tree1b_lod1_2.bin");
-		m_meshTrunk[2] = meshLoad("meshes/tree1b_lod2_2.bin");
-
-		// Imgui.
-		imguiCreate();
-
-		m_scrollArea  = 0;
-		m_transitions = true;
-
-		m_transitionFrame = 0;
-		m_currLod         = 0;
-		m_targetLod       = 0;
-	}
-
-	virtual int shutdown() BX_OVERRIDE
-	{
-		imguiDestroy();
-
-		for (uint32_t ii = 0; ii < BX_COUNTOF(m_meshTop); ++ii)
-		{
-			meshUnload(m_meshTop[ii]);
-			meshUnload(m_meshTrunk[ii]);
-		}
-
-		// Cleanup.
-		bgfx::destroyProgram(m_program);
-
-		bgfx::destroyUniform(s_texColor);
-		bgfx::destroyUniform(s_texStipple);
-		bgfx::destroyUniform(u_stipple);
-
-		bgfx::destroyTexture(m_textureStipple);
-		bgfx::destroyTexture(m_textureLeafs);
-		bgfx::destroyTexture(m_textureBark);
-
-		// Shutdown bgfx.
-		bgfx::shutdown();
-
-		return 0;
-	}
-
-	bool update() BX_OVERRIDE
-	{
-		if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
-		{
-			imguiBeginFrame(m_mouseState.m_mx
-				,  m_mouseState.m_my
-				, (m_mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT   : 0)
-				| (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT  : 0)
-				| (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
-				,  m_mouseState.m_mz
-				, m_width
-				, m_height
-				);
-
-			imguiBeginScrollArea("Toggle transitions", m_width - m_width / 5 - 10, 10, m_width / 5, m_height / 6, &m_scrollArea);
-			imguiSeparatorLine();
-
-			if (imguiButton(m_transitions ? "ON" : "OFF") )
-			{
-				m_transitions = !m_transitions;
-			}
-
-			static float distance = 2.0f;
-			imguiSlider("Distance", distance, 2.0f, 6.0f, 0.01f);
-
-			imguiEndScrollArea();
-			imguiEndFrame();
-
-			// Set view 0 default viewport.
-			bgfx::setViewRect(0, 0, 0, m_width, m_height);
-
-			// This dummy draw call is here to make sure that view 0 is cleared
-			// if no other draw calls are submitted to view 0.
-			bgfx::touch(0);
-
-			int64_t now = bx::getHPCounter();
-			static int64_t last = now;
-			const int64_t frameTime = now - last;
-			last = now;
-			const double freq = double(bx::getHPFrequency() );
-			const double toMs = 1000.0/freq;
-
-			// Use debug font to print information about this example.
-			bgfx::dbgTextClear();
-			bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/12-lod");
-			bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Mesh LOD transitions.");
-			bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-			float at[3]  = { 0.0f, 1.0f,      0.0f };
-			float eye[3] = { 0.0f, 2.0f, -distance };
-
-			// Set view and projection matrix for view 0.
-			const bgfx::HMD* hmd = bgfx::getHMD();
-			if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING) )
-			{
-				float view[16];
-				bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);
-				bgfx::setViewTransform(0, view, hmd->eye[0].projection, BGFX_VIEW_STEREO, hmd->eye[1].projection);
-
-				// Set view 0 default viewport.
-				//
-				// Use HMD's m_width/m_height since HMD's internal frame buffer size
-				// might be much larger than window size.
-				bgfx::setViewRect(0, 0, 0, hmd->width, hmd->height);
-			}
-			else
-			{
-				float view[16];
-				bx::mtxLookAt(view, eye, at);
-
-				float proj[16];
-				bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f);
-				bgfx::setViewTransform(0, view, proj);
-
-				// Set view 0 default viewport.
-				bgfx::setViewRect(0, 0, 0, m_width, m_height);
-			}
-
-			float mtx[16];
-			bx::mtxScale(mtx, 0.1f, 0.1f, 0.1f);
-
-			float stipple[3];
-			float stippleInv[3];
-
-			const int currentLODframe = m_transitions ? 32-m_transitionFrame : 32;
-			const int mainLOD = m_transitions ? m_currLod : m_targetLod;
-
-			stipple[0] = 0.0f;
-			stipple[1] = -1.0f;
-			stipple[2] = (float(currentLODframe)*4.0f/255.0f) - (1.0f/255.0f);
-
-			stippleInv[0] = (float(31)*4.0f/255.0f);
-			stippleInv[1] = 1.0f;
-			stippleInv[2] = (float(m_transitionFrame)*4.0f/255.0f) - (1.0f/255.0f);
-
-			const uint64_t stateTransparent = 0
-				| BGFX_STATE_RGB_WRITE
-				| BGFX_STATE_ALPHA_WRITE
-				| BGFX_STATE_DEPTH_TEST_LESS
-				| BGFX_STATE_CULL_CCW
-				| BGFX_STATE_MSAA
-				| BGFX_STATE_BLEND_ALPHA
-				;
-
-			const uint64_t stateOpaque = BGFX_STATE_DEFAULT;
-
-			bgfx::setTexture(0, s_texColor, m_textureBark);
-			bgfx::setTexture(1, s_texStipple, m_textureStipple);
-			bgfx::setUniform(u_stipple, stipple);
-			meshSubmit(m_meshTrunk[mainLOD], 0, m_program, mtx, stateOpaque);
-
-			bgfx::setTexture(0, s_texColor, m_textureLeafs);
-			bgfx::setTexture(1, s_texStipple, m_textureStipple);
-			bgfx::setUniform(u_stipple, stipple);
-			meshSubmit(m_meshTop[mainLOD], 0, m_program, mtx, stateTransparent);
-
-			if (m_transitions
-			&& (m_transitionFrame != 0) )
-			{
-				bgfx::setTexture(0, s_texColor, m_textureBark);
-				bgfx::setTexture(1, s_texStipple, m_textureStipple);
-				bgfx::setUniform(u_stipple, stippleInv);
-				meshSubmit(m_meshTrunk[m_targetLod], 0, m_program, mtx, stateOpaque);
-
-				bgfx::setTexture(0, s_texColor, m_textureLeafs);
-				bgfx::setTexture(1, s_texStipple, m_textureStipple);
-				bgfx::setUniform(u_stipple, stippleInv);
-				meshSubmit(m_meshTop[m_targetLod], 0, m_program, mtx, stateTransparent);
-			}
-
-			int lod = 0;
-			if (eye[2] < -2.5f)
-			{
-				lod = 1;
-			}
-
-			if (eye[2] < -5.0f)
-			{
-				lod = 2;
-			}
-
-			if (m_targetLod != lod)
-			{
-				if (m_targetLod == m_currLod)
-				{
-					m_targetLod = lod;
-				}
-			}
-
-			if (m_currLod != m_targetLod)
-			{
-				m_transitionFrame++;
-			}
-
-			if (m_transitionFrame > 32)
-			{
-				m_currLod = m_targetLod;
-				m_transitionFrame = 0;
-			}
-
-			// Advance to next frame. Rendering thread will be kicked to
-			// process submitted rendering primitives.
-			bgfx::frame();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	entry::MouseState m_mouseState;
-	uint32_t m_width;
-	uint32_t m_height;
-	uint32_t m_debug;
-	uint32_t m_reset;
-
-	Mesh* m_meshTop[3];
-	Mesh* m_meshTrunk[3];
-
-	bgfx::ProgramHandle m_program;
-	bgfx::UniformHandle s_texColor;
-	bgfx::UniformHandle s_texStipple;
-	bgfx::UniformHandle u_stipple;
-
-	bgfx::TextureHandle m_textureStipple;
-	bgfx::TextureHandle m_textureLeafs;
-	bgfx::TextureHandle m_textureBark;
-
-	int32_t m_scrollArea;
-	int32_t m_transitionFrame;
-	int32_t m_currLod;
-	int32_t m_targetLod;
-	bool    m_transitions;
-};
-
-ENTRY_IMPLEMENT_MAIN(ExampleLod);

+ 0 - 18
third/bgfx/examples/12-lod/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

BIN
third/bgfx/examples/12-lod/screenshot.png


+ 0 - 8
third/bgfx/examples/12-lod/varying.def.sc

@@ -1,8 +0,0 @@
-vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
-vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
-vec3 v_pos       : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
-vec3 v_view      : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
-
-vec3 a_position  : POSITION;
-vec2 a_texcoord0 : TEXCOORD0;
-vec3 a_normal    : NORMAL;

+ 0 - 23
third/bgfx/examples/12-lod/vs_tree.sc

@@ -1,23 +0,0 @@
-$input a_position, a_normal, a_texcoord0
-$output v_pos, v_view, v_normal, v_texcoord0
-
-/*
- * Copyright 2013 Milos Tosic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	vec3 pos = a_position;
-
-	vec3 normal = a_normal.xyz*2.0 - 1.0;
-
-	gl_Position = mul(u_modelViewProj, vec4(pos, 1.0) );
-	v_pos = gl_Position.xyz/gl_Position.w;
-	v_view = mul(u_modelView, vec4(pos, 1.0) ).xyz;
-
-	v_normal = mul(u_modelView, vec4(normal, 0.0) ).xyz;
-	v_texcoord0 = a_texcoord0;
-}

BIN
third/bgfx/examples/13-stencil/figure-rgba.tga


BIN
third/bgfx/examples/13-stencil/flare.tga


+ 0 - 11
third/bgfx/examples/13-stencil/fs_stencil_color_black.sc

@@ -1,11 +0,0 @@
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-void main()
-{
-	gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
-}

+ 0 - 88
third/bgfx/examples/13-stencil/fs_stencil_color_lighting.sc

@@ -1,88 +0,0 @@
-$input v_normal, v_view
-
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-#define MAX_NUM_LIGHTS 5
-
-uniform vec4 u_params;
-uniform vec4 u_ambient;
-uniform vec4 u_diffuse;
-uniform vec4 u_color;
-uniform vec4 u_specular_shininess;
-uniform vec4 u_lightPosRadius[MAX_NUM_LIGHTS];
-uniform vec4 u_lightRgbInnerR[MAX_NUM_LIGHTS];
-
-#define u_ambientPass  u_params.x
-#define u_lightingPass u_params.y
-#define u_lightCount   u_params.z
-#define u_lightIndex   u_params.w
-#define u_specular     u_specular_shininess.xyz
-#define u_shininess    u_specular_shininess.w
-
-vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
-{
-	float ndotl = dot(_normal, _lightDir);
-	vec3 reflected = 2.0*ndotl*_normal - _lightDir; // reflect(_lightDir, _normal);
-	float rdotv = dot(reflected, _viewDir);
-	return vec2(ndotl, rdotv);
-}
-
-vec4 lit(float _ndotl, float _rdotv, float _m)
-{
-	float diff = max(0.0, _ndotl);
-	float spec = step(0.0, _ndotl) * pow(max(0.0, _rdotv), _m);
-	return vec4(1.0, diff, spec, 1.0);
-}
-
-vec3 calcLight(int _idx, vec3 _view, vec3 _normal, vec3 _viewDir)
-{
-	vec3 lightPos = mul(u_view, vec4(u_lightPosRadius[_idx].xyz, 1.0)).xyz;
-	vec3 toLight = lightPos - _view;
-	vec3 lightDir = normalize(toLight);
-
-	vec2 bln = blinn(lightDir, _normal, _viewDir);
-	vec4 lc = lit(bln.x, bln.y, u_shininess);
-
-	float dist = max(length(toLight), u_lightPosRadius[_idx].w);
-	float attn = 250.0 * pow(dist, -2.0);
-	vec3 rgb = (lc.y * u_diffuse.xyz + lc.z * u_specular) * u_lightRgbInnerR[_idx].rgb * attn;
-
-	return rgb;
-}
-
-void main()
-{
-	vec3 normal = normalize(v_normal);
-	vec3 viewDir = -normalize(v_view);
-
-	vec3 ambientColor = u_ambient.xyz * u_ambientPass;
-
-	vec3 lightColor = vec3_splat(0.0);
-	for(int ii = 0; ii < MAX_NUM_LIGHTS; ++ii)
-	{
-		float condition = 0.0;
-		if (u_lightCount > 1.0)
-		{
-			condition = 1.0 - step(u_lightCount, float(ii));
-		}
-		else
-		{
-			condition = float(float(ii) == u_lightIndex);
-		}
-		lightColor += calcLight(ii, v_view, normal, viewDir) * condition;
-	}
-	lightColor *= u_lightingPass;
-
-	vec3 color = u_color.xyz;
-
-	vec3 ambient = toGamma(ambientColor * color);
-	vec3 diffuse = toGamma(lightColor * color);
-	gl_FragColor.xyz = clamp(ambient + diffuse, 0.0, 1.0);
-
-	gl_FragColor.w = u_color.w;
-}

+ 0 - 22
third/bgfx/examples/13-stencil/fs_stencil_color_texture.sc

@@ -1,22 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-uniform vec4 u_color;
-SAMPLER2D(s_texColor, 0);
-
-void main()
-{
-	vec4 color = toLinear(texture2D(s_texColor, v_texcoord0) );
-
-	if (color.x < 0.1)
-	{
-		discard;
-	}
-
-	gl_FragColor = toGamma(color + u_color);
-}

+ 0 - 14
third/bgfx/examples/13-stencil/fs_stencil_texture.sc

@@ -1,14 +0,0 @@
-$input v_texcoord0
-
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-SAMPLER2D(s_texColor, 0);
-
-void main()
-{
-	gl_FragColor = texture2D(s_texColor, v_texcoord0);
-}

+ 0 - 90
third/bgfx/examples/13-stencil/fs_stencil_texture_lighting.sc

@@ -1,90 +0,0 @@
-$input v_normal, v_view, v_texcoord0
-
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh"
-
-#define MAX_NUM_LIGHTS 5
-
-uniform vec4 u_params;
-uniform vec4 u_ambient;
-uniform vec4 u_diffuse;
-uniform vec4 u_color;
-uniform vec4 u_specular_shininess;
-uniform vec4 u_lightPosRadius[MAX_NUM_LIGHTS];
-uniform vec4 u_lightRgbInnerR[MAX_NUM_LIGHTS];
-SAMPLER2D(s_texColor, 0);
-
-#define u_ambientPass  u_params.x
-#define u_lightingPass u_params.y
-#define u_lightCount   u_params.z
-#define u_lightIndex   u_params.w
-#define u_specular     u_specular_shininess.xyz
-#define u_shininess    u_specular_shininess.w
-
-vec2 blinn(vec3 _lightDir, vec3 _normal, vec3 _viewDir)
-{
-	float ndotl = dot(_normal, _lightDir);
-	vec3 reflected = 2.0*ndotl*_normal - _lightDir; // reflect(_lightDir, _normal);
-	float rdotv = dot(reflected, _viewDir);
-	return vec2(ndotl, rdotv);
-}
-
-vec4 lit(float _ndotl, float _rdotv, float _m)
-{
-	float diff = max(0.0, _ndotl);
-	float spec = step(0.0, _ndotl) * pow(max(0.0, _rdotv), _m);
-	return vec4(1.0, diff, spec, 1.0);
-}
-
-vec3 calcLight(int _idx, vec3 _view, vec3 _normal, vec3 _viewDir)
-{
-	vec3 lightPos = mul(u_view, vec4(u_lightPosRadius[_idx].xyz, 1.0)).xyz;
-	vec3 toLight = lightPos - _view;
-	vec3 lightDir = normalize(toLight);
-
-	vec2 bln = blinn(lightDir, _normal, _viewDir);
-	vec4 lc = lit(bln.x, bln.y, u_shininess);
-
-	float dist = max(length(toLight), u_lightPosRadius[_idx].w);
-	float attn = 250.0 * pow(dist, -2.0);
-	vec3 rgb = (lc.y * u_diffuse.xyz + lc.z * u_specular) * u_lightRgbInnerR[_idx].rgb * attn;
-
-	return rgb;
-}
-
-void main()
-{
-	vec3 normal = normalize(v_normal);
-	vec3 viewDir = -normalize(v_view);
-
-	vec3 ambientColor = u_ambient.xyz * u_ambientPass;
-
-	vec3 lightColor = vec3_splat(0.0);
-	for(int ii = 0; ii < MAX_NUM_LIGHTS; ++ii)
-	{
-		float condition = 0.0;
-		if (u_lightCount > 1.0) // Stencil Reflection Scene.
-		{
-			condition = 1.0 - step(u_lightCount, float(ii)); // True for every light up to u_lightCount.
-		}
-		else // Projection Shadows Scene.
-		{
-			condition = float(float(ii) == u_lightIndex); // True only for current light.
-		}
-
-		lightColor += calcLight(ii, v_view, normal, viewDir) * condition;
-	}
-	lightColor *= u_lightingPass;
-
-	vec3 color = toLinear(texture2D(s_texColor, v_texcoord0)).xyz;
-
-	vec3 ambient = toGamma(ambientColor * color);
-	vec3 diffuse = toGamma(lightColor * color);
-	gl_FragColor.xyz = clamp(ambient + diffuse, 0.0, 1.0);
-
-	gl_FragColor.w = u_color.w;
-}

+ 0 - 18
third/bgfx/examples/13-stencil/makefile

@@ -1,18 +0,0 @@
-#
-# Copyright 2011-2016 Branimir Karadzic. All rights reserved.
-# License: http://www.opensource.org/licenses/BSD-2-Clause
-#
-
-BGFX_DIR=../..
-RUNTIME_DIR=$(BGFX_DIR)/examples/runtime
-BUILD_DIR=../../.build
-
-include $(BGFX_DIR)/scripts/shader.mk
-
-rebuild:
-	@make -s --no-print-directory TARGET=0 clean all
-	@make -s --no-print-directory TARGET=1 clean all
-	@make -s --no-print-directory TARGET=2 clean all
-	@make -s --no-print-directory TARGET=3 clean all
-	@make -s --no-print-directory TARGET=4 clean all
-	@make -s --no-print-directory TARGET=5 clean all

BIN
third/bgfx/examples/13-stencil/screenshot.png


+ 0 - 1402
third/bgfx/examples/13-stencil/stencil.cpp

@@ -1,1402 +0,0 @@
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include <string>
-#include <vector>
-
-#include "common.h"
-#include "bgfx_utils.h"
-
-#include <bx/crtimpl.h>
-#include "camera.h"
-#include "imgui/imgui.h"
-
-#define RENDER_VIEWID_RANGE1_PASS_0   1
-#define RENDER_VIEWID_RANGE1_PASS_1   2
-#define RENDER_VIEWID_RANGE1_PASS_2   3
-#define RENDER_VIEWID_RANGE1_PASS_3   4
-#define RENDER_VIEWID_RANGE1_PASS_4   5
-#define RENDER_VIEWID_RANGE1_PASS_5   6
-#define RENDER_VIEWID_RANGE5_PASS_6   7
-#define RENDER_VIEWID_RANGE1_PASS_7  13
-
-#define MAX_NUM_LIGHTS 5
-
-uint32_t packUint32(uint8_t _x, uint8_t _y, uint8_t _z, uint8_t _w)
-{
-	union
-	{
-		uint32_t ui32;
-		uint8_t arr[4];
-	} un;
-
-	un.arr[0] = _x;
-	un.arr[1] = _y;
-	un.arr[2] = _z;
-	un.arr[3] = _w;
-
-	return un.ui32;
-}
-
-uint32_t packF4u(float _x, float _y = 0.0f, float _z = 0.0f, float _w = 0.0f)
-{
-	const uint8_t xx = uint8_t(_x*127.0f + 128.0f);
-	const uint8_t yy = uint8_t(_y*127.0f + 128.0f);
-	const uint8_t zz = uint8_t(_z*127.0f + 128.0f);
-	const uint8_t ww = uint8_t(_w*127.0f + 128.0f);
-	return packUint32(xx, yy, zz, ww);
-}
-
-struct PosNormalTexcoordVertex
-{
-	float    m_x;
-	float    m_y;
-	float    m_z;
-	uint32_t m_normal;
-	float    m_u;
-	float    m_v;
-
-	static void init()
-	{
-		ms_decl
-			.begin()
-			.add(bgfx::Attrib::Position,  3, bgfx::AttribType::Float)
-			.add(bgfx::Attrib::Normal,    4, bgfx::AttribType::Uint8, true, true)
-			.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
-			.end();
-	}
-
-	static bgfx::VertexDecl ms_decl;
-};
-
-bgfx::VertexDecl PosNormalTexcoordVertex::ms_decl;
-
-static const float s_texcoord = 5.0f;
-static PosNormalTexcoordVertex s_hplaneVertices[] =
-{
-	{ -1.0f, 0.0f,  1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, s_texcoord },
-	{  1.0f, 0.0f,  1.0f, packF4u(0.0f, 1.0f, 0.0f), s_texcoord, 0.0f       },
-	{ -1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f,       s_texcoord },
-	{  1.0f, 0.0f, -1.0f, packF4u(0.0f, 1.0f, 0.0f), 0.0f,       0.0f       },
-};
-
-static PosNormalTexcoordVertex s_vplaneVertices[] =
-{
-	{ -1.0f,  1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 1.0f },
-	{  1.0f,  1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 1.0f, 0.0f },
-	{ -1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 1.0f },
-	{  1.0f, -1.0f, 0.0f, packF4u(0.0f, 0.0f, -1.0f), 0.0f, 0.0f },
-};
-
-static const PosNormalTexcoordVertex s_cubeVertices[] =
-{
-	{ -1.0f,  1.0f,  1.0f, packF4u( 0.0f,  1.0f,  0.0f), 1.0f, 1.0f },
-	{  1.0f,  1.0f,  1.0f, packF4u( 0.0f,  1.0f,  0.0f), 0.0f, 1.0f },
-	{ -1.0f,  1.0f, -1.0f, packF4u( 0.0f,  1.0f,  0.0f), 1.0f, 0.0f },
-	{  1.0f,  1.0f, -1.0f, packF4u( 0.0f,  1.0f,  0.0f), 0.0f, 0.0f },
-	{ -1.0f, -1.0f,  1.0f, packF4u( 0.0f, -1.0f,  0.0f), 1.0f, 1.0f },
-	{  1.0f, -1.0f,  1.0f, packF4u( 0.0f, -1.0f,  0.0f), 0.0f, 1.0f },
-	{ -1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f,  0.0f), 1.0f, 0.0f },
-	{  1.0f, -1.0f, -1.0f, packF4u( 0.0f, -1.0f,  0.0f), 0.0f, 0.0f },
-	{  1.0f, -1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 0.0f, 0.0f },
-	{  1.0f,  1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 0.0f, 1.0f },
-	{ -1.0f, -1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 1.0f, 0.0f },
-	{ -1.0f,  1.0f,  1.0f, packF4u( 0.0f,  0.0f,  1.0f), 1.0f, 1.0f },
-	{  1.0f, -1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 0.0f, 0.0f },
-	{  1.0f,  1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 0.0f, 1.0f },
-	{ -1.0f, -1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 1.0f, 0.0f },
-	{ -1.0f,  1.0f, -1.0f, packF4u( 0.0f,  0.0f, -1.0f), 1.0f, 1.0f },
-	{  1.0f,  1.0f, -1.0f, packF4u( 1.0f,  0.0f,  0.0f), 1.0f, 1.0f },
-	{  1.0f,  1.0f,  1.0f, packF4u( 1.0f,  0.0f,  0.0f), 0.0f, 1.0f },
-	{  1.0f, -1.0f, -1.0f, packF4u( 1.0f,  0.0f,  0.0f), 1.0f, 0.0f },
-	{  1.0f, -1.0f,  1.0f, packF4u( 1.0f,  0.0f,  0.0f), 0.0f, 0.0f },
-	{ -1.0f,  1.0f, -1.0f, packF4u(-1.0f,  0.0f,  0.0f), 1.0f, 1.0f },
-	{ -1.0f,  1.0f,  1.0f, packF4u(-1.0f,  0.0f,  0.0f), 0.0f, 1.0f },
-	{ -1.0f, -1.0f, -1.0f, packF4u(-1.0f,  0.0f,  0.0f), 1.0f, 0.0f },
-	{ -1.0f, -1.0f,  1.0f, packF4u(-1.0f,  0.0f,  0.0f), 0.0f, 0.0f },
-};
-
-static const uint16_t s_cubeIndices[] =
-{
-	0,  1,  2,
-	1,  3,  2,
-	4,  6,  5,
-	5,  6,  7,
-
-	8,  9, 10,
-	9, 11, 10,
-	12, 14, 13,
-	13, 14, 15,
-
-	16, 17, 18,
-	17, 19, 18,
-	20, 22, 21,
-	21, 22, 23,
-};
-
-static const uint16_t s_planeIndices[] =
-{
-	0, 1, 2,
-	1, 3, 2,
-};
-
-static bool s_flipV = false;
-static uint32_t s_viewMask = 0;
-static uint32_t s_clearMask = 0;
-static bgfx::UniformHandle s_texColor;
-
-inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far)
-{
-	bx::mtxProj(_result, _fovy, _aspect, _near, _far, s_flipV);
-}
-
-void setViewClearMask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
-{
-	for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
-	{
-		viewMask >>= ntz;
-		view += ntz;
-
-		bgfx::setViewClear( (uint8_t)view, _flags, _rgba, _depth, _stencil);
-	}
-}
-
-void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj)
-{
-	for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
-	{
-		viewMask >>= ntz;
-		view += ntz;
-
-		bgfx::setViewTransform( (uint8_t)view, _view, _proj);
-	}
-}
-
-void setViewRectMask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
-{
-	for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) )
-	{
-		viewMask >>= ntz;
-		view += ntz;
-
-		bgfx::setViewRect( (uint8_t)view, _x, _y, _width, _height);
-	}
-}
-
-void mtxReflected(float*__restrict _result
-				  , const float* __restrict _p  /* plane */
-				  , const float* __restrict _n  /* normal */
-				  )
-{
-	float dot = bx::vec3Dot(_p, _n);
-
-	_result[ 0] =  1.0f -  2.0f * _n[0] * _n[0]; //1-2Nx^2
-	_result[ 1] = -2.0f * _n[0] * _n[1];         //-2*Nx*Ny
-	_result[ 2] = -2.0f * _n[0] * _n[2];         //-2*NxNz
-	_result[ 3] =  0.0f;                         //0
-
-	_result[ 4] = -2.0f * _n[0] * _n[1];         //-2*NxNy
-	_result[ 5] =  1.0f -  2.0f * _n[1] * _n[1]; //1-2*Ny^2
-	_result[ 6] = -2.0f * _n[1] * _n[2];         //-2*NyNz
-	_result[ 7] =  0.0f;                         //0
-
-	_result[ 8] = -2.0f * _n[0] * _n[2];         //-2*NxNz
-	_result[ 9] = -2.0f * _n[1] * _n[2];         //-2NyNz
-	_result[10] =  1.0f -  2.0f * _n[2] * _n[2]; //1-2*Nz^2
-	_result[11] =  0.0f;                         //0
-
-	_result[12] =  2.0f * dot * _n[0];           //2*dot*Nx
-	_result[13] =  2.0f * dot * _n[1];           //2*dot*Ny
-	_result[14] =  2.0f * dot * _n[2];           //2*dot*Nz
-	_result[15] =  1.0f;                         //1
-}
-
-void mtxShadow(float* __restrict _result
-			   , const float* __restrict _ground
-			   , const float* __restrict _light
-			   )
-{
-	float dot = _ground[0] * _light[0]
-		+ _ground[1] * _light[1]
-		+ _ground[2] * _light[2]
-		+ _ground[3] * _light[3]
-		;
-
-	_result[ 0] =  dot - _light[0] * _ground[0];
-	_result[ 1] = 0.0f - _light[1] * _ground[0];
-	_result[ 2] = 0.0f - _light[2] * _ground[0];
-	_result[ 3] = 0.0f - _light[3] * _ground[0];
-
-	_result[ 4] = 0.0f - _light[0] * _ground[1];
-	_result[ 5] =  dot - _light[1] * _ground[1];
-	_result[ 6] = 0.0f - _light[2] * _ground[1];
-	_result[ 7] = 0.0f - _light[3] * _ground[1];
-
-	_result[ 8] = 0.0f - _light[0] * _ground[2];
-	_result[ 9] = 0.0f - _light[1] * _ground[2];
-	_result[10] =  dot - _light[2] * _ground[2];
-	_result[11] = 0.0f - _light[3] * _ground[2];
-
-	_result[12] = 0.0f - _light[0] * _ground[3];
-	_result[13] = 0.0f - _light[1] * _ground[3];
-	_result[14] = 0.0f - _light[2] * _ground[3];
-	_result[15] =  dot - _light[3] * _ground[3];
-}
-
-void mtxBillboard(float* __restrict _result
-				  , const float* __restrict _view
-				  , const float* __restrict _pos
-				  , const float* __restrict _scale)
-{
-	_result[ 0] = _view[0]  * _scale[0];
-	_result[ 1] = _view[4]  * _scale[0];
-	_result[ 2] = _view[8]  * _scale[0];
-	_result[ 3] = 0.0f;
-	_result[ 4] = _view[1]  * _scale[1];
-	_result[ 5] = _view[5]  * _scale[1];
-	_result[ 6] = _view[9]  * _scale[1];
-	_result[ 7] = 0.0f;
-	_result[ 8] = _view[2]  * _scale[2];
-	_result[ 9] = _view[6]  * _scale[2];
-	_result[10] = _view[10] * _scale[2];
-	_result[11] = 0.0f;
-	_result[12] = _pos[0];
-	_result[13] = _pos[1];
-	_result[14] = _pos[2];
-	_result[15] = 1.0f;
-}
-
-struct Uniforms
-{
-	void init()
-	{
-		m_params.m_ambientPass   = 1.0f;
-		m_params.m_lightingPass  = 1.0f;
-		m_params.m_lightCount    = 4.0f;
-		m_params.m_lightIndex    = 4.0f;
-
-		m_ambient[0] = 0.02f;
-		m_ambient[1] = 0.02f;
-		m_ambient[2] = 0.02f;
-		m_ambient[3] = 0.0f; //unused
-
-		m_diffuse[0] = 0.2f;
-		m_diffuse[1] = 0.2f;
-		m_diffuse[2] = 0.2f;
-		m_diffuse[3] = 0.0f; //unused
-
-		m_specular_shininess[0] = 1.0f;
-		m_specular_shininess[1] = 1.0f;
-		m_specular_shininess[2] = 1.0f;
-		m_specular_shininess[3] = 10.0f; //shininess
-
-		m_color[0] = 1.0f;
-		m_color[1] = 1.0f;
-		m_color[2] = 1.0f;
-		m_color[3] = 1.0f;
-
-		m_time = 0.0f;
-
-		for (uint8_t ii = 0; ii < MAX_NUM_LIGHTS; ++ii)
-		{
-			m_lightPosRadius[ii][0] = 0.0f;
-			m_lightPosRadius[ii][1] = 0.0f;
-			m_lightPosRadius[ii][2] = 0.0f;
-			m_lightPosRadius[ii][3] = 1.0f;
-
-			m_lightRgbInnerR[ii][0] = 1.0f;
-			m_lightRgbInnerR[ii][1] = 1.0f;
-			m_lightRgbInnerR[ii][2] = 1.0f;
-			m_lightRgbInnerR[ii][3] = 1.0f;
-		}
-
-		u_params             = bgfx::createUniform("u_params",              bgfx::UniformType::Vec4);
-		u_ambient            = bgfx::createUniform("u_ambient",             bgfx::UniformType::Vec4);
-		u_diffuse            = bgfx::createUniform("u_diffuse",             bgfx::UniformType::Vec4);
-		u_specular_shininess = bgfx::createUniform("u_specular_shininess",  bgfx::UniformType::Vec4);
-		u_color              = bgfx::createUniform("u_color",               bgfx::UniformType::Vec4);
-		u_lightPosRadius     = bgfx::createUniform("u_lightPosRadius",      bgfx::UniformType::Vec4, MAX_NUM_LIGHTS);
-		u_lightRgbInnerR     = bgfx::createUniform("u_lightRgbInnerR",      bgfx::UniformType::Vec4, MAX_NUM_LIGHTS);
-	}
-
-	//call this once at initialization
-	void submitConstUniforms()
-	{
-		bgfx::setUniform(u_ambient,            &m_ambient);
-		bgfx::setUniform(u_diffuse,            &m_diffuse);
-		bgfx::setUniform(u_specular_shininess, &m_specular_shininess);
-	}
-
-	//call this before each draw call
-	void submitPerDrawUniforms()
-	{
-		bgfx::setUniform(u_params,         &m_params);
-		bgfx::setUniform(u_color,          &m_color);
-		bgfx::setUniform(u_lightPosRadius, &m_lightPosRadius, MAX_NUM_LIGHTS);
-		bgfx::setUniform(u_lightRgbInnerR, &m_lightRgbInnerR, MAX_NUM_LIGHTS);
-	}
-
-	void destroy()
-	{
-		bgfx::destroyUniform(u_params);
-		bgfx::destroyUniform(u_ambient);
-		bgfx::destroyUniform(u_diffuse);
-		bgfx::destroyUniform(u_specular_shininess);
-		bgfx::destroyUniform(u_color);
-		bgfx::destroyUniform(u_lightPosRadius);
-		bgfx::destroyUniform(u_lightRgbInnerR);
-	}
-
-	struct Params
-	{
-		float m_ambientPass;
-		float m_lightingPass;
-		float m_lightCount;
-		float m_lightIndex;
-	};
-
-	struct SvParams
-	{
-		float m_useStencilTex;
-		float m_dfail;
-		float m_unused0;
-		float m_unused1;
-	};
-
-
-	Params m_params;
-	SvParams m_svparams;
-	float m_ambient[4];
-	float m_diffuse[4];
-	float m_specular_shininess[4];
-	float m_color[4];
-	float m_time;
-	float m_lightPosRadius[MAX_NUM_LIGHTS][4];
-	float m_lightRgbInnerR[MAX_NUM_LIGHTS][4];
-
-	/**
-	 * u_params.x - u_ambientPass
-	 * u_params.y - u_lightingPass
-	 * u_params.z - u_lightCount
-	 * u_params.w - u_lightIndex
-	 */
-	bgfx::UniformHandle u_params;
-	bgfx::UniformHandle u_ambient;
-	bgfx::UniformHandle u_diffuse;
-	bgfx::UniformHandle u_specular_shininess;
-	bgfx::UniformHandle u_color;
-	bgfx::UniformHandle u_lightPosRadius;
-	bgfx::UniformHandle u_lightRgbInnerR;
-};
-static Uniforms s_uniforms;
-
-//-------------------------------------------------
-// Render state
-//-------------------------------------------------
-
-struct RenderState
-{
-	enum Enum
-	{
-		StencilReflection_CraftStencil = 0,
-		StencilReflection_DrawReflected,
-		StencilReflection_BlendPlane,
-		StencilReflection_DrawScene,
-
-		ProjectionShadows_DrawAmbient,
-		ProjectionShadows_CraftStencil,
-		ProjectionShadows_DrawDiffuse,
-
-		Custom_BlendLightTexture,
-		Custom_DrawPlaneBottom,
-
-		Count
-	};
-
-	uint64_t m_state;
-	uint32_t m_blendFactorRgba;
-	uint32_t m_fstencil;
-	uint32_t m_bstencil;
-};
-
-static RenderState s_renderStates[RenderState::Count] =
-{
-	{ // StencilReflection_CraftStencil
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_DEPTH_WRITE
-		| BGFX_STATE_DEPTH_TEST_LESS
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_TEST_ALWAYS         // pass always
-		| BGFX_STENCIL_FUNC_REF(1)         // value = 1
-		| BGFX_STENCIL_FUNC_RMASK(0xff)
-		| BGFX_STENCIL_OP_FAIL_S_REPLACE
-		| BGFX_STENCIL_OP_FAIL_Z_REPLACE
-		| BGFX_STENCIL_OP_PASS_Z_REPLACE   // store the value
-		, BGFX_STENCIL_NONE
-	},
-	{ // StencilReflection_DrawReflected
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_ALPHA_WRITE
-		| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
-		| BGFX_STATE_DEPTH_WRITE
-		| BGFX_STATE_DEPTH_TEST_LESS
-		| BGFX_STATE_CULL_CW    //reflection matrix has inverted normals. using CCW instead of CW.
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_TEST_EQUAL
-		| BGFX_STENCIL_FUNC_REF(1)
-		| BGFX_STENCIL_FUNC_RMASK(1)
-		| BGFX_STENCIL_OP_FAIL_S_KEEP
-		| BGFX_STENCIL_OP_FAIL_Z_KEEP
-		| BGFX_STENCIL_OP_PASS_Z_KEEP
-		, BGFX_STENCIL_NONE
-	},
-	{ // StencilReflection_BlendPlane
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_DEPTH_WRITE
-		| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_SRC_COLOR)
-		| BGFX_STATE_DEPTH_TEST_LESS
-		| BGFX_STATE_CULL_CCW
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_NONE
-		, BGFX_STENCIL_NONE
-	},
-	{ // StencilReflection_DrawScene
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_DEPTH_WRITE
-		| BGFX_STATE_DEPTH_TEST_LESS
-		| BGFX_STATE_CULL_CCW
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_NONE
-		, BGFX_STENCIL_NONE
-	},
-	{ // ProjectionShadows_DrawAmbient
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_DEPTH_WRITE // write depth !
-		| BGFX_STATE_DEPTH_TEST_LESS
-		| BGFX_STATE_CULL_CCW
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_NONE
-		, BGFX_STENCIL_NONE
-	},
-	{ // ProjectionShadows_CraftStencil
-		BGFX_STATE_DEPTH_TEST_LESS
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_TEST_ALWAYS         // pass always
-		| BGFX_STENCIL_FUNC_REF(1)         // value = 1
-		| BGFX_STENCIL_FUNC_RMASK(0xff)
-		| BGFX_STENCIL_OP_FAIL_S_KEEP
-		| BGFX_STENCIL_OP_FAIL_Z_KEEP
-		| BGFX_STENCIL_OP_PASS_Z_REPLACE   // store the value
-		, BGFX_STENCIL_NONE
-	},
-	{ // ProjectionShadows_DrawDiffuse
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
-		| BGFX_STATE_DEPTH_TEST_EQUAL
-		| BGFX_STATE_CULL_CCW
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_TEST_NOTEQUAL
-		| BGFX_STENCIL_FUNC_REF(1)
-		| BGFX_STENCIL_FUNC_RMASK(1)
-		| BGFX_STENCIL_OP_FAIL_S_KEEP
-		| BGFX_STENCIL_OP_FAIL_Z_KEEP
-		| BGFX_STENCIL_OP_PASS_Z_KEEP
-		, BGFX_STENCIL_NONE
-	},
-	{ // Custom_BlendLightTexture
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_ALPHA_WRITE
-		| BGFX_STATE_DEPTH_WRITE
-		| BGFX_STATE_DEPTH_TEST_LESS
-		| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_COLOR, BGFX_STATE_BLEND_INV_SRC_COLOR)
-		| BGFX_STATE_CULL_CCW
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_NONE
-		, BGFX_STENCIL_NONE
-	},
-	{ // Custom_DrawPlaneBottom
-		BGFX_STATE_RGB_WRITE
-		| BGFX_STATE_CULL_CW
-		| BGFX_STATE_MSAA
-		, UINT32_MAX
-		, BGFX_STENCIL_NONE
-		, BGFX_STENCIL_NONE
-	},
-};
-
-struct ViewState
-{
-	ViewState(uint32_t _width = 1280, uint32_t _height = 720)
-		: m_width(_width)
-		, m_height(_height)
-	{
-	}
-
-	uint32_t m_width;
-	uint32_t m_height;
-
-	float m_view[16];
-	float m_proj[16];
-};
-
-struct ClearValues
-{
-	ClearValues(uint32_t _clearRgba     = 0x30303000
-		, float    _clearDepth    = 1.0f
-		, uint8_t  _clearStencil  = 0
-		)
-		: m_clearRgba(_clearRgba)
-		, m_clearDepth(_clearDepth)
-		, m_clearStencil(_clearStencil)
-	{ }
-
-	uint32_t m_clearRgba;
-	float    m_clearDepth;
-	uint8_t  m_clearStencil;
-};
-
-void clearView(uint8_t _id, uint8_t _flags, const ClearValues& _clearValues)
-{
-	bgfx::setViewClear(_id
-		, _flags
-		, _clearValues.m_clearRgba
-		, _clearValues.m_clearDepth
-		, _clearValues.m_clearStencil
-		);
-
-	// Keep track of cleared views
-	s_clearMask |= 1 << _id;
-}
-
-void clearViewMask(uint32_t _viewMask, uint8_t _flags, const ClearValues& _clearValues)
-{
-	setViewClearMask(_viewMask
-		, _flags
-		, _clearValues.m_clearRgba
-		, _clearValues.m_clearDepth
-		, _clearValues.m_clearStencil
-		);
-
-	// Keep track of cleared views
-	s_clearMask |= _viewMask;
-}
-
-struct Aabb
-{
-	float m_min[3];
-	float m_max[3];
-};
-
-struct Obb
-{
-	float m_mtx[16];
-};
-
-struct Sphere
-{
-	float m_center[3];
-	float m_radius;
-};
-
-struct Primitive
-{
-	uint32_t m_startIndex;
-	uint32_t m_numIndices;
-	uint32_t m_startVertex;
-	uint32_t m_numVertices;
-
-	Sphere m_sphere;
-	Aabb m_aabb;
-	Obb m_obb;
-};
-
-typedef std::vector<Primitive> PrimitiveArray;
-
-struct Group
-{
-	Group()
-	{
-		reset();
-	}
-
-	void reset()
-	{
-		m_vbh.idx = bgfx::invalidHandle;
-		m_ibh.idx = bgfx::invalidHandle;
-		m_prims.clear();
-	}
-
-	bgfx::VertexBufferHandle m_vbh;
-	bgfx::IndexBufferHandle m_ibh;
-	Sphere m_sphere;
-	Aabb m_aabb;
-	Obb m_obb;
-	PrimitiveArray m_prims;
-};
-
-namespace bgfx
-{
-	int32_t read(bx::ReaderI* _reader, bgfx::VertexDecl& _decl, bx::Error* _err = NULL);
-}
-
-struct Mesh
-{
-	void load(const void* _vertices, uint32_t _numVertices, const bgfx::VertexDecl _decl, const uint16_t* _indices, uint32_t _numIndices)
-	{
-		Group group;
-		const bgfx::Memory* mem;
-		uint32_t size;
-
-		size = _numVertices*_decl.getStride();
-		mem = bgfx::makeRef(_vertices, size);
-		group.m_vbh = bgfx::createVertexBuffer(mem, _decl);
-
-		size = _numIndices*2;
-		mem = bgfx::makeRef(_indices, size);
-		group.m_ibh = bgfx::createIndexBuffer(mem);
-
-		m_groups.push_back(group);
-	}
-
-	void load(const char* _filePath)
-	{
-#define BGFX_CHUNK_MAGIC_VB  BX_MAKEFOURCC('V', 'B', ' ', 0x1)
-#define BGFX_CHUNK_MAGIC_IB  BX_MAKEFOURCC('I', 'B', ' ', 0x0)
-#define BGFX_CHUNK_MAGIC_PRI BX_MAKEFOURCC('P', 'R', 'I', 0x0)
-
-		bx::CrtFileReader reader;
-		bx::open(&reader, _filePath);
-
-		Group group;
-
-		uint32_t chunk;
-		while (4 == bx::read(&reader, chunk) )
-		{
-			switch (chunk)
-			{
-			case BGFX_CHUNK_MAGIC_VB:
-				{
-					bx::read(&reader, group.m_sphere);
-					bx::read(&reader, group.m_aabb);
-					bx::read(&reader, group.m_obb);
-
-					bgfx::read(&reader, m_decl);
-					uint16_t stride = m_decl.getStride();
-
-					uint16_t numVertices;
-					bx::read(&reader, numVertices);
-					const bgfx::Memory* mem = bgfx::alloc(numVertices*stride);
-					bx::read(&reader, mem->data, mem->size);
-
-					group.m_vbh = bgfx::createVertexBuffer(mem, m_decl);
-				}
-				break;
-
-			case BGFX_CHUNK_MAGIC_IB:
-				{
-					uint32_t numIndices;
-					bx::read(&reader, numIndices);
-					const bgfx::Memory* mem = bgfx::alloc(numIndices*2);
-					bx::read(&reader, mem->data, mem->size);
-					group.m_ibh = bgfx::createIndexBuffer(mem);
-				}
-				break;
-
-			case BGFX_CHUNK_MAGIC_PRI:
-				{
-					uint16_t len;
-					bx::read(&reader, len);
-
-					std::string material;
-					material.resize(len);
-					bx::read(&reader, const_cast<char*>(material.c_str() ), len);
-
-					uint16_t num;
-					bx::read(&reader, num);
-
-					for (uint32_t ii = 0; ii < num; ++ii)
-					{
-						bx::read(&reader, len);
-
-						std::string name;
-						name.resize(len);
-						bx::read(&reader, const_cast<char*>(name.c_str() ), len);
-
-						Primitive prim;
-						bx::read(&reader, prim.m_startIndex);
-						bx::read(&reader, prim.m_numIndices);
-						bx::read(&reader, prim.m_startVertex);
-						bx::read(&reader, prim.m_numVertices);
-						bx::read(&reader, prim.m_sphere);
-						bx::read(&reader, prim.m_aabb);
-						bx::read(&reader, prim.m_obb);
-
-						group.m_prims.push_back(prim);
-					}
-
-					m_groups.push_back(group);
-					group.reset();
-				}
-				break;
-
-			default:
-				DBG("%08x at %d", chunk, reader.seek() );
-				abort();
-				break;
-			}
-		}
-
-		bx::close(&reader);
-	}
-
-	void unload()
-	{
-		for (GroupArray::const_iterator it = m_groups.begin(), itEnd = m_groups.end(); it != itEnd; ++it)
-		{
-			const Group& group = *it;
-			bgfx::destroyVertexBuffer(group.m_vbh);
-
-			if (bgfx::invalidHandle != group.m_ibh.idx)
-			{
-				bgfx::destroyIndexBuffer(group.m_ibh);
-			}
-		}
-		m_groups.clear();
-	}
-
-	void submit(uint8_t _viewId, float* _mtx, bgfx::ProgramHandle _program, const RenderState& _renderState)
-	{
-		bgfx::TextureHandle texture = BGFX_INVALID_HANDLE;
-		submit(_viewId, _mtx, _program, _renderState, texture);
-	}
-
-	void submit(uint8_t _viewId, float* _mtx, bgfx::ProgramHandle _program, const RenderState& _renderState, bgfx::TextureHandle _texture)
-	{
-		for (GroupArray::const_iterator it = m_groups.begin(), itEnd = m_groups.end(); it != itEnd; ++it)
-		{
-			const Group& group = *it;
-
-			// Set uniforms
-			s_uniforms.submitPerDrawUniforms();
-
-			// Set model matrix for rendering.
-			bgfx::setTransform(_mtx);
-			bgfx::setIndexBuffer(group.m_ibh);
-			bgfx::setVertexBuffer(group.m_vbh);
-
-			// Set texture
-			if (bgfx::invalidHandle != _texture.idx)
-			{
-				bgfx::setTexture(0, s_texColor, _texture);
-			}
-
-			// Apply render state
-			bgfx::setStencil(_renderState.m_fstencil, _renderState.m_bstencil);
-			bgfx::setState(_renderState.m_state, _renderState.m_blendFactorRgba);
-
-			// Submit
-			bgfx::submit(_viewId, _program);
-
-			// Keep track of submited view ids
-			s_viewMask |= 1 << _viewId;
-		}
-	}
-
-	bgfx::VertexDecl m_decl;
-	typedef std::vector<Group> GroupArray;
-	GroupArray m_groups;
-};
-
-int _main_(int _argc, char** _argv)
-{
-	Args args(_argc, _argv);
-
-	ViewState viewState(1280, 720);
-	ClearValues clearValues(0x30303000, 1.0f, 0);
-
-	uint32_t debug = BGFX_DEBUG_TEXT;
-	uint32_t reset = BGFX_RESET_VSYNC;
-
-	bgfx::init(args.m_type, args.m_pciId);
-	bgfx::reset(viewState.m_width, viewState.m_height, reset);
-
-	// Enable debug text.
-	bgfx::setDebug(debug);
-
-	// Setup root path for binary shaders. Shader binaries are different
-	// for each renderer.
-	switch (bgfx::getRendererType() )
-	{
-	case bgfx::RendererType::OpenGL:
-	case bgfx::RendererType::OpenGLES:
-		s_flipV = true;
-		break;
-
-	default:
-		break;
-	}
-
-	// Imgui.
-	imguiCreate();
-
-	PosNormalTexcoordVertex::init();
-
-	s_uniforms.init();
-	s_uniforms.submitConstUniforms();
-
-	s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
-
-	bgfx::ProgramHandle programTextureLighting = loadProgram("vs_stencil_texture_lighting", "fs_stencil_texture_lighting");
-	bgfx::ProgramHandle programColorLighting   = loadProgram("vs_stencil_color_lighting",   "fs_stencil_color_lighting"  );
-	bgfx::ProgramHandle programColorTexture    = loadProgram("vs_stencil_color_texture",    "fs_stencil_color_texture"   );
-	bgfx::ProgramHandle programColorBlack      = loadProgram("vs_stencil_color",            "fs_stencil_color_black"     );
-	bgfx::ProgramHandle programTexture         = loadProgram("vs_stencil_texture",          "fs_stencil_texture"         );
-
-	Mesh bunnyMesh;
-	Mesh columnMesh;
-	Mesh cubeMesh;
-	Mesh hplaneMesh;
-	Mesh vplaneMesh;
-	bunnyMesh.load("meshes/bunny.bin");
-	columnMesh.load("meshes/column.bin");
-	cubeMesh.load(s_cubeVertices, BX_COUNTOF(s_cubeVertices), PosNormalTexcoordVertex::ms_decl, s_cubeIndices, BX_COUNTOF(s_cubeIndices) );
-	hplaneMesh.load(s_hplaneVertices, BX_COUNTOF(s_hplaneVertices), PosNormalTexcoordVertex::ms_decl, s_planeIndices, BX_COUNTOF(s_planeIndices) );
-	vplaneMesh.load(s_vplaneVertices, BX_COUNTOF(s_vplaneVertices), PosNormalTexcoordVertex::ms_decl, s_planeIndices, BX_COUNTOF(s_planeIndices) );
-
-	bgfx::TextureHandle figureTex     = loadTexture("textures/figure-rgba.dds");
-	bgfx::TextureHandle flareTex      = loadTexture("textures/flare.dds");
-	bgfx::TextureHandle fieldstoneTex = loadTexture("textures/fieldstone-rgba.dds");
-
-	// Setup lights.
-	const float rgbInnerR[][4] =
-	{
-		{ 1.0f, 0.7f, 0.2f, 0.0f }, //yellow
-		{ 0.7f, 0.2f, 1.0f, 0.0f }, //purple
-		{ 0.2f, 1.0f, 0.7f, 0.0f }, //cyan
-		{ 1.0f, 0.4f, 0.2f, 0.0f }, //orange
-		{ 0.7f, 0.7f, 0.7f, 0.0f }, //white
-	};
-
-	float lightRgbInnerR[MAX_NUM_LIGHTS][4];
-	for (uint8_t ii = 0, jj = 0; ii < MAX_NUM_LIGHTS; ++ii, ++jj)
-	{
-		const uint8_t index = jj%BX_COUNTOF(rgbInnerR);
-		lightRgbInnerR[ii][0] = rgbInnerR[index][0];
-		lightRgbInnerR[ii][1] = rgbInnerR[index][1];
-		lightRgbInnerR[ii][2] = rgbInnerR[index][2];
-		lightRgbInnerR[ii][3] = rgbInnerR[index][3];
-	}
-	memcpy(s_uniforms.m_lightRgbInnerR, lightRgbInnerR, MAX_NUM_LIGHTS * 4*sizeof(float) );
-
-	// Set view and projection matrices.
-	const float aspect = float(viewState.m_width)/float(viewState.m_height);
-	mtxProj(viewState.m_proj, 60.0f, aspect, 0.1f, 100.0f);
-
-	float initialPos[3] = { 0.0f, 18.0f, -40.0f };
-	cameraCreate();
-	cameraSetPosition(initialPos);
-	cameraSetVerticalAngle(-0.35f);
-	cameraGetViewMtx(viewState.m_view);
-
-	int64_t timeOffset = bx::getHPCounter();
-
-	enum Scene
-	{
-		StencilReflectionScene = 0,
-		ProjectionShadowsScene,
-	};
-
-	Scene scene = StencilReflectionScene;
-	float settings_numLights       = 4.0f;
-	float settings_reflectionValue = 0.8f;
-	bool  settings_updateLights    = true;
-	bool  settings_updateScene     = true;
-
-	static const char* titles[3] =
-	{
-		"Stencil Reflection Scene",
-		"Projection Shadows Scene",
-	};
-
-	entry::MouseState mouseState;
-	while (!entry::processEvents(viewState.m_width, viewState.m_height, debug, reset, &mouseState) )
-	{
-		imguiBeginFrame(mouseState.m_mx
-			, mouseState.m_my
-			, (mouseState.m_buttons[entry::MouseButton::Left  ] ? IMGUI_MBUT_LEFT   : 0)
-			| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT  : 0)
-			| (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
-			, mouseState.m_mz
-			, viewState.m_width
-			, viewState.m_height
-			);
-
-		static int32_t scrollArea = 0;
-		imguiBeginScrollArea("Settings", viewState.m_width - 256 - 10, 10, 256, 215, &scrollArea);
-
-		if (imguiCheck(titles[StencilReflectionScene], StencilReflectionScene == scene) )
-		{
-			scene = StencilReflectionScene;
-			settings_numLights = 4.0f;
-		}
-
-		if (imguiCheck(titles[ProjectionShadowsScene], ProjectionShadowsScene == scene) )
-		{
-			scene = ProjectionShadowsScene;
-			settings_numLights = 1.0f;
-		}
-
-		imguiSeparatorLine();
-		imguiSlider("Lights", settings_numLights, 1.0f, float(MAX_NUM_LIGHTS), 1.0f);
-		if (scene == StencilReflectionScene)
-		{
-			imguiSlider("Reflection value", settings_reflectionValue, 0.0f, 1.0f, 0.01f);
-		}
-
-		if (imguiCheck("Update lights", settings_updateLights) )
-		{
-			settings_updateLights = !settings_updateLights;
-		}
-
-		if (imguiCheck("Update scene", settings_updateScene) )
-		{
-			settings_updateScene = !settings_updateScene;
-		}
-
-		imguiEndScrollArea();
-		imguiEndFrame();
-
-		// Update settings.
-		uint8_t numLights = (uint8_t)settings_numLights;
-		s_uniforms.m_params.m_ambientPass     = 1.0f;
-		s_uniforms.m_params.m_lightingPass    = 1.0f;
-		s_uniforms.m_params.m_lightCount      = settings_numLights;
-		s_uniforms.m_params.m_lightIndex      = 0.0f;
-		s_uniforms.m_color[3]                 = settings_reflectionValue;
-
-		// Time.
-		int64_t now = bx::getHPCounter();
-		static int64_t last = now;
-		const int64_t frameTime = now - last;
-		last = now;
-		const double freq = double(bx::getHPFrequency() );
-		const double toMs = 1000.0/freq;
-		const float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) );
-		const float deltaTime = float(frameTime/freq);
-		s_uniforms.m_time = time;
-
-		// Use debug font to print information about this example.
-		bgfx::dbgTextClear();
-		bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/13-stencil");
-		bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Stencil reflections and shadows.");
-		bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
-
-		// Update camera.
-		cameraUpdate(deltaTime, mouseState);
-		cameraGetViewMtx(viewState.m_view);
-
-		static float lightTimeAccumulator = 0.0f;
-		if (settings_updateLights)
-		{
-			lightTimeAccumulator += deltaTime;
-		}
-
-		static float sceneTimeAccumulator = 0.0f;
-		if (settings_updateScene)
-		{
-			sceneTimeAccumulator += deltaTime;
-		}
-
-		float lightPosRadius[MAX_NUM_LIGHTS][4];
-		const float radius = (scene == StencilReflectionScene) ? 15.0f : 25.0f;
-		for (uint8_t ii = 0; ii < numLights; ++ii)
-		{
-			lightPosRadius[ii][0] = sinf( (lightTimeAccumulator*1.1f + ii*0.03f + ii*bx::piHalf*1.07f ) )*20.0f;
-			lightPosRadius[ii][1] = 8.0f + (1.0f - cosf( (lightTimeAccumulator*1.5f + ii*0.29f + bx::piHalf*1.49f ) ) )*4.0f;
-			lightPosRadius[ii][2] = cosf( (lightTimeAccumulator*1.3f + ii*0.13f + ii*bx::piHalf*1.79f ) )*20.0f;
-			lightPosRadius[ii][3] = radius;
-		}
-		memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float) );
-
-		// Floor position.
-		float floorMtx[16];
-		bx::mtxSRT(floorMtx
-			, 20.0f  //scaleX
-			, 20.0f  //scaleY
-			, 20.0f  //scaleZ
-			, 0.0f   //rotX
-			, 0.0f   //rotY
-			, 0.0f   //rotZ
-			, 0.0f   //translateX
-			, 0.0f   //translateY
-			, 0.0f   //translateZ
-			);
-
-		// Bunny position.
-		float bunnyMtx[16];
-		bx::mtxSRT(bunnyMtx
-			, 5.0f
-			, 5.0f
-			, 5.0f
-			, 0.0f
-			, 1.56f - sceneTimeAccumulator
-			, 0.0f
-			, 0.0f
-			, 2.0f
-			, 0.0f
-			);
-
-		// Columns position.
-		const float dist = 14.0f;
-		const float columnPositions[4][3] =
-		{
-			{  dist, 0.0f,  dist },
-			{ -dist, 0.0f,  dist },
-			{  dist, 0.0f, -dist },
-			{ -dist, 0.0f, -dist },
-		};
-
-		float columnMtx[4][16];
-		for (uint8_t ii = 0; ii < 4; ++ii)
-		{
-			bx::mtxSRT(columnMtx[ii]
-				, 1.0f
-				, 1.0f
-				, 1.0f
-				, 0.0f
-				, 0.0f
-				, 0.0f
-				, columnPositions[ii][0]
-				, columnPositions[ii][1]
-				, columnPositions[ii][2]
-				);
-		}
-
-		const uint8_t numCubes = 9;
-		float cubeMtx[numCubes][16];
-		for (uint16_t ii = 0; ii < numCubes; ++ii)
-		{
-			bx::mtxSRT(cubeMtx[ii]
-				, 1.0f
-				, 1.0f
-				, 1.0f
-				, 0.0f
-				, 0.0f
-				, 0.0f
-				, sinf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
-				, 4.0f
-				, cosf(ii * 2.0f + 13.0f - sceneTimeAccumulator) * 13.0f
-				);
-		}
-
-		// Make sure at the beginning everything gets cleared.
-		clearView(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL, clearValues);
-		bgfx::touch(0);
-		s_viewMask |= 1;
-
-		// Bunny and columns color.
-		s_uniforms.m_color[0] = 0.70f;
-		s_uniforms.m_color[1] = 0.65f;
-		s_uniforms.m_color[2] = 0.60f;
-
-		switch (scene)
-		{
-		case StencilReflectionScene:
-			{
-				// First pass - Draw plane.
-
-				// Setup params for this scene.
-				s_uniforms.m_params.m_ambientPass = 1.0f;
-				s_uniforms.m_params.m_lightingPass = 1.0f;
-
-				// Floor.
-				hplaneMesh.submit(RENDER_VIEWID_RANGE1_PASS_0
-					, floorMtx
-					, programColorBlack
-					, s_renderStates[RenderState::StencilReflection_CraftStencil]
-					);
-
-				// Second pass - Draw reflected objects.
-
-				// Clear depth from previous pass.
-				clearView(RENDER_VIEWID_RANGE1_PASS_1, BGFX_CLEAR_DEPTH, clearValues);
-
-				// Compute reflected matrix.
-				float reflectMtx[16];
-				float plane_pos[3] = { 0.0f, 0.01f, 0.0f };
-				float normal[3] = { 0.0f, 1.0f, 0.0f };
-				mtxReflected(reflectMtx, plane_pos, normal);
-
-				// Reflect lights.
-				float reflectedLights[MAX_NUM_LIGHTS][4];
-				for (uint8_t ii = 0; ii < numLights; ++ii)
-				{
-					bx::vec3MulMtx(reflectedLights[ii], lightPosRadius[ii], reflectMtx);
-					reflectedLights[ii][3] = lightPosRadius[ii][3];
-				}
-				memcpy(s_uniforms.m_lightPosRadius, reflectedLights, numLights * 4*sizeof(float) );
-
-				// Reflect and submit bunny.
-				float mtxReflectedBunny[16];
-				bx::mtxMul(mtxReflectedBunny, bunnyMtx, reflectMtx);
-				bunnyMesh.submit(RENDER_VIEWID_RANGE1_PASS_1
-					, mtxReflectedBunny
-					, programColorLighting
-					, s_renderStates[RenderState::StencilReflection_DrawReflected]
-					);
-
-				// Reflect and submit columns.
-				float mtxReflectedColumn[16];
-				for (uint8_t ii = 0; ii < 4; ++ii)
-				{
-					bx::mtxMul(mtxReflectedColumn, columnMtx[ii], reflectMtx);
-					columnMesh.submit(RENDER_VIEWID_RANGE1_PASS_1
-						, mtxReflectedColumn
-						, programColorLighting
-						, s_renderStates[RenderState::StencilReflection_DrawReflected]
-						);
-				}
-
-				// Set lights back.
-				memcpy(s_uniforms.m_lightPosRadius, lightPosRadius, numLights * 4*sizeof(float) );
-				// Third pass - Blend plane.
-
-				// Floor.
-				hplaneMesh.submit(RENDER_VIEWID_RANGE1_PASS_2
-					, floorMtx
-					, programTextureLighting
-					, s_renderStates[RenderState::StencilReflection_BlendPlane]
-					, fieldstoneTex
-					);
-
-				// Fourth pass - Draw everything else but the plane.
-
-				// Bunny.
-				bunnyMesh.submit(RENDER_VIEWID_RANGE1_PASS_3
-					, bunnyMtx
-					, programColorLighting
-					, s_renderStates[RenderState::StencilReflection_DrawScene]
-					);
-
-				// Columns.
-				for (uint8_t ii = 0; ii < 4; ++ii)
-				{
-					columnMesh.submit(RENDER_VIEWID_RANGE1_PASS_3
-						, columnMtx[ii]
-						, programColorLighting
-						, s_renderStates[RenderState::StencilReflection_DrawScene]
-						);
-				}
-
-			}
-			break;
-
-		case ProjectionShadowsScene:
-			{
-				// First pass - Draw entire scene. (ambient only).
-				s_uniforms.m_params.m_ambientPass = 1.0f;
-				s_uniforms.m_params.m_lightingPass = 0.0f;
-
-				// Bunny.
-				bunnyMesh.submit(RENDER_VIEWID_RANGE1_PASS_0
-					, bunnyMtx
-					, programColorLighting
-					, s_renderStates[RenderState::ProjectionShadows_DrawAmbient]
-				);
-
-				// Floor.
-				hplaneMesh.submit(RENDER_VIEWID_RANGE1_PASS_0
-					, floorMtx
-					, programTextureLighting
-					, s_renderStates[RenderState::ProjectionShadows_DrawAmbient]
-					, fieldstoneTex
-					);
-
-				// Cubes.
-				for (uint8_t ii = 0; ii < numCubes; ++ii)
-				{
-					cubeMesh.submit(RENDER_VIEWID_RANGE1_PASS_0
-						, cubeMtx[ii]
-						, programTextureLighting
-						, s_renderStates[RenderState::ProjectionShadows_DrawAmbient]
-						, figureTex
-						);
-				}
-
-				// Ground plane.
-				float ground[4];
-				float plane_pos[3] = { 0.0f, 0.0f, 0.0f };
-				float normal[3] = { 0.0f, 1.0f, 0.0f };
-				memcpy(ground, normal, sizeof(float) * 3);
-				ground[3] = -bx::vec3Dot(plane_pos, normal) - 0.01f; // - 0.01 against z-fighting
-
-				for (uint8_t ii = 0, viewId = RENDER_VIEWID_RANGE5_PASS_6; ii < numLights; ++ii, ++viewId)
-				{
-					// Clear stencil for this light source.
-					clearView(viewId, BGFX_CLEAR_STENCIL, clearValues);
-
-					// Draw shadow projection of scene objects.
-
-					// Get homogeneous light pos.
-					float* lightPos = lightPosRadius[ii];
-					float pos[4];
-					memcpy(pos, lightPos, sizeof(float) * 3);
-					pos[3] = 1.0f;
-
-					// Calculate shadow mtx for current light.
-					float shadowMtx[16];
-					mtxShadow(shadowMtx, ground, pos);
-
-					// Submit bunny's shadow.
-					float mtxShadowedBunny[16];
-					bx::mtxMul(mtxShadowedBunny, bunnyMtx, shadowMtx);
-					bunnyMesh.submit(viewId
-						, mtxShadowedBunny
-						, programColorBlack
-						, s_renderStates[RenderState::ProjectionShadows_CraftStencil]
-					);
-
-					// Submit cube shadows.
-					float mtxShadowedCube[16];
-					for (uint8_t jj = 0; jj < numCubes; ++jj)
-					{
-						bx::mtxMul(mtxShadowedCube, cubeMtx[jj], shadowMtx);
-						cubeMesh.submit(viewId
-							, mtxShadowedCube
-							, programColorBlack
-							, s_renderStates[RenderState::ProjectionShadows_CraftStencil]
-						);
-					}
-
-					// Draw entire scene. (lighting pass only. blending is on)
-					s_uniforms.m_params.m_ambientPass = 0.0f;
-					s_uniforms.m_params.m_lightingPass = 1.0f;
-					s_uniforms.m_params.m_lightCount = 1.0f;
-					s_uniforms.m_params.m_lightIndex = float(ii);
-
-					// Bunny.
-					bunnyMesh.submit(viewId
-						, bunnyMtx
-						, programColorLighting
-						, s_renderStates[RenderState::ProjectionShadows_DrawDiffuse]
-					);
-
-					// Floor.
-					hplaneMesh.submit(viewId
-						, floorMtx
-						, programTextureLighting
-						, s_renderStates[RenderState::ProjectionShadows_DrawDiffuse]
-						, fieldstoneTex
-						);
-
-					// Cubes.
-					for (uint8_t jj = 0; jj < numCubes; ++jj)
-					{
-						cubeMesh.submit(viewId
-							, cubeMtx[jj]
-							, programTextureLighting
-							, s_renderStates[RenderState::ProjectionShadows_DrawDiffuse]
-							, figureTex
-							);
-					}
-				}
-
-				// Reset these to default..
-				s_uniforms.m_params.m_ambientPass = 1.0f;
-				s_uniforms.m_params.m_lightingPass = 1.0f;
-			}
-			break;
-		};
-
-		//lights
-		const float lightScale[3] = { 1.5f, 1.5f, 1.5f };
-		float lightMtx[16];
-		for (uint8_t ii = 0; ii < numLights; ++ii)
-		{
-			s_uniforms.m_color[0] = lightRgbInnerR[ii][0];
-			s_uniforms.m_color[1] = lightRgbInnerR[ii][1];
-			s_uniforms.m_color[2] = lightRgbInnerR[ii][2];
-
-			mtxBillboard(lightMtx, viewState.m_view, lightPosRadius[ii], lightScale);
-			vplaneMesh.submit(RENDER_VIEWID_RANGE1_PASS_7
-				, lightMtx
-				, programColorTexture
-				, s_renderStates[RenderState::Custom_BlendLightTexture]
-				, flareTex
-				);
-		}
-
-		// Draw floor bottom.
-		float floorBottomMtx[16];
-		bx::mtxSRT(floorBottomMtx
-			, 20.0f  //scaleX
-			, 20.0f  //scaleY
-			, 20.0f  //scaleZ
-			, 0.0f   //rotX
-			, 0.0f   //rotY
-			, 0.0f   //rotZ
-			, 0.0f   //translateX
-			, -0.1f  //translateY
-			, 0.0f   //translateZ
-			);
-
-		hplaneMesh.submit(RENDER_VIEWID_RANGE1_PASS_7
-			, floorBottomMtx
-			, programTexture
-			, s_renderStates[RenderState::Custom_DrawPlaneBottom]
-			, figureTex
-			);
-
-		// Setup view rect and transform for all used views.
-		setViewRectMask(s_viewMask, 0, 0, viewState.m_width, viewState.m_height);
-		setViewTransformMask(s_viewMask, viewState.m_view, viewState.m_proj);
-		s_viewMask = 0;
-
-		// Advance to next frame. Rendering thread will be kicked to
-		// process submitted rendering primitives.
-		bgfx::frame();
-
-		//reset clear values on used views
-		clearViewMask(s_clearMask, BGFX_CLEAR_NONE, clearValues);
-		s_clearMask = 0;
-	}
-
-	// Cleanup.
-	bunnyMesh.unload();
-	columnMesh.unload();
-	cubeMesh.unload();
-	hplaneMesh.unload();
-	vplaneMesh.unload();
-
-	bgfx::destroyTexture(figureTex);
-	bgfx::destroyTexture(fieldstoneTex);
-	bgfx::destroyTexture(flareTex);
-
-	bgfx::destroyProgram(programTextureLighting);
-	bgfx::destroyProgram(programColorLighting);
-	bgfx::destroyProgram(programColorTexture);
-	bgfx::destroyProgram(programColorBlack);
-	bgfx::destroyProgram(programTexture);
-
-	bgfx::destroyUniform(s_texColor);
-
-	s_uniforms.destroy();
-
-	cameraDestroy();
-	imguiDestroy();
-
-	// Shutdown bgfx.
-	bgfx::shutdown();
-
-	return 0;
-}

+ 0 - 7
third/bgfx/examples/13-stencil/varying.def.sc

@@ -1,7 +0,0 @@
-vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
-vec3 v_view      : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
-vec3 v_normal    : NORMAL    = vec3(0.0, 0.0, 1.0);
-
-vec3 a_position  : POSITION;
-vec4 a_normal    : NORMAL;
-vec2 a_texcoord0 : TEXCOORD0;

+ 0 - 13
third/bgfx/examples/13-stencil/vs_stencil_color.sc

@@ -1,13 +0,0 @@
-$input a_position
-
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh" 
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-}

+ 0 - 18
third/bgfx/examples/13-stencil/vs_stencil_color_lighting.sc

@@ -1,18 +0,0 @@
-$input a_position, a_normal, a_texcoord0
-$output  v_normal, v_view
-
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh" 
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-
-	vec4 normal = a_normal * 2.0 - 1.0;
-	v_normal = mul(u_modelView, vec4(normal.xyz, 0.0) ).xyz;
-	v_view   = mul(u_modelView, vec4(a_position, 1.0) ).xyz;
-}

+ 0 - 16
third/bgfx/examples/13-stencil/vs_stencil_color_texture.sc

@@ -1,16 +0,0 @@
-$input a_position, a_texcoord0
-$output v_texcoord0
-
-/*
- * Copyright 2013-2014 Dario Manesku. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
- */
-
-#include "../common/common.sh" 
-
-void main()
-{
-	gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
-
-    v_texcoord0 = a_texcoord0;
-}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно