diff --git a/examples/00-helloworld/helloworld.cpp b/examples/00-helloworld/helloworld.cpp index 4575f0cc5..539599953 100644 --- a/examples/00-helloworld/helloworld.cpp +++ b/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; diff --git a/examples/01-cubes/cubes.cpp b/examples/01-cubes/cubes.cpp index b7d892a98..f222697cd 100644 --- a/examples/01-cubes/cubes.cpp +++ b/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; diff --git a/examples/02-metaballs/metaballs.cpp b/examples/02-metaballs/metaballs.cpp index ceb23e882..12f51ac02 100644 --- a/examples/02-metaballs/metaballs.cpp +++ b/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; diff --git a/examples/03-raymarch/raymarch.cpp b/examples/03-raymarch/raymarch.cpp index 082cff666..a3ac68345 100644 --- a/examples/03-raymarch/raymarch.cpp +++ b/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; diff --git a/examples/04-mesh/mesh.cpp b/examples/04-mesh/mesh.cpp index 7e5121b4d..ad466f7ed 100644 --- a/examples/04-mesh/mesh.cpp +++ b/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; diff --git a/examples/05-instancing/instancing.cpp b/examples/05-instancing/instancing.cpp index dc368d16a..144386483 100644 --- a/examples/05-instancing/instancing.cpp +++ b/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; diff --git a/examples/06-bump/bump.cpp b/examples/06-bump/bump.cpp index 4d6390b7a..443211122 100644 --- a/examples/06-bump/bump.cpp +++ b/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; diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index 346a48a45..e31c11d35 100644 --- a/examples/07-callback/callback.cpp +++ b/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 diff --git a/examples/08-update/update.cpp b/examples/08-update/update.cpp index da4a290dd..debb312cc 100644 --- a/examples/08-update/update.cpp +++ b/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; diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index 27e653775..456a74c42 100644 --- a/examples/09-hdr/hdr.cpp +++ b/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; diff --git a/examples/10-font/font.cpp b/examples/10-font/font.cpp index 1cc6d93b0..cabd8a844 100644 --- a/examples/10-font/font.cpp +++ b/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; diff --git a/examples/11-fontsdf/fontsdf.cpp b/examples/11-fontsdf/fontsdf.cpp index b15e23c0c..da4adcc2c 100644 --- a/examples/11-fontsdf/fontsdf.cpp +++ b/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; diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index 3f9a15226..4331e45f0 100644 --- a/examples/12-lod/lod.cpp +++ b/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; diff --git a/examples/13-stencil/stencil.cpp b/examples/13-stencil/stencil.cpp index 2bfc8968f..f7328bc70 100644 --- a/examples/13-stencil/stencil.cpp +++ b/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; diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 314459c9f..3f9b28fc6 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/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; diff --git a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index a96b11e6b..32b584483 100644 --- a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/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; diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index d25c9e0a7..e7c6b4e02 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/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); diff --git a/examples/17-drawstress/drawstress.cpp b/examples/17-drawstress/drawstress.cpp index 237933000..79d13c80d 100644 --- a/examples/17-drawstress/drawstress.cpp +++ b/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; diff --git a/examples/18-ibl/ibl.cpp b/examples/18-ibl/ibl.cpp index e6411760a..d9d05f369 100644 --- a/examples/18-ibl/ibl.cpp +++ b/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 diff --git a/examples/19-oit/oit.cpp b/examples/19-oit/oit.cpp index a992af032..138add049 100644 --- a/examples/19-oit/oit.cpp +++ b/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; diff --git a/examples/20-nanovg/nanovg.cpp b/examples/20-nanovg/nanovg.cpp index 19d504fb6..d8dfb8038 100644 --- a/examples/20-nanovg/nanovg.cpp +++ b/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; diff --git a/examples/21-deferred/deferred.cpp b/examples/21-deferred/deferred.cpp index 833ad9b27..c8f449f99 100644 --- a/examples/21-deferred/deferred.cpp +++ b/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; diff --git a/examples/22-windows/windows.cpp b/examples/22-windows/windows.cpp index 32be28309..f494da4b7 100644 --- a/examples/22-windows/windows.cpp +++ b/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; diff --git a/examples/23-vectordisplay/main.cpp b/examples/23-vectordisplay/main.cpp index a0ad6ac77..353e29493 100644 --- a/examples/23-vectordisplay/main.cpp +++ b/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; diff --git a/examples/24-nbody/nbody.cpp b/examples/24-nbody/nbody.cpp index 65b641043..28cbc7946 100644 --- a/examples/24-nbody/nbody.cpp +++ b/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; diff --git a/examples/25-c99/helloworld.c b/examples/25-c99/helloworld.c index 6fb38ae0d..d81ffdb35 100644 --- a/examples/25-c99/helloworld.c +++ b/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; diff --git a/examples/26-occlusion/occlusion.cpp b/examples/26-occlusion/occlusion.cpp index 9aa9c4bc0..fcab057ee 100644 --- a/examples/26-occlusion/occlusion.cpp +++ b/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; diff --git a/examples/27-terrain/terrain.cpp b/examples/27-terrain/terrain.cpp index 398fc1c6d..af90d3d02 100644 --- a/examples/27-terrain/terrain.cpp +++ b/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; diff --git a/examples/28-wireframe/wireframe.cpp b/examples/28-wireframe/wireframe.cpp index f9ac0eb89..d42f356fc 100644 --- a/examples/28-wireframe/wireframe.cpp +++ b/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 diff --git a/examples/29-debugdraw/debugdraw.cpp b/examples/29-debugdraw/debugdraw.cpp index e38158983..f80039ede 100644 --- a/examples/29-debugdraw/debugdraw.cpp +++ b/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; diff --git a/examples/30-picking/picking.cpp b/examples/30-picking/picking.cpp index 36876a052..6519a826e 100644 --- a/examples/30-picking/picking.cpp +++ b/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; diff --git a/examples/31-rsm/reflectiveshadowmap.cpp b/examples/31-rsm/reflectiveshadowmap.cpp index 2d7706d9f..11a27f9dc 100644 --- a/examples/31-rsm/reflectiveshadowmap.cpp +++ b/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; diff --git a/examples/32-particles/particles.cpp b/examples/32-particles/particles.cpp index 4d9ccbe55..203452d18 100644 --- a/examples/32-particles/particles.cpp +++ b/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; diff --git a/examples/33-pom/pom.cpp b/examples/33-pom/pom.cpp index 8fcd5f952..72b710782 100644 --- a/examples/33-pom/pom.cpp +++ b/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; diff --git a/examples/common/bgfx_utils.cpp b/examples/common/bgfx_utils.cpp index 028b3b9e6..b394128e9 100644 --- a/examples/common/bgfx_utils.cpp +++ b/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) { diff --git a/examples/common/bgfx_utils.h b/examples/common/bgfx_utils.h index e81510ff0..45b24904d 100644 --- a/examples/common/bgfx_utils.h +++ b/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; diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 3d28be47e..53a095af1 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -22,7 +22,7 @@ #define RMT_ENABLED ENTRY_CONFIG_PROFILER #include -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) ) diff --git a/examples/common/entry/entry.h b/examples/common/entry/entry.h index 794c0f7fb..d614a9c31 100644 --- a/examples/common/entry/entry.h +++ b/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 diff --git a/examples/common/entry/entry_glfw.cpp b/examples/common/entry/entry_glfw.cpp index ba679a888..312494350 100644 --- a/examples/common/entry/entry_glfw.cpp +++ b/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); diff --git a/examples/common/entry/entry_p.h b/examples/common/entry/entry_p.h index ab45cfef5..6938158b5 100644 --- a/examples/common/entry/entry_p.h +++ b/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); diff --git a/examples/common/entry/entry_x11.cpp b/examples/common/entry/entry_x11.cpp index 78e4306eb..f55ee4baf 100644 --- a/examples/common/entry/entry_x11.cpp +++ b/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); diff --git a/examples/common/example-glue.cpp b/examples/common/example-glue.cpp index 4ea35fd59..88b898b32 100644 --- a/examples/common/example-glue.cpp +++ b/examples/common/example-glue.cpp @@ -5,6 +5,8 @@ #include "imgui/imgui.h" #include "entry/entry.h" +#include "entry/cmd.h" +#include bool showExampleDialog(entry::AppI* _app) { @@ -45,8 +47,9 @@ bool showExampleDialog(entry::AppI* _app) if (1 < num && ImGui::Combo("Example", ¤t, items, num) ) { - entry::setRestartArgs(items[current]); - restart = true; + char command[1024]; + bx::snprintf(command, BX_COUNTOF(command), "app restart %s", items[current]); + cmdExec(command); } }