Branimir Karadžić 8 years ago
parent
commit
917385f79e
42 changed files with 181 additions and 140 deletions
  1. 3 3
      examples/00-helloworld/helloworld.cpp
  2. 3 3
      examples/01-cubes/cubes.cpp
  3. 3 3
      examples/02-metaballs/metaballs.cpp
  4. 3 3
      examples/03-raymarch/raymarch.cpp
  5. 3 3
      examples/04-mesh/mesh.cpp
  6. 3 3
      examples/05-instancing/instancing.cpp
  7. 3 3
      examples/06-bump/bump.cpp
  8. 3 3
      examples/07-callback/callback.cpp
  9. 3 3
      examples/08-update/update.cpp
  10. 3 3
      examples/09-hdr/hdr.cpp
  11. 3 3
      examples/10-font/font.cpp
  12. 3 3
      examples/11-fontsdf/fontsdf.cpp
  13. 3 3
      examples/12-lod/lod.cpp
  14. 3 3
      examples/13-stencil/stencil.cpp
  15. 3 3
      examples/14-shadowvolumes/shadowvolumes.cpp
  16. 3 3
      examples/15-shadowmaps-simple/shadowmaps_simple.cpp
  17. 3 3
      examples/16-shadowmaps/shadowmaps.cpp
  18. 3 3
      examples/17-drawstress/drawstress.cpp
  19. 3 3
      examples/18-ibl/ibl.cpp
  20. 3 3
      examples/19-oit/oit.cpp
  21. 3 3
      examples/20-nanovg/nanovg.cpp
  22. 3 3
      examples/21-deferred/deferred.cpp
  23. 3 3
      examples/22-windows/windows.cpp
  24. 3 3
      examples/23-vectordisplay/main.cpp
  25. 3 3
      examples/24-nbody/nbody.cpp
  26. 1 1
      examples/25-c99/helloworld.c
  27. 3 3
      examples/26-occlusion/occlusion.cpp
  28. 3 3
      examples/27-terrain/terrain.cpp
  29. 3 3
      examples/28-wireframe/wireframe.cpp
  30. 3 3
      examples/29-debugdraw/debugdraw.cpp
  31. 3 3
      examples/30-picking/picking.cpp
  32. 3 3
      examples/31-rsm/reflectiveshadowmap.cpp
  33. 3 3
      examples/32-particles/particles.cpp
  34. 3 3
      examples/33-pom/pom.cpp
  35. 1 1
      examples/common/bgfx_utils.cpp
  36. 1 1
      examples/common/bgfx_utils.h
  37. 64 23
      examples/common/entry/entry.cpp
  38. 2 5
      examples/common/entry/entry.h
  39. 3 3
      examples/common/entry/entry_glfw.cpp
  40. 1 1
      examples/common/entry/entry_p.h
  41. 4 4
      examples/common/entry/entry_x11.cpp
  42. 5 2
      examples/common/example-glue.cpp

+ 3 - 3
examples/00-helloworld/helloworld.cpp

@@ -20,12 +20,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_TEXT;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/01-cubes/cubes.cpp

@@ -83,14 +83,14 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		BX_UNUSED(s_cubeTriList, s_cubeTriStrip);
 
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/02-metaballs/metaballs.cpp

@@ -484,12 +484,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/03-raymarch/raymarch.cpp

@@ -107,12 +107,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/04-mesh/mesh.cpp

@@ -18,12 +18,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/05-instancing/instancing.cpp

@@ -67,12 +67,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/06-bump/bump.cpp

@@ -90,12 +90,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/07-callback/callback.cpp

