From 5bda86b70222c378f1baf8bda43f9ddad3907493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 26 Nov 2016 22:38:47 -0800 Subject: [PATCH] 01-cubes: Switched to tristrip to test functionality. --- examples/01-cubes/cubes.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/examples/01-cubes/cubes.cpp b/examples/01-cubes/cubes.cpp index c44b74f04..9fe6a7020 100644 --- a/examples/01-cubes/cubes.cpp +++ b/examples/01-cubes/cubes.cpp @@ -27,7 +27,7 @@ struct PosColorVertex bgfx::VertexDecl PosColorVertex::ms_decl; -static PosColorVertex s_cubeVertices[8] = +static PosColorVertex s_cubeVertices[] = { {-1.0f, 1.0f, 1.0f, 0xff000000 }, { 1.0f, 1.0f, 1.0f, 0xff0000ff }, @@ -39,7 +39,7 @@ static PosColorVertex s_cubeVertices[8] = { 1.0f, -1.0f, -1.0f, 0xffffffff }, }; -static const uint16_t s_cubeIndices[36] = +static const uint16_t s_cubeTriList[] = { 0, 1, 2, // 0 1, 3, 2, @@ -55,6 +55,22 @@ static const uint16_t s_cubeIndices[36] = 6, 3, 7, }; +static const uint16_t s_cubeTriStrip[] = +{ + 0, 1, 2, + 3, + 7, + 1, + 5, + 0, + 4, + 2, + 6, + 7, + 4, + 5, +}; + class ExampleCubes : public entry::AppI { void init(int _argc, char** _argv) BX_OVERRIDE @@ -93,7 +109,7 @@ class ExampleCubes : public entry::AppI // Create static index buffer. m_ibh = bgfx::createIndexBuffer( // Static data can be passed with bgfx::makeRef - bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) + bgfx::makeRef(s_cubeTriStrip, sizeof(s_cubeTriStrip) ) ); // Create program from shaders. @@ -187,7 +203,10 @@ class ExampleCubes : public entry::AppI bgfx::setIndexBuffer(m_ibh); // Set render states. - bgfx::setState(BGFX_STATE_DEFAULT); + bgfx::setState(0 + | BGFX_STATE_DEFAULT + | BGFX_STATE_PT_TRISTRIP + ); // Submit primitive for rendering to view 0. bgfx::submit(0, m_program);