diff --git a/internal/igwrap/backend/render.go b/internal/igwrap/backend/render.go index ef76278..ad7f522 100644 --- a/internal/igwrap/backend/render.go +++ b/internal/igwrap/backend/render.go @@ -56,6 +56,8 @@ func renderInit() { gl.BindTexture(gl.TEXTURE_2D, uint32(lastTexture)) gl.BindBuffer(gl.ARRAY_BUFFER, uint32(lastArrayBuffer)) gl.BindVertexArray(uint32(lastVertexArray)) + + io.SetBackendFlags(imgui.BackendFlagsRendererHasVtxOffset) } func CreateFontsTexture() { @@ -190,7 +192,6 @@ func Render(win *glfw.Window) { // Draw for _, list := range draw.CommandLists() { - var indexBufferOffset uintptr vertexBuffer, vertexBufferSize := list.VertexBuffer() gl.BindBuffer(gl.ARRAY_BUFFER, vbo) @@ -208,9 +209,14 @@ func Render(win *glfw.Window) { gl.BindTexture(gl.TEXTURE_2D, uint32(cmd.TextureID())) clipRect := cmd.ClipRect() gl.Scissor(int32(clipRect.X), int32(fbHeight)-int32(clipRect.W), int32(clipRect.Z-clipRect.X), int32(clipRect.W-clipRect.Y)) - gl.DrawElementsWithOffset(gl.TRIANGLES, int32(cmd.ElementCount()), uint32(drawType), indexBufferOffset) + gl.DrawElementsBaseVertexWithOffset( + gl.TRIANGLES, + int32(cmd.ElementCount()), + uint32(drawType), + uintptr(cmd.IndexOffset()*indexSize), + int32(cmd.VertexOffset()), + ) } - indexBufferOffset += uintptr(cmd.ElementCount() * indexSize) } } gl.DeleteVertexArrays(1, &vao)