summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2021-07-30 13:47:21 +0200
committerraysan5 <[email protected]>2021-07-30 13:47:21 +0200
commita8e9e1387f0abaa46557dd2076973cd30784148c (patch)
treed9c6a91f159e6adedc79e3c71b1fd2d0d6d71f1f /src
parent1613057881a2554231bc8169ee483d7f153e57ff (diff)
downloadraylib-a8e9e1387f0abaa46557dd2076973cd30784148c.tar.gz
raylib-a8e9e1387f0abaa46557dd2076973cd30784148c.zip
REVIEWED: Avoid UBSAN warnings #1891
Diffstat (limited to 'src')
-rw-r--r--src/rlgl.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index ece72f8c..10cde309 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -3227,7 +3227,8 @@ void rlDrawVertexArray(int offset, int count)
void rlDrawVertexArrayElements(int offset, int count, void *buffer)
{
- glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (unsigned short *)buffer + offset);
+ if (buffer == 0) glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, offset);
+ else glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (unsigned short *)buffer + offset);
}
void rlDrawVertexArrayInstanced(int offset, int count, int instances)
@@ -3240,7 +3241,8 @@ void rlDrawVertexArrayInstanced(int offset, int count, int instances)
void rlDrawVertexArrayElementsInstanced(int offset, int count, void *buffer, int instances)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
- glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (unsigned short *)buffer + offset, instances);
+ if (buffer == 0) glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, offset, instances);
+ else glDrawElementsInstanced(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, (unsigned short *)buffer + offset, instances);
#endif
}