Added ability to set start vertex when setting vertex buffer.

This commit is contained in:
Branimir Karadžić 2014-04-10 22:09:17 -07:00
parent 9534f26868
commit 78475a30e6
4 changed files with 10 additions and 13 deletions

View file

@ -65,7 +65,7 @@ static PosColorVertex s_cubeVertices[28] =
{ 1.0f, -1.0f, 1.0f, 2.0f, -2.0f, 2.0f }, { 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 0, 1, 2, // 0
1, 3, 2, 1, 3, 2,
@ -84,9 +84,6 @@ static const uint16_t s_cubeIndices[42] =
20, 22, 21, // 10 20, 22, 21, // 10
21, 22, 23, 21, 22, 23,
24, 25, 26, //
25, 27, 26,
}; };
static const char* s_shaderPath = NULL; static const char* s_shaderPath = NULL;
@ -478,8 +475,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
bgfx::setProgram(programCmp); bgfx::setProgram(programCmp);
// Set vertex and index buffer. // Set vertex and index buffer.
bgfx::setVertexBuffer(vbh); bgfx::setVertexBuffer(vbh, 24, 4);
bgfx::setIndexBuffer(ibh, 36, 6); bgfx::setIndexBuffer(ibh, 0, 6);
// Bind texture. // Bind texture.
bgfx::setTexture(0, u_texColor, textures[ii]); bgfx::setTexture(0, u_texColor, textures[ii]);

View file

@ -1245,7 +1245,7 @@ namespace bgfx
void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _numIndices = UINT32_MAX); void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _numIndices = UINT32_MAX);
/// Set vertex buffer for draw primitive. /// 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. /// Set vertex buffer for draw primitive.
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices = UINT32_MAX); void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices = UINT32_MAX);

View file

@ -2275,10 +2275,10 @@ namespace bgfx
s_ctx->setIndexBuffer(_tib, numIndices); 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(); BGFX_CHECK_MAIN_THREAD();
s_ctx->setVertexBuffer(_handle, _numVertices); s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
} }
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices)

View file

@ -1137,10 +1137,10 @@ namespace bgfx
m_discard = 0 == _numIndices; 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); 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_numVertices = _numVertices;
m_state.m_vertexBuffer = _handle; m_state.m_vertexBuffer = _handle;
} }
@ -2481,9 +2481,9 @@ namespace bgfx
m_submit->setIndexBuffer(_tib, _numIndices); 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) ) BGFX_API_FUNC(void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices) )