@@ -321,12 +321,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 
 		bgfx::init(
 			  args.m_type

+ 3 - 3
examples/08-update/update.cpp

@@ -127,12 +127,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/09-hdr/hdr.cpp

@@ -145,12 +145,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/10-font/font.cpp

@@ -59,12 +59,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/11-fontsdf/fontsdf.cpp

@@ -42,12 +42,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/12-lod/lod.cpp

@@ -34,12 +34,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/13-stencil/stencil.cpp

@@ -513,7 +513,7 @@ static RenderState s_renderStates[RenderState::Count] =
 
 struct ViewState
 {
-	ViewState(uint32_t _width = 1280, uint32_t _height = 720)
+	ViewState(uint32_t _width = 0, uint32_t _height = 0)
 		: m_width(_width)
 		, m_height(_height)
 	{
@@ -795,11 +795,11 @@ public:
 	{
 	}
 
-	virtual void init(int _argc, char** _argv) BX_OVERRIDE
+	virtual void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_viewState = ViewState(1280, 720);
+		m_viewState   = ViewState(_width, _height);
 		m_clearValues = ClearValues(0x30303000, 1.0f, 0);
 
 		m_debug = BGFX_DEBUG_NONE;

+ 3 - 3
examples/14-shadowvolumes/shadowvolumes.cpp

@@ -524,7 +524,7 @@ static RenderState s_renderStates[RenderState::Count]  =
 
 struct ViewState
 {
-	ViewState(uint32_t _width = 1280, uint32_t _height = 720)
+	ViewState(uint32_t _width = 0, uint32_t _height = 0)
 		: m_width(_width)
 		, m_height(_height)
 	{
@@ -1875,11 +1875,11 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_viewState = ViewState(1280, 720);
+		m_viewState   = ViewState(_width, _height);
 		m_clearValues = { 0x00000000, 1.0f, 0 };
 
 		m_debug = BGFX_DEBUG_NONE;

+ 3 - 3
examples/15-shadowmaps-simple/shadowmaps_simple.cpp

@@ -66,12 +66,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/16-shadowmaps/shadowmaps.cpp

@@ -1289,15 +1289,15 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 
-		m_width = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_viewState = ViewState(uint16_t(m_width), uint16_t(m_height));
 		m_clearValues = ClearValues(0x00000000, 1.0f, 0);
 

+ 3 - 3
examples/17-drawstress/drawstress.cpp

@@ -91,12 +91,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_NONE;
 

+ 3 - 3
examples/18-ibl/ibl.cpp

@@ -489,12 +489,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset  = 0
 			| BGFX_RESET_VSYNC

+ 3 - 3
examples/19-oit/oit.cpp

@@ -157,12 +157,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/20-nanovg/nanovg.cpp

@@ -1241,12 +1241,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/21-deferred/deferred.cpp

@@ -198,12 +198,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/22-windows/windows.cpp

@@ -74,12 +74,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/23-vectordisplay/main.cpp

@@ -42,11 +42,11 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
-		m_width = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug = BGFX_DEBUG_NONE;
 		m_reset = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/24-nbody/nbody.cpp

@@ -118,12 +118,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 1 - 1
examples/25-c99/helloworld.c

@@ -13,7 +13,7 @@ uint16_t uint16_max(uint16_t _a, uint16_t _b)
 	return _a < _b ? _b : _a;
 }
 
-int _main_(int _argc, char** _argv)
+int32_t _main_(int32_t _argc, char** _argv)
 {
 	uint32_t width  = 1280;
 	uint32_t height = 720;

+ 3 - 3
examples/26-occlusion/occlusion.cpp

@@ -70,12 +70,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/27-terrain/terrain.cpp

@@ -67,12 +67,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/28-wireframe/wireframe.cpp

@@ -315,12 +315,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = 0
 			| BGFX_RESET_VSYNC

+ 3 - 3
examples/29-debugdraw/debugdraw.cpp

@@ -37,12 +37,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC | BGFX_RESET_MSAA_X16;
 

+ 3 - 3
examples/30-picking/picking.cpp

@@ -26,12 +26,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/31-rsm/reflectiveshadowmap.cpp

@@ -199,12 +199,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/32-particles/particles.cpp

@@ -235,12 +235,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 3 - 3
examples/33-pom/pom.cpp

@@ -116,12 +116,12 @@ public:
 	{
 	}
 
-	void init(int _argc, char** _argv) BX_OVERRIDE
+	void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) BX_OVERRIDE
 	{
 		Args args(_argc, _argv);
 
-		m_width  = 1280;
-		m_height = 720;
+		m_width  = _width;
+		m_height = _height;
 		m_debug  = BGFX_DEBUG_NONE;
 		m_reset  = BGFX_RESET_VSYNC;
 

+ 1 - 1
examples/common/bgfx_utils.cpp

@@ -648,7 +648,7 @@ void meshSubmit(const Mesh* _mesh, const MeshState*const* _state, uint8_t _numPa
 	_mesh->submit(_state, _numPasses, _mtx, _numMatrices);
 }
 
-Args::Args(int _argc, char** _argv)
+Args::Args(int _argc, const char* const* _argv)
 	: m_type(bgfx::RendererType::Count)
 	, m_pciId(BGFX_PCI_ID_NONE)
 {

+ 1 - 1
examples/common/bgfx_utils.h

@@ -101,7 +101,7 @@ void meshSubmit(const Mesh* _mesh, const MeshState*const* _state, uint8_t _numPa
 ///
 struct Args
 {
-	Args(int _argc, char** _argv);
+	Args(int _argc, const char* const* _argv);
 
 	bgfx::RendererType::Enum m_type;
 	uint16_t m_pciId;

+ 64 - 23
examples/common/entry/entry.cpp

@@ -22,7 +22,7 @@
 #define RMT_ENABLED ENTRY_CONFIG_PROFILER
 #include <remotery/lib/Remotery.h>
 
-extern "C" int _main_(int _argc, char** _argv);
+extern "C" int32_t _main_(int32_t _argc, char** _argv);
 
 namespace entry
 {
@@ -277,10 +277,10 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		if (_argc > 1)
 		{
 			inputSetMouseLock(_argc > 1 ? bx::toBool(_argv[1]) : !inputIsMouseLocked() );
-			return 0;
+			return bx::kExitSuccess;
 		}
 
-		return 1;
+		return bx::kExitFailure;
 	}
 
 	int cmdGraphics(CmdContext* /*_context*/, void* /*_userData*/, int _argc, char const* const* _argv)
@@ -299,7 +299,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 			||  setOrToggle(s_reset, "depthclamp",  BGFX_RESET_DEPTH_CLAMP,        1, _argc, _argv)
 			   )
 			{
-				return 0;
+				return bx::kExitSuccess;
 			}
 			else if (setOrToggle(s_debug, "stats",     BGFX_DEBUG_STATS,     1, _argc, _argv)
 				 ||  setOrToggle(s_debug, "ifh",       BGFX_DEBUG_IFH,       1, _argc, _argv)
@@ -307,7 +307,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 				 ||  setOrToggle(s_debug, "wireframe", BGFX_DEBUG_WIREFRAME, 1, _argc, _argv) )
 			{
 				bgfx::setDebug(s_debug);
-				return 0;
+				return bx::kExitSuccess;
 			}
 			else if (0 == bx::strCmp(_argv[1], "screenshot") )
 			{
@@ -327,23 +327,23 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 					bgfx::requestScreenShot(fbh, filePath);
 				}
 
-				return 0;
+				return bx::kExitSuccess;
 			}
 			else if (0 == bx::strCmp(_argv[1], "fullscreen") )
 			{
 				WindowHandle window = { 0 };
 				toggleFullscreen(window);
-				return 0;
+				return bx::kExitSuccess;
 			}
 		}
 
-		return 1;
+		return bx::kExitFailure;
 	}
 
 	int cmdExit(CmdContext* /*_context*/, void* /*_userData*/, int /*_argc*/, char const* const* /*_argv*/)
 	{
 		s_exit = true;
-		return 0;
+		return bx::kExitSuccess;
 	}
 
 	static const InputBinding s_bindings[] =
@@ -379,9 +379,47 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 	}
 #endif // BX_PLATFORM_EMSCRIPTEN
 
-	static AppI*    s_apps    = NULL;
-	static uint32_t s_numApps = 0;
-	static char     s_restartArgs[1024] = { '\0' };
+	static AppI*    s_currentApp = NULL;
+	static AppI*    s_apps       = NULL;
+	static uint32_t s_numApps    = 0;
+
+	static char s_restartArgs[1024] = { '\0' };
+
+	int cmdApp(CmdContext* /*_context*/, void* /*_userData*/, int _argc, char const* const* _argv)
+	{
+		if (0 == bx::strCmp(_argv[1], "restart")
+		&&  NULL != s_currentApp)
+		{
+			if (1 == _argc)
+			{
+				bx::strCopy(s_restartArgs, BX_COUNTOF(s_restartArgs), s_currentApp->getName() );
+				return bx::kExitSuccess;
+			}
+
+			if (0 == bx::strCmp(_argv[2], "next") )
+			{
+				AppI* next = s_currentApp->getNext();
+				if (NULL == next)
+				{
+					next = getFirstApp();
+				}
+
+				bx::strCopy(s_restartArgs, BX_COUNTOF(s_restartArgs), next->getName() );
+				return bx::kExitSuccess;
+			}
+
+			for (AppI* app = getFirstApp(); NULL != app; app = app->getNext() )
+			{
+				if (0 == bx::strCmp(_argv[2], app->getName() ) )
+				{
+					bx::strCopy(s_restartArgs, BX_COUNTOF(s_restartArgs), app->getName() );
+					return bx::kExitSuccess;
+				}
+			}
+		}
+
+		return bx::kExitFailure;
+	}
 
 	AppI::AppI(const char* _name, const char* _description)
 	{
@@ -418,14 +456,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		return s_numApps;
 	}
 
-	void setRestartArgs(const char* _args)
+	int runApp(AppI* _app, int _argc, const char* const* _argv)
 	{
-		bx::strCopy(s_restartArgs, BX_COUNTOF(s_restartArgs), _args);
-	}
-
-	int runApp(AppI* _app, int _argc, char** _argv)
-	{
-		_app->init(_argc, _argv);
+		_app->init(_argc, _argv, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);
 		bgfx::frame();
 
 		WindowHandle defaultWindow = { 0 };
@@ -435,7 +468,13 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		s_app = _app;
 		emscripten_set_main_loop(&updateApp, -1, 1);
 #else
-		while (_app->update() );
+		while (_app->update() )
+		{
+			if (0 != bx::strLen(s_restartArgs) )
+			{
+				break;
+			}
+		}
 #endif // BX_PLATFORM_EMSCRIPTEN
 
 		return _app->shutdown();
@@ -476,7 +515,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		BX_FREE(g_allocator, apps);
 	}
 
-	int main(int _argc, char** _argv)
+	int main(int _argc, const char* const* _argv)
 	{
 		//DBG(BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME);
 
@@ -510,6 +549,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		cmdAdd("mouselock", cmdMouseLock);
 		cmdAdd("graphics",  cmdGraphics );
 		cmdAdd("exit",      cmdExit     );
+		cmdAdd("app",       cmdApp      );
 
 		inputInit();
 		inputAddBindings("bindings", s_bindings);
@@ -549,11 +589,12 @@ restart:
 		s_restartArgs[0] = '\0';
 		if (0 == s_numApps)
 		{
-			result = ::_main_(_argc, _argv);
+			result = ::_main_(_argc, (char**)_argv);
 		}
 		else
 		{
-			result = runApp(NULL == selected ? getFirstApp() : selected, _argc, _argv);
+			s_currentApp = NULL == selected ? getFirstApp() : selected;
+			result = runApp(s_currentApp, _argc, _argv);
 		}
 
 		if (0 != bx::strLen(s_restartArgs) )

+ 2 - 5
examples/common/entry/entry.h

@@ -286,7 +286,7 @@ namespace entry
 		virtual ~AppI() = 0;
 
 		///
-		virtual void init(int _argc, char** _argv) = 0;
+		virtual void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) = 0;
 
 		///
 		virtual int  shutdown() = 0;
@@ -321,10 +321,7 @@ namespace entry
 	uint32_t getNumApps();
 
 	///
-	void setRestartArgs(const char* _args);
-
-	///
-	int runApp(AppI* _app, int _argc, char** _argv);
+	int runApp(AppI* _app, int _argc, const char* const* _argv);
 
 } // namespace entry
 

+ 3 - 3
examples/common/entry/entry_glfw.cpp

@@ -228,7 +228,7 @@ namespace entry
 	struct MainThreadEntry
 	{
 		int m_argc;
-		char** m_argv;
+		const char* const* m_argv;
 
 		static int32_t threadFunc(void* _userData);
 	};
@@ -393,7 +393,7 @@ namespace entry
 			s_translateKey[GLFW_KEY_Z]            = Key::KeyZ;
 		}
 
-		int run(int _argc, char** _argv)
+		int run(int _argc, const char* const* _argv)
 		{
 			m_mte.m_argc = _argc;
 			m_mte.m_argv = _argv;
@@ -852,7 +852,7 @@ namespace entry
 	}
 }
 
