diff --git a/examples/08-update/update.cpp b/examples/08-update/update.cpp index 464b5846..3e95683f 100644 --- a/examples/08-update/update.cpp +++ b/examples/08-update/update.cpp @@ -65,7 +65,7 @@ static PosColorVertex s_cubeVertices[28] = { 1.0f, -1.0f, 1.0f, 2.0f, -2.0f, 2.0f }, }; -static const uint16_t s_cubeIndices[42] = +static const uint16_t s_cubeIndices[36] = { 0, 1, 2, // 0 1, 3, 2, @@ -84,9 +84,6 @@ static const uint16_t s_cubeIndices[42] = 20, 22, 21, // 10 21, 22, 23, - - 24, 25, 26, // - 25, 27, 26, }; static const char* s_shaderPath = NULL; @@ -478,8 +475,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::setProgram(programCmp); // Set vertex and index buffer. - bgfx::setVertexBuffer(vbh); - bgfx::setIndexBuffer(ibh, 36, 6); + bgfx::setVertexBuffer(vbh, 24, 4); + bgfx::setIndexBuffer(ibh, 0, 6); // Bind texture. bgfx::setTexture(0, u_texColor, textures[ii]); diff --git a/include/bgfx.h b/include/bgfx.h index 3c3541e4..481e60de 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -1245,7 +1245,7 @@ namespace bgfx void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _numIndices = UINT32_MAX); /// Set vertex buffer for draw primitive. - void setVertexBuffer(VertexBufferHandle _handle, uint32_t _numVertices = UINT32_MAX); + void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex = 0, uint32_t _numVertices = UINT32_MAX); /// Set vertex buffer for draw primitive. void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices = UINT32_MAX); diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 90d5b507..ca85342d 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2275,10 +2275,10 @@ namespace bgfx s_ctx->setIndexBuffer(_tib, numIndices); } - void setVertexBuffer(VertexBufferHandle _handle, uint32_t _numVertices) + void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) { BGFX_CHECK_MAIN_THREAD(); - s_ctx->setVertexBuffer(_handle, _numVertices); + s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices); } void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 6cf8b881..327039f8 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1137,10 +1137,10 @@ namespace bgfx m_discard = 0 == _numIndices; } - void setVertexBuffer(VertexBufferHandle _handle, uint32_t _numVertices) + void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) { BX_CHECK(_handle.idx < BGFX_CONFIG_MAX_VERTEX_BUFFERS, "Invalid vertex buffer handle. %d (< %d)", _handle.idx, BGFX_CONFIG_MAX_VERTEX_BUFFERS); - m_state.m_startVertex = 0; + m_state.m_startVertex = _startVertex; m_state.m_numVertices = _numVertices; m_state.m_vertexBuffer = _handle; } @@ -2481,9 +2481,9 @@ namespace bgfx m_submit->setIndexBuffer(_tib, _numIndices); } - BGFX_API_FUNC(void setVertexBuffer(VertexBufferHandle _handle, uint32_t _numVertices) ) + BGFX_API_FUNC(void setVertexBuffer(VertexBufferHandle _handle, uint32_t _numVertices, uint32_t _startVertex) ) { - m_submit->setVertexBuffer(_handle, _numVertices); + m_submit->setVertexBuffer(_handle, _numVertices, _startVertex); } BGFX_API_FUNC(void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) )