From 1c51d8100696f460aae1bea8d4711c9406f42305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 23 Oct 2015 20:52:22 -0700 Subject: [PATCH] Cleanup. --- examples/01-cubes/cubes.cpp | 6 ++++-- examples/02-metaballs/metaballs.cpp | 8 +++++--- examples/03-raymarch/raymarch.cpp | 6 ++++-- examples/04-mesh/mesh.cpp | 6 ++++-- examples/05-instancing/instancing.cpp | 6 ++++-- examples/06-bump/bump.cpp | 6 ++++-- examples/07-callback/callback.cpp | 11 +++++++---- examples/10-font/font.cpp | 9 +++++---- examples/11-fontsdf/fontsdf.cpp | 7 ++++--- examples/12-lod/lod.cpp | 6 ++++-- examples/13-stencil/stencil.cpp | 6 ++++-- examples/14-shadowvolumes/shadowvolumes.cpp | 6 ++++-- examples/15-shadowmaps-simple/shadowmaps_simple.cpp | 6 ++++-- examples/16-shadowmaps/shadowmaps.cpp | 6 ++++-- examples/17-drawstress/drawstress.cpp | 12 +++++++----- examples/18-ibl/ibl.cpp | 6 ++++-- examples/19-oit/oit.cpp | 6 ++++-- examples/20-nanovg/nanovg.cpp | 8 +++++--- examples/21-deferred/deferred.cpp | 6 ++++-- examples/22-windows/windows.cpp | 6 ++++-- examples/23-vectordisplay/main.cpp | 6 ++++-- examples/24-nbody/nbody.cpp | 6 ++++-- 22 files changed, 97 insertions(+), 54 deletions(-) diff --git a/examples/01-cubes/cubes.cpp b/examples/01-cubes/cubes.cpp index d3679d1e..4025975b 100644 --- a/examples/01-cubes/cubes.cpp +++ b/examples/01-cubes/cubes.cpp @@ -57,14 +57,16 @@ static const uint16_t s_cubeIndices[36] = class Cubes : public entry::AppI { - void init(int /*_argc*/, char** /*_argv*/) BX_OVERRIDE + 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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(m_width, m_height, m_reset); // Enable debug text. diff --git a/examples/02-metaballs/metaballs.cpp b/examples/02-metaballs/metaballs.cpp index 6593f3d3..982d2489 100644 --- a/examples/02-metaballs/metaballs.cpp +++ b/examples/02-metaballs/metaballs.cpp @@ -4,7 +4,7 @@ */ #include "common.h" -#include +#include "bgfx_utils.h" // embedded shaders #include "vs_metaballs.bin.h" @@ -464,14 +464,16 @@ uint32_t triangulate(uint8_t* _result, uint32_t _stride, const float* __restrict class Metaballs : public entry::AppI { - void init(int /*_argc*/, char** /*_argv*/) BX_OVERRIDE + 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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(m_width, m_height, m_reset); // Enable debug text. diff --git a/examples/03-raymarch/raymarch.cpp b/examples/03-raymarch/raymarch.cpp index 7fd619db..1ba4d3ec 100644 --- a/examples/03-raymarch/raymarch.cpp +++ b/examples/03-raymarch/raymarch.cpp @@ -102,14 +102,16 @@ void renderScreenSpaceQuad(uint32_t _view, bgfx::ProgramHandle _program, float _ } } -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/04-mesh/mesh.cpp b/examples/04-mesh/mesh.cpp index bf4c4269..8c10b2b3 100644 --- a/examples/04-mesh/mesh.cpp +++ b/examples/04-mesh/mesh.cpp @@ -6,14 +6,16 @@ #include "common.h" #include "bgfx_utils.h" -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/05-instancing/instancing.cpp b/examples/05-instancing/instancing.cpp index 2313adcc..3d9f9505 100644 --- a/examples/05-instancing/instancing.cpp +++ b/examples/05-instancing/instancing.cpp @@ -55,14 +55,16 @@ static const uint16_t s_cubeIndices[36] = 6, 3, 7, }; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/06-bump/bump.cpp b/examples/06-bump/bump.cpp index 1cbf7459..e373bf65 100644 --- a/examples/06-bump/bump.cpp +++ b/examples/06-bump/bump.cpp @@ -105,14 +105,16 @@ static const uint16_t s_cubeIndices[36] = class Bump : public entry::AppI { - void init(int /*_argc*/, char** /*_argv*/) BX_OVERRIDE + 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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(m_width, m_height, m_reset); // Enable debug text. diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index fa0b0329..0def881a 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -364,8 +364,10 @@ private: uint32_t m_maxBlocks; }; -int _main_(int /*_argc*/, char** /*_argv*/) +int _main_(int _argc, char** _argv) { + Args args(_argc, _argv); + BgfxCallback callback; BgfxAllocator allocator; @@ -376,9 +378,10 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::RendererType::Enum renderers[bgfx::RendererType::Count]; uint8_t numRenderers = bgfx::getSupportedRenderers(renderers); - bgfx::init( - renderers[bx::getHPCounter() % numRenderers] /* randomize renderer */ - , BGFX_PCI_ID_NONE + 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 diff --git a/examples/10-font/font.cpp b/examples/10-font/font.cpp index 660ff299..1701e566 100644 --- a/examples/10-font/font.cpp +++ b/examples/10-font/font.cpp @@ -4,8 +4,8 @@ */ #include "common.h" +#include "bgfx_utils.h" -#include #include #include #include @@ -46,15 +46,16 @@ TrueTypeHandle loadTtf(FontManager* _fm, const char* _filePath) return invalid; } -int _main_(int /*_argc*/, char** /*_argv*/) +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(); - + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/11-fontsdf/fontsdf.cpp b/examples/11-fontsdf/fontsdf.cpp index d54d4756..72881bb9 100644 --- a/examples/11-fontsdf/fontsdf.cpp +++ b/examples/11-fontsdf/fontsdf.cpp @@ -64,15 +64,16 @@ TrueTypeHandle loadTtf(FontManager* _fm, const char* _filePath) return invalid; } -int _main_(int /*_argc*/, char** /*_argv*/) +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(); - + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index c57d7bd8..931f6430 100644 --- a/examples/12-lod/lod.cpp +++ b/examples/12-lod/lod.cpp @@ -23,14 +23,16 @@ KnightPos knightTour[8*4] = {7,1}, {6,3}, {5,1}, {7,0}, {6,2}, {4,3}, {3,1}, {2,3}, }; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/13-stencil/stencil.cpp b/examples/13-stencil/stencil.cpp index 7a1e90d2..168c19ba 100644 --- a/examples/13-stencil/stencil.cpp +++ b/examples/13-stencil/stencil.cpp @@ -828,15 +828,17 @@ struct Mesh GroupArray m_groups; }; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(viewState.m_width, viewState.m_height, reset); // Enable debug text. diff --git a/examples/14-shadowvolumes/shadowvolumes.cpp b/examples/14-shadowvolumes/shadowvolumes.cpp index 17a19ab5..f8d50612 100644 --- a/examples/14-shadowvolumes/shadowvolumes.cpp +++ b/examples/14-shadowvolumes/shadowvolumes.cpp @@ -1850,15 +1850,17 @@ bool clipTest(const float* _planes, uint8_t _planeNum, const Mesh& _mesh, const return false; } -int _main_(int /*_argc*/, char** /*_argv*/) +int _main_(int _argc, char** _argv) { + Args args(_argc, _argv); + ViewState viewState(1280, 720); ClearValues clearValues = {0x00000000, 1.0f, 0}; uint32_t debug = BGFX_DEBUG_TEXT; uint32_t reset = BGFX_RESET_VSYNC; - bgfx::init(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(viewState.m_width, viewState.m_height, reset); // Enable debug text. diff --git a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index 513a37f2..badef17d 100644 --- a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp @@ -66,14 +66,16 @@ static const uint16_t s_planeIndices[] = 1, 3, 2, }; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); bgfx::RendererType::Enum renderer = bgfx::getRendererType(); diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index 34ce52c3..e447e99a 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/examples/16-shadowmaps/shadowmaps.cpp @@ -1313,15 +1313,17 @@ struct ShadowMapSettings #undef IMGUI_FLOAT_PARAM }; -int _main_(int /*_argc*/, char** /*_argv*/) +int _main_(int _argc, char** _argv) { + Args args(_argc, _argv); + uint32_t debug = BGFX_DEBUG_TEXT; uint32_t reset = BGFX_RESET_VSYNC; ViewState viewState(1280, 720); ClearValues clearValues(0x00000000, 1.0f, 0); - bgfx::init(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(viewState.m_width, viewState.m_height, reset); // Enable debug text. diff --git a/examples/17-drawstress/drawstress.cpp b/examples/17-drawstress/drawstress.cpp index 1f40768b..ff035625 100644 --- a/examples/17-drawstress/drawstress.cpp +++ b/examples/17-drawstress/drawstress.cpp @@ -3,10 +3,10 @@ * License: http://www.opensource.org/licenses/BSD-2-Clause */ -#include -#include - #include "common.h" +#include "bgfx_utils.h" + +#include #include "imgui/imgui.h" // embedded shaders @@ -72,8 +72,10 @@ static const int64_t lowwm = 1000000/57; class DrawStress : public entry::AppI { - void init(int /*_argc*/, char** /*_argv*/) BX_OVERRIDE + void init(int _argc, char** _argv) BX_OVERRIDE { + Args args(_argc, _argv); + m_width = 1280; m_height = 720; m_debug = BGFX_DEBUG_TEXT; @@ -91,7 +93,7 @@ class DrawStress : public entry::AppI m_deltaTimeAvgNs = 0; m_numFrames = 0; - bgfx::init(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(m_width, m_height, m_reset); const bgfx::Caps* caps = bgfx::getCaps(); diff --git a/examples/18-ibl/ibl.cpp b/examples/18-ibl/ibl.cpp index 2d98aba5..8f9f13a3 100644 --- a/examples/18-ibl/ibl.cpp +++ b/examples/18-ibl/ibl.cpp @@ -213,14 +213,16 @@ struct LightProbe bgfx::TextureHandle m_texIrr; }; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/19-oit/oit.cpp b/examples/19-oit/oit.cpp index 7457364e..c25f3962 100644 --- a/examples/19-oit/oit.cpp +++ b/examples/19-oit/oit.cpp @@ -146,14 +146,16 @@ void screenSpaceQuad(float _textureWidth, float _textureHeight, bool _originBott } } -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Create vertex stream declaration. diff --git a/examples/20-nanovg/nanovg.cpp b/examples/20-nanovg/nanovg.cpp index 2f4060a4..3f31e2c6 100644 --- a/examples/20-nanovg/nanovg.cpp +++ b/examples/20-nanovg/nanovg.cpp @@ -22,11 +22,11 @@ // #include "common.h" +#include "bgfx_utils.h" #include #include -#include #include #include #include "entry/entry.h" @@ -1201,14 +1201,16 @@ void renderDemo(struct NVGcontext* vg, float mx, float my, float width, float he nvgRestore(vg); } -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text. diff --git a/examples/21-deferred/deferred.cpp b/examples/21-deferred/deferred.cpp index e40ce62f..f1201363 100644 --- a/examples/21-deferred/deferred.cpp +++ b/examples/21-deferred/deferred.cpp @@ -215,14 +215,16 @@ void screenSpaceQuad(float _textureWidth, float _textureHeight, float _texelHalf class Deferred : public entry::AppI { - void init(int /*_argc*/, char** /*_argv*/) BX_OVERRIDE + 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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(m_width, m_height, m_reset); // Enable m_debug text. diff --git a/examples/22-windows/windows.cpp b/examples/22-windows/windows.cpp index 36156fce..24187e27 100644 --- a/examples/22-windows/windows.cpp +++ b/examples/22-windows/windows.cpp @@ -92,14 +92,16 @@ static const InputBinding s_bindings[] = INPUT_BINDING_END }; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); const bgfx::Caps* caps = bgfx::getCaps(); diff --git a/examples/23-vectordisplay/main.cpp b/examples/23-vectordisplay/main.cpp index f0999cb7..2cd1574a 100644 --- a/examples/23-vectordisplay/main.cpp +++ b/examples/23-vectordisplay/main.cpp @@ -30,14 +30,16 @@ struct PosColorVertex bgfx::VertexDecl PosColorVertex::ms_decl; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); const bgfx::RendererType::Enum renderer = bgfx::getRendererType(); diff --git a/examples/24-nbody/nbody.cpp b/examples/24-nbody/nbody.cpp index 854a55a7..dbd978b4 100644 --- a/examples/24-nbody/nbody.cpp +++ b/examples/24-nbody/nbody.cpp @@ -96,14 +96,16 @@ static const float s_quadVertices[] = static const uint16_t s_quadIndices[] = { 0, 1, 2, 2, 3, 0, }; -int _main_(int /*_argc*/, char** /*_argv*/) +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(); + bgfx::init(args.m_type, args.m_pciId); bgfx::reset(width, height, reset); // Enable debug text.