01-cubes: Added line strip primitive.

This commit is contained in:
Branimir Karadžić 2018-10-08 10:10:40 -07:00
parent 209a7804a5
commit 20bd0607e4

View File

@ -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;