-int main(int _argc, char** _argv)
+int main(int _argc, const char* const* _argv)
 {
 	using namespace entry;
 	return s_ctx.run(_argc, _argv);

+ 1 - 1
examples/common/entry/entry_p.h

@@ -67,7 +67,7 @@ namespace entry
 		static void static_deallocate(void* _ptr, size_t /*_bytes*/);
 	};
 
-	int main(int _argc, char** _argv);
+	int main(int _argc, const char* const* _argv);
 
 	char keyToAscii(Key::Enum _key, uint8_t _modifiers);
 

+ 4 - 4
examples/common/entry/entry_x11.cpp

@@ -220,8 +220,8 @@ namespace entry
 
 	struct MainThreadEntry
 	{
-		int m_argc;
-		char** m_argv;
+		int32_t m_argc;
+		const char* const* m_argv;
 
 		static int32_t threadFunc(void* _userData);
 	};
@@ -343,7 +343,7 @@ namespace entry
 			m_mz = 0;
 		}
 
-		int32_t run(int _argc, char** _argv)
+		int32_t run(int _argc, const char* const* _argv)
 		{
 			XInitThreads();
 			m_display = XOpenDisplay(0);
@@ -773,7 +773,7 @@ namespace entry
 
 } // namespace entry
 
-int main(int _argc, char** _argv)
+int main(int _argc, const char* const* _argv)
 {
 	using namespace entry;
 	return s_ctx.run(_argc, _argv);

+ 5 - 2
examples/common/example-glue.cpp

@@ -5,6 +5,8 @@
 
 #include "imgui/imgui.h"
 #include "entry/entry.h"
+#include "entry/cmd.h"
+#include <bx/string.h>
 
 bool showExampleDialog(entry::AppI* _app)
 {
@@ -45,8 +47,9 @@ bool showExampleDialog(entry::AppI* _app)
 		if (1 < num
 		&&  ImGui::Combo("Example", &current, items, num) )
 		{
-			entry::setRestartArgs(items[current]);
-			restart = true;
+			char command[1024];
+			bx::snprintf(command, BX_COUNTOF(command), "app restart %s", items[current]);
+			cmdExec(command);
 		}
 	}