mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/jsutil: Move a function to internal/graphicsdriver/opengl
This commit is contained in:
parent
610ebbbab5
commit
a826ecb29b
@ -99,6 +99,15 @@ var (
|
|||||||
webGL2MightBeAvailable = !forceWebGL1 && (js.Global().Get("WebGL2RenderingContext").Truthy() || js.Global().Get("go2cpp").Truthy())
|
webGL2MightBeAvailable = !forceWebGL1 && (js.Global().Get("WebGL2RenderingContext").Truthy() || js.Global().Get("go2cpp").Truthy())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func uint8ArrayToSlice(value js.Value, length int) []byte {
|
||||||
|
if l := value.Get("byteLength").Int(); length > l {
|
||||||
|
length = l
|
||||||
|
}
|
||||||
|
s := make([]byte, length)
|
||||||
|
js.CopyBytesToGo(s, value)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
type contextImpl struct {
|
type contextImpl struct {
|
||||||
gl *gl
|
gl *gl
|
||||||
lastProgramID programID
|
lastProgramID programID
|
||||||
@ -236,7 +245,7 @@ func (c *context) framebufferPixels(f *framebuffer, width, height int) []byte {
|
|||||||
p := jsutil.TemporaryUint8Array(l, nil)
|
p := jsutil.TemporaryUint8Array(l, nil)
|
||||||
gl.readPixels.Invoke(0, 0, width, height, gles.RGBA, gles.UNSIGNED_BYTE, p)
|
gl.readPixels.Invoke(0, 0, width, height, gles.RGBA, gles.UNSIGNED_BYTE, p)
|
||||||
|
|
||||||
return jsutil.Uint8ArrayToSlice(p, l)
|
return uint8ArrayToSlice(p, l)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) framebufferPixelsToBuffer(f *framebuffer, buffer buffer, width, height int) {
|
func (c *context) framebufferPixelsToBuffer(f *framebuffer, buffer buffer, width, height int) {
|
||||||
|
@ -22,15 +22,6 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Uint8ArrayToSlice(value js.Value, length int) []byte {
|
|
||||||
if l := value.Get("byteLength").Int(); length > l {
|
|
||||||
length = l
|
|
||||||
}
|
|
||||||
s := make([]byte, length)
|
|
||||||
js.CopyBytesToGo(s, value)
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func sliceToByteSlice(s interface{}) (bs []byte) {
|
func sliceToByteSlice(s interface{}) (bs []byte) {
|
||||||
switch s := s.(type) {
|
switch s := s.(type) {
|
||||||
case []int8:
|
case []int8:
|
||||||
|
Loading…
Reference in New Issue
Block a user