From b7fb12208a7f3b774b023e61649c6a0b8fed9b6f Mon Sep 17 00:00:00 2001 From: paradust7 <102263465+paradust7@users.noreply.github.com> Date: Mon, 23 Mar 2026 13:06:53 -0700 Subject: [PATCH] Assert when glDrawElements cannot draw anything because of missing vertex bounds --- src/lib/libglemu.js | 2 +- src/lib/libwebgl.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/libglemu.js b/src/lib/libglemu.js index a76ce93f2b5c4..256221838c13f 100644 --- a/src/lib/libglemu.js +++ b/src/lib/libglemu.js @@ -3036,7 +3036,7 @@ var LibraryGLEmulation = { // upload based on the indices. If they are in a buffer on the GPU, that is very // inconvenient! So if you do not have an array buffer, you should also not have // an element array buffer. But best is to use both buffers! - assert(!GLctx.currentElementArrayBufferBinding); + assert(!GLctx.currentElementArrayBufferBinding, 'must use array buffers when using element buffer'); #endif for (var i = 0; i < numProvidedIndexes; i++) { var currIndex = {{{ makeGetValue('ptr', 'i*2', 'u16') }}}; diff --git a/src/lib/libwebgl.js b/src/lib/libwebgl.js index 381be93d0c351..abed4624e4cd5 100644 --- a/src/lib/libwebgl.js +++ b/src/lib/libwebgl.js @@ -575,6 +575,10 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; var cb = GL.currentContext.clientBuffers[i]; if (!cb.clientside || !cb.enabled) continue; +#if ASSERTIONS + assert(count || !GLctx.currentElementArrayBufferBinding, 'must use array buffers when using element buffer'); +#endif + GL.resetBufferBinding = true; var size = GL.calcBufLength(cb.size, cb.type, cb.stride, count);