mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Remove support of Go 1.13 and Go 1.14
Updates #1258 Updates #1415 Updates #1462
This commit is contained in:
parent
4276e2964e
commit
a627c41217
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
go: ['1.13.15', '1.14.15', '1.15.13', '1.16.5']
|
||||
go: ['1.15.13', '1.16.5']
|
||||
name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
|
@ -24,7 +24,6 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/audio/internal/go2cpp"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/jsutil"
|
||||
)
|
||||
|
||||
func IsAvailable() bool {
|
||||
@ -206,7 +205,7 @@ func (p *player) appendBufferImpl(audioBuffer js.Value) {
|
||||
// appendBuffer is called as the 'ended' callback of a buffer.
|
||||
// 'this' is an AudioBufferSourceNode that already finishes its playing.
|
||||
for i, n := range p.bufferSourceNodes {
|
||||
if jsutil.Equal(n, audioBuffer) {
|
||||
if n.Equal(audioBuffer) {
|
||||
p.bufferSourceNodes = append(p.bufferSourceNodes[:i], p.bufferSourceNodes[i+1:]...)
|
||||
break
|
||||
}
|
||||
|
@ -42,27 +42,27 @@ type (
|
||||
)
|
||||
|
||||
func (t textureNative) equal(rhs textureNative) bool {
|
||||
return jsutil.Equal(js.Value(t), js.Value(rhs))
|
||||
return js.Value(t).Equal(js.Value(rhs))
|
||||
}
|
||||
|
||||
func (f framebufferNative) equal(rhs framebufferNative) bool {
|
||||
return jsutil.Equal(js.Value(f), js.Value(rhs))
|
||||
return js.Value(f).Equal(js.Value(rhs))
|
||||
}
|
||||
|
||||
func (s shader) equal(rhs shader) bool {
|
||||
return jsutil.Equal(js.Value(s), js.Value(rhs))
|
||||
return js.Value(s).Equal(js.Value(rhs))
|
||||
}
|
||||
|
||||
func (b buffer) equal(rhs buffer) bool {
|
||||
return jsutil.Equal(js.Value(b), js.Value(rhs))
|
||||
return js.Value(b).Equal(js.Value(rhs))
|
||||
}
|
||||
|
||||
func (u uniformLocation) equal(rhs uniformLocation) bool {
|
||||
return jsutil.Equal(js.Value(u), js.Value(rhs))
|
||||
return js.Value(u).Equal(js.Value(rhs))
|
||||
}
|
||||
|
||||
func (p program) equal(rhs program) bool {
|
||||
return jsutil.Equal(p.value, rhs.value) && p.id == rhs.id
|
||||
return p.value.Equal(rhs.value) && p.id == rhs.id
|
||||
}
|
||||
|
||||
var InvalidTexture = textureNative(js.Null())
|
||||
@ -107,9 +107,9 @@ func (c *context) initGL() {
|
||||
gl = canvas.Call("getContext", "webgl2", attr)
|
||||
} else {
|
||||
gl = canvas.Call("getContext", "webgl", attr)
|
||||
if jsutil.Equal(gl, js.Null()) {
|
||||
if !gl.Truthy() {
|
||||
gl = canvas.Call("getContext", "experimental-webgl", attr)
|
||||
if jsutil.Equal(gl, js.Null()) {
|
||||
if !gl.Truthy() {
|
||||
panic("opengl: getContext failed")
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ func (c *context) scissor(x, y, width, height int) {
|
||||
func (c *context) newTexture(width, height int) (textureNative, error) {
|
||||
gl := c.gl
|
||||
t := gl.createTexture.Invoke()
|
||||
if jsutil.Equal(t, js.Null()) {
|
||||
if !t.Truthy() {
|
||||
return textureNative(js.Null()), errors.New("opengl: glGenTexture failed")
|
||||
}
|
||||
gl.pixelStorei.Invoke(gles.UNPACK_ALIGNMENT, 4)
|
||||
@ -287,7 +287,7 @@ func (c *context) newFragmentShader(source string) (shader, error) {
|
||||
func (c *context) newShader(shaderType int, source string) (shader, error) {
|
||||
gl := c.gl
|
||||
s := gl.createShader.Invoke(int(shaderType))
|
||||
if jsutil.Equal(s, js.Null()) {
|
||||
if !s.Truthy() {
|
||||
return shader(js.Null()), fmt.Errorf("opengl: glCreateShader failed: shader type: %d", shaderType)
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ func (c *context) deleteShader(s shader) {
|
||||
func (c *context) newProgram(shaders []shader, attributes []string) (program, error) {
|
||||
gl := c.gl
|
||||
v := gl.createProgram.Invoke()
|
||||
if jsutil.Equal(v, js.Null()) {
|
||||
if !v.Truthy() {
|
||||
return program{}, errors.New("opengl: glCreateProgram failed")
|
||||
}
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2019 The Ebiten Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build !go1.14
|
||||
|
||||
package jsutil
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
)
|
||||
|
||||
func Equal(a, b js.Value) bool {
|
||||
return a == b
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2019 The Ebiten Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build go1.14
|
||||
|
||||
package jsutil
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
)
|
||||
|
||||
func Equal(a, b js.Value) bool {
|
||||
return a.Equal(b)
|
||||
}
|
@ -20,7 +20,6 @@ import (
|
||||
"unicode"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/jsutil"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -48,7 +47,7 @@ func jsKeyToID(key js.Value) int {
|
||||
// js.Value cannot be used as a map key.
|
||||
// As the number of keys is around 100, just a dumb loop should work.
|
||||
for i, k := range jsKeys {
|
||||
if jsutil.Equal(k, key) {
|
||||
if k.Equal(key) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
@ -343,7 +342,7 @@ func (i *Input) updateFromEvent(e js.Value) {
|
||||
// Avoid using js.Value.String() as String creates a Uint8Array via a TextEncoder and causes a heavy
|
||||
// overhead (#1437).
|
||||
switch t := e.Get("type"); {
|
||||
case jsutil.Equal(t, stringKeydown):
|
||||
case t.Equal(stringKeydown):
|
||||
c := e.Get("code")
|
||||
if c.Type() != js.TypeString {
|
||||
code := e.Get("keyCode").Int()
|
||||
@ -358,20 +357,20 @@ func (i *Input) updateFromEvent(e js.Value) {
|
||||
i.keyDownEdge(code)
|
||||
return
|
||||
}
|
||||
if jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowUp]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowDown]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowLeft]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyArrowRight]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyBackspace]) ||
|
||||
jsutil.Equal(c, driverKeyToJSKey[driver.KeyTab]) {
|
||||
if c.Equal(driverKeyToJSKey[driver.KeyArrowUp]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyArrowDown]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyArrowLeft]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyArrowRight]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyBackspace]) ||
|
||||
c.Equal(driverKeyToJSKey[driver.KeyTab]) {
|
||||
e.Call("preventDefault")
|
||||
}
|
||||
i.keyDown(c)
|
||||
case jsutil.Equal(t, stringKeypress):
|
||||
case t.Equal(stringKeypress):
|
||||
if r := rune(e.Get("charCode").Int()); unicode.IsPrint(r) {
|
||||
i.runeBuffer = append(i.runeBuffer, r)
|
||||
}
|
||||
case jsutil.Equal(t, stringKeyup):
|
||||
case t.Equal(stringKeyup):
|
||||
if e.Get("code").Type() != js.TypeString {
|
||||
// Assume that UA is Edge.
|
||||
code := e.Get("keyCode").Int()
|
||||
@ -379,21 +378,21 @@ func (i *Input) updateFromEvent(e js.Value) {
|
||||
return
|
||||
}
|
||||
i.keyUp(e.Get("code"))
|
||||
case jsutil.Equal(t, stringMousedown):
|
||||
case t.Equal(stringMousedown):
|
||||
button := e.Get("button").Int()
|
||||
i.mouseDown(button)
|
||||
i.setMouseCursorFromEvent(e)
|
||||
case jsutil.Equal(t, stringMouseup):
|
||||
case t.Equal(stringMouseup):
|
||||
button := e.Get("button").Int()
|
||||
i.mouseUp(button)
|
||||
i.setMouseCursorFromEvent(e)
|
||||
case jsutil.Equal(t, stringMousemove):
|
||||
case t.Equal(stringMousemove):
|
||||
i.setMouseCursorFromEvent(e)
|
||||
case jsutil.Equal(t, stringWheel):
|
||||
case t.Equal(stringWheel):
|
||||
// TODO: What if e.deltaMode is not DOM_DELTA_PIXEL?
|
||||
i.wheelX = -e.Get("deltaX").Float()
|
||||
i.wheelY = -e.Get("deltaY").Float()
|
||||
case jsutil.Equal(t, stringTouchstart) || jsutil.Equal(t, stringTouchend) || jsutil.Equal(t, stringTouchmove):
|
||||
case t.Equal(stringTouchstart) || t.Equal(stringTouchend) || t.Equal(stringTouchmove):
|
||||
i.updateTouchesFromEvent(e)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/opengl"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/jsutil"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/restorable"
|
||||
)
|
||||
|
||||
@ -560,7 +559,7 @@ func (u *UserInterface) Run(context driver.UIContext) error {
|
||||
if u.initFocused && window.Truthy() {
|
||||
// Do not focus the canvas when the current document is in an iframe.
|
||||
// Otherwise, the parent page tries to focus the iframe on every loading, which is annoying (#1373).
|
||||
isInIframe := !jsutil.Equal(window.Get("location"), window.Get("parent").Get("location"))
|
||||
isInIframe := !window.Get("location").Equal(window.Get("parent").Get("location"))
|
||||
if !isInIframe {
|
||||
canvas.Call("focus")
|
||||
}
|
||||
@ -602,7 +601,7 @@ func (u *UserInterface) SetScreenTransparent(transparent bool) {
|
||||
|
||||
func (u *UserInterface) IsScreenTransparent() bool {
|
||||
bodyStyle := document.Get("body").Get("style")
|
||||
return jsutil.Equal(bodyStyle.Get("backgroundColor"), stringTransparent)
|
||||
return bodyStyle.Get("backgroundColor").Equal(stringTransparent)
|
||||
}
|
||||
|
||||
func (u *UserInterface) ResetForFrame() {
|
||||
|
Loading…
Reference in New Issue
Block a user