From 5ba7854656f5c53e9eb89992e1d935329ef11aeb Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 20 Feb 2020 20:50:01 +0100 Subject: [PATCH] gpu/gl: fix offset calculation in DrawElements The offset argument to DrawElements is in 16-bit shorts, while the underlying DrawElements use byte offsets. No users of DrawElements use a non-zero offset, so nothing changed. Signed-off-by: Elias Naur --- gpu/gl/backend.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gpu/gl/backend.go b/gpu/gl/backend.go index e5b7fa9a..ed11dadd 100644 --- a/gpu/gl/backend.go +++ b/gpu/gl/backend.go @@ -274,7 +274,9 @@ func (b *Backend) SetBlend(enable bool) { func (b *Backend) DrawElements(mode gpu.DrawMode, off, count int) { b.prepareDraw() - b.funcs.DrawElements(toGLDrawMode(mode), count, UNSIGNED_SHORT, off) + // off is in 16-bit indices, but DrawElements take a byte offset. + byteOff := off * 2 + b.funcs.DrawElements(toGLDrawMode(mode), count, UNSIGNED_SHORT, byteOff) } func (b *Backend) DrawArrays(mode gpu.DrawMode, off, count int) {