mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-13 22:47:26 +01:00
graphicsdriver/opengl: Avoid unnecessary creation of Uint16Array/Float32Array
Updates #1426
This commit is contained in:
parent
5897e1ab7c
commit
44e2455c65
@ -455,16 +455,14 @@ func (c *context) bindElementArrayBuffer(b buffer) {
|
|||||||
|
|
||||||
func (c *context) arrayBufferSubData(data []float32) {
|
func (c *context) arrayBufferSubData(data []float32) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
arr8 := jsutil.TemporaryUint8Array(len(data) * 4)
|
arr := jsutil.TemporaryUint8Array(len(data) * 4)
|
||||||
arr := js.Global().Get("Float32Array").New(arr8.Get("buffer"), arr8.Get("byteOffset"), len(data))
|
|
||||||
jsutil.CopySliceToJS(arr, data)
|
jsutil.CopySliceToJS(arr, data)
|
||||||
gl.Call("bufferSubData", gles.ARRAY_BUFFER, 0, arr)
|
gl.Call("bufferSubData", gles.ARRAY_BUFFER, 0, arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) elementArrayBufferSubData(data []uint16) {
|
func (c *context) elementArrayBufferSubData(data []uint16) {
|
||||||
gl := c.gl
|
gl := c.gl
|
||||||
arr8 := jsutil.TemporaryUint8Array(len(data) * 2)
|
arr := jsutil.TemporaryUint8Array(len(data) * 2)
|
||||||
arr := js.Global().Get("Uint16Array").New(arr8.Get("buffer"), arr8.Get("byteOffset"), len(data))
|
|
||||||
jsutil.CopySliceToJS(arr, data)
|
jsutil.CopySliceToJS(arr, data)
|
||||||
gl.Call("bufferSubData", gles.ELEMENT_ARRAY_BUFFER, 0, arr)
|
gl.Call("bufferSubData", gles.ELEMENT_ARRAY_BUFFER, 0, arr)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user