mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/glfw: merge internal/goglfw into internal/glfw
This also changes APIs in internal/glfw to return errors. Updates #2703
This commit is contained in:
parent
370e506dc9
commit
e7ad5c52fe
2
.github/workflows/govetblock_windows.txt
vendored
2
.github/workflows/govetblock_windows.txt
vendored
@ -1,2 +1,2 @@
|
|||||||
|
github.com/hajimehoshi/ebiten/v2/internal/glfw
|
||||||
github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/directx
|
github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/directx
|
||||||
github.com/hajimehoshi/ebiten/v2/internal/goglfw
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -839,7 +839,7 @@ func _AdjustWindowRectEx(lpRect *_RECT, dwStyle uint32, menu bool, dwExStyle uin
|
|||||||
}
|
}
|
||||||
r, _, e := procAdjustWindowRectEx.Call(uintptr(unsafe.Pointer(lpRect)), uintptr(dwStyle), bMenu, uintptr(dwExStyle))
|
r, _, e := procAdjustWindowRectEx.Call(uintptr(unsafe.Pointer(lpRect)), uintptr(dwStyle), bMenu, uintptr(dwExStyle))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: AdjustWindowRectEx failed: %w", e)
|
return fmt.Errorf("glfw: AdjustWindowRectEx failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -851,7 +851,7 @@ func _AdjustWindowRectExForDpi(lpRect *_RECT, dwStyle uint32, menu bool, dwExSty
|
|||||||
}
|
}
|
||||||
r, _, e := procAdjustWindowRectExForDpi.Call(uintptr(unsafe.Pointer(lpRect)), uintptr(dwStyle), bMenu, uintptr(dwExStyle), uintptr(dpi))
|
r, _, e := procAdjustWindowRectExForDpi.Call(uintptr(unsafe.Pointer(lpRect)), uintptr(dwStyle), bMenu, uintptr(dwExStyle), uintptr(dpi))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: AdjustWindowRectExForDpi failed: %w", e)
|
return fmt.Errorf("glfw: AdjustWindowRectExForDpi failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -859,7 +859,7 @@ func _AdjustWindowRectExForDpi(lpRect *_RECT, dwStyle uint32, menu bool, dwExSty
|
|||||||
func _BringWindowToTop(hWnd windows.HWND) error {
|
func _BringWindowToTop(hWnd windows.HWND) error {
|
||||||
r, _, e := procBringWindowToTop.Call(uintptr(hWnd))
|
r, _, e := procBringWindowToTop.Call(uintptr(hWnd))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: BringWindowToTop failed: %w", e)
|
return fmt.Errorf("glfw: BringWindowToTop failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -870,7 +870,7 @@ func _ChangeDisplaySettingsExW(deviceName string, lpDevMode *_DEVMODEW, hwnd win
|
|||||||
var err error
|
var err error
|
||||||
lpszDeviceName, err = windows.UTF16PtrFromString(deviceName)
|
lpszDeviceName, err = windows.UTF16PtrFromString(deviceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: device name must not include a NUL character")
|
panic("glfw: device name must not include a NUL character")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,7 +884,7 @@ func _ChangeDisplaySettingsExW(deviceName string, lpDevMode *_DEVMODEW, hwnd win
|
|||||||
func _ChangeWindowMessageFilterEx(hwnd windows.HWND, message uint32, action uint32, pChangeFilterStruct *_CHANGEFILTERSTRUCT) error {
|
func _ChangeWindowMessageFilterEx(hwnd windows.HWND, message uint32, action uint32, pChangeFilterStruct *_CHANGEFILTERSTRUCT) error {
|
||||||
r, _, e := procChangeWindowMessageFilterEx.Call(uintptr(hwnd), uintptr(message), uintptr(action), uintptr(unsafe.Pointer(pChangeFilterStruct)))
|
r, _, e := procChangeWindowMessageFilterEx.Call(uintptr(hwnd), uintptr(message), uintptr(action), uintptr(unsafe.Pointer(pChangeFilterStruct)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: ChangeWindowMessageFilterEx failed: %w", e)
|
return fmt.Errorf("glfw: ChangeWindowMessageFilterEx failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ func _ChangeWindowMessageFilterEx(hwnd windows.HWND, message uint32, action uint
|
|||||||
func _ChoosePixelFormat(hdc _HDC, ppfd *_PIXELFORMATDESCRIPTOR) (int32, error) {
|
func _ChoosePixelFormat(hdc _HDC, ppfd *_PIXELFORMATDESCRIPTOR) (int32, error) {
|
||||||
r, _, e := procChoosePixelFormat.Call(uintptr(hdc), uintptr(unsafe.Pointer(ppfd)))
|
r, _, e := procChoosePixelFormat.Call(uintptr(hdc), uintptr(unsafe.Pointer(ppfd)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, fmt.Errorf("goglfw: ChoosePixelFormat failed: %w", e)
|
return 0, fmt.Errorf("glfw: ChoosePixelFormat failed: %w", e)
|
||||||
}
|
}
|
||||||
return int32(r), nil
|
return int32(r), nil
|
||||||
}
|
}
|
||||||
@ -900,7 +900,7 @@ func _ChoosePixelFormat(hdc _HDC, ppfd *_PIXELFORMATDESCRIPTOR) (int32, error) {
|
|||||||
func _ClientToScreen(hWnd windows.HWND, lpPoint *_POINT) error {
|
func _ClientToScreen(hWnd windows.HWND, lpPoint *_POINT) error {
|
||||||
r, _, e := procClientToScreen.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpPoint)))
|
r, _, e := procClientToScreen.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpPoint)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: ClientToScreen failed: %w", e)
|
return fmt.Errorf("glfw: ClientToScreen failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -908,7 +908,7 @@ func _ClientToScreen(hWnd windows.HWND, lpPoint *_POINT) error {
|
|||||||
func _ClipCursor(lpRect *_RECT) error {
|
func _ClipCursor(lpRect *_RECT) error {
|
||||||
r, _, e := procClipCursor.Call(uintptr(unsafe.Pointer(lpRect)))
|
r, _, e := procClipCursor.Call(uintptr(unsafe.Pointer(lpRect)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: ClipCursor failed: %w", e)
|
return fmt.Errorf("glfw: ClipCursor failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -916,7 +916,7 @@ func _ClipCursor(lpRect *_RECT) error {
|
|||||||
func _CreateBitmap(nWidth int32, nHeight int32, nPlanes uint32, nBitCount uint32, lpBits unsafe.Pointer) (_HBITMAP, error) {
|
func _CreateBitmap(nWidth int32, nHeight int32, nPlanes uint32, nBitCount uint32, lpBits unsafe.Pointer) (_HBITMAP, error) {
|
||||||
r, _, e := procCreateBitmap.Call(uintptr(nWidth), uintptr(nHeight), uintptr(nPlanes), uintptr(nBitCount), uintptr(lpBits))
|
r, _, e := procCreateBitmap.Call(uintptr(nWidth), uintptr(nHeight), uintptr(nPlanes), uintptr(nBitCount), uintptr(lpBits))
|
||||||
if _HBITMAP(r) == 0 {
|
if _HBITMAP(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: CreateBitmap failed: %w", e)
|
return 0, fmt.Errorf("glfw: CreateBitmap failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HBITMAP(r), nil
|
return _HBITMAP(r), nil
|
||||||
}
|
}
|
||||||
@ -926,7 +926,7 @@ func _CreateDIBSection(hdc _HDC, pbmi *_BITMAPV5HEADER, usage uint32, hSection w
|
|||||||
var bits *byte
|
var bits *byte
|
||||||
r, _, e := procCreateDIBSection.Call(uintptr(hdc), uintptr(unsafe.Pointer(pbmi)), uintptr(usage), uintptr(unsafe.Pointer(&bits)), uintptr(hSection), uintptr(offset))
|
r, _, e := procCreateDIBSection.Call(uintptr(hdc), uintptr(unsafe.Pointer(pbmi)), uintptr(usage), uintptr(unsafe.Pointer(&bits)), uintptr(hSection), uintptr(offset))
|
||||||
if _HBITMAP(r) == 0 {
|
if _HBITMAP(r) == 0 {
|
||||||
return 0, nil, fmt.Errorf("goglfw: CreateDIBSection failed: %w", e)
|
return 0, nil, fmt.Errorf("glfw: CreateDIBSection failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HBITMAP(r), bits, nil
|
return _HBITMAP(r), bits, nil
|
||||||
}
|
}
|
||||||
@ -934,7 +934,7 @@ func _CreateDIBSection(hdc _HDC, pbmi *_BITMAPV5HEADER, usage uint32, hSection w
|
|||||||
func _CreateRectRgn(x1, y1, x2, y2 int32) (_HRGN, error) {
|
func _CreateRectRgn(x1, y1, x2, y2 int32) (_HRGN, error) {
|
||||||
r, _, e := procCreateRectRgn.Call(uintptr(x1), uintptr(y1), uintptr(x2), uintptr(y2))
|
r, _, e := procCreateRectRgn.Call(uintptr(x1), uintptr(y1), uintptr(x2), uintptr(y2))
|
||||||
if _HRGN(r) == 0 {
|
if _HRGN(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: CreateRectRgn failed: %w", e)
|
return 0, fmt.Errorf("glfw: CreateRectRgn failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HRGN(r), nil
|
return _HRGN(r), nil
|
||||||
}
|
}
|
||||||
@ -942,7 +942,7 @@ func _CreateRectRgn(x1, y1, x2, y2 int32) (_HRGN, error) {
|
|||||||
func _CreateIconIndirect(piconinfo *_ICONINFO) (_HICON, error) {
|
func _CreateIconIndirect(piconinfo *_ICONINFO) (_HICON, error) {
|
||||||
r, _, e := procCreateIconIndirect.Call(uintptr(unsafe.Pointer(piconinfo)))
|
r, _, e := procCreateIconIndirect.Call(uintptr(unsafe.Pointer(piconinfo)))
|
||||||
if _HICON(r) == 0 {
|
if _HICON(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: CreateIconIndirect failed: %w", e)
|
return 0, fmt.Errorf("glfw: CreateIconIndirect failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HICON(r), nil
|
return _HICON(r), nil
|
||||||
}
|
}
|
||||||
@ -953,7 +953,7 @@ func _CreateWindowExW(dwExStyle uint32, className string, windowName string, dwS
|
|||||||
var err error
|
var err error
|
||||||
lpClassName, err = windows.UTF16PtrFromString(className)
|
lpClassName, err = windows.UTF16PtrFromString(className)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: class name msut not include a NUL character")
|
panic("glfw: class name msut not include a NUL character")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,7 +962,7 @@ func _CreateWindowExW(dwExStyle uint32, className string, windowName string, dwS
|
|||||||
var err error
|
var err error
|
||||||
lpWindowName, err = windows.UTF16PtrFromString(windowName)
|
lpWindowName, err = windows.UTF16PtrFromString(windowName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: window name msut not include a NUL character")
|
panic("glfw: window name msut not include a NUL character")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,7 +974,7 @@ func _CreateWindowExW(dwExStyle uint32, className string, windowName string, dwS
|
|||||||
runtime.KeepAlive(lpWindowName)
|
runtime.KeepAlive(lpWindowName)
|
||||||
|
|
||||||
if windows.HWND(r) == 0 {
|
if windows.HWND(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: CreateWindowExW failed: %w", e)
|
return 0, fmt.Errorf("glfw: CreateWindowExW failed: %w", e)
|
||||||
}
|
}
|
||||||
return windows.HWND(r), nil
|
return windows.HWND(r), nil
|
||||||
}
|
}
|
||||||
@ -987,7 +987,7 @@ func _DefWindowProcW(hWnd windows.HWND, uMsg uint32, wParam _WPARAM, lParam _LPA
|
|||||||
func _DestroyIcon(hIcon _HICON) error {
|
func _DestroyIcon(hIcon _HICON) error {
|
||||||
r, _, e := procDestroyIcon.Call(uintptr(hIcon))
|
r, _, e := procDestroyIcon.Call(uintptr(hIcon))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: DestroyIcon failed: %w", e)
|
return fmt.Errorf("glfw: DestroyIcon failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -995,7 +995,7 @@ func _DestroyIcon(hIcon _HICON) error {
|
|||||||
func _DestroyWindow(hWnd windows.HWND) error {
|
func _DestroyWindow(hWnd windows.HWND) error {
|
||||||
r, _, e := procDestroyWindow.Call(uintptr(hWnd))
|
r, _, e := procDestroyWindow.Call(uintptr(hWnd))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: DestroyWindow failed: %w", e)
|
return fmt.Errorf("glfw: DestroyWindow failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1003,7 +1003,7 @@ func _DestroyWindow(hWnd windows.HWND) error {
|
|||||||
func _DeleteObject(ho _HGDIOBJ) error {
|
func _DeleteObject(ho _HGDIOBJ) error {
|
||||||
r, _, e := procDeleteObject.Call(uintptr(ho))
|
r, _, e := procDeleteObject.Call(uintptr(ho))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: DeleteObject failed: %w", e)
|
return fmt.Errorf("glfw: DeleteObject failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1011,7 +1011,7 @@ func _DeleteObject(ho _HGDIOBJ) error {
|
|||||||
func _DescribePixelFormat(hdc _HDC, iPixelFormat int32, nBytes uint32, ppfd *_PIXELFORMATDESCRIPTOR) (int32, error) {
|
func _DescribePixelFormat(hdc _HDC, iPixelFormat int32, nBytes uint32, ppfd *_PIXELFORMATDESCRIPTOR) (int32, error) {
|
||||||
r, _, e := procDescribePixelFormat.Call(uintptr(hdc), uintptr(iPixelFormat), uintptr(nBytes), uintptr(unsafe.Pointer(ppfd)))
|
r, _, e := procDescribePixelFormat.Call(uintptr(hdc), uintptr(iPixelFormat), uintptr(nBytes), uintptr(unsafe.Pointer(ppfd)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, fmt.Errorf("goglfw: DescribePixelFormat failed: %w", e)
|
return 0, fmt.Errorf("glfw: DescribePixelFormat failed: %w", e)
|
||||||
}
|
}
|
||||||
return int32(r), nil
|
return int32(r), nil
|
||||||
}
|
}
|
||||||
@ -1054,7 +1054,7 @@ func _DragQueryPoint(hDrop _HDROP) (_POINT, bool) {
|
|||||||
func _DwmEnableBlurBehindWindow(hWnd windows.HWND, pBlurBehind *_DWM_BLURBEHIND) error {
|
func _DwmEnableBlurBehindWindow(hWnd windows.HWND, pBlurBehind *_DWM_BLURBEHIND) error {
|
||||||
r, _, _ := procDwmEnableBlurBehindWindow.Call(uintptr(hWnd), uintptr(unsafe.Pointer(pBlurBehind)))
|
r, _, _ := procDwmEnableBlurBehindWindow.Call(uintptr(hWnd), uintptr(unsafe.Pointer(pBlurBehind)))
|
||||||
if uint32(r) != uint32(windows.S_OK) {
|
if uint32(r) != uint32(windows.S_OK) {
|
||||||
return fmt.Errorf("goglfw: DwmEnableBlurBehindWindow failed: %w", handleError(windows.Handle(uint32(r))))
|
return fmt.Errorf("glfw: DwmEnableBlurBehindWindow failed: %w", handleError(windows.Handle(uint32(r))))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1064,7 +1064,7 @@ func _DwmGetColorizationColor() (uint32, bool, error) {
|
|||||||
var opaqueBlend int32
|
var opaqueBlend int32
|
||||||
r, _, _ := procDwmGetColorizationColor.Call(uintptr(unsafe.Pointer(&colorization)), uintptr(unsafe.Pointer(&opaqueBlend)))
|
r, _, _ := procDwmGetColorizationColor.Call(uintptr(unsafe.Pointer(&colorization)), uintptr(unsafe.Pointer(&opaqueBlend)))
|
||||||
if uint32(r) != uint32(windows.S_OK) {
|
if uint32(r) != uint32(windows.S_OK) {
|
||||||
return 0, false, fmt.Errorf("goglfw: DwmGetColorizationColor failed: %w", handleError(windows.Handle(uint32(r))))
|
return 0, false, fmt.Errorf("glfw: DwmGetColorizationColor failed: %w", handleError(windows.Handle(uint32(r))))
|
||||||
}
|
}
|
||||||
return colorization, opaqueBlend != 0, nil
|
return colorization, opaqueBlend != 0, nil
|
||||||
}
|
}
|
||||||
@ -1072,7 +1072,7 @@ func _DwmGetColorizationColor() (uint32, bool, error) {
|
|||||||
func _DwmFlush() error {
|
func _DwmFlush() error {
|
||||||
r, _, _ := procDwmFlush.Call()
|
r, _, _ := procDwmFlush.Call()
|
||||||
if uint32(r) != uint32(windows.S_OK) {
|
if uint32(r) != uint32(windows.S_OK) {
|
||||||
return fmt.Errorf("goglfw: DwmFlush failed: %w", handleError(windows.Handle(uint32(r))))
|
return fmt.Errorf("glfw: DwmFlush failed: %w", handleError(windows.Handle(uint32(r))))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1081,7 +1081,7 @@ func _DwmIsCompositionEnabled() (bool, error) {
|
|||||||
var enabled int32
|
var enabled int32
|
||||||
r, _, _ := procDwmIsCompositionEnabled.Call(uintptr(unsafe.Pointer(&enabled)))
|
r, _, _ := procDwmIsCompositionEnabled.Call(uintptr(unsafe.Pointer(&enabled)))
|
||||||
if uint32(r) != uint32(windows.S_OK) {
|
if uint32(r) != uint32(windows.S_OK) {
|
||||||
return false, fmt.Errorf("goglfw: DwmIsCompositionEnabled failed: %w", handleError(windows.Handle(uint32(r))))
|
return false, fmt.Errorf("glfw: DwmIsCompositionEnabled failed: %w", handleError(windows.Handle(uint32(r))))
|
||||||
}
|
}
|
||||||
return enabled != 0, nil
|
return enabled != 0, nil
|
||||||
}
|
}
|
||||||
@ -1089,7 +1089,7 @@ func _DwmIsCompositionEnabled() (bool, error) {
|
|||||||
func _EnableNonClientDpiScaling(hwnd windows.HWND) error {
|
func _EnableNonClientDpiScaling(hwnd windows.HWND) error {
|
||||||
r, _, e := procEnableNonClientDpiScaling.Call(uintptr(hwnd))
|
r, _, e := procEnableNonClientDpiScaling.Call(uintptr(hwnd))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: EnableNonClientDpiScaling failed: %w", e)
|
return fmt.Errorf("glfw: EnableNonClientDpiScaling failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1100,7 +1100,7 @@ func _EnumDisplayDevicesW(device string, iDevNum uint32, dwFlags uint32) (_DISPL
|
|||||||
var err error
|
var err error
|
||||||
lpDevice, err = windows.UTF16PtrFromString(device)
|
lpDevice, err = windows.UTF16PtrFromString(device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: device name must not include a NUL character")
|
panic("glfw: device name must not include a NUL character")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1118,7 +1118,7 @@ func _EnumDisplayDevicesW(device string, iDevNum uint32, dwFlags uint32) (_DISPL
|
|||||||
func _EnumDisplayMonitors(hdc _HDC, lprcClip *_RECT, lpfnEnum uintptr, dwData _LPARAM) error {
|
func _EnumDisplayMonitors(hdc _HDC, lprcClip *_RECT, lpfnEnum uintptr, dwData _LPARAM) error {
|
||||||
r, _, e := procEnumDisplayMonitors.Call(uintptr(hdc), uintptr(unsafe.Pointer(lprcClip)), uintptr(lpfnEnum), uintptr(dwData))
|
r, _, e := procEnumDisplayMonitors.Call(uintptr(hdc), uintptr(unsafe.Pointer(lprcClip)), uintptr(lpfnEnum), uintptr(dwData))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: EnumDisplayMonitors failed: %w", e)
|
return fmt.Errorf("glfw: EnumDisplayMonitors failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1129,7 +1129,7 @@ func _EnumDisplaySettingsExW(deviceName string, iModeNum uint32, dwFlags uint32)
|
|||||||
var err error
|
var err error
|
||||||
lpszDeviceName, err = windows.UTF16PtrFromString(deviceName)
|
lpszDeviceName, err = windows.UTF16PtrFromString(deviceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: device name must not include a NUL character")
|
panic("glfw: device name must not include a NUL character")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,7 +1151,7 @@ func _EnumDisplaySettingsW(deviceName string, iModeNum uint32) (_DEVMODEW, bool)
|
|||||||
var err error
|
var err error
|
||||||
lpszDeviceName, err = windows.UTF16PtrFromString(deviceName)
|
lpszDeviceName, err = windows.UTF16PtrFromString(deviceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: device name must not include a NUL character")
|
panic("glfw: device name must not include a NUL character")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1184,7 +1184,7 @@ func _GetActiveWindow() windows.HWND {
|
|||||||
func _GetClassLongPtrW(hWnd windows.HWND, nIndex int32) (uintptr, error) {
|
func _GetClassLongPtrW(hWnd windows.HWND, nIndex int32) (uintptr, error) {
|
||||||
r, _, e := procGetClassLongPtrW.Call(uintptr(hWnd), uintptr(nIndex))
|
r, _, e := procGetClassLongPtrW.Call(uintptr(hWnd), uintptr(nIndex))
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: GetClassLongPtrW failed: %w", e)
|
return 0, fmt.Errorf("glfw: GetClassLongPtrW failed: %w", e)
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
@ -1193,7 +1193,7 @@ func _GetClientRect(hWnd windows.HWND) (_RECT, error) {
|
|||||||
var rect _RECT
|
var rect _RECT
|
||||||
r, _, e := procGetClientRect.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&rect)))
|
r, _, e := procGetClientRect.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&rect)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return _RECT{}, fmt.Errorf("goglfw: GetClientRect failed: %w", e)
|
return _RECT{}, fmt.Errorf("glfw: GetClientRect failed: %w", e)
|
||||||
}
|
}
|
||||||
return rect, nil
|
return rect, nil
|
||||||
}
|
}
|
||||||
@ -1202,7 +1202,7 @@ func _GetCursorPos() (_POINT, error) {
|
|||||||
var point _POINT
|
var point _POINT
|
||||||
r, _, e := procGetCursorPos.Call(uintptr(unsafe.Pointer(&point)))
|
r, _, e := procGetCursorPos.Call(uintptr(unsafe.Pointer(&point)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return _POINT{}, fmt.Errorf("goglfw: GetCursorPos failed: %w", e)
|
return _POINT{}, fmt.Errorf("glfw: GetCursorPos failed: %w", e)
|
||||||
}
|
}
|
||||||
return point, nil
|
return point, nil
|
||||||
}
|
}
|
||||||
@ -1210,7 +1210,7 @@ func _GetCursorPos() (_POINT, error) {
|
|||||||
func _GetDC(hWnd windows.HWND) (_HDC, error) {
|
func _GetDC(hWnd windows.HWND) (_HDC, error) {
|
||||||
r, _, e := procGetDC.Call(uintptr(hWnd))
|
r, _, e := procGetDC.Call(uintptr(hWnd))
|
||||||
if _HDC(r) == 0 {
|
if _HDC(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: GetDC failed: %w", e)
|
return 0, fmt.Errorf("glfw: GetDC failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HDC(r), nil
|
return _HDC(r), nil
|
||||||
}
|
}
|
||||||
@ -1233,7 +1233,7 @@ func _GetKeyState(nVirtKey int32) int16 {
|
|||||||
func _GetLayeredWindowAttributes(hWnd windows.HWND) (key _COLORREF, alpha byte, flags uint32, err error) {
|
func _GetLayeredWindowAttributes(hWnd windows.HWND) (key _COLORREF, alpha byte, flags uint32, err error) {
|
||||||
r, _, e := procGetLayeredWindowAttributes.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&key)), uintptr(unsafe.Pointer(&alpha)), uintptr(unsafe.Pointer(&flags)))
|
r, _, e := procGetLayeredWindowAttributes.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&key)), uintptr(unsafe.Pointer(&alpha)), uintptr(unsafe.Pointer(&flags)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, 0, 0, fmt.Errorf("goglfw: GetLayeredWindowAttributes failed: %w", e)
|
return 0, 0, 0, fmt.Errorf("glfw: GetLayeredWindowAttributes failed: %w", e)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1250,14 +1250,14 @@ func _GetModuleHandleExW(dwFlags uint32, lpModuleName any) (_HMODULE, error) {
|
|||||||
if moduleName != "" {
|
if moduleName != "" {
|
||||||
p, err := windows.UTF16PtrFromString(moduleName)
|
p, err := windows.UTF16PtrFromString(moduleName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: module name must not include a NUL character")
|
panic("glfw: module name must not include a NUL character")
|
||||||
}
|
}
|
||||||
ptr = unsafe.Pointer(p)
|
ptr = unsafe.Pointer(p)
|
||||||
}
|
}
|
||||||
case unsafe.Pointer:
|
case unsafe.Pointer:
|
||||||
ptr = moduleName
|
ptr = moduleName
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("goglfw: GetModuleHandleExW: lpModuleName must be a string or an unsafe.Pointer but %T", moduleName)
|
return 0, fmt.Errorf("glfw: GetModuleHandleExW: lpModuleName must be a string or an unsafe.Pointer but %T", moduleName)
|
||||||
}
|
}
|
||||||
|
|
||||||
var module _HMODULE
|
var module _HMODULE
|
||||||
@ -1265,7 +1265,7 @@ func _GetModuleHandleExW(dwFlags uint32, lpModuleName any) (_HMODULE, error) {
|
|||||||
runtime.KeepAlive(ptr)
|
runtime.KeepAlive(ptr)
|
||||||
|
|
||||||
if int32(r) != 1 {
|
if int32(r) != 1 {
|
||||||
return 0, fmt.Errorf("goglfw: GetModuleHandleExW failed: %w", e)
|
return 0, fmt.Errorf("glfw: GetModuleHandleExW failed: %w", e)
|
||||||
}
|
}
|
||||||
return module, nil
|
return module, nil
|
||||||
}
|
}
|
||||||
@ -1293,7 +1293,7 @@ func _GetMonitorInfoW_Ex(hMonitor _HMONITOR) (_MONITORINFOEXW, bool) {
|
|||||||
func _GetDpiForMonitor(hmonitor _HMONITOR, dpiType _MONITOR_DPI_TYPE) (dpiX, dpiY uint32, err error) {
|
func _GetDpiForMonitor(hmonitor _HMONITOR, dpiType _MONITOR_DPI_TYPE) (dpiX, dpiY uint32, err error) {
|
||||||
r, _, _ := procGetDpiForMonitor.Call(uintptr(hmonitor), uintptr(dpiType), uintptr(unsafe.Pointer(&dpiX)), uintptr(unsafe.Pointer(&dpiY)))
|
r, _, _ := procGetDpiForMonitor.Call(uintptr(hmonitor), uintptr(dpiType), uintptr(unsafe.Pointer(&dpiX)), uintptr(unsafe.Pointer(&dpiY)))
|
||||||
if uint32(r) != uint32(windows.S_OK) {
|
if uint32(r) != uint32(windows.S_OK) {
|
||||||
return 0, 0, fmt.Errorf("goglfw: GetDpiForMonitor failed: %w", handleError(windows.Handle(uint32(r))))
|
return 0, 0, fmt.Errorf("glfw: GetDpiForMonitor failed: %w", handleError(windows.Handle(uint32(r))))
|
||||||
}
|
}
|
||||||
return dpiX, dpiY, nil
|
return dpiX, dpiY, nil
|
||||||
}
|
}
|
||||||
@ -1301,7 +1301,7 @@ func _GetDpiForMonitor(hmonitor _HMONITOR, dpiType _MONITOR_DPI_TYPE) (dpiX, dpi
|
|||||||
func _GetRawInputData(hRawInput _HRAWINPUT, uiCommand uint32, pData unsafe.Pointer, pcbSize *uint32) (uint32, error) {
|
func _GetRawInputData(hRawInput _HRAWINPUT, uiCommand uint32, pData unsafe.Pointer, pcbSize *uint32) (uint32, error) {
|
||||||
r, _, e := procGetRawInputData.Call(uintptr(hRawInput), uintptr(uiCommand), uintptr(pData), uintptr(unsafe.Pointer(pcbSize)), unsafe.Sizeof(_RAWINPUTHEADER{}))
|
r, _, e := procGetRawInputData.Call(uintptr(hRawInput), uintptr(uiCommand), uintptr(pData), uintptr(unsafe.Pointer(pcbSize)), unsafe.Sizeof(_RAWINPUTHEADER{}))
|
||||||
if uint32(r) == (1<<32)-1 {
|
if uint32(r) == (1<<32)-1 {
|
||||||
return 0, fmt.Errorf("goglfw: GetRawInputData failed: %w", e)
|
return 0, fmt.Errorf("glfw: GetRawInputData failed: %w", e)
|
||||||
}
|
}
|
||||||
return uint32(r), nil
|
return uint32(r), nil
|
||||||
}
|
}
|
||||||
@ -1309,7 +1309,7 @@ func _GetRawInputData(hRawInput _HRAWINPUT, uiCommand uint32, pData unsafe.Point
|
|||||||
func _GetSystemMetrics(nIndex int32) (int32, error) {
|
func _GetSystemMetrics(nIndex int32) (int32, error) {
|
||||||
r, _, e := procGetSystemMetrics.Call(uintptr(nIndex))
|
r, _, e := procGetSystemMetrics.Call(uintptr(nIndex))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, fmt.Errorf("goglfw: GetSystemMetrics failed: %w", e)
|
return 0, fmt.Errorf("glfw: GetSystemMetrics failed: %w", e)
|
||||||
}
|
}
|
||||||
return int32(r), nil
|
return int32(r), nil
|
||||||
}
|
}
|
||||||
@ -1317,7 +1317,7 @@ func _GetSystemMetrics(nIndex int32) (int32, error) {
|
|||||||
func _GetSystemMetricsForDpi(nIndex int32, dpi uint32) (int32, error) {
|
func _GetSystemMetricsForDpi(nIndex int32, dpi uint32) (int32, error) {
|
||||||
r, _, e := procGetSystemMetricsForDpi.Call(uintptr(nIndex), uintptr(dpi))
|
r, _, e := procGetSystemMetricsForDpi.Call(uintptr(nIndex), uintptr(dpi))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, fmt.Errorf("goglfw: GetSystemMetrics failed: %w", e)
|
return 0, fmt.Errorf("glfw: GetSystemMetrics failed: %w", e)
|
||||||
}
|
}
|
||||||
return int32(r), nil
|
return int32(r), nil
|
||||||
}
|
}
|
||||||
@ -1325,7 +1325,7 @@ func _GetSystemMetricsForDpi(nIndex int32, dpi uint32) (int32, error) {
|
|||||||
func _GetWindowLongW(hWnd windows.HWND, nIndex int32) (int32, error) {
|
func _GetWindowLongW(hWnd windows.HWND, nIndex int32) (int32, error) {
|
||||||
r, _, e := procGetWindowLongW.Call(uintptr(hWnd), uintptr(nIndex))
|
r, _, e := procGetWindowLongW.Call(uintptr(hWnd), uintptr(nIndex))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, fmt.Errorf("goglfw: GetWindowLongW failed: %w", e)
|
return 0, fmt.Errorf("glfw: GetWindowLongW failed: %w", e)
|
||||||
}
|
}
|
||||||
return int32(r), nil
|
return int32(r), nil
|
||||||
}
|
}
|
||||||
@ -1336,7 +1336,7 @@ func _GetWindowPlacement(hWnd windows.HWND) (_WINDOWPLACEMENT, error) {
|
|||||||
|
|
||||||
r, _, e := procGetWindowPlacement.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&wp)))
|
r, _, e := procGetWindowPlacement.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&wp)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return _WINDOWPLACEMENT{}, fmt.Errorf("goglfw: GetWindowPlacement failed: %w", e)
|
return _WINDOWPLACEMENT{}, fmt.Errorf("glfw: GetWindowPlacement failed: %w", e)
|
||||||
}
|
}
|
||||||
return wp, nil
|
return wp, nil
|
||||||
}
|
}
|
||||||
@ -1345,7 +1345,7 @@ func _GetWindowRect(hWnd windows.HWND) (_RECT, error) {
|
|||||||
var rect _RECT
|
var rect _RECT
|
||||||
r, _, e := procGetWindowRect.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&rect)))
|
r, _, e := procGetWindowRect.Call(uintptr(hWnd), uintptr(unsafe.Pointer(&rect)))
|
||||||
if int(r) == 0 {
|
if int(r) == 0 {
|
||||||
return _RECT{}, fmt.Errorf("goglfw: GetWindowRect failed: %w", e)
|
return _RECT{}, fmt.Errorf("glfw: GetWindowRect failed: %w", e)
|
||||||
}
|
}
|
||||||
return rect, nil
|
return rect, nil
|
||||||
}
|
}
|
||||||
@ -1368,7 +1368,7 @@ func _IsZoomed(hWnd windows.HWND) bool {
|
|||||||
func _LoadCursorW(hInstance _HINSTANCE, lpCursorName uintptr) (_HCURSOR, error) {
|
func _LoadCursorW(hInstance _HINSTANCE, lpCursorName uintptr) (_HCURSOR, error) {
|
||||||
r, _, e := procLoadCursorW.Call(uintptr(hInstance), lpCursorName)
|
r, _, e := procLoadCursorW.Call(uintptr(hInstance), lpCursorName)
|
||||||
if _HCURSOR(r) == 0 {
|
if _HCURSOR(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: LoadCursorW: %w", e)
|
return 0, fmt.Errorf("glfw: LoadCursorW: %w", e)
|
||||||
}
|
}
|
||||||
return _HCURSOR(r), nil
|
return _HCURSOR(r), nil
|
||||||
}
|
}
|
||||||
@ -1376,7 +1376,7 @@ func _LoadCursorW(hInstance _HINSTANCE, lpCursorName uintptr) (_HCURSOR, error)
|
|||||||
func _LoadImageW(hInst _HINSTANCE, name uintptr, typ uint32, cx int32, cy int32, fuLoad uint32) (windows.Handle, error) {
|
func _LoadImageW(hInst _HINSTANCE, name uintptr, typ uint32, cx int32, cy int32, fuLoad uint32) (windows.Handle, error) {
|
||||||
r, _, e := procLoadImageW.Call(uintptr(hInst), name, uintptr(typ), uintptr(cx), uintptr(cy), uintptr(fuLoad))
|
r, _, e := procLoadImageW.Call(uintptr(hInst), name, uintptr(typ), uintptr(cx), uintptr(cy), uintptr(fuLoad))
|
||||||
if windows.Handle(r) == 0 {
|
if windows.Handle(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: LoadImageW: %w", e)
|
return 0, fmt.Errorf("glfw: LoadImageW: %w", e)
|
||||||
}
|
}
|
||||||
return windows.Handle(r), nil
|
return windows.Handle(r), nil
|
||||||
}
|
}
|
||||||
@ -1398,7 +1398,7 @@ func _MoveWindow(hWnd windows.HWND, x, y, nWidth, nHeight int32, repaint bool) e
|
|||||||
}
|
}
|
||||||
r, _, e := procMoveWindow.Call(uintptr(hWnd), uintptr(x), uintptr(y), uintptr(nWidth), uintptr(nHeight), bRepaint)
|
r, _, e := procMoveWindow.Call(uintptr(hWnd), uintptr(x), uintptr(y), uintptr(nWidth), uintptr(nHeight), bRepaint)
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: MoveWindow: %w", e)
|
return fmt.Errorf("glfw: MoveWindow: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1410,7 +1410,7 @@ func _MsgWaitForMultipleObjects(nCount uint32, pHandles *windows.Handle, waitAll
|
|||||||
}
|
}
|
||||||
r, _, e := procMsgWaitForMultipleObjects.Call(uintptr(nCount), uintptr(unsafe.Pointer(pHandles)), fWaitAll, uintptr(dwMilliseconds), uintptr(dwWakeMask))
|
r, _, e := procMsgWaitForMultipleObjects.Call(uintptr(nCount), uintptr(unsafe.Pointer(pHandles)), fWaitAll, uintptr(dwMilliseconds), uintptr(dwWakeMask))
|
||||||
if uint32(r) == _WAIT_FAILED {
|
if uint32(r) == _WAIT_FAILED {
|
||||||
return 0, fmt.Errorf("goglfw: MsgWaitForMultipleObjects failed: %w", e)
|
return 0, fmt.Errorf("glfw: MsgWaitForMultipleObjects failed: %w", e)
|
||||||
}
|
}
|
||||||
return uint32(r), nil
|
return uint32(r), nil
|
||||||
}
|
}
|
||||||
@ -1428,7 +1428,7 @@ func _PeekMessageW(lpMsg *_MSG, hWnd windows.HWND, wMsgFilterMin uint32, wMsgFil
|
|||||||
func _PostMessageW(hWnd windows.HWND, msg uint32, wParam _WPARAM, lParam _LPARAM) error {
|
func _PostMessageW(hWnd windows.HWND, msg uint32, wParam _WPARAM, lParam _LPARAM) error {
|
||||||
r, _, e := procPostMessageW.Call(uintptr(hWnd), uintptr(msg), uintptr(wParam), uintptr(lParam))
|
r, _, e := procPostMessageW.Call(uintptr(hWnd), uintptr(msg), uintptr(wParam), uintptr(lParam))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: PostMessageW failed: %w", e)
|
return fmt.Errorf("glfw: PostMessageW failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1445,7 +1445,7 @@ func _PtInRect(lprc *_RECT, pt _POINT) bool {
|
|||||||
// Adjust the alignment for ARM.
|
// Adjust the alignment for ARM.
|
||||||
r, _, _ = procPtInRect.Call(uintptr(unsafe.Pointer(lprc)), 0, uintptr(pt.x), uintptr(pt.y))
|
r, _, _ = procPtInRect.Call(uintptr(unsafe.Pointer(lprc)), 0, uintptr(pt.x), uintptr(pt.y))
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("goglfw: GOARCH=%s is not supported", runtime.GOARCH))
|
panic(fmt.Sprintf("glfw: GOARCH=%s is not supported", runtime.GOARCH))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return int32(r) != 0
|
return int32(r) != 0
|
||||||
@ -1454,7 +1454,7 @@ func _PtInRect(lprc *_RECT, pt _POINT) bool {
|
|||||||
func _RegisterClassExW(unnamedParam1 *_WNDCLASSEXW) (_ATOM, error) {
|
func _RegisterClassExW(unnamedParam1 *_WNDCLASSEXW) (_ATOM, error) {
|
||||||
r, _, e := procRegisterClassExW.Call(uintptr(unsafe.Pointer(unnamedParam1)))
|
r, _, e := procRegisterClassExW.Call(uintptr(unsafe.Pointer(unnamedParam1)))
|
||||||
if _ATOM(r) == 0 {
|
if _ATOM(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: RegisterClassExW failed: %w", e)
|
return 0, fmt.Errorf("glfw: RegisterClassExW failed: %w", e)
|
||||||
}
|
}
|
||||||
return _ATOM(r), nil
|
return _ATOM(r), nil
|
||||||
}
|
}
|
||||||
@ -1462,7 +1462,7 @@ func _RegisterClassExW(unnamedParam1 *_WNDCLASSEXW) (_ATOM, error) {
|
|||||||
func _RegisterDeviceNotificationW(hRecipient windows.Handle, notificationFilter unsafe.Pointer, flags uint32) (_HDEVNOTIFY, error) {
|
func _RegisterDeviceNotificationW(hRecipient windows.Handle, notificationFilter unsafe.Pointer, flags uint32) (_HDEVNOTIFY, error) {
|
||||||
r, _, e := procRegisterDeviceNotificationW.Call(uintptr(hRecipient), uintptr(notificationFilter), uintptr(flags))
|
r, _, e := procRegisterDeviceNotificationW.Call(uintptr(hRecipient), uintptr(notificationFilter), uintptr(flags))
|
||||||
if _HDEVNOTIFY(r) == 0 {
|
if _HDEVNOTIFY(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: RegisterDeviceNotificationW failed: %w", e)
|
return 0, fmt.Errorf("glfw: RegisterDeviceNotificationW failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HDEVNOTIFY(r), nil
|
return _HDEVNOTIFY(r), nil
|
||||||
}
|
}
|
||||||
@ -1474,7 +1474,7 @@ func _RegisterRawInputDevices(pRawInputDevices []_RAWINPUTDEVICE) error {
|
|||||||
}
|
}
|
||||||
r, _, e := procRegisterRawInputDevices.Call(uintptr(rawInputDevices), uintptr(len(pRawInputDevices)), unsafe.Sizeof(_RAWINPUTDEVICE{}))
|
r, _, e := procRegisterRawInputDevices.Call(uintptr(rawInputDevices), uintptr(len(pRawInputDevices)), unsafe.Sizeof(_RAWINPUTDEVICE{}))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: RegisterRawInputDevices failed: %w", e)
|
return fmt.Errorf("glfw: RegisterRawInputDevices failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1482,7 +1482,7 @@ func _RegisterRawInputDevices(pRawInputDevices []_RAWINPUTDEVICE) error {
|
|||||||
func _ReleaseCapture() error {
|
func _ReleaseCapture() error {
|
||||||
r, _, e := procReleaseCapture.Call()
|
r, _, e := procReleaseCapture.Call()
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: ReleaseCapture failed: %w", e)
|
return fmt.Errorf("glfw: ReleaseCapture failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1495,7 +1495,7 @@ func _ReleaseDC(hWnd windows.HWND, hDC _HDC) int32 {
|
|||||||
func _ScreenToClient(hWnd windows.HWND, lpPoint *_POINT) error {
|
func _ScreenToClient(hWnd windows.HWND, lpPoint *_POINT) error {
|
||||||
r, _, e := procScreenToClient.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpPoint)))
|
r, _, e := procScreenToClient.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpPoint)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: ScreenToClient failed: %w", e)
|
return fmt.Errorf("glfw: ScreenToClient failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1518,7 +1518,7 @@ func _SetCursor(hCursor _HCURSOR) _HCURSOR {
|
|||||||
func _SetCursorPos(x, y int32) error {
|
func _SetCursorPos(x, y int32) error {
|
||||||
r, _, e := procSetCursorPos.Call(uintptr(x), uintptr(y))
|
r, _, e := procSetCursorPos.Call(uintptr(x), uintptr(y))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SetCursorPos failed: %w", e)
|
return fmt.Errorf("glfw: SetCursorPos failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1526,7 +1526,7 @@ func _SetCursorPos(x, y int32) error {
|
|||||||
func _SetFocus(hWnd windows.HWND) (windows.HWND, error) {
|
func _SetFocus(hWnd windows.HWND) (windows.HWND, error) {
|
||||||
r, _, e := procSetFocus.Call(uintptr(hWnd))
|
r, _, e := procSetFocus.Call(uintptr(hWnd))
|
||||||
if windows.HWND(r) == 0 {
|
if windows.HWND(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: SetFocus failed: %w", e)
|
return 0, fmt.Errorf("glfw: SetFocus failed: %w", e)
|
||||||
}
|
}
|
||||||
return windows.HWND(r), nil
|
return windows.HWND(r), nil
|
||||||
}
|
}
|
||||||
@ -1539,7 +1539,7 @@ func _SetForegroundWindow(hWnd windows.HWND) bool {
|
|||||||
func _SetLayeredWindowAttributes(hwnd windows.HWND, crKey _COLORREF, bAlpha byte, dwFlags uint32) error {
|
func _SetLayeredWindowAttributes(hwnd windows.HWND, crKey _COLORREF, bAlpha byte, dwFlags uint32) error {
|
||||||
r, _, e := procSetLayeredWindowAttributes.Call(uintptr(hwnd), uintptr(crKey), uintptr(bAlpha), uintptr(dwFlags))
|
r, _, e := procSetLayeredWindowAttributes.Call(uintptr(hwnd), uintptr(crKey), uintptr(bAlpha), uintptr(dwFlags))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SetLayeredWindowAttributes failed: %w", e)
|
return fmt.Errorf("glfw: SetLayeredWindowAttributes failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1547,7 +1547,7 @@ func _SetLayeredWindowAttributes(hwnd windows.HWND, crKey _COLORREF, bAlpha byte
|
|||||||
func _SetPixelFormat(hdc _HDC, format int32, ppfd *_PIXELFORMATDESCRIPTOR) error {
|
func _SetPixelFormat(hdc _HDC, format int32, ppfd *_PIXELFORMATDESCRIPTOR) error {
|
||||||
r, _, e := procSetPixelFormat.Call(uintptr(hdc), uintptr(format), uintptr(unsafe.Pointer(ppfd)))
|
r, _, e := procSetPixelFormat.Call(uintptr(hdc), uintptr(format), uintptr(unsafe.Pointer(ppfd)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SetPixelFormat failed: %w", e)
|
return fmt.Errorf("glfw: SetPixelFormat failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1560,7 +1560,7 @@ func _SetProcessDPIAware() bool {
|
|||||||
func _SetProcessDpiAwareness(value _PROCESS_DPI_AWARENESS) error {
|
func _SetProcessDpiAwareness(value _PROCESS_DPI_AWARENESS) error {
|
||||||
r, _, _ := procSetProcessDpiAwareness.Call(uintptr(value))
|
r, _, _ := procSetProcessDpiAwareness.Call(uintptr(value))
|
||||||
if uint32(r) != uint32(windows.S_OK) {
|
if uint32(r) != uint32(windows.S_OK) {
|
||||||
return fmt.Errorf("goglfw: SetProcessDpiAwareness failed: %w", handleError(windows.Handle(uint32(r))))
|
return fmt.Errorf("glfw: SetProcessDpiAwareness failed: %w", handleError(windows.Handle(uint32(r))))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1568,7 +1568,7 @@ func _SetProcessDpiAwareness(value _PROCESS_DPI_AWARENESS) error {
|
|||||||
func _SetProcessDpiAwarenessContext(value _DPI_AWARENESS_CONTEXT) error {
|
func _SetProcessDpiAwarenessContext(value _DPI_AWARENESS_CONTEXT) error {
|
||||||
r, _, e := procSetProcessDpiAwarenessContext.Call(uintptr(value))
|
r, _, e := procSetProcessDpiAwarenessContext.Call(uintptr(value))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SetProcessDpiAwarenessContext failed: %w", e)
|
return fmt.Errorf("glfw: SetProcessDpiAwarenessContext failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1581,7 +1581,7 @@ func _SetThreadExecutionState(esFlags _EXECUTION_STATE) _EXECUTION_STATE {
|
|||||||
func _SetWindowLongW(hWnd windows.HWND, nIndex int32, dwNewLong int32) (int32, error) {
|
func _SetWindowLongW(hWnd windows.HWND, nIndex int32, dwNewLong int32) (int32, error) {
|
||||||
r, _, e := procSetWindowLongW.Call(uintptr(hWnd), uintptr(nIndex), uintptr(dwNewLong))
|
r, _, e := procSetWindowLongW.Call(uintptr(hWnd), uintptr(nIndex), uintptr(dwNewLong))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, fmt.Errorf("goglfw: SetWindowLongW failed: %w", e)
|
return 0, fmt.Errorf("glfw: SetWindowLongW failed: %w", e)
|
||||||
}
|
}
|
||||||
return int32(r), nil
|
return int32(r), nil
|
||||||
}
|
}
|
||||||
@ -1589,7 +1589,7 @@ func _SetWindowLongW(hWnd windows.HWND, nIndex int32, dwNewLong int32) (int32, e
|
|||||||
func _SetWindowPlacement(hWnd windows.HWND, lpwndpl *_WINDOWPLACEMENT) error {
|
func _SetWindowPlacement(hWnd windows.HWND, lpwndpl *_WINDOWPLACEMENT) error {
|
||||||
r, _, e := procSetWindowPlacement.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpwndpl)))
|
r, _, e := procSetWindowPlacement.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpwndpl)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SetWindowPlacement failed: %w", e)
|
return fmt.Errorf("glfw: SetWindowPlacement failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1597,7 +1597,7 @@ func _SetWindowPlacement(hWnd windows.HWND, lpwndpl *_WINDOWPLACEMENT) error {
|
|||||||
func _SetWindowPos(hWnd windows.HWND, hWndInsertAfter windows.HWND, x, y, cx, cy int32, uFlags uint32) error {
|
func _SetWindowPos(hWnd windows.HWND, hWndInsertAfter windows.HWND, x, y, cx, cy int32, uFlags uint32) error {
|
||||||
r, _, e := procSetWindowPos.Call(uintptr(hWnd), uintptr(hWndInsertAfter), uintptr(x), uintptr(y), uintptr(cx), uintptr(cy), uintptr(uFlags))
|
r, _, e := procSetWindowPos.Call(uintptr(hWnd), uintptr(hWndInsertAfter), uintptr(x), uintptr(y), uintptr(cx), uintptr(cy), uintptr(uFlags))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SetWindowPos failed: %w", e)
|
return fmt.Errorf("glfw: SetWindowPos failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1606,14 +1606,14 @@ func _SetWindowTextW(hWnd windows.HWND, str string) error {
|
|||||||
// An empty string is also a valid value. Always create an uint16 pointer.
|
// An empty string is also a valid value. Always create an uint16 pointer.
|
||||||
lpString, err := windows.UTF16PtrFromString(str)
|
lpString, err := windows.UTF16PtrFromString(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: str must not include a NUL character")
|
panic("glfw: str must not include a NUL character")
|
||||||
}
|
}
|
||||||
|
|
||||||
r, _, e := procSetWindowTextW.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpString)))
|
r, _, e := procSetWindowTextW.Call(uintptr(hWnd), uintptr(unsafe.Pointer(lpString)))
|
||||||
runtime.KeepAlive(lpString)
|
runtime.KeepAlive(lpString)
|
||||||
|
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SetWindowTextW failed: %w", e)
|
return fmt.Errorf("glfw: SetWindowTextW failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1626,7 +1626,7 @@ func _ShowWindow(hWnd windows.HWND, nCmdShow int32) bool {
|
|||||||
func _SwapBuffers(unnamedParam1 _HDC) error {
|
func _SwapBuffers(unnamedParam1 _HDC) error {
|
||||||
r, _, e := procSwapBuffers.Call(uintptr(unnamedParam1))
|
r, _, e := procSwapBuffers.Call(uintptr(unnamedParam1))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SwapBuffers failed: %w", e)
|
return fmt.Errorf("glfw: SwapBuffers failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1634,7 +1634,7 @@ func _SwapBuffers(unnamedParam1 _HDC) error {
|
|||||||
func _SystemParametersInfoW(uiAction uint32, uiParam uint32, pvParam uintptr, fWinIni uint32) error {
|
func _SystemParametersInfoW(uiAction uint32, uiParam uint32, pvParam uintptr, fWinIni uint32) error {
|
||||||
r, _, e := procSystemParametersInfoW.Call(uintptr(uiAction), uintptr(uiParam), pvParam, uintptr(fWinIni))
|
r, _, e := procSystemParametersInfoW.Call(uintptr(uiAction), uintptr(uiParam), pvParam, uintptr(fWinIni))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: SystemParametersInfoW failed: %w", e)
|
return fmt.Errorf("glfw: SystemParametersInfoW failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1642,7 +1642,7 @@ func _SystemParametersInfoW(uiAction uint32, uiParam uint32, pvParam uintptr, fW
|
|||||||
func _TlsAlloc() (uint32, error) {
|
func _TlsAlloc() (uint32, error) {
|
||||||
r, _, e := procTlsAlloc.Call()
|
r, _, e := procTlsAlloc.Call()
|
||||||
if uint32(r) == _TLS_OUT_OF_INDEXES {
|
if uint32(r) == _TLS_OUT_OF_INDEXES {
|
||||||
return 0, fmt.Errorf("goglfw: TlsAlloc failed: %w", e)
|
return 0, fmt.Errorf("glfw: TlsAlloc failed: %w", e)
|
||||||
}
|
}
|
||||||
return uint32(r), nil
|
return uint32(r), nil
|
||||||
}
|
}
|
||||||
@ -1650,7 +1650,7 @@ func _TlsAlloc() (uint32, error) {
|
|||||||
func _TlsFree(dwTlsIndex uint32) error {
|
func _TlsFree(dwTlsIndex uint32) error {
|
||||||
r, _, e := procTlsFree.Call(uintptr(dwTlsIndex))
|
r, _, e := procTlsFree.Call(uintptr(dwTlsIndex))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: TlsFree failed: %w", e)
|
return fmt.Errorf("glfw: TlsFree failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1658,7 +1658,7 @@ func _TlsFree(dwTlsIndex uint32) error {
|
|||||||
func _TlsGetValue(dwTlsIndex uint32) (uintptr, error) {
|
func _TlsGetValue(dwTlsIndex uint32) (uintptr, error) {
|
||||||
r, _, e := procTlsGetValue.Call(uintptr(dwTlsIndex))
|
r, _, e := procTlsGetValue.Call(uintptr(dwTlsIndex))
|
||||||
if r == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if r == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return 0, fmt.Errorf("goglfw: TlsGetValue failed: %w", e)
|
return 0, fmt.Errorf("glfw: TlsGetValue failed: %w", e)
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
@ -1666,7 +1666,7 @@ func _TlsGetValue(dwTlsIndex uint32) (uintptr, error) {
|
|||||||
func _TlsSetValue(dwTlsIndex uint32, lpTlsValue uintptr) error {
|
func _TlsSetValue(dwTlsIndex uint32, lpTlsValue uintptr) error {
|
||||||
r, _, e := procTlsSetValue.Call(uintptr(dwTlsIndex), lpTlsValue)
|
r, _, e := procTlsSetValue.Call(uintptr(dwTlsIndex), lpTlsValue)
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: TlsSetValue failed: %w", e)
|
return fmt.Errorf("glfw: TlsSetValue failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1697,7 +1697,7 @@ func _TranslateMessage(lpMsg *_MSG) bool {
|
|||||||
func _TrackMouseEvent(lpEventTrack *_TRACKMOUSEEVENT) error {
|
func _TrackMouseEvent(lpEventTrack *_TRACKMOUSEEVENT) error {
|
||||||
r, _, e := procTrackMouseEvent.Call(uintptr(unsafe.Pointer(lpEventTrack)))
|
r, _, e := procTrackMouseEvent.Call(uintptr(unsafe.Pointer(lpEventTrack)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: TrackMouseEvent failed: %w", e)
|
return fmt.Errorf("glfw: TrackMouseEvent failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1708,7 +1708,7 @@ func _UnregisterClassW(className string, hInstance _HINSTANCE) error {
|
|||||||
var err error
|
var err error
|
||||||
lpClassName, err = windows.UTF16PtrFromString(className)
|
lpClassName, err = windows.UTF16PtrFromString(className)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: class name must not include a NUL character")
|
panic("glfw: class name must not include a NUL character")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1716,7 +1716,7 @@ func _UnregisterClassW(className string, hInstance _HINSTANCE) error {
|
|||||||
runtime.KeepAlive(lpClassName)
|
runtime.KeepAlive(lpClassName)
|
||||||
|
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: UnregisterClassW failed: %w", e)
|
return fmt.Errorf("glfw: UnregisterClassW failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1724,7 +1724,7 @@ func _UnregisterClassW(className string, hInstance _HINSTANCE) error {
|
|||||||
func _UnregisterDeviceNotification(handle _HDEVNOTIFY) error {
|
func _UnregisterDeviceNotification(handle _HDEVNOTIFY) error {
|
||||||
r, _, e := procUnregisterDeviceNotification.Call(uintptr(handle))
|
r, _, e := procUnregisterDeviceNotification.Call(uintptr(handle))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: UnregisterDeviceNotification failed: %w", e)
|
return fmt.Errorf("glfw: UnregisterDeviceNotification failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1732,7 +1732,7 @@ func _UnregisterDeviceNotification(handle _HDEVNOTIFY) error {
|
|||||||
func _WaitMessage() error {
|
func _WaitMessage() error {
|
||||||
r, _, e := procWaitMessage.Call()
|
r, _, e := procWaitMessage.Call()
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: WaitMessage failed: %w", e)
|
return fmt.Errorf("glfw: WaitMessage failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1740,7 +1740,7 @@ func _WaitMessage() error {
|
|||||||
func wglCreateContext(unnamedParam1 _HDC) (_HGLRC, error) {
|
func wglCreateContext(unnamedParam1 _HDC) (_HGLRC, error) {
|
||||||
r, _, e := procWGLCreateContext.Call(uintptr(unnamedParam1))
|
r, _, e := procWGLCreateContext.Call(uintptr(unnamedParam1))
|
||||||
if _HGLRC(r) == 0 {
|
if _HGLRC(r) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: wglCreateContext failed: %w", e)
|
return 0, fmt.Errorf("glfw: wglCreateContext failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HGLRC(r), nil
|
return _HGLRC(r), nil
|
||||||
}
|
}
|
||||||
@ -1749,7 +1749,7 @@ func wglCreateContextAttribsARB(hDC _HDC, hshareContext _HGLRC, attribList *int3
|
|||||||
r, _, e := syscall.Syscall(procWGLCreateContextAttribsARB, 3, uintptr(hDC), uintptr(hshareContext), uintptr(unsafe.Pointer(attribList)))
|
r, _, e := syscall.Syscall(procWGLCreateContextAttribsARB, 3, uintptr(hDC), uintptr(hshareContext), uintptr(unsafe.Pointer(attribList)))
|
||||||
if _HGLRC(r) == 0 {
|
if _HGLRC(r) == 0 {
|
||||||
// TODO: Show more detailed error? See the original implementation.
|
// TODO: Show more detailed error? See the original implementation.
|
||||||
return 0, fmt.Errorf("goglfw: wglCreateContextAttribsARB failed: %w", e)
|
return 0, fmt.Errorf("glfw: wglCreateContextAttribsARB failed: %w", e)
|
||||||
}
|
}
|
||||||
return _HGLRC(r), nil
|
return _HGLRC(r), nil
|
||||||
}
|
}
|
||||||
@ -1757,7 +1757,7 @@ func wglCreateContextAttribsARB(hDC _HDC, hshareContext _HGLRC, attribList *int3
|
|||||||
func wglDeleteContext(unnamedParam1 _HGLRC) error {
|
func wglDeleteContext(unnamedParam1 _HGLRC) error {
|
||||||
r, _, e := procWGLDeleteContext.Call(uintptr(unnamedParam1))
|
r, _, e := procWGLDeleteContext.Call(uintptr(unnamedParam1))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: wglDeleteContext failed: %w", e)
|
return fmt.Errorf("glfw: wglDeleteContext failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1793,7 +1793,7 @@ func wglGetExtensionsStringEXT_Available() bool {
|
|||||||
func wglGetPixelFormatAttribivARB(hdc _HDC, iPixelFormat int32, iLayerPlane int32, nAttributes uint32, piAttributes *int32, piValues *int32) error {
|
func wglGetPixelFormatAttribivARB(hdc _HDC, iPixelFormat int32, iLayerPlane int32, nAttributes uint32, piAttributes *int32, piValues *int32) error {
|
||||||
r, _, e := syscall.Syscall6(procWGLGetPixelFormatAttribivARB, 6, uintptr(hdc), uintptr(iPixelFormat), uintptr(iLayerPlane), uintptr(nAttributes), uintptr(unsafe.Pointer(piAttributes)), uintptr(unsafe.Pointer(piValues)))
|
r, _, e := syscall.Syscall6(procWGLGetPixelFormatAttribivARB, 6, uintptr(hdc), uintptr(iPixelFormat), uintptr(iLayerPlane), uintptr(nAttributes), uintptr(unsafe.Pointer(piAttributes)), uintptr(unsafe.Pointer(piValues)))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: wglGetPixelFormatAttribivARB failed: %w", e)
|
return fmt.Errorf("glfw: wglGetPixelFormatAttribivARB failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1801,7 +1801,7 @@ func wglGetPixelFormatAttribivARB(hdc _HDC, iPixelFormat int32, iLayerPlane int3
|
|||||||
func wglGetProcAddress(unnamedParam1 string) uintptr {
|
func wglGetProcAddress(unnamedParam1 string) uintptr {
|
||||||
ptr, err := windows.BytePtrFromString(unnamedParam1)
|
ptr, err := windows.BytePtrFromString(unnamedParam1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: unnamedParam1 must not include a NUL character")
|
panic("glfw: unnamedParam1 must not include a NUL character")
|
||||||
}
|
}
|
||||||
r, _, _ := procWGLGetProcAddress.Call(uintptr(unsafe.Pointer(ptr)))
|
r, _, _ := procWGLGetProcAddress.Call(uintptr(unsafe.Pointer(ptr)))
|
||||||
return r
|
return r
|
||||||
@ -1810,7 +1810,7 @@ func wglGetProcAddress(unnamedParam1 string) uintptr {
|
|||||||
func wglMakeCurrent(unnamedParam1 _HDC, unnamedParam2 _HGLRC) error {
|
func wglMakeCurrent(unnamedParam1 _HDC, unnamedParam2 _HGLRC) error {
|
||||||
r, _, e := procWGLMakeCurrent.Call(uintptr(unnamedParam1), uintptr(unnamedParam2))
|
r, _, e := procWGLMakeCurrent.Call(uintptr(unnamedParam1), uintptr(unnamedParam2))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: wglMakeCurrent failed: %w", e)
|
return fmt.Errorf("glfw: wglMakeCurrent failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1818,7 +1818,7 @@ func wglMakeCurrent(unnamedParam1 _HDC, unnamedParam2 _HGLRC) error {
|
|||||||
func wglShareLists(unnamedParam1 _HGLRC, unnamedParam2 _HGLRC) error {
|
func wglShareLists(unnamedParam1 _HGLRC, unnamedParam2 _HGLRC) error {
|
||||||
r, _, e := procWGLShareLists.Call(uintptr(unnamedParam1), uintptr(unnamedParam2))
|
r, _, e := procWGLShareLists.Call(uintptr(unnamedParam1), uintptr(unnamedParam2))
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: wglShareLists failed: %w", e)
|
return fmt.Errorf("glfw: wglShareLists failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1826,7 +1826,7 @@ func wglShareLists(unnamedParam1 _HGLRC, unnamedParam2 _HGLRC) error {
|
|||||||
func wglSwapIntervalEXT(interval int32) error {
|
func wglSwapIntervalEXT(interval int32) error {
|
||||||
r, _, e := syscall.Syscall(procWGLSwapIntervalEXT, 1, uintptr(interval), 0, 0)
|
r, _, e := syscall.Syscall(procWGLSwapIntervalEXT, 1, uintptr(interval), 0, 0)
|
||||||
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
if int32(r) == 0 && !errors.Is(e, windows.ERROR_SUCCESS) {
|
||||||
return fmt.Errorf("goglfw: wglSwapIntervalEXT failed: %w", e)
|
return fmt.Errorf("glfw: wglSwapIntervalEXT failed: %w", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
@ -16,69 +16,30 @@
|
|||||||
|
|
||||||
package glfw
|
package glfw
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/goglfw"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ToCharModsCallback(cb func(window *Window, char rune, mods ModifierKey)) CharModsCallback {
|
func ToCharModsCallback(cb func(window *Window, char rune, mods ModifierKey)) CharModsCallback {
|
||||||
if cb == nil {
|
return cb
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return func(window *goglfw.Window, char rune, mods goglfw.ModifierKey) {
|
|
||||||
cb((*Window)(window), char, ModifierKey(mods))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToCloseCallback(cb func(window *Window)) CloseCallback {
|
func ToCloseCallback(cb func(window *Window)) CloseCallback {
|
||||||
if cb == nil {
|
return cb
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return func(window *goglfw.Window) {
|
|
||||||
cb((*Window)(window))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToDropCallback(cb func(window *Window, names []string)) DropCallback {
|
func ToDropCallback(cb func(window *Window, names []string)) DropCallback {
|
||||||
if cb == nil {
|
return cb
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return func(window *goglfw.Window, names []string) {
|
|
||||||
cb((*Window)(window), names)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToFramebufferSizeCallback(cb func(window *Window, width int, height int)) FramebufferSizeCallback {
|
func ToFramebufferSizeCallback(cb func(window *Window, width int, height int)) FramebufferSizeCallback {
|
||||||
if cb == nil {
|
return cb
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return func(window *goglfw.Window, width int, height int) {
|
|
||||||
cb((*Window)(window), width, height)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToMonitorCallback(cb func(monitor *Monitor, event PeripheralEvent)) MonitorCallback {
|
func ToMonitorCallback(cb func(monitor *Monitor, event PeripheralEvent)) MonitorCallback {
|
||||||
if cb == nil {
|
return cb
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return func(monitor *goglfw.Monitor, event goglfw.PeripheralEvent) {
|
|
||||||
cb((*Monitor)(monitor), PeripheralEvent(event))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToScrollCallback(cb func(window *Window, xoff float64, yoff float64)) ScrollCallback {
|
func ToScrollCallback(cb func(window *Window, xoff float64, yoff float64)) ScrollCallback {
|
||||||
if cb == nil {
|
return cb
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return func(window *goglfw.Window, xoff float64, yoff float64) {
|
|
||||||
cb((*Window)(window), xoff, yoff)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToSizeCallback(cb func(window *Window, width int, height int)) SizeCallback {
|
func ToSizeCallback(cb func(window *Window, width int, height int)) SizeCallback {
|
||||||
if cb == nil {
|
return cb
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return func(window *goglfw.Window, width int, height int) {
|
|
||||||
cb((*Window)(window), width, height)
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -26,13 +26,13 @@ func checkValidContextConfig(ctxconfig *ctxconfig) error {
|
|||||||
if ctxconfig.source != NativeContextAPI &&
|
if ctxconfig.source != NativeContextAPI &&
|
||||||
ctxconfig.source != EGLContextAPI &&
|
ctxconfig.source != EGLContextAPI &&
|
||||||
ctxconfig.source != OSMesaContextAPI {
|
ctxconfig.source != OSMesaContextAPI {
|
||||||
return fmt.Errorf("goglfw: invalid context creation API 0x%08X: %w", ctxconfig.source, InvalidEnum)
|
return fmt.Errorf("glfw: invalid context creation API 0x%08X: %w", ctxconfig.source, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.client != NoAPI &&
|
if ctxconfig.client != NoAPI &&
|
||||||
ctxconfig.client != OpenGLAPI &&
|
ctxconfig.client != OpenGLAPI &&
|
||||||
ctxconfig.client != OpenGLESAPI {
|
ctxconfig.client != OpenGLESAPI {
|
||||||
return fmt.Errorf("goglfw: invalid client API 0x%08X: %w", ctxconfig.client, InvalidEnum)
|
return fmt.Errorf("glfw: invalid client API 0x%08X: %w", ctxconfig.client, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.client == OpenGLAPI {
|
if ctxconfig.client == OpenGLAPI {
|
||||||
@ -46,25 +46,25 @@ func checkValidContextConfig(ctxconfig *ctxconfig) error {
|
|||||||
// OpenGL 3.x series ended with version 3.3
|
// OpenGL 3.x series ended with version 3.3
|
||||||
// For now, let everything else through
|
// For now, let everything else through
|
||||||
|
|
||||||
return fmt.Errorf("goglfw: invalid OpenGL version %d.%d: %w", ctxconfig.major, ctxconfig.minor, InvalidValue)
|
return fmt.Errorf("glfw: invalid OpenGL version %d.%d: %w", ctxconfig.major, ctxconfig.minor, InvalidValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.profile != 0 {
|
if ctxconfig.profile != 0 {
|
||||||
if ctxconfig.profile != OpenGLCoreProfile && ctxconfig.profile != OpenGLCompatProfile {
|
if ctxconfig.profile != OpenGLCoreProfile && ctxconfig.profile != OpenGLCompatProfile {
|
||||||
return fmt.Errorf("goglfw: invalid OpenGL profile 0x%08X: %w", ctxconfig.profile, InvalidEnum)
|
return fmt.Errorf("glfw: invalid OpenGL profile 0x%08X: %w", ctxconfig.profile, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.major <= 2 || (ctxconfig.major == 3 && ctxconfig.minor < 2) {
|
if ctxconfig.major <= 2 || (ctxconfig.major == 3 && ctxconfig.minor < 2) {
|
||||||
// Desktop OpenGL context profiles are only defined for version 3.2
|
// Desktop OpenGL context profiles are only defined for version 3.2
|
||||||
// and above
|
// and above
|
||||||
|
|
||||||
return fmt.Errorf("goglfw: context profiles are only defined for OpenGL version 3.2 and above: %w", InvalidValue)
|
return fmt.Errorf("glfw: context profiles are only defined for OpenGL version 3.2 and above: %w", InvalidValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.forward && ctxconfig.major <= 2 {
|
if ctxconfig.forward && ctxconfig.major <= 2 {
|
||||||
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
||||||
return fmt.Errorf("goglfw: forward-compatibility is only defined for OpenGL version 3.0 and above: %w", InvalidValue)
|
return fmt.Errorf("glfw: forward-compatibility is only defined for OpenGL version 3.0 and above: %w", InvalidValue)
|
||||||
}
|
}
|
||||||
} else if ctxconfig.client == OpenGLESAPI {
|
} else if ctxconfig.client == OpenGLESAPI {
|
||||||
if ctxconfig.major < 1 || ctxconfig.minor < 0 ||
|
if ctxconfig.major < 1 || ctxconfig.minor < 0 ||
|
||||||
@ -75,19 +75,19 @@ func checkValidContextConfig(ctxconfig *ctxconfig) error {
|
|||||||
// OpenGL ES 2.x series ended with version 2.0
|
// OpenGL ES 2.x series ended with version 2.0
|
||||||
// For now, let everything else through
|
// For now, let everything else through
|
||||||
|
|
||||||
return fmt.Errorf("goglfw: invalid OpenGL ES version %d.%d: %w", ctxconfig.major, ctxconfig.minor, InvalidValue)
|
return fmt.Errorf("glfw: invalid OpenGL ES version %d.%d: %w", ctxconfig.major, ctxconfig.minor, InvalidValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.robustness != 0 {
|
if ctxconfig.robustness != 0 {
|
||||||
if ctxconfig.robustness != NoResetNotification && ctxconfig.robustness != LoseContextOnReset {
|
if ctxconfig.robustness != NoResetNotification && ctxconfig.robustness != LoseContextOnReset {
|
||||||
return fmt.Errorf("goglfw: invalid context robustness mode 0x%08X: %w", ctxconfig.robustness, InvalidEnum)
|
return fmt.Errorf("glfw: invalid context robustness mode 0x%08X: %w", ctxconfig.robustness, InvalidEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.release != 0 {
|
if ctxconfig.release != 0 {
|
||||||
if ctxconfig.release != ReleaseBehaviorNone && ctxconfig.release != ReleaseBehaviorFlush {
|
if ctxconfig.release != ReleaseBehaviorNone && ctxconfig.release != ReleaseBehaviorFlush {
|
||||||
return fmt.Errorf("goglfw: invalid context release behavior 0x%08X: %w", ctxconfig.release, InvalidEnum)
|
return fmt.Errorf("glfw: invalid context release behavior 0x%08X: %w", ctxconfig.release, InvalidEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,16 +267,16 @@ func (w *Window) refreshContextAttribs(ctxconfig *ctxconfig) (ferr error) {
|
|||||||
getIntegerv := w.context.getProcAddress("glGetIntegerv")
|
getIntegerv := w.context.getProcAddress("glGetIntegerv")
|
||||||
getString := w.context.getProcAddress("glGetString")
|
getString := w.context.getProcAddress("glGetString")
|
||||||
if getIntegerv == 0 || getString == 0 {
|
if getIntegerv == 0 || getString == 0 {
|
||||||
return fmt.Errorf("goglfw: entry point retrieval is broken: %w", PlatformError)
|
return fmt.Errorf("glfw: entry point retrieval is broken: %w", PlatformError)
|
||||||
}
|
}
|
||||||
|
|
||||||
r, _, _ := purego.SyscallN(getString, GL_VERSION)
|
r, _, _ := purego.SyscallN(getString, GL_VERSION)
|
||||||
version := bytePtrToString((*byte)(unsafe.Pointer(r)))
|
version := bytePtrToString((*byte)(unsafe.Pointer(r)))
|
||||||
if version == "" {
|
if version == "" {
|
||||||
if ctxconfig.client == OpenGLAPI {
|
if ctxconfig.client == OpenGLAPI {
|
||||||
return fmt.Errorf("goglfw: OpenGL version string retrieval is broken: %w", PlatformError)
|
return fmt.Errorf("glfw: OpenGL version string retrieval is broken: %w", PlatformError)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("goglfw: OpenGL ES version string retrieval is broken: %w", PlatformError)
|
return fmt.Errorf("glfw: OpenGL ES version string retrieval is broken: %w", PlatformError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,9 +294,9 @@ func (w *Window) refreshContextAttribs(ctxconfig *ctxconfig) (ferr error) {
|
|||||||
m := regexp.MustCompile(`^(\d+)(\.(\d+)(\.(\d+))?)?`).FindStringSubmatch(version)
|
m := regexp.MustCompile(`^(\d+)(\.(\d+)(\.(\d+))?)?`).FindStringSubmatch(version)
|
||||||
if m == nil {
|
if m == nil {
|
||||||
if w.context.client == OpenGLAPI {
|
if w.context.client == OpenGLAPI {
|
||||||
return fmt.Errorf("goglfw: no version found in OpenGL version string: %w", PlatformError)
|
return fmt.Errorf("glfw: no version found in OpenGL version string: %w", PlatformError)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("goglfw: no version found in OpenGL ES version string: %w", PlatformError)
|
return fmt.Errorf("glfw: no version found in OpenGL ES version string: %w", PlatformError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.context.major, _ = strconv.Atoi(m[1])
|
w.context.major, _ = strconv.Atoi(m[1])
|
||||||
@ -312,9 +312,9 @@ func (w *Window) refreshContextAttribs(ctxconfig *ctxconfig) (ferr error) {
|
|||||||
// {GLX|WGL}_ARB_create_context extension and fail here
|
// {GLX|WGL}_ARB_create_context extension and fail here
|
||||||
|
|
||||||
if w.context.client == OpenGLAPI {
|
if w.context.client == OpenGLAPI {
|
||||||
return fmt.Errorf("goglfw: requested OpenGL version %d.%d, got version %d.%d: %w", ctxconfig.major, ctxconfig.minor, w.context.major, w.context.minor, VersionUnavailable)
|
return fmt.Errorf("glfw: requested OpenGL version %d.%d, got version %d.%d: %w", ctxconfig.major, ctxconfig.minor, w.context.major, w.context.minor, VersionUnavailable)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("goglfw: requested OpenGL ES version %d.%d, got version %d.%d: %w", ctxconfig.major, ctxconfig.minor, w.context.major, w.context.minor, VersionUnavailable)
|
return fmt.Errorf("glfw: requested OpenGL ES version %d.%d, got version %d.%d: %w", ctxconfig.major, ctxconfig.minor, w.context.major, w.context.minor, VersionUnavailable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ func (w *Window) refreshContextAttribs(ctxconfig *ctxconfig) (ferr error) {
|
|||||||
|
|
||||||
glGetStringi := w.context.getProcAddress("glGetStringi")
|
glGetStringi := w.context.getProcAddress("glGetStringi")
|
||||||
if glGetStringi == 0 {
|
if glGetStringi == 0 {
|
||||||
return fmt.Errorf("goglfw: entry point retrieval is broken: %w", PlatformError)
|
return fmt.Errorf("glfw: entry point retrieval is broken: %w", PlatformError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ func (w *Window) MakeContextCurrent() error {
|
|||||||
previous := (*Window)(unsafe.Pointer(ptr))
|
previous := (*Window)(unsafe.Pointer(ptr))
|
||||||
|
|
||||||
if w != nil && w.context.client == NoAPI {
|
if w != nil && w.context.client == NoAPI {
|
||||||
return fmt.Errorf("goglfw: cannot make current with a window that has no OpenGL or OpenGL ES context: %w", NoWindowContext)
|
return fmt.Errorf("glfw: cannot make current with a window that has no OpenGL or OpenGL ES context: %w", NoWindowContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
if previous != nil {
|
if previous != nil {
|
||||||
@ -499,7 +499,7 @@ func (w *Window) SwapBuffers() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if w.context.client == NoAPI {
|
if w.context.client == NoAPI {
|
||||||
return fmt.Errorf("goglfw: cannot swap buffers of a window that has no OpenGL or OpenGL ES context: %w", NoWindowContext)
|
return fmt.Errorf("glfw: cannot swap buffers of a window that has no OpenGL or OpenGL ES context: %w", NoWindowContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := w.context.swapBuffers(w); err != nil {
|
if err := w.context.swapBuffers(w); err != nil {
|
||||||
@ -519,7 +519,7 @@ func SwapInterval(interval int) error {
|
|||||||
}
|
}
|
||||||
window := (*Window)(unsafe.Pointer(ptr))
|
window := (*Window)(unsafe.Pointer(ptr))
|
||||||
if window == nil {
|
if window == nil {
|
||||||
return fmt.Errorf("goglfw: cannot set swap interval without a current OpenGL or OpenGL ES context %w", NoCurrentContext)
|
return fmt.Errorf("glfw: cannot set swap interval without a current OpenGL or OpenGL ES context %w", NoCurrentContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := window.context.swapInterval(interval); err != nil {
|
if err := window.context.swapInterval(interval); err != nil {
|
||||||
@ -544,7 +544,7 @@ func ExtensionSupported(extension string) (bool, error) {
|
|||||||
}
|
}
|
||||||
window := (*Window)(unsafe.Pointer(ptr))
|
window := (*Window)(unsafe.Pointer(ptr))
|
||||||
if window == nil {
|
if window == nil {
|
||||||
return false, fmt.Errorf("goglfw: cannot query extension without a current OpenGL or OpenGL ES context %w", NoCurrentContext)
|
return false, fmt.Errorf("glfw: cannot query extension without a current OpenGL or OpenGL ES context %w", NoCurrentContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
if window.context.major >= 3 {
|
if window.context.major >= 3 {
|
||||||
@ -558,7 +558,7 @@ func ExtensionSupported(extension string) (bool, error) {
|
|||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < int(count); i++ {
|
||||||
r, _, _ := purego.SyscallN(glGetStringi, GL_EXTENSIONS, uintptr(i))
|
r, _, _ := purego.SyscallN(glGetStringi, GL_EXTENSIONS, uintptr(i))
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
return false, fmt.Errorf("goglfw: extension string retrieval is broken: %w", PlatformError)
|
return false, fmt.Errorf("glfw: extension string retrieval is broken: %w", PlatformError)
|
||||||
}
|
}
|
||||||
|
|
||||||
en := bytePtrToString((*byte)(unsafe.Pointer(r)))
|
en := bytePtrToString((*byte)(unsafe.Pointer(r)))
|
||||||
@ -572,7 +572,7 @@ func ExtensionSupported(extension string) (bool, error) {
|
|||||||
glGetString := window.context.getProcAddress("glGetString")
|
glGetString := window.context.getProcAddress("glGetString")
|
||||||
r, _, _ := purego.SyscallN(glGetString, GL_EXTENSIONS)
|
r, _, _ := purego.SyscallN(glGetString, GL_EXTENSIONS)
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
return false, fmt.Errorf("goglfw: extension string retrieval is broken: %w", PlatformError)
|
return false, fmt.Errorf("glfw: extension string retrieval is broken: %w", PlatformError)
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions := bytePtrToString((*byte)(unsafe.Pointer(r)))
|
extensions := bytePtrToString((*byte)(unsafe.Pointer(r)))
|
21
internal/glfw/glfw3h_windows.go
Normal file
21
internal/glfw/glfw3h_windows.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// SPDX-FileCopyrightText: 2002-2006 Marcus Geelnard
|
||||||
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
|
package glfw
|
||||||
|
|
||||||
|
type VidMode struct {
|
||||||
|
Width int
|
||||||
|
Height int
|
||||||
|
RedBits int
|
||||||
|
GreenBits int
|
||||||
|
BlueBits int
|
||||||
|
RefreshRate int
|
||||||
|
}
|
||||||
|
|
||||||
|
type Image struct {
|
||||||
|
Width int
|
||||||
|
Height int
|
||||||
|
Pixels []byte
|
||||||
|
}
|
@ -61,9 +61,9 @@ type Cursor struct {
|
|||||||
c *cglfw.Cursor
|
c *cglfw.Cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateStandardCursor(shape StandardCursor) *Cursor {
|
func CreateStandardCursor(shape StandardCursor) (*Cursor, error) {
|
||||||
c := cglfw.CreateStandardCursor(cglfw.StandardCursor(shape))
|
c := cglfw.CreateStandardCursor(cglfw.StandardCursor(shape))
|
||||||
return &Cursor{c: c}
|
return &Cursor{c: c}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Monitor struct {
|
type Monitor struct {
|
||||||
@ -75,14 +75,15 @@ func (m *Monitor) GetContentScale() (float32, float32, error) {
|
|||||||
return x, y, nil
|
return x, y, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Monitor) GetPos() (x, y int) {
|
func (m *Monitor) GetPos() (x, y int, err error) {
|
||||||
return m.m.GetPos()
|
x, y = m.m.GetPos()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Monitor) GetVideoMode() *VidMode {
|
func (m *Monitor) GetVideoMode() (*VidMode, error) {
|
||||||
v := m.m.GetVideoMode()
|
v := m.m.GetVideoMode()
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return &VidMode{
|
return &VidMode{
|
||||||
Width: v.Width,
|
Width: v.Width,
|
||||||
@ -91,11 +92,11 @@ func (m *Monitor) GetVideoMode() *VidMode {
|
|||||||
GreenBits: v.GreenBits,
|
GreenBits: v.GreenBits,
|
||||||
BlueBits: v.BlueBits,
|
BlueBits: v.BlueBits,
|
||||||
RefreshRate: v.RefreshRate,
|
RefreshRate: v.RefreshRate,
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Monitor) GetName() string {
|
func (m *Monitor) GetName() (string, error) {
|
||||||
return m.m.GetName()
|
return m.m.GetName(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Window struct {
|
type Window struct {
|
||||||
@ -109,164 +110,181 @@ func (w *Window) Destroy() {
|
|||||||
theWindows.remove(w.w)
|
theWindows.remove(w.w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Focus() {
|
func (w *Window) Focus() error {
|
||||||
w.w.Focus()
|
w.w.Focus()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetAttrib(attrib Hint) int {
|
func (w *Window) GetAttrib(attrib Hint) (int, error) {
|
||||||
return w.w.GetAttrib(cglfw.Hint(attrib))
|
return w.w.GetAttrib(cglfw.Hint(attrib)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetCursorPos() (x, y float64) {
|
func (w *Window) GetCursorPos() (x, y float64, err error) {
|
||||||
return w.w.GetCursorPos()
|
x, y = w.w.GetCursorPos()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetInputMode(mode InputMode) int {
|
func (w *Window) GetInputMode(mode InputMode) (int, error) {
|
||||||
return w.w.GetInputMode(cglfw.InputMode(mode))
|
return w.w.GetInputMode(cglfw.InputMode(mode)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetKey(key Key) Action {
|
func (w *Window) GetKey(key Key) (Action, error) {
|
||||||
return Action(w.w.GetKey(cglfw.Key(key)))
|
return Action(w.w.GetKey(cglfw.Key(key))), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetMonitor() *Monitor {
|
func (w *Window) GetMonitor() (*Monitor, error) {
|
||||||
m := w.w.GetMonitor()
|
m := w.w.GetMonitor()
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return &Monitor{m}
|
return &Monitor{m}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetMouseButton(button MouseButton) Action {
|
func (w *Window) GetMouseButton(button MouseButton) (Action, error) {
|
||||||
return Action(w.w.GetMouseButton(cglfw.MouseButton(button)))
|
return Action(w.w.GetMouseButton(cglfw.MouseButton(button))), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetPos() (x, y int) {
|
func (w *Window) GetPos() (x, y int, err error) {
|
||||||
return w.w.GetPos()
|
x, y = w.w.GetPos()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetSize() (width, height int) {
|
func (w *Window) GetSize() (width, height int, err error) {
|
||||||
return w.w.GetSize()
|
width, height = w.w.GetSize()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Hide() {
|
func (w *Window) Hide() {
|
||||||
w.w.Hide()
|
w.w.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Iconify() {
|
func (w *Window) Iconify() error {
|
||||||
w.w.Iconify()
|
w.w.Iconify()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) MakeContextCurrent() {
|
func (w *Window) MakeContextCurrent() error {
|
||||||
w.w.MakeContextCurrent()
|
w.w.MakeContextCurrent()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Maximize() {
|
func (w *Window) Maximize() error {
|
||||||
w.w.Maximize()
|
w.w.Maximize()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Restore() {
|
func (w *Window) Restore() error {
|
||||||
w.w.Restore()
|
w.w.Restore()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetAttrib(attrib Hint, value int) {
|
func (w *Window) SetAttrib(attrib Hint, value int) error {
|
||||||
w.w.SetAttrib(cglfw.Hint(attrib), value)
|
w.w.SetAttrib(cglfw.Hint(attrib), value)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback) {
|
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback, err error) {
|
||||||
w.w.SetCharModsCallback(cbfun)
|
w.w.SetCharModsCallback(cbfun)
|
||||||
return ToCharModsCallback(nil) // TODO
|
return ToCharModsCallback(nil), nil // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback) {
|
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback, err error) {
|
||||||
w.w.SetCloseCallback(cbfun)
|
w.w.SetCloseCallback(cbfun)
|
||||||
return ToCloseCallback(nil) // TODO
|
return ToCloseCallback(nil), nil // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetCursor(cursor *Cursor) {
|
func (w *Window) SetCursor(cursor *Cursor) error {
|
||||||
var c *cglfw.Cursor
|
var c *cglfw.Cursor
|
||||||
if cursor != nil {
|
if cursor != nil {
|
||||||
c = cursor.c
|
c = cursor.c
|
||||||
}
|
}
|
||||||
w.w.SetCursor(c)
|
w.w.SetCursor(c)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetCursorPos(xpos, ypos float64) {
|
func (w *Window) SetCursorPos(xpos, ypos float64) error {
|
||||||
w.w.SetCursorPos(xpos, ypos)
|
w.w.SetCursorPos(xpos, ypos)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback, err error) {
|
||||||
w.w.SetDropCallback(cbfun)
|
w.w.SetDropCallback(cbfun)
|
||||||
return ToDropCallback(nil) // TODO
|
return ToDropCallback(nil), nil // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback) {
|
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback, err error) {
|
||||||
w.w.SetFramebufferSizeCallback(cbfun)
|
w.w.SetFramebufferSizeCallback(cbfun)
|
||||||
return ToFramebufferSizeCallback(nil) // TODO
|
return ToFramebufferSizeCallback(nil), nil // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback) {
|
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback, err error) {
|
||||||
w.w.SetScrollCallback(cbfun)
|
w.w.SetScrollCallback(cbfun)
|
||||||
return ToScrollCallback(nil) // TODO
|
return ToScrollCallback(nil), nil // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetShouldClose(value bool) {
|
func (w *Window) SetShouldClose(value bool) error {
|
||||||
w.w.SetShouldClose(value)
|
w.w.SetShouldClose(value)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback) {
|
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback, err error) {
|
||||||
w.w.SetSizeCallback(cbfun)
|
w.w.SetSizeCallback(cbfun)
|
||||||
prev := w.prevSizeCallback
|
prev := w.prevSizeCallback
|
||||||
w.prevSizeCallback = cbfun
|
w.prevSizeCallback = cbfun
|
||||||
return prev
|
return prev, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) error {
|
||||||
w.w.SetSizeLimits(minw, minh, maxw, maxh)
|
w.w.SetSizeLimits(minw, minh, maxw, maxh)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetAspectRatio(numer, denom int) {
|
func (w *Window) SetIcon(images []image.Image) error {
|
||||||
w.w.SetAspectRatio(numer, denom)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetIcon(images []image.Image) {
|
|
||||||
w.w.SetIcon(images)
|
w.w.SetIcon(images)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetInputMode(mode InputMode, value int) {
|
func (w *Window) SetInputMode(mode InputMode, value int) error {
|
||||||
w.w.SetInputMode(cglfw.InputMode(mode), value)
|
w.w.SetInputMode(cglfw.InputMode(mode), value)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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 *cglfw.Monitor
|
var m *cglfw.Monitor
|
||||||
if monitor != nil {
|
if monitor != nil {
|
||||||
m = monitor.m
|
m = monitor.m
|
||||||
}
|
}
|
||||||
w.w.SetMonitor(m, xpos, ypos, width, height, refreshRate)
|
w.w.SetMonitor(m, xpos, ypos, width, height, refreshRate)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetPos(xpos, ypos int) {
|
func (w *Window) SetPos(xpos, ypos int) error {
|
||||||
w.w.SetPos(xpos, ypos)
|
w.w.SetPos(xpos, ypos)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetSize(width, height int) {
|
func (w *Window) SetSize(width, height int) error {
|
||||||
w.w.SetSize(width, height)
|
w.w.SetSize(width, height)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetTitle(title string) {
|
func (w *Window) SetTitle(title string) error {
|
||||||
w.w.SetTitle(title)
|
w.w.SetTitle(title)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) ShouldClose() bool {
|
func (w *Window) ShouldClose() (bool, error) {
|
||||||
return w.w.ShouldClose()
|
return w.w.ShouldClose(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) Show() {
|
func (w *Window) Show() error {
|
||||||
w.w.Show()
|
w.w.Show()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SwapBuffers() {
|
func (w *Window) SwapBuffers() error {
|
||||||
w.w.SwapBuffers()
|
w.w.SwapBuffers()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateWindow(width, height int, title string, monitor *Monitor, share *Window) (*Window, error) {
|
func CreateWindow(width, height int, title string, monitor *Monitor, share *Window) (*Window, error) {
|
||||||
@ -286,12 +304,12 @@ func CreateWindow(width, height int, title string, monitor *Monitor, share *Wind
|
|||||||
return theWindows.add(w), nil
|
return theWindows.add(w), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetKeyName(key Key, scancode int) string {
|
func GetKeyName(key Key, scancode int) (string, error) {
|
||||||
return cglfw.GetKeyName(cglfw.Key(key), scancode)
|
return cglfw.GetKeyName(cglfw.Key(key), scancode), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMonitors() []*Monitor {
|
func GetMonitors() ([]*Monitor, error) {
|
||||||
ms := []*Monitor{}
|
var ms []*Monitor
|
||||||
for _, m := range cglfw.GetMonitors() {
|
for _, m := range cglfw.GetMonitors() {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
ms = append(ms, &Monitor{m})
|
ms = append(ms, &Monitor{m})
|
||||||
@ -299,7 +317,7 @@ func GetMonitors() []*Monitor {
|
|||||||
ms = append(ms, nil)
|
ms = append(ms, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ms
|
return ms, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPrimaryMonitor() *Monitor {
|
func GetPrimaryMonitor() *Monitor {
|
||||||
@ -314,35 +332,41 @@ func Init() error {
|
|||||||
return cglfw.Init()
|
return cglfw.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
func PollEvents() {
|
func PollEvents() error {
|
||||||
cglfw.PollEvents()
|
cglfw.PollEvents()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PostEmptyEvent() {
|
func PostEmptyEvent() error {
|
||||||
cglfw.PostEmptyEvent()
|
cglfw.PostEmptyEvent()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetMonitorCallback(cbfun MonitorCallback) MonitorCallback {
|
func SetMonitorCallback(cbfun MonitorCallback) (MonitorCallback, error) {
|
||||||
cglfw.SetMonitorCallback(cbfun)
|
cglfw.SetMonitorCallback(cbfun)
|
||||||
return ToMonitorCallback(nil)
|
return ToMonitorCallback(nil), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SwapInterval(interval int) {
|
func SwapInterval(interval int) error {
|
||||||
cglfw.SwapInterval(interval)
|
cglfw.SwapInterval(interval)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Terminate() {
|
func Terminate() error {
|
||||||
cglfw.Terminate()
|
cglfw.Terminate()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitEvents() {
|
func WaitEvents() error {
|
||||||
cglfw.WaitEvents()
|
cglfw.WaitEvents()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitEventsTimeout(timeout float64) {
|
func WaitEventsTimeout(timeout float64) {
|
||||||
cglfw.WaitEventsTimeout(timeout)
|
cglfw.WaitEventsTimeout(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WindowHint(target Hint, hint int) {
|
func WindowHint(target Hint, hint int) error {
|
||||||
cglfw.WindowHint(cglfw.Hint(target), hint)
|
cglfw.WindowHint(cglfw.Hint(target), hint)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,416 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package glfw
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"image"
|
|
||||||
"image/draw"
|
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/goglfw"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Cursor goglfw.Cursor
|
|
||||||
|
|
||||||
func CreateStandardCursor(shape StandardCursor) *Cursor {
|
|
||||||
c, err := goglfw.CreateStandardCursor(goglfw.StandardCursor(shape))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return (*Cursor)(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Monitor goglfw.Monitor
|
|
||||||
|
|
||||||
func (m *Monitor) GetContentScale() (float32, float32, error) {
|
|
||||||
return (*goglfw.Monitor)(m).GetContentScale()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Monitor) GetPos() (int, int) {
|
|
||||||
x, y, err := (*goglfw.Monitor)(m).GetPos()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return x, y
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Monitor) GetVideoMode() *VidMode {
|
|
||||||
v, err := (*goglfw.Monitor)(m).GetVideoMode()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return (*VidMode)(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Monitor) GetName() string {
|
|
||||||
v, err := (*goglfw.Monitor)(m).GetName()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
type Window goglfw.Window
|
|
||||||
|
|
||||||
func (w *Window) Destroy() {
|
|
||||||
if err := (*goglfw.Window)(w).Destroy(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) Focus() {
|
|
||||||
if err := (*goglfw.Window)(w).Focus(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetAttrib(attrib Hint) int {
|
|
||||||
r, err := (*goglfw.Window)(w).GetAttrib(goglfw.Hint(attrib))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetCursorPos() (x, y float64) {
|
|
||||||
x, y, err := (*goglfw.Window)(w).GetCursorPos()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return x, y
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetInputMode(mode InputMode) int {
|
|
||||||
r, err := (*goglfw.Window)(w).GetInputMode(goglfw.InputMode(mode))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetKey(key Key) Action {
|
|
||||||
r, err := (*goglfw.Window)(w).GetKey(goglfw.Key(key))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return Action(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetMonitor() *Monitor {
|
|
||||||
m, err := (*goglfw.Window)(w).GetMonitor()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return (*Monitor)(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetMouseButton(button MouseButton) Action {
|
|
||||||
r, err := (*goglfw.Window)(w).GetMouseButton(goglfw.MouseButton(button))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return Action(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetPos() (int, int) {
|
|
||||||
x, y, err := (*goglfw.Window)(w).GetPos()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return x, y
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) GetSize() (int, int) {
|
|
||||||
width, height, err := (*goglfw.Window)(w).GetSize()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return width, height
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) Hide() {
|
|
||||||
if err := (*goglfw.Window)(w).Hide(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) Iconify() {
|
|
||||||
if err := (*goglfw.Window)(w).Iconify(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) MakeContextCurrent() {
|
|
||||||
if err := (*goglfw.Window)(w).MakeContextCurrent(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) Maximize() {
|
|
||||||
if err := (*goglfw.Window)(w).Maximize(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) Restore() {
|
|
||||||
if err := (*goglfw.Window)(w).Restore(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetAttrib(attrib Hint, value int) {
|
|
||||||
if err := (*goglfw.Window)(w).SetAttrib(goglfw.Hint(attrib), value); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback) {
|
|
||||||
f, err := (*goglfw.Window)(w).SetCharModsCallback(cbfun)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback) {
|
|
||||||
f, err := (*goglfw.Window)(w).SetCloseCallback(cbfun)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetCursor(cursor *Cursor) {
|
|
||||||
if err := (*goglfw.Window)(w).SetCursor((*goglfw.Cursor)(cursor)); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetCursorPos(xpos, ypos float64) {
|
|
||||||
if err := (*goglfw.Window)(w).SetCursorPos(xpos, ypos); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
|
||||||
f, err := (*goglfw.Window)(w).SetDropCallback(cbfun)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback) {
|
|
||||||
f, err := (*goglfw.Window)(w).SetFramebufferSizeCallback(cbfun)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback) {
|
|
||||||
f, err := (*goglfw.Window)(w).SetScrollCallback(cbfun)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetShouldClose(value bool) {
|
|
||||||
if err := (*goglfw.Window)(w).SetShouldClose(value); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback) {
|
|
||||||
f, err := (*goglfw.Window)(w).SetSizeCallback(cbfun)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
|
|
||||||
if err := (*goglfw.Window)(w).SetSizeLimits(minw, minh, maxw, maxh); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetAspectRatio(numer, denom int) {
|
|
||||||
if err := (*goglfw.Window)(w).SetAspectRatio(numer, denom); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetIcon(images []image.Image) {
|
|
||||||
gimgs := make([]*goglfw.Image, len(images))
|
|
||||||
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] = &goglfw.Image{
|
|
||||||
Width: b.Dx(),
|
|
||||||
Height: b.Dy(),
|
|
||||||
Pixels: m.Pix,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := (*goglfw.Window)(w).SetIcon(gimgs); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetInputMode(mode InputMode, value int) {
|
|
||||||
if err := (*goglfw.Window)(w).SetInputMode(goglfw.InputMode(mode), value); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int) {
|
|
||||||
if err := (*goglfw.Window)(w).SetMonitor((*goglfw.Monitor)(monitor), xpos, ypos, width, height, refreshRate); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetPos(xpos, ypos int) {
|
|
||||||
if err := (*goglfw.Window)(w).SetPos(xpos, ypos); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetSize(width, height int) {
|
|
||||||
if err := (*goglfw.Window)(w).SetSize(width, height); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SetTitle(title string) {
|
|
||||||
if err := (*goglfw.Window)(w).SetTitle(title); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) ShouldClose() bool {
|
|
||||||
r, err := (*goglfw.Window)(w).ShouldClose()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) Show() {
|
|
||||||
if err := (*goglfw.Window)(w).Show(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Window) SwapBuffers() {
|
|
||||||
if err := (*goglfw.Window)(w).SwapBuffers(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateWindow(width, height int, title string, monitor *Monitor, share *Window) (*Window, error) {
|
|
||||||
w, err := goglfw.CreateWindow(width, height, title, (*goglfw.Monitor)(monitor), (*goglfw.Window)(share))
|
|
||||||
// TODO: acceptError(APIUnavailable, VersionUnavailable)?
|
|
||||||
return (*Window)(w), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetKeyName(key Key, scancode int) string {
|
|
||||||
name, err := goglfw.GetKeyName(goglfw.Key(key), scancode)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetMonitors() []*Monitor {
|
|
||||||
ms, err := goglfw.GetMonitors()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
result := make([]*Monitor, 0, len(ms))
|
|
||||||
for _, m := range ms {
|
|
||||||
result = append(result, (*Monitor)(m))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetPrimaryMonitor() *Monitor {
|
|
||||||
m, err := goglfw.GetPrimaryMonitor()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return (*Monitor)(m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Init() error {
|
|
||||||
// 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
|
|
||||||
// (#1229).
|
|
||||||
// TODO: acceptError(APIUnavailable, InvalidValue)?
|
|
||||||
err := goglfw.Init()
|
|
||||||
if err != nil && !errors.Is(err, goglfw.InvalidValue) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func PollEvents() {
|
|
||||||
if err := goglfw.PollEvents(); err != nil && !errors.Is(err, goglfw.InvalidValue) {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func PostEmptyEvent() {
|
|
||||||
if err := goglfw.PostEmptyEvent(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetMonitorCallback(cbfun MonitorCallback) MonitorCallback {
|
|
||||||
f, err := goglfw.SetMonitorCallback(cbfun)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func SwapInterval(interval int) {
|
|
||||||
if err := goglfw.SwapInterval(interval); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Terminate() {
|
|
||||||
if err := goglfw.Terminate(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WaitEvents() {
|
|
||||||
if err := goglfw.WaitEvents(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WindowHint(target Hint, hint int) {
|
|
||||||
if err := goglfw.WindowHint(goglfw.Hint(target), hint); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,11 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
func terminate() error {
|
func terminate() error {
|
||||||
for _, w := range _glfw.windows {
|
for _, w := range _glfw.windows {
|
||||||
@ -36,6 +40,14 @@ func terminate() error {
|
|||||||
func Init() (ferr error) {
|
func Init() (ferr error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
|
// 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
|
||||||
|
// (#1229).
|
||||||
|
if errors.Is(ferr, InvalidValue) {
|
||||||
|
ferr = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
_ = terminate()
|
_ = terminate()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -142,7 +142,7 @@ func (w *Window) GetInputMode(mode InputMode) (int, error) {
|
|||||||
case RawMouseMotion:
|
case RawMouseMotion:
|
||||||
return boolToInt(w.rawMouseMotion), nil
|
return boolToInt(w.rawMouseMotion), nil
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("goglfw: invalid input mode 0x%08X: %w", mode, InvalidEnum)
|
return 0, fmt.Errorf("glfw: invalid input mode 0x%08X: %w", mode, InvalidEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ func (w *Window) SetInputMode(mode InputMode, value int) error {
|
|||||||
switch mode {
|
switch mode {
|
||||||
case CursorMode:
|
case CursorMode:
|
||||||
if value != CursorNormal && value != CursorHidden && value != CursorDisabled {
|
if value != CursorNormal && value != CursorHidden && value != CursorDisabled {
|
||||||
return fmt.Errorf("goglfw: invalid cursor mode 0x%08X: %w", value, InvalidEnum)
|
return fmt.Errorf("glfw: invalid cursor mode 0x%08X: %w", value, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.cursorMode == value {
|
if w.cursorMode == value {
|
||||||
@ -215,7 +215,7 @@ func (w *Window) SetInputMode(mode InputMode, value int) error {
|
|||||||
|
|
||||||
case RawMouseMotion:
|
case RawMouseMotion:
|
||||||
if !platformRawMouseMotionSupported() {
|
if !platformRawMouseMotionSupported() {
|
||||||
return fmt.Errorf("goglfw: raw mouse motion is not supported on this system: %w", PlatformError)
|
return fmt.Errorf("glfw: raw mouse motion is not supported on this system: %w", PlatformError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.rawMouseMotion == intToBool(value) {
|
if w.rawMouseMotion == intToBool(value) {
|
||||||
@ -229,7 +229,7 @@ func (w *Window) SetInputMode(mode InputMode, value int) error {
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("goglfw: invalid input mode 0x%08X: %w", mode, InvalidEnum)
|
return fmt.Errorf("glfw: invalid input mode 0x%08X: %w", mode, InvalidEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ func GetKeyScancode(key Key) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if key < KeySpace || key > KeyLast {
|
if key < KeySpace || key > KeyLast {
|
||||||
return 0, fmt.Errorf("goglfw: invalid key %d: %w", key, InvalidEnum)
|
return 0, fmt.Errorf("glfw: invalid key %d: %w", key, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
return platformGetKeyScancode(key), nil
|
return platformGetKeyScancode(key), nil
|
||||||
@ -273,7 +273,7 @@ func (w *Window) GetKey(key Key) (Action, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if key < KeySpace || key > KeyLast {
|
if key < KeySpace || key > KeyLast {
|
||||||
return 0, fmt.Errorf("goglfw: invalid key %d: %w", key, InvalidEnum)
|
return 0, fmt.Errorf("glfw: invalid key %d: %w", key, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.keys[key] == stick {
|
if w.keys[key] == stick {
|
||||||
@ -291,7 +291,7 @@ func (w *Window) GetMouseButton(button MouseButton) (Action, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if button < MouseButton1 || button > MouseButtonLast {
|
if button < MouseButton1 || button > MouseButtonLast {
|
||||||
return 0, fmt.Errorf("goglfw: invalid mouse button %d: %w", button, InvalidEnum)
|
return 0, fmt.Errorf("glfw: invalid mouse button %d: %w", button, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.mouseButtons[button] == stick {
|
if w.mouseButtons[button] == stick {
|
||||||
@ -321,7 +321,7 @@ func (w *Window) SetCursorPos(xpos, ypos float64) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if xpos != xpos || xpos < -math.MaxFloat64 || xpos > math.MaxFloat64 || ypos != ypos || ypos < -math.MaxFloat64 || ypos > math.MaxFloat64 {
|
if xpos != xpos || xpos < -math.MaxFloat64 || xpos > math.MaxFloat64 || ypos != ypos || ypos < -math.MaxFloat64 || ypos > math.MaxFloat64 {
|
||||||
return fmt.Errorf("goglfw: invalid cursor position %f %f: %w", xpos, ypos, InvalidValue)
|
return fmt.Errorf("glfw: invalid cursor position %f %f: %w", xpos, ypos, InvalidValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !w.platformWindowFocused() {
|
if !w.platformWindowFocused() {
|
||||||
@ -354,7 +354,7 @@ func CreateStandardCursor(shape StandardCursor) (*Cursor, error) {
|
|||||||
shape != ResizeNESWCursor &&
|
shape != ResizeNESWCursor &&
|
||||||
shape != ResizeAllCursor &&
|
shape != ResizeAllCursor &&
|
||||||
shape != NotAllowedCursor {
|
shape != NotAllowedCursor {
|
||||||
return nil, fmt.Errorf("goglfw: invalid standard cursor 0x%08X: %w", shape, InvalidEnum)
|
return nil, fmt.Errorf("glfw: invalid standard cursor 0x%08X: %w", shape, InvalidEnum)
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor := &Cursor{}
|
cursor := &Cursor{}
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"sort"
|
@ -1,27 +0,0 @@
|
|||||||
// 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 (
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/goglfw"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (w *Window) GetWin32Window() uintptr {
|
|
||||||
r, err := (*goglfw.Window)(w).GetWin32Window()
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return uintptr(r)
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package glfw
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/goglfw"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
CharModsCallback = goglfw.CharModsCallback
|
|
||||||
CloseCallback = goglfw.CloseCallback
|
|
||||||
DropCallback = goglfw.DropCallback
|
|
||||||
FramebufferSizeCallback = goglfw.FramebufferSizeCallback
|
|
||||||
MonitorCallback = goglfw.MonitorCallback
|
|
||||||
ScrollCallback = goglfw.ScrollCallback
|
|
||||||
SizeCallback = goglfw.SizeCallback
|
|
||||||
)
|
|
||||||
|
|
||||||
type VidMode goglfw.VidMode
|
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -221,12 +221,12 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(usableConfigs) == 0 {
|
if len(usableConfigs) == 0 {
|
||||||
return 0, fmt.Errorf("goglfw: the driver does not appear to support OpenGL")
|
return 0, fmt.Errorf("glfw: the driver does not appear to support OpenGL")
|
||||||
}
|
}
|
||||||
|
|
||||||
closest := chooseFBConfig(fbconfig_, usableConfigs)
|
closest := chooseFBConfig(fbconfig_, usableConfigs)
|
||||||
if closest == nil {
|
if closest == nil {
|
||||||
return 0, fmt.Errorf("goglfw: failed to find a suitable pixel format")
|
return 0, fmt.Errorf("glfw: failed to find a suitable pixel format")
|
||||||
}
|
}
|
||||||
|
|
||||||
return int(closest.handle), nil
|
return int(closest.handle), nil
|
||||||
@ -361,7 +361,7 @@ func destroyContextWGL(window *Window) error {
|
|||||||
|
|
||||||
func initWGL() error {
|
func initWGL() error {
|
||||||
if microsoftgdk.IsXbox() {
|
if microsoftgdk.IsXbox() {
|
||||||
return fmt.Errorf("goglfw: WGL is not available in Xbox")
|
return fmt.Errorf("glfw: WGL is not available in Xbox")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _glfw.platformContext.inited {
|
if _glfw.platformContext.inited {
|
||||||
@ -475,15 +475,15 @@ func (w *Window) createContextWGL(ctxconfig *ctxconfig, fbconfig *fbconfig) erro
|
|||||||
|
|
||||||
if ctxconfig.client == OpenGLAPI {
|
if ctxconfig.client == OpenGLAPI {
|
||||||
if ctxconfig.forward && !_glfw.platformContext.ARB_create_context {
|
if ctxconfig.forward && !_glfw.platformContext.ARB_create_context {
|
||||||
return fmt.Errorf("goglfw: a forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable: %w", VersionUnavailable)
|
return fmt.Errorf("glfw: a forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable: %w", VersionUnavailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxconfig.profile != 0 && !_glfw.platformContext.ARB_create_context_profile {
|
if ctxconfig.profile != 0 && !_glfw.platformContext.ARB_create_context_profile {
|
||||||
return fmt.Errorf("goglfw: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable: %w", VersionUnavailable)
|
return fmt.Errorf("glfw: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable: %w", VersionUnavailable)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if !_glfw.platformContext.ARB_create_context || !_glfw.platformContext.ARB_create_context_profile || !_glfw.platformContext.EXT_create_context_es2_profile {
|
if !_glfw.platformContext.ARB_create_context || !_glfw.platformContext.ARB_create_context_profile || !_glfw.platformContext.EXT_create_context_es2_profile {
|
||||||
return fmt.Errorf("goglfw: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable: %w", ApiUnavailable)
|
return fmt.Errorf("glfw: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable: %w", APIUnavailable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@ -2,7 +2,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2021 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2021 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -189,21 +189,21 @@ func (m *Monitor) setVideoModeWin32(desired *VidMode) error {
|
|||||||
m.platform.modeChanged = true
|
m.platform.modeChanged = true
|
||||||
return nil
|
return nil
|
||||||
case _DISP_CHANGE_BADDUALVIEW:
|
case _DISP_CHANGE_BADDUALVIEW:
|
||||||
return errors.New("goglfw: the system uses DualView at Monitor.setVideoModeWin32")
|
return errors.New("glfw: the system uses DualView at Monitor.setVideoModeWin32")
|
||||||
case _DISP_CHANGE_BADFLAGS:
|
case _DISP_CHANGE_BADFLAGS:
|
||||||
return errors.New("goglfw: invalid flags at Monitor.setVideoModeWin32")
|
return errors.New("glfw: invalid flags at Monitor.setVideoModeWin32")
|
||||||
case _DISP_CHANGE_BADMODE:
|
case _DISP_CHANGE_BADMODE:
|
||||||
return errors.New("goglfw: graphics mode not supported at Monitor.setVideoModeWin32")
|
return errors.New("glfw: graphics mode not supported at Monitor.setVideoModeWin32")
|
||||||
case _DISP_CHANGE_BADPARAM:
|
case _DISP_CHANGE_BADPARAM:
|
||||||
return errors.New("goglfw: invalid parameter at Monitor.setVideoModeWin32")
|
return errors.New("glfw: invalid parameter at Monitor.setVideoModeWin32")
|
||||||
case _DISP_CHANGE_FAILED:
|
case _DISP_CHANGE_FAILED:
|
||||||
return errors.New("goglfw: graphics mode failed at Monitor.setVideoModeWin32")
|
return errors.New("glfw: graphics mode failed at Monitor.setVideoModeWin32")
|
||||||
case _DISP_CHANGE_NOTUPDATED:
|
case _DISP_CHANGE_NOTUPDATED:
|
||||||
return errors.New("goglfw: failed to write to registry at Monitor.setVideoModeWin32")
|
return errors.New("glfw: failed to write to registry at Monitor.setVideoModeWin32")
|
||||||
case _DISP_CHANGE_RESTART:
|
case _DISP_CHANGE_RESTART:
|
||||||
return errors.New("goglfw: computer restart required at Monitor.setVideoModeWin32")
|
return errors.New("glfw: computer restart required at Monitor.setVideoModeWin32")
|
||||||
default:
|
default:
|
||||||
return errors.New("goglfw: unknown error at Monitor.setVideoModeWin32")
|
return errors.New("glfw: unknown error at Monitor.setVideoModeWin32")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
@ -3,11 +3,11 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
func (t *tls) create() error {
|
func (t *tls) create() error {
|
||||||
if t.platform.allocated {
|
if t.platform.allocated {
|
||||||
panic("goglfw: TLS must not be allocated")
|
panic("glfw: TLS must not be allocated")
|
||||||
}
|
}
|
||||||
|
|
||||||
i, err := _TlsAlloc()
|
i, err := _TlsAlloc()
|
||||||
@ -32,7 +32,7 @@ func (t *tls) destroy() error {
|
|||||||
|
|
||||||
func (t *tls) get() (uintptr, error) {
|
func (t *tls) get() (uintptr, error) {
|
||||||
if !t.platform.allocated {
|
if !t.platform.allocated {
|
||||||
panic("goglfw: TLS must be allocated")
|
panic("glfw: TLS must be allocated")
|
||||||
}
|
}
|
||||||
|
|
||||||
return _TlsGetValue(t.platform.index)
|
return _TlsGetValue(t.platform.index)
|
||||||
@ -40,7 +40,7 @@ func (t *tls) get() (uintptr, error) {
|
|||||||
|
|
||||||
func (t *tls) set(value uintptr) error {
|
func (t *tls) set(value uintptr) error {
|
||||||
if !t.platform.allocated {
|
if !t.platform.allocated {
|
||||||
panic("goglfw: TLS must be allocated")
|
panic("glfw: TLS must be allocated")
|
||||||
}
|
}
|
||||||
|
|
||||||
return _TlsSetValue(t.platform.index, value)
|
return _TlsSetValue(t.platform.index, value)
|
@ -3,7 +3,7 @@
|
|||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -1209,7 +1209,7 @@ func (w *Window) createNativeWindow(wndconfig *wndconfig, fbconfig *fbconfig) er
|
|||||||
if w.monitor != nil {
|
if w.monitor != nil {
|
||||||
mi, ok := _GetMonitorInfoW(w.monitor.platform.handle)
|
mi, ok := _GetMonitorInfoW(w.monitor.platform.handle)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("goglfw: GetMonitorInfoW failed")
|
return fmt.Errorf("glfw: GetMonitorInfoW failed")
|
||||||
}
|
}
|
||||||
// NOTE: This window placement is temporary and approximate, as the
|
// NOTE: This window placement is temporary and approximate, as the
|
||||||
// correct position and size cannot be known until the monitor
|
// correct position and size cannot be known until the monitor
|
||||||
@ -1361,7 +1361,7 @@ func registerWindowClassWin32() error {
|
|||||||
wc.hCursor = cursor
|
wc.hCursor = cursor
|
||||||
className, err := windows.UTF16FromString(_GLFW_WNDCLASSNAME)
|
className, err := windows.UTF16FromString(_GLFW_WNDCLASSNAME)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("goglfw: _GLFW_WNDCLASSNAME must not inclucde a NUL character")
|
panic("glfw: _GLFW_WNDCLASSNAME must not inclucde a NUL character")
|
||||||
}
|
}
|
||||||
wc.lpszClassName = &className[0]
|
wc.lpszClassName = &className[0]
|
||||||
defer runtime.KeepAlive(className)
|
defer runtime.KeepAlive(className)
|
||||||
@ -2303,7 +2303,7 @@ func (c *Cursor) platformCreateStandardCursor(shape StandardCursor) error {
|
|||||||
case NotAllowedCursor: // v3.4
|
case NotAllowedCursor: // v3.4
|
||||||
id = _OCR_NO
|
id = _OCR_NO
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("goglfw: invalid shape: %d", shape)
|
return fmt.Errorf("glfw: invalid shape: %d", shape)
|
||||||
}
|
}
|
||||||
|
|
||||||
h, err := _LoadImageW(0, uintptr(id), _IMAGE_CURSOR, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED)
|
h, err := _LoadImageW(0, uintptr(id), _IMAGE_CURSOR, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED)
|
||||||
@ -2338,11 +2338,11 @@ func (w *Window) platformSetCursor(cursor *Cursor) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func platformSetClipboardString(str string) error {
|
func platformSetClipboardString(str string) error {
|
||||||
panic("goglfw: platformSetClipboardString is not implemented")
|
panic("glfw: platformSetClipboardString is not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func platformGetClipboardString() (string, error) {
|
func platformGetClipboardString() (string, error) {
|
||||||
panic("goglfw: platformGetClipboardString is not implemented")
|
panic("glfw: platformGetClipboardString is not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) GetWin32Window() (windows.HWND, error) {
|
func (w *Window) GetWin32Window() (windows.HWND, error) {
|
@ -4,10 +4,12 @@
|
|||||||
// SPDX-FileCopyrightText: 2012 Torsten Walluhn <tw@mad-cad.net>
|
// SPDX-FileCopyrightText: 2012 Torsten Walluhn <tw@mad-cad.net>
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
||||||
|
|
||||||
package goglfw
|
package glfw
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"image"
|
||||||
|
"image/draw"
|
||||||
"math"
|
"math"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
@ -92,7 +94,7 @@ func CreateWindow(width, height int, title string, monitor *Monitor, share *Wind
|
|||||||
}
|
}
|
||||||
|
|
||||||
if width <= 0 || height <= 0 {
|
if width <= 0 || height <= 0 {
|
||||||
return nil, fmt.Errorf("goglfw: invalid window size %dx%d: %w", width, height, InvalidValue)
|
return nil, fmt.Errorf("glfw: invalid window size %dx%d: %w", width, height, InvalidValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
fbconfig := _glfw.hints.framebuffer
|
fbconfig := _glfw.hints.framebuffer
|
||||||
@ -276,7 +278,7 @@ func WindowHint(hint Hint, value int) error {
|
|||||||
case RefreshRate:
|
case RefreshRate:
|
||||||
_glfw.hints.refreshRate = value
|
_glfw.hints.refreshRate = value
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("goglfw: invalid window hint 0x%08X: %w", hint, InvalidEnum)
|
return fmt.Errorf("glfw: invalid window hint 0x%08X: %w", hint, InvalidEnum)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -349,11 +351,24 @@ func (w *Window) SetTitle(title string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetIcon(images []*Image) error {
|
func (w *Window) SetIcon(images []image.Image) error {
|
||||||
if !_glfw.initialized {
|
if !_glfw.initialized {
|
||||||
return NotInitialized
|
return NotInitialized
|
||||||
}
|
}
|
||||||
if err := w.platformSetWindowIcon(images); err != nil {
|
|
||||||
|
gimgs := make([]*Image, len(images))
|
||||||
|
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] = &Image{
|
||||||
|
Width: b.Dx(),
|
||||||
|
Height: b.Dy(),
|
||||||
|
Pixels: m.Pix,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := w.platformSetWindowIcon(gimgs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -405,13 +420,13 @@ func (w *Window) SetSizeLimits(minwidth, minheight, maxwidth, maxheight int) err
|
|||||||
|
|
||||||
if minwidth != DontCare && minheight != DontCare {
|
if minwidth != DontCare && minheight != DontCare {
|
||||||
if minwidth < 0 || minheight < 0 {
|
if minwidth < 0 || minheight < 0 {
|
||||||
return fmt.Errorf("goglfw: invalid window minimum size %dx%d: %w", minwidth, minheight, InvalidValue)
|
return fmt.Errorf("glfw: invalid window minimum size %dx%d: %w", minwidth, minheight, InvalidValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if maxwidth != DontCare && maxheight != DontCare {
|
if maxwidth != DontCare && maxheight != DontCare {
|
||||||
if maxwidth < 0 || maxheight < 0 || maxwidth < minwidth || maxheight < minheight {
|
if maxwidth < 0 || maxheight < 0 || maxwidth < minwidth || maxheight < minheight {
|
||||||
return fmt.Errorf("goglfw: invalid window maximum size %dx%d: %w", maxwidth, maxheight, InvalidValue)
|
return fmt.Errorf("glfw: invalid window maximum size %dx%d: %w", maxwidth, maxheight, InvalidValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +453,7 @@ func (w *Window) SetAspectRatio(numer, denom int) error {
|
|||||||
|
|
||||||
if numer != DontCare && denom != DontCare {
|
if numer != DontCare && denom != DontCare {
|
||||||
if numer <= 0 || denom <= 0 {
|
if numer <= 0 || denom <= 0 {
|
||||||
return fmt.Errorf("goglfw: invalid window aspect ratio %d:%d: %w", numer, denom, InvalidValue)
|
return fmt.Errorf("glfw: invalid window aspect ratio %d:%d: %w", numer, denom, InvalidValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,7 +504,7 @@ func (w *Window) SetOpacity(opacity float32) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opacity != opacity || opacity < 0 || opacity > 1 {
|
if opacity != opacity || opacity < 0 || opacity > 1 {
|
||||||
return fmt.Errorf("goglfw: invalid window opacity %f: %w", opacity, InvalidValue)
|
return fmt.Errorf("glfw: invalid window opacity %f: %w", opacity, InvalidValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := w.platformSetWindowOpacity(opacity); err != nil {
|
if err := w.platformSetWindowOpacity(opacity); err != nil {
|
||||||
@ -633,7 +648,7 @@ func (w *Window) GetAttrib(attrib Hint) (int, error) {
|
|||||||
case ContextNoError:
|
case ContextNoError:
|
||||||
return boolToInt(w.context.noerror), nil
|
return boolToInt(w.context.noerror), nil
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("goglfw: invalid window attribute 0x%08X: %w", attrib, InvalidEnum)
|
return 0, fmt.Errorf("glfw: invalid window attribute 0x%08X: %w", attrib, InvalidEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +706,7 @@ func (w *Window) SetAttrib(attrib Hint, value int) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("goglfw: invalid window attribute 0x%08X: %w", attrib, InvalidEnum)
|
return fmt.Errorf("glfw: invalid window attribute 0x%08X: %w", attrib, InvalidEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -708,11 +723,11 @@ func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refresh
|
|||||||
}
|
}
|
||||||
|
|
||||||
if width <= 0 || height <= 0 {
|
if width <= 0 || height <= 0 {
|
||||||
return fmt.Errorf("goglfw: invalid window size %dx%d: %w", width, height, InvalidValue)
|
return fmt.Errorf("glfw: invalid window size %dx%d: %w", width, height, InvalidValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if refreshRate < 0 && refreshRate != DontCare {
|
if refreshRate < 0 && refreshRate != DontCare {
|
||||||
return fmt.Errorf("goglfw: invalid refresh rate %d: %w", refreshRate, InvalidValue)
|
return fmt.Errorf("glfw: invalid refresh rate %d: %w", refreshRate, InvalidValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
w.videoMode.Width = width
|
w.videoMode.Width = width
|
||||||
@ -846,7 +861,7 @@ func WaitEventsTimeout(timeout float64) error {
|
|||||||
return NotInitialized
|
return NotInitialized
|
||||||
}
|
}
|
||||||
if timeout != timeout || timeout < 0.0 || timeout > math.MaxFloat64 {
|
if timeout != timeout || timeout < 0.0 || timeout > math.MaxFloat64 {
|
||||||
return fmt.Errorf("goglfw: invalid time %f: %w", timeout, InvalidValue)
|
return fmt.Errorf("glfw: invalid time %f: %w", timeout, InvalidValue)
|
||||||
}
|
}
|
||||||
if err := platformWaitEventsTimeout(timeout); err != nil {
|
if err := platformWaitEventsTimeout(timeout); err != nil {
|
||||||
return err
|
return err
|
@ -1,341 +0,0 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
// SPDX-FileCopyrightText: 2002-2006 Marcus Geelnard
|
|
||||||
// SPDX-FileCopyrightText: 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
|
||||||
// SPDX-FileCopyrightText: 2022 The Ebitengine Authors
|
|
||||||
|
|
||||||
package goglfw
|
|
||||||
|
|
||||||
const (
|
|
||||||
NoAPI = 0
|
|
||||||
OpenGLAPI = 0x00030001
|
|
||||||
OpenGLESAPI = 0x00030002
|
|
||||||
|
|
||||||
NoRobustness = 0
|
|
||||||
NoResetNotification = 0x00031001
|
|
||||||
LoseContextOnReset = 0x00031002
|
|
||||||
|
|
||||||
OpenGLAnyProfile = 0
|
|
||||||
OpenGLCoreProfile = 0x00032001
|
|
||||||
OpenGLCompatProfile = 0x00032002
|
|
||||||
|
|
||||||
CursorNormal = 0x00034001
|
|
||||||
CursorHidden = 0x00034002
|
|
||||||
CursorDisabled = 0x00034003
|
|
||||||
|
|
||||||
AnyReleaseBehavior = 0
|
|
||||||
ReleaseBehaviorFlush = 0x00035001
|
|
||||||
ReleaseBehaviorNone = 0x00035002
|
|
||||||
|
|
||||||
NativeContextAPI = 0x00036001
|
|
||||||
EGLContextAPI = 0x00036002
|
|
||||||
OSMesaContextAPI = 0x00036003
|
|
||||||
|
|
||||||
DontCare = -1
|
|
||||||
)
|
|
||||||
|
|
||||||
type Action int
|
|
||||||
|
|
||||||
const (
|
|
||||||
Release Action = 0
|
|
||||||
Press Action = 1
|
|
||||||
Repeat Action = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
type Hint int
|
|
||||||
|
|
||||||
const (
|
|
||||||
Focused Hint = 0x00020001
|
|
||||||
Iconified Hint = 0x00020002
|
|
||||||
Resizable Hint = 0x00020003
|
|
||||||
Visible Hint = 0x00020004
|
|
||||||
Decorated Hint = 0x00020005
|
|
||||||
AutoIconify Hint = 0x00020006
|
|
||||||
Floating Hint = 0x00020007
|
|
||||||
Maximized Hint = 0x00020008
|
|
||||||
CenterCursor Hint = 0x00020009
|
|
||||||
TransparentFramebuffer Hint = 0x0002000A
|
|
||||||
Hovered Hint = 0x0002000B
|
|
||||||
FocusOnShow Hint = 0x0002000C
|
|
||||||
MousePassthrough Hint = 0x0002000D
|
|
||||||
|
|
||||||
RedBits Hint = 0x00021001
|
|
||||||
GreenBits Hint = 0x00021002
|
|
||||||
BlueBits Hint = 0x00021003
|
|
||||||
AlphaBits Hint = 0x00021004
|
|
||||||
DepthBits Hint = 0x00021005
|
|
||||||
StencilBits Hint = 0x00021006
|
|
||||||
AccumRedBits Hint = 0x00021007
|
|
||||||
AccumGreenBits Hint = 0x00021008
|
|
||||||
AccumBlueBits Hint = 0x00021009
|
|
||||||
AccumAlphaBits Hint = 0x0002100A
|
|
||||||
AuxBuffers Hint = 0x0002100B
|
|
||||||
Stereo Hint = 0x0002100C
|
|
||||||
Samples Hint = 0x0002100D
|
|
||||||
SRGBCapable Hint = 0x0002100E
|
|
||||||
RefreshRate Hint = 0x0002100F
|
|
||||||
DoubleBuffer Hint = 0x00021010
|
|
||||||
|
|
||||||
ClientAPI Hint = 0x00022001
|
|
||||||
ContextVersionMajor Hint = 0x00022002
|
|
||||||
ContextVersionMinor Hint = 0x00022003
|
|
||||||
ContextRevision Hint = 0x00022004
|
|
||||||
ContextRobustness Hint = 0x00022005
|
|
||||||
OpenGLForwardCompat Hint = 0x00022006
|
|
||||||
OpenGLDebugContext Hint = 0x00022007
|
|
||||||
OpenGLProfile Hint = 0x00022008
|
|
||||||
ContextReleaseBehavior Hint = 0x00022009
|
|
||||||
ContextNoError Hint = 0x0002200A
|
|
||||||
ContextCreationAPI Hint = 0x0002200B
|
|
||||||
ScaleToMonitor Hint = 0x0002200C
|
|
||||||
)
|
|
||||||
|
|
||||||
type InputMode int
|
|
||||||
|
|
||||||
const (
|
|
||||||
CursorMode InputMode = 0x00033001
|
|
||||||
StickyKeysMode InputMode = 0x00033002
|
|
||||||
StickyMouseButtonsMode InputMode = 0x00033003
|
|
||||||
LockKeyMods InputMode = 0x00033004
|
|
||||||
RawMouseMotion InputMode = 0x00033005
|
|
||||||
)
|
|
||||||
|
|
||||||
type Key int
|
|
||||||
|
|
||||||
const (
|
|
||||||
KeyUnknown Key = -1
|
|
||||||
|
|
||||||
// Printable keys
|
|
||||||
KeySpace Key = 32
|
|
||||||
KeyApostrophe Key = 39 // '
|
|
||||||
KeyComma Key = 44 // ,
|
|
||||||
KeyMinus Key = 45 // -
|
|
||||||
KeyPeriod Key = 46 // .
|
|
||||||
KeySlash Key = 47 // /
|
|
||||||
Key0 Key = 48
|
|
||||||
Key1 Key = 49
|
|
||||||
Key2 Key = 50
|
|
||||||
Key3 Key = 51
|
|
||||||
Key4 Key = 52
|
|
||||||
Key5 Key = 53
|
|
||||||
Key6 Key = 54
|
|
||||||
Key7 Key = 55
|
|
||||||
Key8 Key = 56
|
|
||||||
Key9 Key = 57
|
|
||||||
KeySemicolon Key = 59 // ;
|
|
||||||
KeyEqual Key = 61 // =
|
|
||||||
KeyA Key = 65
|
|
||||||
KeyB Key = 66
|
|
||||||
KeyC Key = 67
|
|
||||||
KeyD Key = 68
|
|
||||||
KeyE Key = 69
|
|
||||||
KeyF Key = 70
|
|
||||||
KeyG Key = 71
|
|
||||||
KeyH Key = 72
|
|
||||||
KeyI Key = 73
|
|
||||||
KeyJ Key = 74
|
|
||||||
KeyK Key = 75
|
|
||||||
KeyL Key = 76
|
|
||||||
KeyM Key = 77
|
|
||||||
KeyN Key = 78
|
|
||||||
KeyO Key = 79
|
|
||||||
KeyP Key = 80
|
|
||||||
KeyQ Key = 81
|
|
||||||
KeyR Key = 82
|
|
||||||
KeyS Key = 83
|
|
||||||
KeyT Key = 84
|
|
||||||
KeyU Key = 85
|
|
||||||
KeyV Key = 86
|
|
||||||
KeyW Key = 87
|
|
||||||
KeyX Key = 88
|
|
||||||
KeyY Key = 89
|
|
||||||
KeyZ Key = 90
|
|
||||||
KeyLeftBracket Key = 91 // [
|
|
||||||
KeyBackslash Key = 92 // \
|
|
||||||
KeyRightBracket Key = 93 // ]
|
|
||||||
KeyGraveAccent Key = 96 // `
|
|
||||||
KeyWorld1 Key = 161 // non-US #1
|
|
||||||
KeyWorld2 Key = 162 // non-US #2
|
|
||||||
|
|
||||||
// Function keys
|
|
||||||
KeyEscape Key = 256
|
|
||||||
KeyEnter Key = 257
|
|
||||||
KeyTab Key = 258
|
|
||||||
KeyBackspace Key = 259
|
|
||||||
KeyInsert Key = 260
|
|
||||||
KeyDelete Key = 261
|
|
||||||
KeyRight Key = 262
|
|
||||||
KeyLeft Key = 263
|
|
||||||
KeyDown Key = 264
|
|
||||||
KeyUp Key = 265
|
|
||||||
KeyPageUp Key = 266
|
|
||||||
KeyPageDown Key = 267
|
|
||||||
KeyHome Key = 268
|
|
||||||
KeyEnd Key = 269
|
|
||||||
KeyCapsLock Key = 280
|
|
||||||
KeyScrollLock Key = 281
|
|
||||||
KeyNumLock Key = 282
|
|
||||||
KeyPrintScreen Key = 283
|
|
||||||
KeyPause Key = 284
|
|
||||||
KeyF1 Key = 290
|
|
||||||
KeyF2 Key = 291
|
|
||||||
KeyF3 Key = 292
|
|
||||||
KeyF4 Key = 293
|
|
||||||
KeyF5 Key = 294
|
|
||||||
KeyF6 Key = 295
|
|
||||||
KeyF7 Key = 296
|
|
||||||
KeyF8 Key = 297
|
|
||||||
KeyF9 Key = 298
|
|
||||||
KeyF10 Key = 299
|
|
||||||
KeyF11 Key = 300
|
|
||||||
KeyF12 Key = 301
|
|
||||||
KeyF13 Key = 302
|
|
||||||
KeyF14 Key = 303
|
|
||||||
KeyF15 Key = 304
|
|
||||||
KeyF16 Key = 305
|
|
||||||
KeyF17 Key = 306
|
|
||||||
KeyF18 Key = 307
|
|
||||||
KeyF19 Key = 308
|
|
||||||
KeyF20 Key = 309
|
|
||||||
KeyF21 Key = 310
|
|
||||||
KeyF22 Key = 311
|
|
||||||
KeyF23 Key = 312
|
|
||||||
KeyF24 Key = 313
|
|
||||||
KeyF25 Key = 314
|
|
||||||
KeyKP0 Key = 320
|
|
||||||
KeyKP1 Key = 321
|
|
||||||
KeyKP2 Key = 322
|
|
||||||
KeyKP3 Key = 323
|
|
||||||
KeyKP4 Key = 324
|
|
||||||
KeyKP5 Key = 325
|
|
||||||
KeyKP6 Key = 326
|
|
||||||
KeyKP7 Key = 327
|
|
||||||
KeyKP8 Key = 328
|
|
||||||
KeyKP9 Key = 329
|
|
||||||
KeyKPDecimal Key = 330
|
|
||||||
KeyKPDivide Key = 331
|
|
||||||
KeyKPMultiply Key = 332
|
|
||||||
KeyKPSubtract Key = 333
|
|
||||||
KeyKPAdd Key = 334
|
|
||||||
KeyKPEnter Key = 335
|
|
||||||
KeyKPEqual Key = 336
|
|
||||||
KeyLeftShift Key = 340
|
|
||||||
KeyLeftControl Key = 341
|
|
||||||
KeyLeftAlt Key = 342
|
|
||||||
KeyLeftSuper Key = 343
|
|
||||||
KeyRightShift Key = 344
|
|
||||||
KeyRightControl Key = 345
|
|
||||||
KeyRightAlt Key = 346
|
|
||||||
KeyRightSuper Key = 347
|
|
||||||
KeyMenu Key = 348
|
|
||||||
|
|
||||||
KeyLast Key = KeyMenu
|
|
||||||
)
|
|
||||||
|
|
||||||
type ModifierKey int
|
|
||||||
|
|
||||||
const (
|
|
||||||
ModShift ModifierKey = 0x0001
|
|
||||||
ModControl ModifierKey = 0x0002
|
|
||||||
ModAlt ModifierKey = 0x0004
|
|
||||||
ModSuper ModifierKey = 0x0008
|
|
||||||
ModCapsLock ModifierKey = 0x0010
|
|
||||||
ModNumLock ModifierKey = 0x0020
|
|
||||||
)
|
|
||||||
|
|
||||||
type MouseButton int
|
|
||||||
|
|
||||||
const (
|
|
||||||
MouseButton1 MouseButton = 0
|
|
||||||
MouseButton2 MouseButton = 1
|
|
||||||
MouseButton3 MouseButton = 2
|
|
||||||
MouseButton4 MouseButton = 3
|
|
||||||
MouseButton5 MouseButton = 4
|
|
||||||
MouseButton6 MouseButton = 5
|
|
||||||
MouseButton7 MouseButton = 6
|
|
||||||
MouseButton8 MouseButton = 7
|
|
||||||
MouseButtonLast MouseButton = MouseButton8
|
|
||||||
MouseButtonLeft MouseButton = MouseButton1
|
|
||||||
MouseButtonRight MouseButton = MouseButton2
|
|
||||||
MouseButtonMiddle MouseButton = MouseButton3
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
NotInitialized Error = 0x00010001
|
|
||||||
NoCurrentContext Error = 0x00010002
|
|
||||||
InvalidEnum Error = 0x00010003
|
|
||||||
InvalidValue Error = 0x00010004
|
|
||||||
OutOfMemory Error = 0x00010005
|
|
||||||
ApiUnavailable Error = 0x00010006
|
|
||||||
VersionUnavailable Error = 0x00010007
|
|
||||||
PlatformError Error = 0x00010008
|
|
||||||
FormatUnavailable Error = 0x00010009
|
|
||||||
NoWindowContext Error = 0x0001000A
|
|
||||||
)
|
|
||||||
|
|
||||||
type PeripheralEvent int
|
|
||||||
|
|
||||||
const (
|
|
||||||
Connected PeripheralEvent = 0x00040001
|
|
||||||
Disconnected PeripheralEvent = 0x00040002
|
|
||||||
)
|
|
||||||
|
|
||||||
type StandardCursor int
|
|
||||||
|
|
||||||
const (
|
|
||||||
ArrowCursor StandardCursor = 0x00036001
|
|
||||||
IBeamCursor StandardCursor = 0x00036002
|
|
||||||
CrosshairCursor StandardCursor = 0x00036003
|
|
||||||
HandCursor StandardCursor = 0x00036004
|
|
||||||
HResizeCursor StandardCursor = 0x00036005
|
|
||||||
VResizeCursor StandardCursor = 0x00036006
|
|
||||||
|
|
||||||
// v3.4
|
|
||||||
ResizeNWSECursor StandardCursor = 0x00036007
|
|
||||||
ResizeNESWCursor StandardCursor = 0x00036008
|
|
||||||
ResizeAllCursor StandardCursor = 0x00036009
|
|
||||||
NotAllowedCursor StandardCursor = 0x0003600A
|
|
||||||
)
|
|
||||||
|
|
||||||
type Error int
|
|
||||||
|
|
||||||
func (e Error) Error() string {
|
|
||||||
switch e {
|
|
||||||
case NotInitialized:
|
|
||||||
return "the GLFW library is not initialized"
|
|
||||||
case NoCurrentContext:
|
|
||||||
return "there is no current context"
|
|
||||||
case InvalidEnum:
|
|
||||||
return "invalid argument for enum parameter"
|
|
||||||
case InvalidValue:
|
|
||||||
return "invalid value for parameter"
|
|
||||||
case OutOfMemory:
|
|
||||||
return "out of memory"
|
|
||||||
case ApiUnavailable:
|
|
||||||
return "the requested API is unavailable"
|
|
||||||
case VersionUnavailable:
|
|
||||||
return "the requested API version is unavailable"
|
|
||||||
case PlatformError:
|
|
||||||
return "a platform-specific error occurred"
|
|
||||||
case FormatUnavailable:
|
|
||||||
return "the requested format is unavailable"
|
|
||||||
case NoWindowContext:
|
|
||||||
return "the specified window has no context"
|
|
||||||
default:
|
|
||||||
return "ERROR: UNKNOWN GLFW ERROR"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type VidMode struct {
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
RedBits int
|
|
||||||
GreenBits int
|
|
||||||
BlueBits int
|
|
||||||
RefreshRate int
|
|
||||||
}
|
|
||||||
|
|
||||||
type Image struct {
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Pixels []byte
|
|
||||||
}
|
|
@ -22,21 +22,40 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *Graphics) SetGLFWClientAPI() {
|
func (g *Graphics) SetGLFWClientAPI() error {
|
||||||
if g.context.ctx.IsES() {
|
if g.context.ctx.IsES() {
|
||||||
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI)
|
if err := glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLESAPI); err != nil {
|
||||||
glfw.WindowHint(glfw.ContextVersionMajor, 3)
|
return err
|
||||||
glfw.WindowHint(glfw.ContextVersionMinor, 0)
|
}
|
||||||
glfw.WindowHint(glfw.ContextCreationAPI, glfw.EGLContextAPI)
|
if err := glfw.WindowHint(glfw.ContextVersionMajor, 3); err != nil {
|
||||||
return
|
return err
|
||||||
|
}
|
||||||
|
if err := glfw.WindowHint(glfw.ContextVersionMinor, 0); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := glfw.WindowHint(glfw.ContextCreationAPI, glfw.EGLContextAPI); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLAPI)
|
if err := glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLAPI); err != nil {
|
||||||
glfw.WindowHint(glfw.ContextVersionMajor, 3)
|
return err
|
||||||
glfw.WindowHint(glfw.ContextVersionMinor, 2)
|
}
|
||||||
|
if err := glfw.WindowHint(glfw.ContextVersionMajor, 3); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := glfw.WindowHint(glfw.ContextVersionMinor, 2); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// macOS requires forward-compatible and a core profile.
|
// macOS requires forward-compatible and a core profile.
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
glfw.WindowHint(glfw.OpenGLForwardCompat, glfw.True)
|
if err := glfw.WindowHint(glfw.OpenGLForwardCompat, glfw.True); err != nil {
|
||||||
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
|
return err
|
||||||
|
}
|
||||||
|
if err := glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -31,20 +31,27 @@ var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{
|
|||||||
glfw.MouseButton5: MouseButton4,
|
glfw.MouseButton5: MouseButton4,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) registerInputCallbacks() {
|
func (u *userInterfaceImpl) registerInputCallbacks() error {
|
||||||
u.window.SetCharModsCallback(glfw.ToCharModsCallback(func(w *glfw.Window, char rune, mods glfw.ModifierKey) {
|
if _, err := u.window.SetCharModsCallback(glfw.ToCharModsCallback(func(w *glfw.Window, char rune, mods glfw.ModifierKey) {
|
||||||
// As this function is called from GLFW callbacks, the current thread is main.
|
// As this function is called from GLFW callbacks, the current thread is main.
|
||||||
u.m.Lock()
|
u.m.Lock()
|
||||||
defer u.m.Unlock()
|
defer u.m.Unlock()
|
||||||
u.inputState.appendRune(char)
|
u.inputState.appendRune(char)
|
||||||
}))
|
})); err != nil {
|
||||||
u.window.SetScrollCallback(glfw.ToScrollCallback(func(w *glfw.Window, xoff float64, yoff float64) {
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := u.window.SetScrollCallback(glfw.ToScrollCallback(func(w *glfw.Window, xoff float64, yoff float64) {
|
||||||
// As this function is called from GLFW callbacks, the current thread is main.
|
// As this function is called from GLFW callbacks, the current thread is main.
|
||||||
u.m.Lock()
|
u.m.Lock()
|
||||||
defer u.m.Unlock()
|
defer u.m.Unlock()
|
||||||
u.inputState.WheelX += xoff
|
u.inputState.WheelX += xoff
|
||||||
u.inputState.WheelY += yoff
|
u.inputState.WheelY += yoff
|
||||||
}))
|
})); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) updateInputState() error {
|
func (u *userInterfaceImpl) updateInputState() error {
|
||||||
@ -61,13 +68,24 @@ func (u *userInterfaceImpl) updateInputStateImpl() error {
|
|||||||
defer u.m.Unlock()
|
defer u.m.Unlock()
|
||||||
|
|
||||||
for uk, gk := range uiKeyToGLFWKey {
|
for uk, gk := range uiKeyToGLFWKey {
|
||||||
u.inputState.KeyPressed[uk] = u.window.GetKey(gk) == glfw.Press
|
s, err := u.window.GetKey(gk)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
u.inputState.KeyPressed[uk] = s == glfw.Press
|
||||||
}
|
}
|
||||||
for gb, ub := range glfwMouseButtonToMouseButton {
|
for gb, ub := range glfwMouseButtonToMouseButton {
|
||||||
u.inputState.MouseButtonPressed[ub] = u.window.GetMouseButton(gb) == glfw.Press
|
s, err := u.window.GetMouseButton(gb)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
u.inputState.MouseButtonPressed[ub] = s == glfw.Press
|
||||||
}
|
}
|
||||||
|
|
||||||
m := u.currentMonitor()
|
m, err := u.currentMonitor()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
s := m.deviceScaleFactor()
|
s := m.deviceScaleFactor()
|
||||||
|
|
||||||
cx, cy := u.savedCursorX, u.savedCursorY
|
cx, cy := u.savedCursorX, u.savedCursorY
|
||||||
@ -80,9 +98,14 @@ func (u *userInterfaceImpl) updateInputStateImpl() error {
|
|||||||
cx2, cy2 := u.context.logicalPositionToClientPosition(cx, cy, s)
|
cx2, cy2 := u.context.logicalPositionToClientPosition(cx, cy, s)
|
||||||
cx2 = dipToGLFWPixel(cx2, m)
|
cx2 = dipToGLFWPixel(cx2, m)
|
||||||
cy2 = dipToGLFWPixel(cy2, m)
|
cy2 = dipToGLFWPixel(cy2, m)
|
||||||
u.window.SetCursorPos(cx2, cy2)
|
if err := u.window.SetCursorPos(cx2, cy2); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cx2, cy2 := u.window.GetCursorPos()
|
cx2, cy2, err := u.window.GetCursorPos()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
cx2 = dipFromGLFWPixel(cx2, m)
|
cx2 = dipFromGLFWPixel(cx2, m)
|
||||||
cy2 = dipFromGLFWPixel(cy2, m)
|
cy2 = dipFromGLFWPixel(cy2, m)
|
||||||
cx, cy = u.context.clientPositionToLogicalPosition(cx2, cy2, s)
|
cx, cy = u.context.clientPositionToLogicalPosition(cx2, cy2, s)
|
||||||
@ -118,7 +141,12 @@ func (u *userInterfaceImpl) keyName(key Key) string {
|
|||||||
if u.isTerminated() {
|
if u.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
name = glfw.GetKeyName(gk, 0)
|
n, err := glfw.GetKeyName(gk, 0)
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
name = n
|
||||||
})
|
})
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
@ -114,11 +114,17 @@ func (m *monitors) monitorFromPosition(x, y int) *Monitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update must be called from the main thread.
|
// update must be called from the main thread.
|
||||||
func (m *monitors) update() {
|
func (m *monitors) update() error {
|
||||||
glfwMonitors := glfw.GetMonitors()
|
glfwMonitors, err := glfw.GetMonitors()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
newMonitors := make([]*Monitor, 0, len(glfwMonitors))
|
newMonitors := make([]*Monitor, 0, len(glfwMonitors))
|
||||||
for i, m := range glfwMonitors {
|
for i, m := range glfwMonitors {
|
||||||
x, y := m.GetPos()
|
x, y, err := m.GetPos()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Detect the update of the content scale by SetContentScaleCallback (#2343).
|
// TODO: Detect the update of the content scale by SetContentScaleCallback (#2343).
|
||||||
contentScale := 1.0
|
contentScale := 1.0
|
||||||
@ -138,13 +144,24 @@ func (m *monitors) update() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
w, h := glfwMonitorSizeInGLFWPixels(m)
|
videoMode, err := m.GetVideoMode()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
name, err := m.GetName()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w, h, err := glfwMonitorSizeInGLFWPixels(m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
b := image.Rect(x, y, x+w, y+h)
|
b := image.Rect(x, y, x+w, y+h)
|
||||||
newMonitors = append(newMonitors, &Monitor{
|
newMonitors = append(newMonitors, &Monitor{
|
||||||
m: m,
|
m: m,
|
||||||
videoMode: m.GetVideoMode(),
|
videoMode: videoMode,
|
||||||
id: i,
|
id: i,
|
||||||
name: m.GetName(),
|
name: name,
|
||||||
boundsInGLFWPixels: b,
|
boundsInGLFWPixels: b,
|
||||||
contentScale: contentScale,
|
contentScale: contentScale,
|
||||||
})
|
})
|
||||||
@ -155,4 +172,5 @@ func (m *monitors) update() {
|
|||||||
m.m.Unlock()
|
m.m.Unlock()
|
||||||
|
|
||||||
atomic.StoreInt32(&m.updateCalled, 1)
|
atomic.StoreInt32(&m.updateCalled, 1)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -122,7 +122,10 @@ func init() {
|
|||||||
{
|
{
|
||||||
Cmd: sel_windowWillEnterFullScreen,
|
Cmd: sel_windowWillEnterFullScreen,
|
||||||
Fn: func(id objc.ID, cmd objc.SEL, notification objc.ID) {
|
Fn: func(id objc.ID, cmd objc.SEL, notification objc.ID) {
|
||||||
theUI.setOrigWindowPosWithCurrentPos()
|
if err := theUI.setOrigWindowPosWithCurrentPos(); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
pushResizableState(id, cocoa.NSNotification{ID: notification}.Object())
|
pushResizableState(id, cocoa.NSNotification{ID: notification}.Object())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -139,7 +142,10 @@ func init() {
|
|||||||
// Even a window has a size limitation, a window can be fullscreen by calling SetFullscreen(true).
|
// Even a window has a size limitation, a window can be fullscreen by calling SetFullscreen(true).
|
||||||
// In this case, the window size limitation is disabled temporarily.
|
// In this case, the window size limitation is disabled temporarily.
|
||||||
// When exiting from fullscreen, reset the window size limitation.
|
// When exiting from fullscreen, reset the window size limitation.
|
||||||
theUI.updateWindowSizeLimits()
|
if err := theUI.updateWindowSizeLimits(); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -185,9 +191,12 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
|
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
|
||||||
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int) {
|
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int, error) {
|
||||||
vm := m.GetVideoMode()
|
vm, err := m.GetVideoMode()
|
||||||
return vm.Width, vm.Height
|
if err != nil {
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
|
return vm.Width, vm.Height, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dipFromGLFWPixel(x float64, monitor *Monitor) float64 {
|
func dipFromGLFWPixel(x float64, monitor *Monitor) float64 {
|
||||||
@ -264,7 +273,7 @@ func initialMonitorByOS() (*Monitor, error) {
|
|||||||
return theMonitors.monitorFromPosition(x, y), nil
|
return theMonitors.monitorFromPosition(x, y), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorFromWindowByOS(w *glfw.Window) *Monitor {
|
func monitorFromWindowByOS(w *glfw.Window) (*Monitor, error) {
|
||||||
window := cocoa.NSWindow{ID: objc.ID(w.GetCocoaWindow())}
|
window := cocoa.NSWindow{ID: objc.ID(w.GetCocoaWindow())}
|
||||||
pool := cocoa.NSAutoreleasePool_new()
|
pool := cocoa.NSAutoreleasePool_new()
|
||||||
screen := cocoa.NSScreen_mainScreen()
|
screen := cocoa.NSScreen_mainScreen()
|
||||||
@ -279,14 +288,14 @@ func monitorFromWindowByOS(w *glfw.Window) *Monitor {
|
|||||||
pool.Release()
|
pool.Release()
|
||||||
for _, m := range theMonitors.append(nil) {
|
for _, m := range theMonitors.append(nil) {
|
||||||
if m.m.GetCocoaMonitor() == aID {
|
if m.m.GetCocoaMonitor() == aID {
|
||||||
return m
|
return m, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) nativeWindow() uintptr {
|
func (u *userInterfaceImpl) nativeWindow() (uintptr, error) {
|
||||||
return u.window.GetCocoaWindow()
|
return u.window.GetCocoaWindow(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) isNativeFullscreen() bool {
|
func (u *userInterfaceImpl) isNativeFullscreen() bool {
|
||||||
@ -372,12 +381,13 @@ func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode)
|
|||||||
objc.ID(u.window.GetCocoaWindow()).Send(sel_setCollectionBehavior, collectionBehavior)
|
objc.ID(u.window.GetCocoaWindow()).Send(sel_setCollectionBehavior, collectionBehavior)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
func initializeWindowAfterCreation(w *glfw.Window) error {
|
||||||
// TODO: Register NSWindowWillEnterFullScreenNotification and so on.
|
// TODO: Register NSWindowWillEnterFullScreenNotification and so on.
|
||||||
// Enable resizing temporary before making the window fullscreen.
|
// Enable resizing temporary before making the window fullscreen.
|
||||||
nswindow := objc.ID(w.GetCocoaWindow())
|
nswindow := objc.ID(w.GetCocoaWindow())
|
||||||
delegate := objc.ID(class_EbitengineWindowDelegate).Send(sel_alloc).Send(sel_initWithOrigDelegate, nswindow.Send(sel_delegate))
|
delegate := objc.ID(class_EbitengineWindowDelegate).Send(sel_alloc).Send(sel_initWithOrigDelegate, nswindow.Send(sel_delegate))
|
||||||
nswindow.Send(sel_setDelegate, delegate)
|
nswindow.Send(sel_setDelegate, delegate)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) skipTaskbar() error {
|
func (u *userInterfaceImpl) skipTaskbar() error {
|
||||||
|
@ -51,8 +51,11 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
|
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
|
||||||
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int) {
|
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int, error) {
|
||||||
vm := m.GetVideoMode()
|
vm, err := m.GetVideoMode()
|
||||||
|
if err != nil {
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
physWidth, physHeight := vm.Width, vm.Height
|
physWidth, physHeight := vm.Width, vm.Height
|
||||||
|
|
||||||
// TODO: if glfw/glfw#1961 gets fixed, this function may need revising.
|
// TODO: if glfw/glfw#1961 gets fixed, this function may need revising.
|
||||||
@ -68,23 +71,27 @@ func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int) {
|
|||||||
// No X11 connection?
|
// No X11 connection?
|
||||||
// Assume we're on pure Wayland then.
|
// Assume we're on pure Wayland then.
|
||||||
// GLFW/Wayland shouldn't be having this issue.
|
// GLFW/Wayland shouldn't be having this issue.
|
||||||
return physWidth, physHeight
|
return physWidth, physHeight, nil
|
||||||
}
|
}
|
||||||
defer xconn.Close()
|
defer xconn.Close()
|
||||||
|
|
||||||
if err := randr.Init(xconn); err != nil {
|
if err := randr.Init(xconn); err != nil {
|
||||||
// No RANDR extension? No problem.
|
// No RANDR extension? No problem.
|
||||||
return physWidth, physHeight
|
return physWidth, physHeight, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
root := xproto.Setup(xconn).DefaultScreen(xconn).Root
|
root := xproto.Setup(xconn).DefaultScreen(xconn).Root
|
||||||
res, err := randr.GetScreenResourcesCurrent(xconn, root).Reply()
|
res, err := randr.GetScreenResourcesCurrent(xconn, root).Reply()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Likely means RANDR is not working. No problem.
|
// Likely means RANDR is not working. No problem.
|
||||||
return physWidth, physHeight
|
return physWidth, physHeight, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
monitorX, monitorY := m.GetPos()
|
monitorX, monitorY, err := m.GetPos()
|
||||||
|
if err != nil {
|
||||||
|
// TODO: Is it OK to ignore this error?
|
||||||
|
return physWidth, physHeight, nil
|
||||||
|
}
|
||||||
|
|
||||||
for _, crtc := range res.Crtcs[:res.NumCrtcs] {
|
for _, crtc := range res.Crtcs[:res.NumCrtcs] {
|
||||||
info, err := randr.GetCrtcInfo(xconn, crtc, res.ConfigTimestamp).Reply()
|
info, err := randr.GetCrtcInfo(xconn, crtc, res.ConfigTimestamp).Reply()
|
||||||
@ -98,12 +105,12 @@ func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if int(info.X) == monitorX && int(info.Y) == monitorY {
|
if int(info.X) == monitorX && int(info.Y) == monitorY {
|
||||||
return int(info.Width), int(info.Height)
|
return int(info.Width), int(info.Height), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monitor not known to XRandR. Weird.
|
// Monitor not known to XRandR. Weird.
|
||||||
return physWidth, physHeight
|
return physWidth, physHeight, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dipFromGLFWPixel(x float64, monitor *Monitor) float64 {
|
func dipFromGLFWPixel(x float64, monitor *Monitor) float64 {
|
||||||
@ -137,14 +144,14 @@ func initialMonitorByOS() (*Monitor, error) {
|
|||||||
return theMonitors.monitorFromPosition(x, y), nil
|
return theMonitors.monitorFromPosition(x, y), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorFromWindowByOS(_ *glfw.Window) *Monitor {
|
func monitorFromWindowByOS(_ *glfw.Window) (*Monitor, error) {
|
||||||
// TODO: Implement this correctly. (#1119).
|
// TODO: Implement this correctly. (#1119).
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) nativeWindow() uintptr {
|
func (u *userInterfaceImpl) nativeWindow() (uintptr, error) {
|
||||||
// TODO: Implement this.
|
// TODO: Implement this.
|
||||||
return 0
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) isNativeFullscreen() bool {
|
func (u *userInterfaceImpl) isNativeFullscreen() bool {
|
||||||
@ -165,15 +172,18 @@ func (u *userInterfaceImpl) adjustViewSizeAfterFullscreen() {
|
|||||||
func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode) {
|
func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
func initializeWindowAfterCreation(w *glfw.Window) error {
|
||||||
// Show the window once before getting the position of the window.
|
// Show the window once before getting the position of the window.
|
||||||
// On Linux/Unix, the window position is not reliable before showing.
|
// On Linux/Unix, the window position is not reliable before showing.
|
||||||
w.Show()
|
if err := w.Show(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Hiding the window makes the position unreliable again. Do not call w.Hide() here (#1829)
|
// Hiding the window makes the position unreliable again. Do not call w.Hide() here (#1829)
|
||||||
// Calling Hide is problematic especially on XWayland and/or Sway.
|
// Calling Hide is problematic especially on XWayland and/or Sway.
|
||||||
// Apparently the window state is inconsistent just after the window is created, but we are not sure.
|
// Apparently the window state is inconsistent just after the window is created, but we are not sure.
|
||||||
// For more details, see the discussion in #1829.
|
// For more details, see the discussion in #1829.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) skipTaskbar() error {
|
func (u *userInterfaceImpl) skipTaskbar() error {
|
||||||
|
@ -85,9 +85,12 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
|
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
|
||||||
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int) {
|
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int, error) {
|
||||||
vm := m.GetVideoMode()
|
vm, err := m.GetVideoMode()
|
||||||
return vm.Width, vm.Height
|
if err != nil {
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
|
return vm.Width, vm.Height, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func dipFromGLFWPixel(x float64, monitor *Monitor) float64 {
|
func dipFromGLFWPixel(x float64, monitor *Monitor) float64 {
|
||||||
@ -138,11 +141,15 @@ func initialMonitorByOS() (*Monitor, error) {
|
|||||||
return theMonitors.monitorFromPosition(x, y), nil
|
return theMonitors.monitorFromPosition(x, y), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorFromWindowByOS(w *glfw.Window) *Monitor {
|
func monitorFromWindowByOS(w *glfw.Window) (*Monitor, error) {
|
||||||
if microsoftgdk.IsXbox() {
|
if microsoftgdk.IsXbox() {
|
||||||
return theMonitors.primaryMonitor()
|
return theMonitors.primaryMonitor(), nil
|
||||||
}
|
}
|
||||||
return monitorFromWin32Window(windows.HWND(w.GetWin32Window()))
|
window, err := w.GetWin32Window()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return monitorFromWin32Window(window), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func monitorFromWin32Window(w windows.HWND) *Monitor {
|
func monitorFromWin32Window(w windows.HWND) *Monitor {
|
||||||
@ -171,8 +178,9 @@ func monitorFromWin32Window(w windows.HWND) *Monitor {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) nativeWindow() uintptr {
|
func (u *userInterfaceImpl) nativeWindow() (uintptr, error) {
|
||||||
return u.window.GetWin32Window()
|
w, err := u.window.GetWin32Window()
|
||||||
|
return uintptr(w), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) isNativeFullscreen() bool {
|
func (u *userInterfaceImpl) isNativeFullscreen() bool {
|
||||||
@ -193,7 +201,8 @@ func (u *userInterfaceImpl) adjustViewSizeAfterFullscreen() {
|
|||||||
func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode) {
|
func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
func initializeWindowAfterCreation(w *glfw.Window) error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) skipTaskbar() error {
|
func (u *userInterfaceImpl) skipTaskbar() error {
|
||||||
@ -212,7 +221,11 @@ func (u *userInterfaceImpl) skipTaskbar() error {
|
|||||||
t := (*_ITaskbarList)(ptr)
|
t := (*_ITaskbarList)(ptr)
|
||||||
defer t.Release()
|
defer t.Release()
|
||||||
|
|
||||||
if err := t.DeleteTab(windows.HWND(u.window.GetWin32Window())); err != nil {
|
w, err := u.window.GetWin32Window()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := t.DeleteTab(w); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,12 @@ func (w *glfwWindow) IsDecorated() bool {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v = w.ui.window.GetAttrib(glfw.Decorated) == glfw.True
|
a, err := w.ui.window.GetAttrib(glfw.Decorated)
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v = a == glfw.True
|
||||||
})
|
})
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
@ -57,7 +62,10 @@ func (w *glfwWindow) SetDecorated(decorated bool) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowDecorated(decorated)
|
if err := w.ui.setWindowDecorated(decorated); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +103,10 @@ func (w *glfwWindow) SetResizingMode(mode WindowResizingMode) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowResizingMode(mode)
|
if err := w.ui.setWindowResizingMode(mode); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +122,12 @@ func (w *glfwWindow) IsFloating() bool {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v = w.ui.window.GetAttrib(glfw.Floating) == glfw.True
|
a, err := w.ui.window.GetAttrib(glfw.Floating)
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v = a == glfw.True
|
||||||
})
|
})
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
@ -128,7 +144,10 @@ func (w *glfwWindow) SetFloating(floating bool) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowFloating(floating)
|
if err := w.ui.setWindowFloating(floating); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +166,12 @@ func (w *glfwWindow) IsMaximized() bool {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v = w.ui.isWindowMaximized()
|
m, err := w.ui.isWindowMaximized()
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v = m
|
||||||
})
|
})
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
@ -176,7 +200,10 @@ func (w *glfwWindow) Maximize() {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.maximizeWindow()
|
if err := w.ui.maximizeWindow(); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +216,12 @@ func (w *glfwWindow) IsMinimized() bool {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v = w.ui.window.GetAttrib(glfw.Iconified) == glfw.True
|
a, err := w.ui.window.GetAttrib(glfw.Iconified)
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v = a == glfw.True
|
||||||
})
|
})
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
@ -203,7 +235,10 @@ func (w *glfwWindow) Minimize() {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.iconifyWindow()
|
if err := w.ui.iconifyWindow(); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +257,10 @@ func (w *glfwWindow) Restore() {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.restoreWindow()
|
if err := w.ui.restoreWindow(); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +279,10 @@ func (w *glfwWindow) SetMonitor(monitor *Monitor) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowMonitor(monitor)
|
if err := w.ui.setWindowMonitor(monitor); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,13 +298,28 @@ func (w *glfwWindow) Position() (int, int) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
f, err := w.ui.isFullscreen()
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var wx, wy int
|
var wx, wy int
|
||||||
if w.ui.isFullscreen() {
|
if f {
|
||||||
wx, wy = w.ui.origWindowPos()
|
wx, wy = w.ui.origWindowPos()
|
||||||
} else {
|
} else {
|
||||||
wx, wy = w.ui.window.GetPos()
|
x, y, err := w.ui.window.GetPos()
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx, wy = x, y
|
||||||
|
}
|
||||||
|
m, err := w.ui.currentMonitor()
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
m := w.ui.currentMonitor()
|
|
||||||
wx -= m.boundsInGLFWPixels.Min.X
|
wx -= m.boundsInGLFWPixels.Min.X
|
||||||
wy -= m.boundsInGLFWPixels.Min.Y
|
wy -= m.boundsInGLFWPixels.Min.Y
|
||||||
xf := dipFromGLFWPixel(float64(wx), m)
|
xf := dipFromGLFWPixel(float64(wx), m)
|
||||||
@ -285,7 +341,15 @@ func (w *glfwWindow) SetPosition(x, y int) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowPositionInDIP(x, y, w.ui.currentMonitor())
|
m, err := w.ui.currentMonitor()
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := w.ui.setWindowPositionInDIP(x, y, m); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,10 +386,18 @@ func (w *glfwWindow) SetSize(width, height int) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if w.ui.isWindowMaximized() && runtime.GOOS != "darwin" {
|
m, err := w.ui.isWindowMaximized()
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if m && runtime.GOOS != "darwin" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := w.ui.setWindowSizeInDIP(width, height, true); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowSizeInDIP(width, height, true)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +420,10 @@ func (w *glfwWindow) SetSizeLimits(minw, minh, maxw, maxh int) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.updateWindowSizeLimits()
|
if err := w.ui.updateWindowSizeLimits(); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +450,10 @@ func (w *glfwWindow) SetTitle(title string) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowTitle(title)
|
if err := w.ui.setWindowTitle(title); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +477,10 @@ func (w *glfwWindow) SetMousePassthrough(enabled bool) {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.ui.setWindowMousePassthrough(enabled)
|
if err := w.ui.setWindowMousePassthrough(enabled); err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +496,12 @@ func (w *glfwWindow) IsMousePassthrough() bool {
|
|||||||
if w.ui.isTerminated() {
|
if w.ui.isTerminated() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v = w.ui.window.GetAttrib(glfw.MousePassthrough) == glfw.True
|
a, err := w.ui.window.GetAttrib(glfw.MousePassthrough)
|
||||||
|
if err != nil {
|
||||||
|
theGlobalState.setError(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
v = a == glfw.True
|
||||||
})
|
})
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user