From 20bd0607e4ff3b5364fafeb9ffcef56b284a98fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 8 Oct 2018 10:10:40 -0700 Subject: [PATCH] 01-cubes: Added line strip primitive. --- examples/01-cubes/cubes.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/01-cubes/cubes.cpp b/examples/01-cubes/cubes.cpp index b26b0f1fd..ea8f8ec6c 100644 --- a/examples/01-cubes/cubes.cpp +++ b/examples/01-cubes/cubes.cpp @@ -91,6 +91,13 @@ static const uint16_t s_cubeLineList[] = 6, 7, }; +static const uint16_t s_cubeLineStrip[] = +{ + 0, 2, 3, 1, 5, 7, 6, 4, + 0, 2, 6, 4, 5, 7, 3, 1, + 0, +}; + static const uint16_t s_cubePoints[] = { 0, 1, 2, 3, 4, 5, 6, 7 @@ -101,6 +108,7 @@ static const char* s_ptNames[] "Triangle List", "Triangle Strip", "Lines", + "Line Strip", "Points", }; @@ -109,8 +117,10 @@ static const uint64_t s_ptState[] UINT64_C(0), BGFX_STATE_PT_TRISTRIP, BGFX_STATE_PT_LINES, + BGFX_STATE_PT_LINESTRIP, BGFX_STATE_PT_POINTS, }; +BX_STATIC_ASSERT(BX_COUNTOF(s_ptState) == BX_COUNTOF(s_ptNames) ); class ExampleCubes : public entry::AppI { @@ -163,26 +173,32 @@ public: , PosColorVertex::ms_decl ); - // Create static index buffer for triangle strip rendering. + // Create static index buffer for triangle list rendering. m_ibh[0] = bgfx::createIndexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeTriList, sizeof(s_cubeTriList) ) ); - // Create static index buffer for triangle list rendering. + // Create static index buffer for triangle strip rendering. m_ibh[1] = bgfx::createIndexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeTriStrip, sizeof(s_cubeTriStrip) ) ); - // Create static index buffer for triangle list rendering. + // Create static index buffer for line list rendering. m_ibh[2] = bgfx::createIndexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubeLineList, sizeof(s_cubeLineList) ) ); - // Create static index buffer for triangle list rendering. + // Create static index buffer for line strip rendering. m_ibh[3] = bgfx::createIndexBuffer( + // Static data can be passed with bgfx::makeRef + bgfx::makeRef(s_cubeLineStrip, sizeof(s_cubeLineStrip) ) + ); + + // Create static index buffer for point list rendering. + m_ibh[4] = bgfx::createIndexBuffer( // Static data can be passed with bgfx::makeRef bgfx::makeRef(s_cubePoints, sizeof(s_cubePoints) ) ); @@ -333,7 +349,7 @@ public: uint32_t m_debug; uint32_t m_reset; bgfx::VertexBufferHandle m_vbh; - bgfx::IndexBufferHandle m_ibh[4]; + bgfx::IndexBufferHandle m_ibh[BX_COUNTOF(s_ptState)]; bgfx::ProgramHandle m_program; int64_t m_timeOffset; int32_t m_pt;