From 702a429afb0eef755e6f747b4381a84d6492a0cb Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 19 Jun 2018 03:31:53 +0900 Subject: [PATCH] opengl: Faster conversion from []float32 to Float32Array --- internal/opengl/context_js.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index f8f543e51..81694c7b4 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -316,10 +316,8 @@ func (c *Context) UniformFloats(p Program, location string, v []float32) { case 4: gl.Call("uniform4f", js.Value(l), v[0], v[1], v[2], v[3]) case 16: - m := js.Global.Get("Float32Array").New(16) - for i := range v { - m.SetIndex(i, v[i]) - } + u8 := js.ValueOf(v) + m := js.Global.Get("Float32Array").New(u8.Get("buffer"), u8.Get("byteOffset").Int(), 16) gl.Call("uniformMatrix4fv", js.Value(l), false, m) default: panic("not reached")