diff --git a/examples/common/nanovg/nanovg_bgfx.cpp b/examples/common/nanovg/nanovg_bgfx.cpp index d697eafcb..506b6d277 100644 --- a/examples/common/nanovg/nanovg_bgfx.cpp +++ b/examples/common/nanovg/nanovg_bgfx.cpp @@ -30,6 +30,8 @@ #include +#include + namespace { #include "vs_nanovg_fill.bin.h" @@ -687,6 +689,14 @@ namespace if (gl->ncalls > 0) { bgfx::allocTransientVertexBuffer(&gl->tvb, gl->nverts, s_nvgDecl); + + int allocated = gl->tvb.size/gl->tvb.stride; + + if (allocated < gl->nverts) { + gl->nverts = allocated; + BX_WARN(true, "Vertex number truncated due to transient vertex buffer overflow"); + } + memcpy(gl->tvb.data, gl->verts, gl->nverts * sizeof(struct NVGvertex) );