2018-12-30 07:35:49 +01:00
|
|
|
// Copyright 2018 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.
|
|
|
|
|
|
|
|
package glfw
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image"
|
2018-12-30 20:59:06 +01:00
|
|
|
"image/draw"
|
2020-09-03 18:18:37 +02:00
|
|
|
"math/bits"
|
2021-06-13 07:41:27 +02:00
|
|
|
"reflect"
|
2018-12-30 07:35:49 +01:00
|
|
|
"runtime"
|
|
|
|
"sync"
|
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
"golang.org/x/sys/windows"
|
|
|
|
)
|
|
|
|
|
2018-12-30 20:59:06 +01:00
|
|
|
type glfwImage struct {
|
|
|
|
width int32
|
|
|
|
height int32
|
|
|
|
pixels uintptr
|
|
|
|
}
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
type glfwWindows map[uintptr]*Window
|
|
|
|
|
|
|
|
var (
|
|
|
|
theGLFWWindows = glfwWindows{}
|
|
|
|
glfwWindowsM sync.Mutex
|
|
|
|
)
|
|
|
|
|
|
|
|
func (w glfwWindows) add(win uintptr) *Window {
|
|
|
|
if win == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
2021-02-23 08:52:09 +01:00
|
|
|
ww := &Window{w: win}
|
2018-12-30 07:35:49 +01:00
|
|
|
glfwWindowsM.Lock()
|
|
|
|
w[win] = ww
|
|
|
|
glfwWindowsM.Unlock()
|
|
|
|
return ww
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w glfwWindows) remove(win uintptr) {
|
|
|
|
glfwWindowsM.Lock()
|
|
|
|
delete(w, win)
|
|
|
|
glfwWindowsM.Unlock()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w glfwWindows) get(win uintptr) *Window {
|
|
|
|
if win == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
glfwWindowsM.Lock()
|
|
|
|
ww := w[win]
|
|
|
|
glfwWindowsM.Unlock()
|
|
|
|
return ww
|
|
|
|
}
|
|
|
|
|
2021-04-11 07:21:38 +02:00
|
|
|
type Cursor struct {
|
|
|
|
c uintptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateStandardCursor(shape StandardCursor) *Cursor {
|
|
|
|
c := glfwDLL.call("glfwCreateStandardCursor", uintptr(shape))
|
|
|
|
panicError()
|
|
|
|
return &Cursor{c: c}
|
|
|
|
}
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
type Monitor struct {
|
|
|
|
m uintptr
|
|
|
|
}
|
|
|
|
|
2019-02-24 15:10:14 +01:00
|
|
|
func (m *Monitor) GetPos() (int, int) {
|
|
|
|
var x, y int32
|
2018-12-30 07:35:49 +01:00
|
|
|
glfwDLL.call("glfwGetMonitorPos", m.m, uintptr(unsafe.Pointer(&x)), uintptr(unsafe.Pointer(&y)))
|
|
|
|
panicError()
|
2019-02-24 15:10:14 +01:00
|
|
|
return int(x), int(y)
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Monitor) GetVideoMode() *VidMode {
|
|
|
|
v := glfwDLL.call("glfwGetVideoMode", m.m)
|
|
|
|
panicError()
|
2021-06-13 07:41:27 +02:00
|
|
|
var vals []int32
|
|
|
|
h := (*reflect.SliceHeader)(unsafe.Pointer(&vals))
|
|
|
|
h.Data = v
|
|
|
|
h.Len = 6
|
|
|
|
h.Cap = 6
|
2018-12-30 07:35:49 +01:00
|
|
|
return &VidMode{
|
2021-06-13 07:41:27 +02:00
|
|
|
Width: int(vals[0]),
|
|
|
|
Height: int(vals[1]),
|
|
|
|
RedBits: int(vals[2]),
|
|
|
|
GreenBits: int(vals[3]),
|
|
|
|
BlueBits: int(vals[4]),
|
|
|
|
RefreshRate: int(vals[5]),
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Window struct {
|
|
|
|
w uintptr
|
2021-02-23 08:52:09 +01:00
|
|
|
|
|
|
|
prevSizeCallback SizeCallback
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) Destroy() {
|
|
|
|
glfwDLL.call("glfwDestroyWindow", w.w)
|
|
|
|
panicError()
|
|
|
|
theGLFWWindows.remove(w.w)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) GetAttrib(attrib Hint) int {
|
|
|
|
r := glfwDLL.call("glfwGetWindowAttrib", w.w, uintptr(attrib))
|
|
|
|
panicError()
|
|
|
|
return int(r)
|
|
|
|
}
|
|
|
|
|
2019-11-26 03:45:52 +01:00
|
|
|
func (w *Window) SetAttrib(attrib Hint, value int) {
|
|
|
|
glfwDLL.call("glfwSetWindowAttrib", w.w, uintptr(attrib), uintptr(value))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
func (w *Window) GetCursorPos() (x, y float64) {
|
|
|
|
glfwDLL.call("glfwGetCursorPos", w.w, uintptr(unsafe.Pointer(&x)), uintptr(unsafe.Pointer(&y)))
|
|
|
|
panicError()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) GetInputMode(mode InputMode) int {
|
|
|
|
r := glfwDLL.call("glfwGetInputMode", w.w, uintptr(mode))
|
|
|
|
panicError()
|
|
|
|
return int(r)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) GetKey(key Key) Action {
|
|
|
|
r := glfwDLL.call("glfwGetKey", w.w, uintptr(key))
|
|
|
|
panicError()
|
|
|
|
return Action(r)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) GetMonitor() *Monitor {
|
|
|
|
m := glfwDLL.call("glfwGetWindowMonitor", w.w)
|
|
|
|
panicError()
|
|
|
|
if m == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return &Monitor{m}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) GetMouseButton(button MouseButton) Action {
|
|
|
|
r := glfwDLL.call("glfwGetMouseButton", w.w, uintptr(button))
|
|
|
|
panicError()
|
|
|
|
return Action(r)
|
|
|
|
}
|
|
|
|
|
2019-02-24 15:10:14 +01:00
|
|
|
func (w *Window) GetPos() (int, int) {
|
|
|
|
var x, y int32
|
2018-12-30 07:35:49 +01:00
|
|
|
glfwDLL.call("glfwGetWindowPos", w.w, uintptr(unsafe.Pointer(&x)), uintptr(unsafe.Pointer(&y)))
|
|
|
|
panicError()
|
2019-02-24 15:10:14 +01:00
|
|
|
return int(x), int(y)
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
2019-02-24 15:10:14 +01:00
|
|
|
func (w *Window) GetSize() (int, int) {
|
|
|
|
var width, height int32
|
2018-12-30 07:35:49 +01:00
|
|
|
glfwDLL.call("glfwGetWindowSize", w.w, uintptr(unsafe.Pointer(&width)), uintptr(unsafe.Pointer(&height)))
|
|
|
|
panicError()
|
2019-02-24 15:10:14 +01:00
|
|
|
return int(width), int(height)
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
2020-03-21 11:26:28 +01:00
|
|
|
func (w *Window) Iconify() {
|
|
|
|
glfwDLL.call("glfwIconifyWindow", w.w)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
func (w *Window) MakeContextCurrent() {
|
|
|
|
glfwDLL.call("glfwMakeContextCurrent", w.w)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2020-03-21 11:26:28 +01:00
|
|
|
func (w *Window) Maximize() {
|
|
|
|
glfwDLL.call("glfwMaximizeWindow", w.w)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:16:23 +01:00
|
|
|
func (w *Window) Restore() {
|
|
|
|
glfwDLL.call("glfwRestoreWindow", w.w)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback) {
|
2021-06-13 14:43:23 +02:00
|
|
|
glfwDLL.call("glfwSetCharModsCallback", w.w, uintptr(cbfun))
|
2018-12-30 07:35:49 +01:00
|
|
|
panicError()
|
2021-06-13 14:43:23 +02:00
|
|
|
return ToCharModsCallback(nil) // TODO
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
2021-06-13 13:52:14 +02:00
|
|
|
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback) {
|
|
|
|
glfwDLL.call("glfwSetWindowCloseCallback", w.w, uintptr(cbfun))
|
|
|
|
panicError()
|
|
|
|
return ToCloseCallback(nil) // TODO
|
|
|
|
}
|
|
|
|
|
2021-04-11 07:21:38 +02:00
|
|
|
func (w *Window) SetCursor(cursor *Cursor) {
|
|
|
|
var c uintptr
|
|
|
|
if cursor != nil {
|
|
|
|
c = cursor.c
|
|
|
|
}
|
|
|
|
glfwDLL.call("glfwSetCursor", w.w, c)
|
|
|
|
}
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback) {
|
2021-06-13 14:43:23 +02:00
|
|
|
glfwDLL.call("glfwSetFramebufferSizeCallback", w.w, uintptr(cbfun))
|
2018-12-30 07:35:49 +01:00
|
|
|
panicError()
|
2021-06-13 14:43:23 +02:00
|
|
|
return ToFramebufferSizeCallback(nil) // TODO
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback) {
|
2021-06-13 14:43:23 +02:00
|
|
|
glfwDLL.call("glfwSetScrollCallback", w.w, uintptr(cbfun))
|
2018-12-30 07:35:49 +01:00
|
|
|
panicError()
|
2021-06-13 14:43:23 +02:00
|
|
|
return ToScrollCallback(nil) // TODO
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
2021-06-13 13:52:14 +02:00
|
|
|
func (w *Window) SetShouldClose(value bool) {
|
|
|
|
var v uintptr = False
|
|
|
|
if value {
|
|
|
|
v = True
|
|
|
|
}
|
|
|
|
glfwDLL.call("glfwSetWindowShouldClose", w.w, v)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2021-02-23 08:52:09 +01:00
|
|
|
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback) {
|
2021-06-13 14:43:23 +02:00
|
|
|
glfwDLL.call("glfwSetWindowSizeCallback", w.w, uintptr(cbfun))
|
2019-01-09 02:34:54 +01:00
|
|
|
panicError()
|
2021-02-23 08:52:09 +01:00
|
|
|
prev := w.prevSizeCallback
|
|
|
|
w.prevSizeCallback = cbfun
|
|
|
|
return prev
|
2019-01-09 02:34:54 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 21:24:13 +02:00
|
|
|
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
|
|
|
glfwDLL.call("glfwSetWindowSizeLimits", w.w, uintptr(minw), uintptr(minh), uintptr(maxw), uintptr(maxh))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
func (w *Window) SetIcon(images []image.Image) {
|
2018-12-30 20:59:06 +01:00
|
|
|
gimgs := make([]glfwImage, len(images))
|
|
|
|
defer runtime.KeepAlive(gimgs)
|
|
|
|
|
|
|
|
for i, img := range images {
|
|
|
|
b := img.Bounds()
|
|
|
|
m := image.NewNRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
|
|
|
|
draw.Draw(m, m.Bounds(), img, b.Min, draw.Src)
|
|
|
|
gimgs[i].width = int32(b.Dx())
|
|
|
|
gimgs[i].height = int32(b.Dy())
|
|
|
|
gimgs[i].pixels = uintptr(unsafe.Pointer(&m.Pix[0]))
|
|
|
|
}
|
2018-12-30 07:35:49 +01:00
|
|
|
|
2018-12-30 20:59:06 +01:00
|
|
|
glfwDLL.call("glfwSetWindowIcon", w.w, uintptr(len(gimgs)), uintptr(unsafe.Pointer(&gimgs[0])))
|
|
|
|
panicError()
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) SetInputMode(mode InputMode, value int) {
|
|
|
|
glfwDLL.call("glfwSetInputMode", w.w, uintptr(mode), uintptr(value))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int) {
|
|
|
|
var m uintptr
|
|
|
|
if monitor != nil {
|
|
|
|
m = monitor.m
|
|
|
|
}
|
|
|
|
glfwDLL.call("glfwSetWindowMonitor", w.w, m, uintptr(xpos), uintptr(ypos), uintptr(width), uintptr(height), uintptr(refreshRate))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) SetPos(xpos, ypos int) {
|
|
|
|
glfwDLL.call("glfwSetWindowPos", w.w, uintptr(xpos), uintptr(ypos))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) SetSize(width, height int) {
|
|
|
|
glfwDLL.call("glfwSetWindowSize", w.w, uintptr(width), uintptr(height))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) SetTitle(title string) {
|
|
|
|
s := []byte(title)
|
|
|
|
s = append(s, 0)
|
|
|
|
defer runtime.KeepAlive(s)
|
|
|
|
glfwDLL.call("glfwSetWindowTitle", w.w, uintptr(unsafe.Pointer(&s[0])))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) ShouldClose() bool {
|
|
|
|
r := glfwDLL.call("glfwWindowShouldClose", w.w)
|
|
|
|
panicError()
|
|
|
|
return r == True
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) Show() {
|
|
|
|
glfwDLL.call("glfwShowWindow", w.w)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *Window) SwapBuffers() {
|
|
|
|
glfwDLL.call("glfwSwapBuffers", w.w)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateWindow(width, height int, title string, monitor *Monitor, share *Window) (*Window, error) {
|
|
|
|
s := []byte(title)
|
|
|
|
s = append(s, 0)
|
|
|
|
defer runtime.KeepAlive(s)
|
|
|
|
|
|
|
|
var gm uintptr
|
|
|
|
if monitor != nil {
|
|
|
|
gm = monitor.m
|
|
|
|
}
|
|
|
|
var gw uintptr
|
|
|
|
if share != nil {
|
|
|
|
gw = share.w
|
|
|
|
}
|
|
|
|
|
|
|
|
w := glfwDLL.call("glfwCreateWindow", uintptr(width), uintptr(height), uintptr(unsafe.Pointer(&s[0])), gm, gw)
|
|
|
|
if w == 0 {
|
|
|
|
return nil, acceptError(APIUnavailable, VersionUnavailable)
|
|
|
|
}
|
|
|
|
return theGLFWWindows.add(w), nil
|
|
|
|
}
|
|
|
|
|
2020-01-09 14:11:32 +01:00
|
|
|
func (j Joystick) GetGUID() string {
|
|
|
|
ptr := glfwDLL.call("glfwGetJoystickGUID", uintptr(j))
|
|
|
|
panicError()
|
|
|
|
var backed [256]byte
|
|
|
|
as := backed[:0]
|
|
|
|
for i := int32(0); ; i++ {
|
|
|
|
b := *(*byte)(unsafe.Pointer(ptr))
|
|
|
|
ptr += unsafe.Sizeof(byte(0))
|
|
|
|
if b == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
as = append(as, b)
|
|
|
|
}
|
|
|
|
r := string(as)
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j Joystick) GetName() string {
|
|
|
|
ptr := glfwDLL.call("glfwGetJoystickName", uintptr(j))
|
|
|
|
panicError()
|
|
|
|
var backed [256]byte
|
|
|
|
as := backed[:0]
|
|
|
|
for i := int32(0); ; i++ {
|
|
|
|
b := *(*byte)(unsafe.Pointer(ptr))
|
|
|
|
ptr += unsafe.Sizeof(byte(0))
|
|
|
|
if b == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
as = append(as, b)
|
|
|
|
}
|
|
|
|
r := string(as)
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:13:44 +01:00
|
|
|
func (j Joystick) GetAxes() []float32 {
|
2019-02-24 15:10:14 +01:00
|
|
|
var l int32
|
2019-11-25 15:13:44 +01:00
|
|
|
ptr := glfwDLL.call("glfwGetJoystickAxes", uintptr(j), uintptr(unsafe.Pointer(&l)))
|
2018-12-30 07:35:49 +01:00
|
|
|
panicError()
|
|
|
|
as := make([]float32, l)
|
2019-02-24 15:10:14 +01:00
|
|
|
for i := int32(0); i < l; i++ {
|
2018-12-30 07:35:49 +01:00
|
|
|
as[i] = *(*float32)(unsafe.Pointer(ptr))
|
|
|
|
ptr += unsafe.Sizeof(float32(0))
|
|
|
|
}
|
|
|
|
return as
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:13:44 +01:00
|
|
|
func (j Joystick) GetButtons() []byte {
|
2019-02-24 15:10:14 +01:00
|
|
|
var l int32
|
2019-11-25 15:13:44 +01:00
|
|
|
ptr := glfwDLL.call("glfwGetJoystickButtons", uintptr(j), uintptr(unsafe.Pointer(&l)))
|
2018-12-30 07:35:49 +01:00
|
|
|
panicError()
|
|
|
|
bs := make([]byte, l)
|
2019-02-24 15:10:14 +01:00
|
|
|
for i := int32(0); i < l; i++ {
|
2018-12-30 07:35:49 +01:00
|
|
|
bs[i] = *(*byte)(unsafe.Pointer(ptr))
|
|
|
|
ptr++
|
|
|
|
}
|
|
|
|
return bs
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetMonitors() []*Monitor {
|
2019-02-24 15:10:14 +01:00
|
|
|
var l int32
|
2018-12-30 07:35:49 +01:00
|
|
|
ptr := glfwDLL.call("glfwGetMonitors", uintptr(unsafe.Pointer(&l)))
|
|
|
|
panicError()
|
|
|
|
ms := make([]*Monitor, l)
|
2019-02-24 15:10:14 +01:00
|
|
|
for i := int32(0); i < l; i++ {
|
2018-12-30 07:35:49 +01:00
|
|
|
m := *(*unsafe.Pointer)(unsafe.Pointer(ptr))
|
|
|
|
if m != nil {
|
|
|
|
ms[i] = &Monitor{uintptr(m)}
|
|
|
|
}
|
2020-09-03 18:18:37 +02:00
|
|
|
ptr += bits.UintSize / 8
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
return ms
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetPrimaryMonitor() *Monitor {
|
|
|
|
m := glfwDLL.call("glfwGetPrimaryMonitor")
|
|
|
|
panicError()
|
|
|
|
if m == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return &Monitor{m}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Init() error {
|
|
|
|
glfwDLL.call("glfwInit")
|
|
|
|
return acceptError(APIUnavailable)
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:13:44 +01:00
|
|
|
func (j Joystick) Present() bool {
|
|
|
|
r := glfwDLL.call("glfwJoystickPresent", uintptr(j))
|
2018-12-30 07:35:49 +01:00
|
|
|
panicError()
|
|
|
|
return r == True
|
|
|
|
}
|
|
|
|
|
|
|
|
func PollEvents() {
|
|
|
|
glfwDLL.call("glfwPollEvents")
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:13:44 +01:00
|
|
|
func SetMonitorCallback(cbfun func(monitor *Monitor, event PeripheralEvent)) {
|
2018-12-30 07:35:49 +01:00
|
|
|
var gcb uintptr
|
|
|
|
if cbfun != nil {
|
2019-11-25 15:13:44 +01:00
|
|
|
gcb = windows.NewCallbackCDecl(func(monitor uintptr, event PeripheralEvent) uintptr {
|
2018-12-30 07:35:49 +01:00
|
|
|
var m *Monitor
|
|
|
|
if monitor != 0 {
|
|
|
|
m = &Monitor{monitor}
|
|
|
|
}
|
|
|
|
cbfun(m, event)
|
|
|
|
return 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
glfwDLL.call("glfwSetMonitorCallback", gcb)
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func SwapInterval(interval int) {
|
|
|
|
glfwDLL.call("glfwSwapInterval", uintptr(interval))
|
|
|
|
panicError()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Terminate() {
|
|
|
|
flushErrors()
|
|
|
|
glfwDLL.call("glfwTerminate")
|
|
|
|
if err := glfwDLL.unload(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WindowHint(target Hint, hint int) {
|
|
|
|
glfwDLL.call("glfwWindowHint", uintptr(target), uintptr(hint))
|
|
|
|
panicError()
|
|
|
|
}
|