mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
ee1c179c83
commit
98dc59c89f
@ -19,33 +19,44 @@ import (
|
||||
// Originally GLFW 3 passes a null pointer to detach the context.
|
||||
// But since we're using receievers, DetachCurrentContext should
|
||||
// be used instead.
|
||||
func (w *Window) MakeContextCurrent() {
|
||||
func (w *Window) MakeContextCurrent() error {
|
||||
C.glfwMakeContextCurrent(w.data)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DetachCurrentContext detaches the current context.
|
||||
func DetachCurrentContext() {
|
||||
func DetachCurrentContext() error {
|
||||
C.glfwMakeContextCurrent(nil)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCurrentContext returns the window whose context is current.
|
||||
func GetCurrentContext() *Window {
|
||||
func GetCurrentContext() (*Window, error) {
|
||||
w := C.glfwGetCurrentContext()
|
||||
panicError()
|
||||
if w == nil {
|
||||
return nil
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return windows.get(w)
|
||||
if w == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return windows.get(w), nil
|
||||
}
|
||||
|
||||
// SwapBuffers swaps the front and back buffers of the window. If the
|
||||
// swap interval is greater than zero, the GPU driver waits the specified number
|
||||
// of screen updates before swapping the buffers.
|
||||
func (w *Window) SwapBuffers() {
|
||||
func (w *Window) SwapBuffers() error {
|
||||
C.glfwSwapBuffers(w.data)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SwapInterval sets the swap interval for the current context, i.e. the number
|
||||
@ -62,9 +73,12 @@ func (w *Window) SwapBuffers() {
|
||||
//
|
||||
// Some GPU drivers do not honor the requested swap interval, either because of
|
||||
// user settings that override the request or due to bugs in the driver.
|
||||
func SwapInterval(interval int) {
|
||||
func SwapInterval(interval int) error {
|
||||
C.glfwSwapInterval(C.int(interval))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExtensionSupported reports whether the specified OpenGL or context creation
|
||||
@ -75,12 +89,14 @@ func SwapInterval(interval int) {
|
||||
// recommended that you cache its results if it's going to be used frequently.
|
||||
// The extension strings will not change during the lifetime of a context, so
|
||||
// there is no danger in doing this.
|
||||
func ExtensionSupported(extension string) bool {
|
||||
func ExtensionSupported(extension string) (bool, error) {
|
||||
e := C.CString(extension)
|
||||
defer C.free(unsafe.Pointer(e))
|
||||
ret := C.glfwExtensionSupported(e) != 0
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// GetProcAddress returns the address of the specified OpenGL or OpenGL ES core
|
||||
@ -91,10 +107,12 @@ func ExtensionSupported(extension string) bool {
|
||||
//
|
||||
// This function is used to provide GL proc resolving capabilities to an
|
||||
// external C library.
|
||||
func GetProcAddress(procname string) unsafe.Pointer {
|
||||
func GetProcAddress(procname string) (unsafe.Pointer, error) {
|
||||
p := C.CString(procname)
|
||||
defer C.free(unsafe.Pointer(p))
|
||||
ret := unsafe.Pointer(C.glfwGetProcAddress(p))
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
@ -324,16 +324,21 @@ func goDropCB(window unsafe.Pointer, count C.int, names **C.char) { // TODO: The
|
||||
}
|
||||
|
||||
// GetInputMode returns the value of an input option of the window.
|
||||
func (w *Window) GetInputMode(mode InputMode) int {
|
||||
func (w *Window) GetInputMode(mode InputMode) (int, error) {
|
||||
ret := int(C.glfwGetInputMode(w.data, C.int(mode)))
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// SetInputMode sets an input option for the window.
|
||||
func (w *Window) SetInputMode(mode InputMode, value int) {
|
||||
func (w *Window) SetInputMode(mode InputMode, value int) error {
|
||||
C.glfwSetInputMode(w.data, C.int(mode), C.int(value))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RawMouseMotionSupported returns whether raw mouse motion is supported on the
|
||||
@ -372,19 +377,23 @@ func GetKeyScancode(key Key) int {
|
||||
// The key functions deal with physical keys, with key tokens named after their
|
||||
// use on the standard US keyboard layout. If you want to input text, use the
|
||||
// Unicode character callback instead.
|
||||
func (w *Window) GetKey(key Key) Action {
|
||||
func (w *Window) GetKey(key Key) (Action, error) {
|
||||
ret := Action(C.glfwGetKey(w.data, C.int(key)))
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// GetKeyName returns the localized name of the specified printable key.
|
||||
//
|
||||
// If the key is glfw.KeyUnknown, the scancode is used, otherwise the scancode is ignored.
|
||||
func GetKeyName(key Key, scancode int) string {
|
||||
func GetKeyName(key Key, scancode int) (string, error) {
|
||||
ret := C.glfwGetKeyName(C.int(key), C.int(scancode))
|
||||
panicError()
|
||||
return C.GoString(ret)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return C.GoString(ret), nil
|
||||
}
|
||||
|
||||
// GetMouseButton returns the last state reported for the specified mouse button.
|
||||
@ -392,10 +401,12 @@ func GetKeyName(key Key, scancode int) string {
|
||||
// If the StickyMouseButtons input mode is enabled, this function returns Press
|
||||
// the first time you call this function after a mouse button has been pressed,
|
||||
// even if the mouse button has already been released.
|
||||
func (w *Window) GetMouseButton(button MouseButton) Action {
|
||||
func (w *Window) GetMouseButton(button MouseButton) (Action, error) {
|
||||
ret := Action(C.glfwGetMouseButton(w.data, C.int(button)))
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// GetCursorPos returns the last reported position of the cursor.
|
||||
@ -406,11 +417,13 @@ func (w *Window) GetMouseButton(button MouseButton) Action {
|
||||
// The coordinate can be converted to their integer equivalents with the floor
|
||||
// function. Casting directly to an integer type works for positive coordinates,
|
||||
// but fails for negative ones.
|
||||
func (w *Window) GetCursorPos() (x, y float64) {
|
||||
func (w *Window) GetCursorPos() (x, y float64, err error) {
|
||||
var xpos, ypos C.double
|
||||
C.glfwGetCursorPos(w.data, &xpos, &ypos)
|
||||
panicError()
|
||||
return float64(xpos), float64(ypos)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return float64(xpos), float64(ypos), nil
|
||||
}
|
||||
|
||||
// SetCursorPos sets the position of the cursor. The specified window must
|
||||
@ -419,9 +432,12 @@ func (w *Window) GetCursorPos() (x, y float64) {
|
||||
//
|
||||
// If the cursor is disabled (with CursorDisabled) then the cursor position is
|
||||
// unbounded and limited only by the minimum and maximum values of a double.
|
||||
func (w *Window) SetCursorPos(xpos, ypos float64) {
|
||||
func (w *Window) SetCursorPos(xpos, ypos float64) error {
|
||||
C.glfwSetCursorPos(w.data, C.double(xpos), C.double(ypos))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateCursor creates a new custom cursor image that can be set for a window with SetCursor.
|
||||
@ -435,7 +451,7 @@ func (w *Window) SetCursorPos(xpos, ypos float64) {
|
||||
//
|
||||
// The cursor hotspot is specified in pixels, relative to the upper-left corner of the cursor image.
|
||||
// Like all other coordinate systems in GLFW, the X-axis points to the right and the Y-axis points down.
|
||||
func CreateCursor(img image.Image, xhot, yhot int) *Cursor {
|
||||
func CreateCursor(img image.Image, xhot, yhot int) (*Cursor, error) {
|
||||
var imgC C.GLFWimage
|
||||
var pixels []uint8
|
||||
b := img.Bounds()
|
||||
@ -458,24 +474,31 @@ func CreateCursor(img image.Image, xhot, yhot int) *Cursor {
|
||||
c := C.glfwCreateCursor(&imgC, C.int(xhot), C.int(yhot))
|
||||
|
||||
free()
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Cursor{c}
|
||||
return &Cursor{c}, nil
|
||||
}
|
||||
|
||||
// CreateStandardCursor returns a cursor with a standard shape,
|
||||
// that can be set for a window with SetCursor.
|
||||
func CreateStandardCursor(shape StandardCursor) *Cursor {
|
||||
func CreateStandardCursor(shape StandardCursor) (*Cursor, error) {
|
||||
c := C.glfwCreateStandardCursor(C.int(shape))
|
||||
panicError()
|
||||
return &Cursor{c}
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Cursor{c}, nil
|
||||
}
|
||||
|
||||
// Destroy destroys a cursor previously created with CreateCursor.
|
||||
// Any remaining cursors will be destroyed by Terminate.
|
||||
func (c *Cursor) Destroy() {
|
||||
func (c *Cursor) Destroy() error {
|
||||
C.glfwDestroyCursor(c.data)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetCursor sets the cursor image to be used when the cursor is over the client area
|
||||
@ -483,13 +506,16 @@ func (c *Cursor) Destroy() {
|
||||
// window is CursorNormal.
|
||||
//
|
||||
// On some platforms, the set cursor may not be visible unless the window also has input focus.
|
||||
func (w *Window) SetCursor(c *Cursor) {
|
||||
func (w *Window) SetCursor(c *Cursor) error {
|
||||
if c == nil {
|
||||
C.glfwSetCursor(w.data, nil)
|
||||
} else {
|
||||
C.glfwSetCursor(w.data, c.data)
|
||||
}
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// KeyCallback is the key callback.
|
||||
@ -507,7 +533,7 @@ type KeyCallback func(w *Window, key Key, scancode int, action Action, mods Modi
|
||||
// fact that the synthetic ones are generated after the window has lost focus,
|
||||
// i.e. Focused will be false and the focus callback will have already been
|
||||
// called.
|
||||
func (w *Window) SetKeyCallback(cbfun KeyCallback) (previous KeyCallback) {
|
||||
func (w *Window) SetKeyCallback(cbfun KeyCallback) (previous KeyCallback, err error) {
|
||||
previous = w.fKeyHolder
|
||||
w.fKeyHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -515,8 +541,10 @@ func (w *Window) SetKeyCallback(cbfun KeyCallback) (previous KeyCallback) {
|
||||
} else {
|
||||
C.glfwSetKeyCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// CharCallback is the character callback.
|
||||
@ -536,7 +564,7 @@ type CharCallback func(w *Window, char rune)
|
||||
// not be called if modifier keys are held down that would prevent normal text
|
||||
// input on that platform, for example a Super (Command) key on OS X or Alt key
|
||||
// on Windows. There is a character with modifiers callback that receives these events.
|
||||
func (w *Window) SetCharCallback(cbfun CharCallback) (previous CharCallback) {
|
||||
func (w *Window) SetCharCallback(cbfun CharCallback) (previous CharCallback, err error) {
|
||||
previous = w.fCharHolder
|
||||
w.fCharHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -544,8 +572,10 @@ func (w *Window) SetCharCallback(cbfun CharCallback) (previous CharCallback) {
|
||||
} else {
|
||||
C.glfwSetCharCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// CharModsCallback is the character with modifiers callback.
|
||||
@ -563,7 +593,7 @@ type CharModsCallback func(w *Window, char rune, mods ModifierKey)
|
||||
// map 1:1 to physical keys, as a key may produce zero, one or more characters.
|
||||
// If you want to know whether a specific physical key was pressed or released,
|
||||
// see the key callback instead.
|
||||
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback) {
|
||||
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback, err error) {
|
||||
previous = w.fCharModsHolder
|
||||
w.fCharModsHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -571,8 +601,10 @@ func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsC
|
||||
} else {
|
||||
C.glfwSetCharModsCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// MouseButtonCallback is the mouse button callback.
|
||||
@ -586,7 +618,7 @@ type MouseButtonCallback func(w *Window, button MouseButton, action Action, mods
|
||||
// user-generated events by the fact that the synthetic ones are generated after
|
||||
// the window has lost focus, i.e. Focused will be false and the focus
|
||||
// callback will have already been called.
|
||||
func (w *Window) SetMouseButtonCallback(cbfun MouseButtonCallback) (previous MouseButtonCallback) {
|
||||
func (w *Window) SetMouseButtonCallback(cbfun MouseButtonCallback) (previous MouseButtonCallback, err error) {
|
||||
previous = w.fMouseButtonHolder
|
||||
w.fMouseButtonHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -594,8 +626,10 @@ func (w *Window) SetMouseButtonCallback(cbfun MouseButtonCallback) (previous Mou
|
||||
} else {
|
||||
C.glfwSetMouseButtonCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// CursorPosCallback the cursor position callback.
|
||||
@ -604,7 +638,7 @@ type CursorPosCallback func(w *Window, xpos float64, ypos float64)
|
||||
// SetCursorPosCallback sets the cursor position callback which is called
|
||||
// when the cursor is moved. The callback is provided with the position relative
|
||||
// to the upper-left corner of the client area of the window.
|
||||
func (w *Window) SetCursorPosCallback(cbfun CursorPosCallback) (previous CursorPosCallback) {
|
||||
func (w *Window) SetCursorPosCallback(cbfun CursorPosCallback) (previous CursorPosCallback, err error) {
|
||||
previous = w.fCursorPosHolder
|
||||
w.fCursorPosHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -612,8 +646,10 @@ func (w *Window) SetCursorPosCallback(cbfun CursorPosCallback) (previous CursorP
|
||||
} else {
|
||||
C.glfwSetCursorPosCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// CursorEnterCallback is the cursor boundary crossing callback.
|
||||
@ -621,7 +657,7 @@ type CursorEnterCallback func(w *Window, entered bool)
|
||||
|
||||
// SetCursorEnterCallback the cursor boundary crossing callback which is called
|
||||
// when the cursor enters or leaves the client area of the window.
|
||||
func (w *Window) SetCursorEnterCallback(cbfun CursorEnterCallback) (previous CursorEnterCallback) {
|
||||
func (w *Window) SetCursorEnterCallback(cbfun CursorEnterCallback) (previous CursorEnterCallback, err error) {
|
||||
previous = w.fCursorEnterHolder
|
||||
w.fCursorEnterHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -629,8 +665,10 @@ func (w *Window) SetCursorEnterCallback(cbfun CursorEnterCallback) (previous Cur
|
||||
} else {
|
||||
C.glfwSetCursorEnterCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// ScrollCallback is the scroll callback.
|
||||
@ -638,7 +676,7 @@ type ScrollCallback func(w *Window, xoff float64, yoff float64)
|
||||
|
||||
// SetScrollCallback sets the scroll callback which is called when a scrolling
|
||||
// device is used, such as a mouse wheel or scrolling area of a touchpad.
|
||||
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback) {
|
||||
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback, err error) {
|
||||
previous = w.fScrollHolder
|
||||
w.fScrollHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -646,8 +684,10 @@ func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallbac
|
||||
} else {
|
||||
C.glfwSetScrollCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// DropCallback is the drop callback.
|
||||
@ -655,7 +695,7 @@ type DropCallback func(w *Window, names []string)
|
||||
|
||||
// SetDropCallback sets the drop callback which is called when an object
|
||||
// is dropped over the window.
|
||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback, err error) {
|
||||
previous = w.fDropHolder
|
||||
w.fDropHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -663,6 +703,8 @@ func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
||||
} else {
|
||||
C.glfwSetDropCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
@ -76,13 +76,15 @@ func goMonitorCB(monitor unsafe.Pointer, event C.int) {
|
||||
}
|
||||
|
||||
// GetMonitors returns a slice of handles for all currently connected monitors.
|
||||
func GetMonitors() []*Monitor {
|
||||
func GetMonitors() ([]*Monitor, error) {
|
||||
var length int
|
||||
|
||||
mC := C.glfwGetMonitors((*C.int)(unsafe.Pointer(&length)))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if mC == nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
m := make([]*Monitor, length)
|
||||
@ -91,27 +93,31 @@ func GetMonitors() []*Monitor {
|
||||
m[i] = &Monitor{C.GetMonitorAtIndex(mC, C.int(i))}
|
||||
}
|
||||
|
||||
return m
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetPrimaryMonitor returns the primary monitor. This is usually the monitor
|
||||
// where elements like the Windows task bar or the OS X menu bar is located.
|
||||
func GetPrimaryMonitor() *Monitor {
|
||||
func GetPrimaryMonitor() (*Monitor, error) {
|
||||
m := C.glfwGetPrimaryMonitor()
|
||||
panicError()
|
||||
if m == nil {
|
||||
return nil
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Monitor{m}
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return &Monitor{m}, nil
|
||||
}
|
||||
|
||||
// GetPos returns the position, in screen coordinates, of the upper-left
|
||||
// corner of the monitor.
|
||||
func (m *Monitor) GetPos() (x, y int) {
|
||||
func (m *Monitor) GetPos() (x, y int, err error) {
|
||||
var xpos, ypos C.int
|
||||
C.glfwGetMonitorPos(m.data, &xpos, &ypos)
|
||||
panicError()
|
||||
return int(xpos), int(ypos)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return int(xpos), int(ypos), nil
|
||||
}
|
||||
|
||||
// GetWorkarea returns the position, in screen coordinates, of the upper-left
|
||||
@ -170,21 +176,25 @@ func (m *Monitor) GetUserPointer() unsafe.Pointer {
|
||||
// Note: Some operating systems do not provide accurate information, either
|
||||
// because the monitor's EDID data is incorrect, or because the driver does not
|
||||
// report it accurately.
|
||||
func (m *Monitor) GetPhysicalSize() (width, height int) {
|
||||
func (m *Monitor) GetPhysicalSize() (width, height int, err error) {
|
||||
var wi, h C.int
|
||||
C.glfwGetMonitorPhysicalSize(m.data, &wi, &h)
|
||||
panicError()
|
||||
return int(wi), int(h)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return int(wi), int(h), nil
|
||||
}
|
||||
|
||||
// GetName returns a human-readable name of the monitor, encoded as UTF-8.
|
||||
func (m *Monitor) GetName() string {
|
||||
func (m *Monitor) GetName() (string, error) {
|
||||
mn := C.glfwGetMonitorName(m.data)
|
||||
panicError()
|
||||
if mn == nil {
|
||||
return ""
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return C.GoString(mn)
|
||||
if mn == nil {
|
||||
return "", nil
|
||||
}
|
||||
return C.GoString(mn), nil
|
||||
}
|
||||
|
||||
// MonitorCallback is the signature for monitor configuration callback
|
||||
@ -211,13 +221,15 @@ func SetMonitorCallback(cbfun MonitorCallback) MonitorCallback {
|
||||
// The returned array is sorted in ascending order, first by color bit depth
|
||||
// (the sum of all channel depths) and then by resolution area (the product of
|
||||
// width and height).
|
||||
func (m *Monitor) GetVideoModes() []*VidMode {
|
||||
func (m *Monitor) GetVideoModes() ([]*VidMode, error) {
|
||||
var length int
|
||||
|
||||
vC := C.glfwGetVideoModes(m.data, (*C.int)(unsafe.Pointer(&length)))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if vC == nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
v := make([]*VidMode, length)
|
||||
@ -227,36 +239,43 @@ func (m *Monitor) GetVideoModes() []*VidMode {
|
||||
v[i] = &VidMode{int(t.width), int(t.height), int(t.redBits), int(t.greenBits), int(t.blueBits), int(t.refreshRate)}
|
||||
}
|
||||
|
||||
return v
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// GetVideoMode returns the current video mode of the monitor. If you
|
||||
// are using a full screen window, the return value will therefore depend on
|
||||
// whether it is focused.
|
||||
func (m *Monitor) GetVideoMode() *VidMode {
|
||||
func (m *Monitor) GetVideoMode() (*VidMode, error) {
|
||||
t := C.glfwGetVideoMode(m.data)
|
||||
if t == nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
panicError()
|
||||
return &VidMode{int(t.width), int(t.height), int(t.redBits), int(t.greenBits), int(t.blueBits), int(t.refreshRate)}
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &VidMode{int(t.width), int(t.height), int(t.redBits), int(t.greenBits), int(t.blueBits), int(t.refreshRate)}, nil
|
||||
}
|
||||
|
||||
// SetGamma generates a 256-element gamma ramp from the specified exponent and then calls
|
||||
// SetGamma with it.
|
||||
func (m *Monitor) SetGamma(gamma float32) {
|
||||
func (m *Monitor) SetGamma(gamma float32) error {
|
||||
C.glfwSetGamma(m.data, C.float(gamma))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetGammaRamp retrieves the current gamma ramp of the monitor.
|
||||
func (m *Monitor) GetGammaRamp() *GammaRamp {
|
||||
func (m *Monitor) GetGammaRamp() (*GammaRamp, error) {
|
||||
var ramp GammaRamp
|
||||
|
||||
rampC := C.glfwGetGammaRamp(m.data)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if rampC == nil {
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
length := int(rampC.size)
|
||||
@ -270,11 +289,11 @@ func (m *Monitor) GetGammaRamp() *GammaRamp {
|
||||
ramp.Blue[i] = uint16(C.GetGammaAtIndex(rampC.blue, C.int(i)))
|
||||
}
|
||||
|
||||
return &ramp
|
||||
return &ramp, nil
|
||||
}
|
||||
|
||||
// SetGammaRamp sets the current gamma ramp for the monitor.
|
||||
func (m *Monitor) SetGammaRamp(ramp *GammaRamp) {
|
||||
func (m *Monitor) SetGammaRamp(ramp *GammaRamp) error {
|
||||
var rampC C.GLFWgammaramp
|
||||
|
||||
length := len(ramp.Red)
|
||||
@ -286,5 +305,8 @@ func (m *Monitor) SetGammaRamp(ramp *GammaRamp) {
|
||||
}
|
||||
|
||||
C.glfwSetGammaRamp(m.data, &rampC)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -302,9 +302,12 @@ func goWindowContentScaleCB(window unsafe.Pointer, x C.float, y C.float) {
|
||||
// DefaultWindowHints resets all window hints to their default values.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func DefaultWindowHints() {
|
||||
func DefaultWindowHints() error {
|
||||
C.glfwDefaultWindowHints()
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WindowHint sets hints for the next call to CreateWindow. The hints,
|
||||
@ -312,9 +315,12 @@ func DefaultWindowHints() {
|
||||
// DefaultWindowHints, or until the library is terminated with Terminate.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func WindowHint(target Hint, hint int) {
|
||||
func WindowHint(target Hint, hint int) error {
|
||||
C.glfwWindowHint(C.int(target), C.int(hint))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WindowHintString sets hints for the next call to CreateWindow. The hints,
|
||||
@ -401,39 +407,50 @@ func CreateWindow(width, height int, title string, monitor *Monitor, share *Wind
|
||||
// function, no further callbacks will be called for that window.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func (w *Window) Destroy() {
|
||||
func (w *Window) Destroy() error {
|
||||
windows.remove(w.data)
|
||||
C.glfwDestroyWindow(w.data)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ShouldClose reports the value of the close flag of the specified window.
|
||||
func (w *Window) ShouldClose() bool {
|
||||
func (w *Window) ShouldClose() (bool, error) {
|
||||
ret := C.glfwWindowShouldClose(w.data) != 0
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// SetShouldClose sets the value of the close flag of the window. This can be
|
||||
// used to override the user's attempt to close the window, or to signal that it
|
||||
// should be closed.
|
||||
func (w *Window) SetShouldClose(value bool) {
|
||||
func (w *Window) SetShouldClose(value bool) error {
|
||||
if !value {
|
||||
C.glfwSetWindowShouldClose(w.data, C.int(False))
|
||||
} else {
|
||||
C.glfwSetWindowShouldClose(w.data, C.int(True))
|
||||
}
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetTitle sets the window title, encoded as UTF-8, of the window.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func (w *Window) SetTitle(title string) {
|
||||
func (w *Window) SetTitle(title string) error {
|
||||
t := C.CString(title)
|
||||
defer C.free(unsafe.Pointer(t))
|
||||
C.glfwSetWindowTitle(w.data, t)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetIcon sets the icon of the specified window. If passed an array of candidate images,
|
||||
@ -448,7 +465,7 @@ func (w *Window) SetTitle(title string) {
|
||||
//
|
||||
// The desired image sizes varies depending on platform and system settings. The selected
|
||||
// images will be rescaled as needed. Good sizes include 16x16, 32x32 and 48x48.
|
||||
func (w *Window) SetIcon(images []image.Image) {
|
||||
func (w *Window) SetIcon(images []image.Image) error {
|
||||
count := len(images)
|
||||
cimages := make([]C.GLFWimage, count)
|
||||
freePixels := make([]func(), count)
|
||||
@ -484,16 +501,21 @@ func (w *Window) SetIcon(images []image.Image) {
|
||||
v()
|
||||
}
|
||||
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPos returns the position, in screen coordinates, of the upper-left
|
||||
// corner of the client area of the window.
|
||||
func (w *Window) GetPos() (x, y int) {
|
||||
func (w *Window) GetPos() (x, y int, err error) {
|
||||
var xpos, ypos C.int
|
||||
C.glfwGetWindowPos(w.data, &xpos, &ypos)
|
||||
panicError()
|
||||
return int(xpos), int(ypos)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return int(xpos), int(ypos), nil
|
||||
}
|
||||
|
||||
// SetPos sets the position, in screen coordinates, of the upper-left corner
|
||||
@ -510,18 +532,23 @@ func (w *Window) GetPos() (x, y int) {
|
||||
// The window manager may put limits on what positions are allowed.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func (w *Window) SetPos(xpos, ypos int) {
|
||||
func (w *Window) SetPos(xpos, ypos int) error {
|
||||
C.glfwSetWindowPos(w.data, C.int(xpos), C.int(ypos))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSize returns the size, in screen coordinates, of the client area of the
|
||||
// specified window.
|
||||
func (w *Window) GetSize() (width, height int) {
|
||||
func (w *Window) GetSize() (width, height int, err error) {
|
||||
var wi, h C.int
|
||||
C.glfwGetWindowSize(w.data, &wi, &h)
|
||||
panicError()
|
||||
return int(wi), int(h)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return int(wi), int(h), nil
|
||||
}
|
||||
|
||||
// SetSize sets the size, in screen coordinates, of the client area of the
|
||||
@ -534,18 +561,24 @@ func (w *Window) GetSize() (width, height int) {
|
||||
// The window manager may put limits on what window sizes are allowed.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func (w *Window) SetSize(width, height int) {
|
||||
func (w *Window) SetSize(width, height int) error {
|
||||
C.glfwSetWindowSize(w.data, C.int(width), C.int(height))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetSizeLimits sets the size limits of the client area of the specified window.
|
||||
// If the window is full screen or not resizable, this function does nothing.
|
||||
//
|
||||
// The size limits are applied immediately and may cause the window to be resized.
|
||||
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
||||
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) error {
|
||||
C.glfwSetWindowSizeLimits(w.data, C.int(minw), C.int(minh), C.int(maxw), C.int(maxh))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetAspectRatio sets the required aspect ratio of the client area of the specified window.
|
||||
@ -557,18 +590,23 @@ func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
||||
// If the numerator and denominator is set to glfw.DontCare then the aspect ratio limit is disabled.
|
||||
//
|
||||
// The aspect ratio is applied immediately and may cause the window to be resized.
|
||||
func (w *Window) SetAspectRatio(numer, denom int) {
|
||||
func (w *Window) SetAspectRatio(numer, denom int) error {
|
||||
C.glfwSetWindowAspectRatio(w.data, C.int(numer), C.int(denom))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetFramebufferSize retrieves the size, in pixels, of the framebuffer of the
|
||||
// specified window.
|
||||
func (w *Window) GetFramebufferSize() (width, height int) {
|
||||
func (w *Window) GetFramebufferSize() (width, height int, err error) {
|
||||
var wi, h C.int
|
||||
C.glfwGetFramebufferSize(w.data, &wi, &h)
|
||||
panicError()
|
||||
return int(wi), int(h)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return int(wi), int(h), nil
|
||||
}
|
||||
|
||||
// GetFrameSize retrieves the size, in screen coordinates, of each edge of the frame
|
||||
@ -577,11 +615,13 @@ func (w *Window) GetFramebufferSize() (width, height int) {
|
||||
//
|
||||
// Because this function retrieves the size of each window frame edge and not the offset
|
||||
// along a particular coordinate axis, the retrieved values will always be zero or positive.
|
||||
func (w *Window) GetFrameSize() (left, top, right, bottom int) {
|
||||
func (w *Window) GetFrameSize() (left, top, right, bottom int, err error) {
|
||||
var l, t, r, b C.int
|
||||
C.glfwGetWindowFrameSize(w.data, &l, &t, &r, &b)
|
||||
panicError()
|
||||
return int(l), int(t), int(r), int(b)
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, 0, 0, 0, err
|
||||
}
|
||||
return int(l), int(t), int(r), int(b), nil
|
||||
}
|
||||
|
||||
// GetContentScale function retrieves the content scale for the specified
|
||||
@ -681,31 +721,39 @@ func (w *Window) Restore() {
|
||||
// already visible or is in full screen mode, this function does nothing.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func (w *Window) Show() {
|
||||
func (w *Window) Show() error {
|
||||
C.glfwShowWindow(w.data)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Hide hides the window, if it was previously visible. If the window is already
|
||||
// hidden or is in full screen mode, this function does nothing.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func (w *Window) Hide() {
|
||||
func (w *Window) Hide() error {
|
||||
C.glfwHideWindow(w.data)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetMonitor returns the handle of the monitor that the window is in
|
||||
// fullscreen on.
|
||||
//
|
||||
// Returns nil if the window is in windowed mode.
|
||||
func (w *Window) GetMonitor() *Monitor {
|
||||
func (w *Window) GetMonitor() (*Monitor, error) {
|
||||
m := C.glfwGetWindowMonitor(w.data)
|
||||
panicError()
|
||||
if m == nil {
|
||||
return nil
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Monitor{m}
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return &Monitor{m}, nil
|
||||
}
|
||||
|
||||
// SetMonitor sets the monitor that the window uses for full screen mode or,
|
||||
@ -723,7 +771,7 @@ func (w *Window) GetMonitor() *Monitor {
|
||||
// When a window transitions from full screen to windowed mode, this function
|
||||
// restores any previous window settings such as whether it is decorated, floating,
|
||||
// resizable, has size or aspect ratio limits, etc..
|
||||
func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int) {
|
||||
func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int) error {
|
||||
var m *C.GLFWmonitor
|
||||
if monitor == nil {
|
||||
m = nil
|
||||
@ -731,15 +779,20 @@ func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refresh
|
||||
m = monitor.data
|
||||
}
|
||||
C.glfwSetWindowMonitor(w.data, m, C.int(xpos), C.int(ypos), C.int(width), C.int(height), C.int(refreshRate))
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAttrib returns an attribute of the window. There are many attributes,
|
||||
// some related to the window and others to its context.
|
||||
func (w *Window) GetAttrib(attrib Hint) int {
|
||||
func (w *Window) GetAttrib(attrib Hint) (int, error) {
|
||||
ret := int(C.glfwGetWindowAttrib(w.data, C.int(attrib)))
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// SetAttrib function sets the value of an attribute of the specified window.
|
||||
@ -759,17 +812,22 @@ func (w *Window) SetAttrib(attrib Hint, value int) {
|
||||
|
||||
// SetUserPointer sets the user-defined pointer of the window. The current value
|
||||
// is retained until the window is destroyed. The initial value is nil.
|
||||
func (w *Window) SetUserPointer(pointer unsafe.Pointer) {
|
||||
func (w *Window) SetUserPointer(pointer unsafe.Pointer) error {
|
||||
C.glfwSetWindowUserPointer(w.data, pointer)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserPointer returns the current value of the user-defined pointer of the
|
||||
// window. The initial value is nil.
|
||||
func (w *Window) GetUserPointer() unsafe.Pointer {
|
||||
func (w *Window) GetUserPointer() (unsafe.Pointer, error) {
|
||||
ret := C.glfwGetWindowUserPointer(w.data)
|
||||
panicError()
|
||||
return ret
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// PosCallback is the window position callback.
|
||||
@ -778,7 +836,7 @@ type PosCallback func(w *Window, xpos int, ypos int)
|
||||
// SetPosCallback sets the position callback of the window, which is called
|
||||
// when the window is moved. The callback is provided with the screen position
|
||||
// of the upper-left corner of the client area of the window.
|
||||
func (w *Window) SetPosCallback(cbfun PosCallback) (previous PosCallback) {
|
||||
func (w *Window) SetPosCallback(cbfun PosCallback) (previous PosCallback, err error) {
|
||||
previous = w.fPosHolder
|
||||
w.fPosHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -786,8 +844,10 @@ func (w *Window) SetPosCallback(cbfun PosCallback) (previous PosCallback) {
|
||||
} else {
|
||||
C.glfwSetWindowPosCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// SizeCallback is the window size callback.
|
||||
@ -796,7 +856,7 @@ type SizeCallback func(w *Window, width int, height int)
|
||||
// SetSizeCallback sets the size callback of the window, which is called when
|
||||
// the window is resized. The callback is provided with the size, in screen
|
||||
// coordinates, of the client area of the window.
|
||||
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback) {
|
||||
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback, err error) {
|
||||
previous = w.fSizeHolder
|
||||
w.fSizeHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -804,8 +864,10 @@ func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback) {
|
||||
} else {
|
||||
C.glfwSetWindowSizeCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// FramebufferSizeCallback is the framebuffer size callback.
|
||||
@ -813,7 +875,7 @@ type FramebufferSizeCallback func(w *Window, width int, height int)
|
||||
|
||||
// SetFramebufferSizeCallback sets the framebuffer resize callback of the specified
|
||||
// window, which is called when the framebuffer of the specified window is resized.
|
||||
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback) {
|
||||
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback, err error) {
|
||||
previous = w.fFramebufferSizeHolder
|
||||
w.fFramebufferSizeHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -821,8 +883,10 @@ func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (prev
|
||||
} else {
|
||||
C.glfwSetFramebufferSizeCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// CloseCallback is the window close callback.
|
||||
@ -837,7 +901,7 @@ type CloseCallback func(w *Window)
|
||||
//
|
||||
// Mac OS X: Selecting Quit from the application menu will trigger the close
|
||||
// callback for all windows.
|
||||
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback) {
|
||||
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback, err error) {
|
||||
previous = w.fCloseHolder
|
||||
w.fCloseHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -845,8 +909,10 @@ func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback)
|
||||
} else {
|
||||
C.glfwSetWindowCloseCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// MaximizeCallback is the function signature for window maximize callback
|
||||
@ -877,7 +943,7 @@ type ContentScaleCallback func(w *Window, x float32, y float32)
|
||||
// window changes.
|
||||
//
|
||||
// This function must only be called from the main thread.
|
||||
func (w *Window) SetContentScaleCallback(cbfun ContentScaleCallback) ContentScaleCallback {
|
||||
func (w *Window) SetContentScaleCallback(cbfun ContentScaleCallback) (ContentScaleCallback, error) {
|
||||
previous := w.fContentScaleHolder
|
||||
w.fContentScaleHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -885,7 +951,10 @@ func (w *Window) SetContentScaleCallback(cbfun ContentScaleCallback) ContentScal
|
||||
} else {
|
||||
C.glfwSetWindowContentScaleCallbackCB(w.data)
|
||||
}
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// RefreshCallback is the window refresh callback.
|
||||
@ -898,7 +967,7 @@ type RefreshCallback func(w *Window)
|
||||
// On compositing window systems such as Aero, Compiz or Aqua, where the window
|
||||
// contents are saved off-screen, this callback may be called only very
|
||||
// infrequently or never at all.
|
||||
func (w *Window) SetRefreshCallback(cbfun RefreshCallback) (previous RefreshCallback) {
|
||||
func (w *Window) SetRefreshCallback(cbfun RefreshCallback) (previous RefreshCallback, err error) {
|
||||
previous = w.fRefreshHolder
|
||||
w.fRefreshHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -906,8 +975,10 @@ func (w *Window) SetRefreshCallback(cbfun RefreshCallback) (previous RefreshCall
|
||||
} else {
|
||||
C.glfwSetWindowRefreshCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// FocusCallback is the window focus callback.
|
||||
@ -919,7 +990,7 @@ type FocusCallback func(w *Window, focused bool)
|
||||
// After the focus callback is called for a window that lost focus, synthetic key
|
||||
// and mouse button release events will be generated for all such that had been
|
||||
// pressed. For more information, see SetKeyCallback and SetMouseButtonCallback.
|
||||
func (w *Window) SetFocusCallback(cbfun FocusCallback) (previous FocusCallback) {
|
||||
func (w *Window) SetFocusCallback(cbfun FocusCallback) (previous FocusCallback, err error) {
|
||||
previous = w.fFocusHolder
|
||||
w.fFocusHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -927,8 +998,10 @@ func (w *Window) SetFocusCallback(cbfun FocusCallback) (previous FocusCallback)
|
||||
} else {
|
||||
C.glfwSetWindowFocusCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// IconifyCallback is the window iconification callback.
|
||||
@ -936,7 +1009,7 @@ type IconifyCallback func(w *Window, iconified bool)
|
||||
|
||||
// SetIconifyCallback sets the iconification callback of the window, which is
|
||||
// called when the window is iconified or restored.
|
||||
func (w *Window) SetIconifyCallback(cbfun IconifyCallback) (previous IconifyCallback) {
|
||||
func (w *Window) SetIconifyCallback(cbfun IconifyCallback) (previous IconifyCallback, err error) {
|
||||
previous = w.fIconifyHolder
|
||||
w.fIconifyHolder = cbfun
|
||||
if cbfun == nil {
|
||||
@ -944,8 +1017,10 @@ func (w *Window) SetIconifyCallback(cbfun IconifyCallback) (previous IconifyCall
|
||||
} else {
|
||||
C.glfwSetWindowIconifyCallbackCB(w.data)
|
||||
}
|
||||
panicError()
|
||||
return previous
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return previous, nil
|
||||
}
|
||||
|
||||
// SetClipboardString sets the system clipboard to the specified UTF-8 encoded
|
||||
@ -955,11 +1030,14 @@ func (w *Window) SetIconifyCallback(cbfun IconifyCallback) (previous IconifyCall
|
||||
// glfw.SetClipboardString(string)
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func (w *Window) SetClipboardString(str string) {
|
||||
func (w *Window) SetClipboardString(str string) error {
|
||||
cp := C.CString(str)
|
||||
defer C.free(unsafe.Pointer(cp))
|
||||
C.glfwSetClipboardString(w.data, cp)
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetClipboardString returns the contents of the system clipboard, if it
|
||||
@ -978,21 +1056,6 @@ func (w *Window) GetClipboardString() string {
|
||||
return C.GoString(cs)
|
||||
}
|
||||
|
||||
// panicErrorExceptForInvalidValue is the same as panicError but ignores
|
||||
// invalidValue.
|
||||
func panicErrorExceptForInvalidValue() {
|
||||
// invalidValue can happen when specific joysticks are used. This issue
|
||||
// will be fixed in GLFW 3.3.5. As a temporary fix, ignore this error.
|
||||
// See go-gl/glfw#292, go-gl/glfw#324, and glfw/glfw#1763.
|
||||
err := acceptError(invalidValue)
|
||||
if e, ok := err.(*Error); ok && e.Code == invalidValue {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// PollEvents processes only those events that have already been received and
|
||||
// then returns immediately. Processing events will cause the window and input
|
||||
// callbacks associated with those events to be called.
|
||||
@ -1002,9 +1065,12 @@ func panicErrorExceptForInvalidValue() {
|
||||
// This function may not be called from a callback.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func PollEvents() {
|
||||
func PollEvents() error {
|
||||
C.glfwPollEvents()
|
||||
panicErrorExceptForInvalidValue()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WaitEvents puts the calling thread to sleep until at least one event has been
|
||||
@ -1020,9 +1086,12 @@ func PollEvents() {
|
||||
// This function may not be called from a callback.
|
||||
//
|
||||
// This function may only be called from the main thread.
|
||||
func WaitEvents() {
|
||||
func WaitEvents() error {
|
||||
C.glfwWaitEvents()
|
||||
panicErrorExceptForInvalidValue()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WaitEventsTimeout puts the calling thread to sleep until at least one event is available in the
|
||||
@ -1047,9 +1116,12 @@ func WaitEvents() {
|
||||
// applications that do not create windows, use native Go primitives.
|
||||
//
|
||||
// Event processing is not required for joystick input to work.
|
||||
func WaitEventsTimeout(timeout float64) {
|
||||
func WaitEventsTimeout(timeout float64) error {
|
||||
C.glfwWaitEventsTimeout(C.double(timeout))
|
||||
panicErrorExceptForInvalidValue()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PostEmptyEvent posts an empty event from the current thread to the main
|
||||
@ -1059,7 +1131,10 @@ func WaitEventsTimeout(timeout float64) {
|
||||
// applications that do not create windows, use native Go primitives.
|
||||
//
|
||||
// This function may be called from secondary threads.
|
||||
func PostEmptyEvent() {
|
||||
func PostEmptyEvent() error {
|
||||
C.glfwPostEmptyEvent()
|
||||
panicError()
|
||||
if err := fetchErrorIgnoringPlatformError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -62,7 +62,10 @@ type Cursor struct {
|
||||
}
|
||||
|
||||
func CreateStandardCursor(shape StandardCursor) (*Cursor, error) {
|
||||
c := cglfw.CreateStandardCursor(cglfw.StandardCursor(shape))
|
||||
c, err := cglfw.CreateStandardCursor(cglfw.StandardCursor(shape))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Cursor{c: c}, nil
|
||||
}
|
||||
|
||||
@ -76,12 +79,14 @@ func (m *Monitor) GetContentScale() (float32, float32, error) {
|
||||
}
|
||||
|
||||
func (m *Monitor) GetPos() (x, y int, err error) {
|
||||
x, y = m.m.GetPos()
|
||||
return
|
||||
return m.m.GetPos()
|
||||
}
|
||||
|
||||
func (m *Monitor) GetVideoMode() (*VidMode, error) {
|
||||
v := m.m.GetVideoMode()
|
||||
v, err := m.m.GetVideoMode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if v == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@ -96,18 +101,19 @@ func (m *Monitor) GetVideoMode() (*VidMode, error) {
|
||||
}
|
||||
|
||||
func (m *Monitor) GetName() (string, error) {
|
||||
return m.m.GetName(), nil
|
||||
return m.m.GetName()
|
||||
}
|
||||
|
||||
type Window struct {
|
||||
w *cglfw.Window
|
||||
|
||||
prevSizeCallback SizeCallback
|
||||
}
|
||||
|
||||
func (w *Window) Destroy() {
|
||||
w.w.Destroy()
|
||||
func (w *Window) Destroy() error {
|
||||
if err := w.w.Destroy(); err != nil {
|
||||
return err
|
||||
}
|
||||
theWindows.remove(w.w)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Window) Focus() error {
|
||||
@ -116,24 +122,30 @@ func (w *Window) Focus() error {
|
||||
}
|
||||
|
||||
func (w *Window) GetAttrib(attrib Hint) (int, error) {
|
||||
return w.w.GetAttrib(cglfw.Hint(attrib)), nil
|
||||
return w.w.GetAttrib(cglfw.Hint(attrib))
|
||||
}
|
||||
|
||||
func (w *Window) GetCursorPos() (x, y float64, err error) {
|
||||
x, y = w.w.GetCursorPos()
|
||||
return
|
||||
return w.w.GetCursorPos()
|
||||
}
|
||||
|
||||
func (w *Window) GetInputMode(mode InputMode) (int, error) {
|
||||
return w.w.GetInputMode(cglfw.InputMode(mode)), nil
|
||||
return w.w.GetInputMode(cglfw.InputMode(mode))
|
||||
}
|
||||
|
||||
func (w *Window) GetKey(key Key) (Action, error) {
|
||||
return Action(w.w.GetKey(cglfw.Key(key))), nil
|
||||
a, err := w.w.GetKey(cglfw.Key(key))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return Action(a), nil
|
||||
}
|
||||
|
||||
func (w *Window) GetMonitor() (*Monitor, error) {
|
||||
m := w.w.GetMonitor()
|
||||
m, err := w.w.GetMonitor()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@ -141,21 +153,23 @@ func (w *Window) GetMonitor() (*Monitor, error) {
|
||||
}
|
||||
|
||||
func (w *Window) GetMouseButton(button MouseButton) (Action, error) {
|
||||
return Action(w.w.GetMouseButton(cglfw.MouseButton(button))), nil
|
||||
a, err := w.w.GetMouseButton(cglfw.MouseButton(button))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return Action(a), nil
|
||||
}
|
||||
|
||||
func (w *Window) GetPos() (x, y int, err error) {
|
||||
x, y = w.w.GetPos()
|
||||
return
|
||||
return w.w.GetPos()
|
||||
}
|
||||
|
||||
func (w *Window) GetSize() (width, height int, err error) {
|
||||
width, height = w.w.GetSize()
|
||||
return
|
||||
return w.w.GetSize()
|
||||
}
|
||||
|
||||
func (w *Window) Hide() {
|
||||
w.w.Hide()
|
||||
func (w *Window) Hide() error {
|
||||
return w.w.Hide()
|
||||
}
|
||||
|
||||
func (w *Window) Iconify() error {
|
||||
@ -164,8 +178,7 @@ func (w *Window) Iconify() error {
|
||||
}
|
||||
|
||||
func (w *Window) MakeContextCurrent() error {
|
||||
w.w.MakeContextCurrent()
|
||||
return nil
|
||||
return w.w.MakeContextCurrent()
|
||||
}
|
||||
|
||||
func (w *Window) Maximize() error {
|
||||
@ -184,13 +197,11 @@ func (w *Window) SetAttrib(attrib Hint, value int) error {
|
||||
}
|
||||
|
||||
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback, err error) {
|
||||
w.w.SetCharModsCallback(cbfun)
|
||||
return ToCharModsCallback(nil), nil // TODO
|
||||
return w.w.SetCharModsCallback(cbfun)
|
||||
}
|
||||
|
||||
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback, err error) {
|
||||
w.w.SetCloseCallback(cbfun)
|
||||
return ToCloseCallback(nil), nil // TODO
|
||||
return w.w.SetCloseCallback(cbfun)
|
||||
}
|
||||
|
||||
func (w *Window) SetCursor(cursor *Cursor) error {
|
||||
@ -198,55 +209,43 @@ func (w *Window) SetCursor(cursor *Cursor) error {
|
||||
if cursor != nil {
|
||||
c = cursor.c
|
||||
}
|
||||
w.w.SetCursor(c)
|
||||
return nil
|
||||
return w.w.SetCursor(c)
|
||||
}
|
||||
|
||||
func (w *Window) SetCursorPos(xpos, ypos float64) error {
|
||||
w.w.SetCursorPos(xpos, ypos)
|
||||
return nil
|
||||
return w.w.SetCursorPos(xpos, ypos)
|
||||
}
|
||||
|
||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback, err error) {
|
||||
w.w.SetDropCallback(cbfun)
|
||||
return ToDropCallback(nil), nil // TODO
|
||||
return w.w.SetDropCallback(cbfun)
|
||||
}
|
||||
|
||||
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback, err error) {
|
||||
w.w.SetFramebufferSizeCallback(cbfun)
|
||||
return ToFramebufferSizeCallback(nil), nil // TODO
|
||||
return w.w.SetFramebufferSizeCallback(cbfun)
|
||||
}
|
||||
|
||||
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback, err error) {
|
||||
w.w.SetScrollCallback(cbfun)
|
||||
return ToScrollCallback(nil), nil // TODO
|
||||
return w.w.SetScrollCallback(cbfun)
|
||||
}
|
||||
|
||||
func (w *Window) SetShouldClose(value bool) error {
|
||||
w.w.SetShouldClose(value)
|
||||
return nil
|
||||
return w.w.SetShouldClose(value)
|
||||
}
|
||||
|
||||
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback, err error) {
|
||||
w.w.SetSizeCallback(cbfun)
|
||||
prev := w.prevSizeCallback
|
||||
w.prevSizeCallback = cbfun
|
||||
return prev, nil
|
||||
return w.w.SetSizeCallback(cbfun)
|
||||
}
|
||||
|
||||
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) error {
|
||||
w.w.SetSizeLimits(minw, minh, maxw, maxh)
|
||||
return nil
|
||||
return w.w.SetSizeLimits(minw, minh, maxw, maxh)
|
||||
}
|
||||
|
||||
func (w *Window) SetIcon(images []image.Image) error {
|
||||
w.w.SetIcon(images)
|
||||
return nil
|
||||
return w.w.SetIcon(images)
|
||||
}
|
||||
|
||||
func (w *Window) SetInputMode(mode InputMode, value int) error {
|
||||
w.w.SetInputMode(cglfw.InputMode(mode), value)
|
||||
return nil
|
||||
return w.w.SetInputMode(cglfw.InputMode(mode), value)
|
||||
}
|
||||
|
||||
func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int) error {
|
||||
@ -254,37 +253,34 @@ func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refresh
|
||||
if monitor != nil {
|
||||
m = monitor.m
|
||||
}
|
||||
w.w.SetMonitor(m, xpos, ypos, width, height, refreshRate)
|
||||
if err := w.w.SetMonitor(m, xpos, ypos, width, height, refreshRate); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Window) SetPos(xpos, ypos int) error {
|
||||
w.w.SetPos(xpos, ypos)
|
||||
return nil
|
||||
return w.w.SetPos(xpos, ypos)
|
||||
}
|
||||
|
||||
func (w *Window) SetSize(width, height int) error {
|
||||
w.w.SetSize(width, height)
|
||||
return nil
|
||||
return w.w.SetSize(width, height)
|
||||
}
|
||||
|
||||
func (w *Window) SetTitle(title string) error {
|
||||
w.w.SetTitle(title)
|
||||
return nil
|
||||
return w.w.SetTitle(title)
|
||||
}
|
||||
|
||||
func (w *Window) ShouldClose() (bool, error) {
|
||||
return w.w.ShouldClose(), nil
|
||||
return w.w.ShouldClose()
|
||||
}
|
||||
|
||||
func (w *Window) Show() error {
|
||||
w.w.Show()
|
||||
return nil
|
||||
return w.w.Show()
|
||||
}
|
||||
|
||||
func (w *Window) SwapBuffers() error {
|
||||
w.w.SwapBuffers()
|
||||
return nil
|
||||
return w.w.SwapBuffers()
|
||||
}
|
||||
|
||||
func CreateWindow(width, height int, title string, monitor *Monitor, share *Window) (*Window, error) {
|
||||
@ -305,12 +301,16 @@ func CreateWindow(width, height int, title string, monitor *Monitor, share *Wind
|
||||
}
|
||||
|
||||
func GetKeyName(key Key, scancode int) (string, error) {
|
||||
return cglfw.GetKeyName(cglfw.Key(key), scancode), nil
|
||||
return cglfw.GetKeyName(cglfw.Key(key), scancode)
|
||||
}
|
||||
|
||||
func GetMonitors() ([]*Monitor, error) {
|
||||
monitors, err := cglfw.GetMonitors()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ms []*Monitor
|
||||
for _, m := range cglfw.GetMonitors() {
|
||||
for _, m := range monitors {
|
||||
if m != nil {
|
||||
ms = append(ms, &Monitor{m})
|
||||
} else {
|
||||
@ -320,12 +320,15 @@ func GetMonitors() ([]*Monitor, error) {
|
||||
return ms, nil
|
||||
}
|
||||
|
||||
func GetPrimaryMonitor() *Monitor {
|
||||
m := cglfw.GetPrimaryMonitor()
|
||||
if m == nil {
|
||||
return nil
|
||||
func GetPrimaryMonitor() (*Monitor, error) {
|
||||
m, err := cglfw.GetPrimaryMonitor()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Monitor{m}
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return &Monitor{m}, nil
|
||||
}
|
||||
|
||||
func Init() error {
|
||||
@ -333,13 +336,11 @@ func Init() error {
|
||||
}
|
||||
|
||||
func PollEvents() error {
|
||||
cglfw.PollEvents()
|
||||
return nil
|
||||
return cglfw.PollEvents()
|
||||
}
|
||||
|
||||
func PostEmptyEvent() error {
|
||||
cglfw.PostEmptyEvent()
|
||||
return nil
|
||||
return cglfw.PostEmptyEvent()
|
||||
}
|
||||
|
||||
func SetMonitorCallback(cbfun MonitorCallback) (MonitorCallback, error) {
|
||||
@ -348,8 +349,7 @@ func SetMonitorCallback(cbfun MonitorCallback) (MonitorCallback, error) {
|
||||
}
|
||||
|
||||
func SwapInterval(interval int) error {
|
||||
cglfw.SwapInterval(interval)
|
||||
return nil
|
||||
return cglfw.SwapInterval(interval)
|
||||
}
|
||||
|
||||
func Terminate() error {
|
||||
@ -358,15 +358,13 @@ func Terminate() error {
|
||||
}
|
||||
|
||||
func WaitEvents() error {
|
||||
cglfw.WaitEvents()
|
||||
return nil
|
||||
return cglfw.WaitEvents()
|
||||
}
|
||||
|
||||
func WaitEventsTimeout(timeout float64) {
|
||||
cglfw.WaitEventsTimeout(timeout)
|
||||
func WaitEventsTimeout(timeout float64) error {
|
||||
return cglfw.WaitEventsTimeout(timeout)
|
||||
}
|
||||
|
||||
func WindowHint(target Hint, hint int) error {
|
||||
cglfw.WindowHint(cglfw.Hint(target), hint)
|
||||
return nil
|
||||
return cglfw.WindowHint(cglfw.Hint(target), hint)
|
||||
}
|
||||
|
@ -322,7 +322,9 @@ func (u *userInterfaceImpl) isNativeFullscreenAvailable() bool {
|
||||
|
||||
func (u *userInterfaceImpl) setNativeFullscreen(fullscreen bool) error {
|
||||
// Toggling fullscreen might ignore events like keyUp. Ensure that events are fired.
|
||||
glfw.WaitEventsTimeout(0.1)
|
||||
if err := glfw.WaitEventsTimeout(0.1); err != nil {
|
||||
return err
|
||||
}
|
||||
w, err := u.window.GetCocoaWindow()
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user