mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Update the version of GLFW to 3.1
This commit is contained in:
parent
2a8bcbfa18
commit
4b9c740ee8
@ -114,7 +114,7 @@ const uiKeysGlfwTmpl = `{{.License}}
|
||||
package ui
|
||||
|
||||
import (
|
||||
glfw "github.com/go-gl/glfw/v3.0/glfw"
|
||||
glfw "github.com/go-gl/glfw/v3.1/glfw"
|
||||
)
|
||||
|
||||
var glfwKeyCodeToKey = map[glfw.Key]Key{
|
||||
|
@ -17,7 +17,7 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
glfw "github.com/go-gl/glfw/v3.0/glfw"
|
||||
glfw "github.com/go-gl/glfw/v3.1/glfw"
|
||||
"math"
|
||||
)
|
||||
|
||||
@ -38,17 +38,14 @@ func (i *input) update(window *glfw.Window, scale int) error {
|
||||
for g, e := range glfwMouseButtonToMouseButton {
|
||||
i.mouseButtonPressed[e] = window.GetMouseButton(g) == glfw.Press
|
||||
}
|
||||
x, y := window.GetCursorPosition()
|
||||
x, y := window.GetCursorPos()
|
||||
i.cursorX = int(math.Floor(x)) / scale
|
||||
i.cursorY = int(math.Floor(y)) / scale
|
||||
for id := glfw.Joystick(0); id < glfw.Joystick(len(i.gamepads)); id++ {
|
||||
if !glfw.JoystickPresent(id) {
|
||||
continue
|
||||
}
|
||||
axes32, err := glfw.GetJoystickAxes(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
axes32 := glfw.GetJoystickAxes(id)
|
||||
i.gamepads[id].axisNum = len(axes32)
|
||||
for a := 0; a < len(i.gamepads[id].axes); a++ {
|
||||
if len(axes32) <= a {
|
||||
@ -57,10 +54,7 @@ func (i *input) update(window *glfw.Window, scale int) error {
|
||||
}
|
||||
i.gamepads[id].axes[a] = float64(axes32[a])
|
||||
}
|
||||
buttons, err := glfw.GetJoystickButtons(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
buttons := glfw.GetJoystickButtons(id)
|
||||
i.gamepads[id].buttonNum = len(buttons)
|
||||
for b := 0; b < len(i.gamepads[id].buttonPressed); b++ {
|
||||
if len(buttons) <= b {
|
||||
|
@ -19,7 +19,7 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
glfw "github.com/go-gl/glfw/v3.0/glfw"
|
||||
glfw "github.com/go-gl/glfw/v3.1/glfw"
|
||||
)
|
||||
|
||||
var glfwKeyCodeToKey = map[glfw.Key]Key{
|
||||
|
@ -18,7 +18,7 @@ package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
glfw "github.com/go-gl/glfw/v3.0/glfw"
|
||||
glfw "github.com/go-gl/glfw/v3.1/glfw"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
@ -32,11 +32,9 @@ var currentUI *userInterface
|
||||
func Init() {
|
||||
runtime.LockOSThread()
|
||||
|
||||
glfw.SetErrorCallback(func(err glfw.ErrorCode, desc string) {
|
||||
panic(fmt.Sprintf("%v: %v\n", err, desc))
|
||||
})
|
||||
if !glfw.Init() {
|
||||
panic("glfw.Init() fails")
|
||||
err := glfw.Init()
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("glfw.Init() fails: %v", err))
|
||||
}
|
||||
glfw.WindowHint(glfw.Visible, glfw.False)
|
||||
glfw.WindowHint(glfw.Resizable, glfw.False)
|
||||
@ -112,20 +110,13 @@ type userInterface struct {
|
||||
}
|
||||
|
||||
func (u *userInterface) start(width, height, scale int, title string) (actualScale int, err error) {
|
||||
monitor, err := glfw.GetPrimaryMonitor()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
videoMode, err := monitor.GetVideoMode()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
videoMode := glfw.GetPrimaryMonitor().GetVideoMode()
|
||||
x := (videoMode.Width - width*scale) / 2
|
||||
y := (videoMode.Height - height*scale) / 3
|
||||
|
||||
u.setScreenSize(width, height, scale)
|
||||
u.window.SetTitle(title)
|
||||
u.window.SetPosition(x, y)
|
||||
u.window.SetPos(x, y)
|
||||
u.window.Show()
|
||||
|
||||
return u.actualScale, nil
|
||||
@ -140,7 +131,7 @@ func (u *userInterface) doEvents() error {
|
||||
if err := u.pollEvents(); err != nil {
|
||||
return err
|
||||
}
|
||||
for u.window.GetAttribute(glfw.Focused) == 0 {
|
||||
for u.window.GetAttrib(glfw.Focused) == 0 {
|
||||
time.Sleep(time.Second / 60)
|
||||
if err := u.pollEvents(); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user