mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Added handle debug checks.
This commit is contained in:
parent
26e96b0489
commit
b80edd19ff
2 changed files with 13 additions and 1 deletions
13
src/bgfx.cpp
13
src/bgfx.cpp
|
@ -19,6 +19,14 @@ namespace bgfx
|
|||
# define BGFX_CHECK_RENDER_THREAD()
|
||||
#endif // BGFX_CONFIG_MULTITHREADED && !BX_PLATFORM_OSX && !BX_PLATFORM_IOS
|
||||
|
||||
#define BGFX_CHECK_HANDLE(_handle, _max) \
|
||||
BX_CHECK(isValid(_handle) \
|
||||
&& _handle.idx < _max \
|
||||
, "Invalid handle. %d (< %d " #_max ")" \
|
||||
, _handle.idx \
|
||||
, _max \
|
||||
);
|
||||
|
||||
#if BX_PLATFORM_ANDROID
|
||||
::ANativeWindow* g_bgfxAndroidWindow = NULL;
|
||||
|
||||
|
@ -2749,18 +2757,21 @@ again:
|
|||
void setUniform(UniformHandle _handle, const void* _value, uint16_t _num)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_UNIFORMS);
|
||||
s_ctx->setUniform(_handle, _value, _num);
|
||||
}
|
||||
|
||||
void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_INDEX_BUFFERS);
|
||||
s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices);
|
||||
}
|
||||
|
||||
void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS);
|
||||
s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices);
|
||||
}
|
||||
|
||||
|
@ -2785,12 +2796,14 @@ again:
|
|||
void setVertexBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_VERTEX_BUFFERS);
|
||||
s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
|
||||
}
|
||||
|
||||
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BGFX_CHECK_HANDLE(_handle, BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS);
|
||||
s_ctx->setVertexBuffer(_handle, _numVertices);
|
||||
}
|
||||
|
||||
|
|
|
@ -1370,7 +1370,6 @@ namespace bgfx
|
|||
|
||||
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_draw.m_startVertex = _startVertex;
|
||||
m_draw.m_numVertices = _numVertices;
|
||||
m_draw.m_vertexBuffer = _handle;
|
||||
|
|
Loading…
Reference in a new issue