mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-13 22:47:26 +01:00
jsutil: Bug fix: byteLenght must be accessed every time to get the latest value
This commit is contained in:
parent
111709d3aa
commit
3d48922d8c
@ -28,34 +28,28 @@ var (
|
|||||||
// temporaryArrayBuffer is a temporary buffer used at gl.readPixels or gl.texSubImage2D.
|
// temporaryArrayBuffer is a temporary buffer used at gl.readPixels or gl.texSubImage2D.
|
||||||
// The read data is converted to Go's byte slice as soon as possible.
|
// The read data is converted to Go's byte slice as soon as possible.
|
||||||
// To avoid often allocating ArrayBuffer, reuse the buffer whenever possible.
|
// To avoid often allocating ArrayBuffer, reuse the buffer whenever possible.
|
||||||
temporaryArrayBuffer = arrayBuffer.New(16)
|
temporaryArrayBuffer = arrayBuffer.New(16)
|
||||||
temporaryArrayBufferByteLength = temporaryArrayBuffer.Get("byteLength")
|
|
||||||
|
|
||||||
// temporaryUint8Array is a Uint8ArrayBuffer whose underlying buffer is always temporaryArrayBuffer.
|
// temporaryUint8Array is a Uint8ArrayBuffer whose underlying buffer is always temporaryArrayBuffer.
|
||||||
temporaryUint8Array = uint8Array.New(temporaryArrayBuffer)
|
temporaryUint8Array = uint8Array.New(temporaryArrayBuffer)
|
||||||
temporaryUint8ArrayByteLength = temporaryUint8Array.Get("byteLength")
|
|
||||||
|
|
||||||
// temporaryFloat32Array is a Float32ArrayBuffer whose underlying buffer is always temporaryArrayBuffer.
|
// temporaryFloat32Array is a Float32ArrayBuffer whose underlying buffer is always temporaryArrayBuffer.
|
||||||
temporaryFloat32Array = float32Array.New(temporaryArrayBuffer)
|
temporaryFloat32Array = float32Array.New(temporaryArrayBuffer)
|
||||||
temporaryFloat32ArrayByteLength = temporaryFloat32Array.Get("byteLength")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ensureTemporaryArrayBufferSize(byteLength int) {
|
func ensureTemporaryArrayBufferSize(byteLength int) {
|
||||||
bufl := temporaryArrayBufferByteLength.Int()
|
bufl := temporaryArrayBuffer.Get("byteLength").Int()
|
||||||
if bufl < byteLength {
|
if bufl < byteLength {
|
||||||
for bufl < byteLength {
|
for bufl < byteLength {
|
||||||
bufl *= 2
|
bufl *= 2
|
||||||
}
|
}
|
||||||
temporaryArrayBuffer = arrayBuffer.New(bufl)
|
temporaryArrayBuffer = arrayBuffer.New(bufl)
|
||||||
temporaryArrayBufferByteLength = temporaryArrayBuffer.Get("byteLength")
|
|
||||||
}
|
}
|
||||||
if temporaryUint8ArrayByteLength.Int() < bufl {
|
if temporaryUint8Array.Get("byteLength").Int() < bufl {
|
||||||
temporaryUint8Array = uint8Array.New(temporaryArrayBuffer)
|
temporaryUint8Array = uint8Array.New(temporaryArrayBuffer)
|
||||||
temporaryUint8ArrayByteLength = temporaryUint8Array.Get("byteLength")
|
|
||||||
}
|
}
|
||||||
if temporaryFloat32ArrayByteLength.Int() < bufl {
|
if temporaryFloat32Array.Get("byteLength").Int() < bufl {
|
||||||
temporaryFloat32Array = float32Array.New(temporaryArrayBuffer)
|
temporaryFloat32Array = float32Array.New(temporaryArrayBuffer)
|
||||||
temporaryFloat32ArrayByteLength = temporaryFloat32Array.Get("byteLength")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user