Hajime Hoshi
8ff42f55a1
internal/graphicsdriver/opengl: Give up restorign on browsers
...
Using restorable images is expensive as this sometimes requires to
load pixels from GPU. On browsers, just reloading the application
should be fine when the context lost happens.
Closes #1603
2021-06-26 16:54:21 +09:00
Hajime Hoshi
49c3c30c79
ebiten: Add IsWindowBeingClosed / SetWindowClosingHandled / IsWindowClosingHandled
...
IsWindowBeingClosed reports whether the window is being closed by
the user.
SetWindowClosingHandled sets whether the window closing is handled
or not. If the state is true, the window is not closed immediately
by the user and the game can handle the closing state. In this case,
the Update function should return an error in order to end the game.
This change also adds examples/windowclosing.
Closes #1574
2021-06-14 02:29:11 +09:00
Hajime Hoshi
f989ce4e64
internal/uidriver/glfw: Rename variables
2021-06-13 23:25:24 +09:00
Hajime Hoshi
3c2d562967
internal/glfw: Bug fix: NewCallbackCDecl objects were leaked
...
Callbacks created by NewCallbackCDecl were never released and then
they are leaked, especially when the window size was changed by
SetWindowSize on Windows.
This change defines new callback ID types with uintptr, and reuse
the callbacks.
Closes #1672
2021-06-13 22:23:01 +09:00
Hajime Hoshi
b54ad73a2b
Add go:build comments with go1.17beta1 fmt
2021-06-11 01:11:46 +09:00
Hajime Hoshi
a627c41217
Remove support of Go 1.13 and Go 1.14
...
Updates #1258
Updates #1415
Updates #1462
2021-06-07 21:44:22 +09:00
Hajime Hoshi
58843b68f9
internal/hooks: Enable to return error at suspend/resume audio
2021-05-04 23:09:01 +09:00
Tom Lister
bea5ab3335
internal/uidriver/glfw: Native macOS implementation for setting cursor shape ( #1624 )
...
Updates #1624
2021-05-02 14:50:50 +09:00
Hajime Hoshi
b509ce523d
internal/uidriver/js: Bug fix: SetFullscreen didn't work on Safari
...
Updates #1611
2021-04-28 23:28:58 +09:00
Tom Lister
5d3a76cbe6
internal/uidriver/js: Implement {Set,}Fullscreen for browsers ( #1623 )
...
Closes #1611
2021-04-27 23:58:32 +09:00
Hajime Hoshi
091e51ae4c
internal/uidriver/glfw: Avoid allocating a new slice
2021-04-25 00:57:06 +09:00
Hajime Hoshi
e2ceb7b3a6
internal/uidriver/glfw: Call fromGLFWPixels from the main thread
...
fromGLFWPixels can invoke driverScaleFactor, and then using the main
thread is safer.
2021-04-24 23:30:51 +09:00
Hajime Hoshi
91f8347500
internal/uidriver/glfw: Avoid busy loop by sleeping
...
Updates #1580
2021-04-24 05:19:23 +09:00
Hajime Hoshi
3df31c0fce
internal/uidriver/glfw: Bug fix: Deadlock at FramebufferSize callback
...
glfw.PollEvents might invoke multiple FramebufferSize callbacks in
theory, this is very rare though. In this case, the sending an object
to the channel never ends.
This change fixes this deadlock by using 'select'.
Closes #1618
2021-04-24 02:22:51 +09:00
Hajime Hoshi
ac9a18931c
internal/uidriver/glfw: Fix comments
...
Updates #1618
2021-04-23 03:28:14 +09:00
Hajime Hoshi
d446aa39a9
internal/uidriver/glfw: Bug fix: Always wait for SetFramebuffer
...
In case when the callback is not called, let's use timeout.
Updates #1618
2021-04-23 03:02:12 +09:00
Hajime Hoshi
c4c331b0d5
Fix misspellings
2021-04-21 22:50:00 +09:00
Hajime Hoshi
4cb6cb9d6a
internal/uidriver/glfw: Misspelling
2021-04-21 22:29:54 +09:00
Hajime Hoshi
1013ca9c66
internal/uidriver/glfw: Bug fix: A window can never be 'maximized' on fullscreen
...
When the window is fullscreen, calling MaximizeWindow never returned.
Apparently the attribute glfw.Maximized can never be true on the
fullscreen mode.
This change fixes the issue by checking the fullscreen state.
2021-04-21 22:25:14 +09:00
Hajime Hoshi
c7dd9a4107
internal/uidriver/glfw: Bug fix: Wait for Restore/Maximize/Iconify finishes explicitly
...
On Linux (and probably other UNIX OSes), glfwRestore, glfwMaximize,
and glfwIconify returns even though the window state has not changed.
Wait for its finish by a for loop and glfw.PollEvents.
Closes #1608
2021-04-21 00:52:06 +09:00
Hajime Hoshi
58572fb000
internal/uidriver/glfw: Bug fix: Unexpected small window size on Linux
...
At the initial phase, GLFW window's GetSize seems unreliable. Do not
call it on Linux. On the other hand, this is still necessary on macOS.
Updates #1606
Closes #1609
2021-04-20 23:38:34 +09:00
Hajime Hoshi
ec5b806241
Revert "internal/uidriver/glfw: Bug fix: Delay to enable SetSize callback"
...
This reverts commit fbe6961528
.
Reason: This doesn't fix the issue unfortunately
2021-04-20 23:01:02 +09:00
Hajime Hoshi
fbe6961528
internal/uidriver/glfw: Bug fix: Delay to enable SetSize callback
...
On Linux, the SetSize callback is invoked with an unexpected value
at the initial phase. Just delay it until the initialization
finishes.
2021-04-20 22:53:48 +09:00
Hajime Hoshi
47f569e473
internal/uidriver/glfw: Bug fix: setWindowSize could not accept a fullscreen size
2021-04-20 20:09:04 +09:00
Hajime Hoshi
ee8bfcd837
internal/uidriver/glfw: Bug fix: Disable the SetSize callback for most of GLFW window functions
...
Updates #1576
Updates #1585
Closes #1606
2021-04-20 18:32:39 +09:00
Hajime Hoshi
74018348c0
internal/uidriver/js: Update the error message
...
Updates #1604
2021-04-20 12:47:38 +09:00
Hajime Hoshi
191cc667e1
internal/uidriver/js: Add an error message when pointerlockerror happens
...
Updates #1604
2021-04-20 12:22:33 +09:00
Hajime Hoshi
18ce150495
internal/uidriver/glfw: Bug fix: getWindowSizeLimits should return -1 when the original value was -1
...
Updates #1602
2021-04-20 11:05:17 +09:00
Hajime Hoshi
dcaa1f9722
internal/uidriver/glfw: Bug fix: Need to reregister the callback after recreating the window
...
Updates #1588
Closes #1593
2021-04-19 01:28:59 +09:00
Hajime Hoshi
fd80583dd0
internal/uidriver/glfw: Bug fix: Defer SetIcon on the fullscreen mode
...
Closes #1587
2021-04-18 22:28:01 +09:00
Hajime Hoshi
7e61189c3d
internal/uidriver/glfw: Bug fix: Avoid registring C callbacks too often
...
Instead of registring/unregistering callbacks, use a boolean flag.
Closes #1588
2021-04-18 22:07:29 +09:00
Hajime Hoshi
c88ee0d0ad
internal/uidriver/glfw: Bug fix: Unregister SetSize callback when undecorate the window
...
Closes #1586
2021-04-18 21:24:56 +09:00
Hajime Hoshi
f5a4216434
internal/uidriver/glfw: Bug fix: Do not call setWindowSize on iconifying
...
The window size might be 0 after iconifying. An iconified window is
invisible to users so setting a window size doesn't make sense anyway.
Closes #1585
2021-04-18 21:06:04 +09:00
Hajime Hoshi
26432dfc9e
Revert "internal/uidriver/glfw: Refactoring: use glfw.Window when possible"
...
This reverts commit 475453d5d2
.
Reason: #1584 : A wrong active monitor was detected at the initial phase?
Closes #1584
2021-04-18 20:05:37 +09:00
Hajime Hoshi
78732d93f6
internal/uidriver/glfw: Bug fix: Crash on some operations on native fullscreen mode (macOS)
...
This change forbids some operations when the wiindow is natively
fullscreened on macOS in order to avoid crashes.
Closes #1578
2021-04-18 18:11:33 +09:00
Hajime Hoshi
fda1fd9a95
internal/uidriver/glfw: Bug fix: FramebufferSize callback was not called when the window size was not changed
...
Closes #1580
2021-04-18 15:22:51 +09:00
Hajime Hoshi
f09cf7fa47
internal/uidriver/glfw: Bug fix: Crash at Iconify
...
This is the same reason as Maximize.
Updates #1576
2021-04-18 01:03:13 +09:00
Hajime Hoshi
b5d4c834b8
internal/uidriver/glfw: Bug fix: More precise window size adjustment
...
Before this change, setWindowSize converts the size in device-
independent pixels once, invokes adjustWindowSizeBasedOnSizeLimitsInDP,
and then restore the values in device-dependent pixels. This might
introduce a slight error and then SetSize be unexpectedly invoked.
Such SetSize call with a slightly different size might not invoke
the FramebufferSize callback, and then this blocked forever when
maximizing the window.
This change fixes this by adjusting the size limits instead of the
window size so that the window size is not modified unexpectedly.
Closes #1577
2021-04-18 00:56:37 +09:00
Hajime Hoshi
d6ab27a5a2
internal/uidriver/glfw: Bug fix: Crash at Restore
...
This is the same reason as Maximize.
Updates #1576
2021-04-18 00:10:40 +09:00
Hajime Hoshi
37944d67c4
internal/uidriver/glfw: Update comments
...
Updates #1576
2021-04-18 00:05:48 +09:00
Hajime Hoshi
ab8477a21a
internal/uidriver/glfw: Bug fix: Crash on Maximize
...
At least on macOS, Maximize invokes the SetSize callback in the game's
Update. This change fixes this issue by unregisting the callback
temporarily like what #1505 did.
Closes #1576
2021-04-18 00:02:58 +09:00
Hajime Hoshi
6df87a0383
internal/uidriver: Add comments
...
Updates #1575
2021-04-17 18:17:26 +09:00
Hajime Hoshi
deba352384
internal/uidriver/glfw: Prefer currentMonitor to get the monitor at deviceScaleFactor
2021-04-17 17:03:50 +09:00
Hajime Hoshi
e89f53774c
internal/uidriver/glfw, internal/devicescale: Add comments
2021-04-17 15:45:46 +09:00
Hajime Hoshi
585f173d1c
internal/uidriver/glfw: Bug fix: Treat pixel units correctly
...
Updates #1385
2021-04-17 04:43:33 +09:00
Hajime Hoshi
99b2b5c1ee
internal/glfw: Bug fix: compile error on Windows
...
Updates #1385
2021-04-17 04:24:19 +09:00
Hajime Hoshi
9b6ba5ed2c
ebiten: Add {Set,}WindowSizeLimits
...
Closes #1385
2021-04-17 03:58:06 +09:00
Hajime Hoshi
4cbbdbf518
internal/uidriver/js: Misspelling
2021-04-16 03:14:46 +09:00
Hajime Hoshi
20705d63a3
internal/uidriver/js: Refactoring
2021-04-16 03:13:12 +09:00
Hajime Hoshi
ead84553a0
internal/uidriver/js: Implement CursorModeCaptured
...
Closes #1572
2021-04-16 03:09:24 +09:00
Hajime Hoshi
3c1226a227
internal/uidriver/js: Bug fix: SetCursorMode didn't work
2021-04-16 01:21:48 +09:00
Hajime Hoshi
d00d0c8556
ebiten: Add CursorShape/SetCursorShape/CursorShapeType
...
This change adds APIs to enable to use system cursor shapes other
than the default shape (an arrow).
This change doesn't add these cursors since they seem a little
different on macOS from the other platforms.
* GLFW_HRESIZE_CURSOR
* GLFW_VRESIZE_CURSOR
Closes #995
2021-04-16 01:09:19 +09:00
Hajime Hoshi
71e899acf3
internal/uidriver/glfw: Refactoring
2021-04-15 02:01:20 +09:00
Hajime Hoshi
4398a5e227
ebiten: Change the key name convention to follow the Web standard
...
Closes #1394
2021-04-14 22:49:07 +09:00
Hajime Hoshi
0246a6407e
ebiten: Guarantee that CursorPosition returns (0, 0) in the very initial state on desktops
...
This change also guarantees that CursorPosition always returns (0, 0)
on mobiles.
2021-04-07 03:08:09 +09:00
Hajime Hoshi
ad3c76b6d9
internal/uidriver/js: Bug fix: CursorPosition crashed before the main loop on browsers
...
Closes #1559
2021-04-07 03:07:09 +09:00
Hajime Hoshi
475453d5d2
internal/uidriver/glfw: Refactoring: use glfw.Window when possible
...
Updates #1122
2021-04-03 17:29:38 +09:00
Hajime Hoshi
19702619ee
ebiten: Bug fix: AdjustPosition could return Inf
...
Before the initialization finishes, AdjustPosition could return Inf
values and in this case AdjustPosition's returning values don't make
sense. Let's return NaN in this case.
Closes #1545
2021-03-27 18:46:14 +09:00
Hajime Hoshi
d415e9c771
internal/uidriver/glfw: Refactoring
2021-03-27 18:35:31 +09:00
Hajime Hoshi
402e1a251a
internal/uidriver/js: Bug fix: CursorMode didn't work on go2cpp
2021-03-21 16:40:35 +09:00
Hajime Hoshi
990fb14f17
internal/uidriver/glfw: Separate createWindow and registring the callback
...
createWindow created a window and also registered the SetSize callback.
This was problematic in setWindowSize, since the callback was invoked
in setWindowSize unexpectedly.
This change separates createWindow and registring the callback so that
the created window in setWindowSize doesn't invoke the callback until
setWindowSize finishes.
Closes #1505
2021-03-06 17:48:28 +09:00
Hajime Hoshi
fda421c5fe
internal/uidriver/glfw: Bug fix: SEGV at setWindowSize
...
u.window can be a different value before and after the function
setWindowSize.
Closes #1522
2021-03-03 23:04:35 +09:00
Hajime Hoshi
d913e66cd9
Revert "uidriver/glfw: Bug fix: Do not iconify the fullscreen window automatically"
...
This reverts commit 61bf10e73e
.
Reason: This prevents the app from iconifying when toggling apps.
Updates #1405
Closes #1504
2021-02-23 20:13:21 +09:00
Hajime Hoshi
18d526c2d3
internal/uidriver/glfw: Bug fix: Crash when returning from fullscreen
...
ForceUpdate was called unexpectedly inside Update. This caused the
race condition.
Closes #1505
2021-02-23 16:52:12 +09:00
Hajime Hoshi
1517f80430
internal/uidriver/glfw: Refactoring
2021-02-11 04:02:18 +09:00
Hajime Hoshi
ec912e5cad
internal/uidriver/glfw: Remove the dirty hack creating a temporary UI instance
...
Updates #1122
2021-02-11 03:45:39 +09:00
Hajime Hoshi
fea802b39d
internal/uidriver: Replace mutex usages with atomic
...
Updates #1073
2021-02-11 02:38:15 +09:00
Hajime Hoshi
9400efa9a5
internal/uidriver/glfw: Update the screen on resizing
...
Closes #1204
2021-02-07 23:03:56 +09:00
Hajime Hoshi
d999b4dc8e
internal/uidriver/glfw: Bug fix: Enable to specify ebiten.Image to SetWindowIcon
...
Closes #1468
2021-02-07 21:18:30 +09:00
Hajime Hoshi
599b3501fd
internal/uidriver/js: Bug fix: GamepadName and GamepadSDLID could return wrong values
...
Updates #1472
2021-01-26 10:35:40 +09:00
Hajime Hoshi
b9a0906537
internal/uidriver/js: Bug fix: nil map
2021-01-26 10:26:52 +09:00
Hajime Hoshi
2dadfdb88e
internal/uidriver: Optimization
2021-01-26 01:02:24 +09:00
Hajime Hoshi
f1848a6d46
internal/uidriver/js: Optimization: Avoid creating new maps for initialization
2021-01-26 00:12:18 +09:00
Hajime Hoshi
e844c257f7
internal/uidriver/js: Bug fix: Compile error
2021-01-25 22:49:45 +09:00
Hajime Hoshi
10e5e9e633
internal/uidriver: Prepare the slice capacities
2021-01-25 22:47:44 +09:00
Hajime Hoshi
40e662d672
internal/uidriver: Optimization
2021-01-24 23:59:44 +09:00
Hajime Hoshi
a0a8d41ff6
uidriver/js: Force to update the screen when resizing
...
Updates #1204
2021-01-18 01:17:58 +09:00
Hajime Hoshi
dd15927710
uidriver/js: Bug fix: IsFocused crashes on go2cpp
2021-01-03 17:53:21 +09:00
Hajime Hoshi
fcbde8d124
uidriver/mobile: Do not use %q at the mobile error message
...
Closes #1447
2021-01-02 02:08:36 +09:00
Hajime Hoshi
bb20c9719e
uidriver/js: Implement gamepads for go2cpp
...
Updates #744
2020-12-27 20:10:45 +09:00
Hajime Hoshi
601fd5eb22
uidriver/js: Update go2cpp touch API
2020-12-27 19:56:24 +09:00
Hajime Hoshi
8e6792ca23
uidriver/js: Refactoring: Use a map for gamepad states
...
This change improves the consistency with touches.
2020-12-27 18:44:16 +09:00
Hajime Hoshi
a6ade8f5cd
uidriver/js: Update touch APIs for go2cpp
2020-12-21 23:01:12 +09:00
Hajime Hoshi
b20f611058
uidriver/js: Implement touches on go2cpp
2020-12-21 18:36:01 +09:00
Hajime Hoshi
8003000976
uidriver/js: Refactoring
2020-12-20 18:19:58 +09:00
Hajime Hoshi
2e2ee2595b
uidriver/js: Refactoring
2020-12-20 18:17:08 +09:00
Hajime Hoshi
5bbb148a38
uidriver/js: Add jsKeyToID to avoid js.Value.String
...
Fixes #1437
2020-12-16 13:30:42 +09:00
Hajime Hoshi
69b1d2e820
uidriver/js: Use js.Value as key strings
...
Updates #1437
2020-12-16 12:53:33 +09:00
Hajime Hoshi
442be20f4d
uidriver/js: Avoid calling String when possible to reduce overhead
...
Updates #1437
2020-12-16 12:41:55 +09:00
Hajime Hoshi
8d2a4ac917
uidriver/glfw: Bug fix: OpenGL was adopted unexpectedly on macOS Big Sur
...
Fixes #1429
2020-12-09 10:21:26 +09:00
Hajime Hoshi
35867c7697
uidriver/js: Add go2cpp.screenWidth/screenHeight
2020-12-09 10:10:34 +09:00
Hajime Hoshi
768fdd2c47
uidriver/js: Separate registering event handlers
2020-12-06 22:56:09 +09:00
Hajime Hoshi
5897e1ab7c
Implement some preparation code for go2cpp
...
Updates #744
2020-11-30 23:18:42 +09:00
Hajime Hoshi
4df958c9fd
Avoid comparing to js.Undefined() for consistency
2020-11-21 14:25:17 +09:00
Hajime Hoshi
3101ffd082
uidriver/glfw: Bug fix: Add more mutex locks for callbacks
...
Updates #1358
2020-11-18 20:43:29 +09:00
Hajime Hoshi
91b01ff83d
uidriver/glfw: Replace thread usages with mutex usages for performance
...
Updates #1358
2020-11-18 19:45:15 +09:00
Hajime Hoshi
14070ee153
uidriver: Copy the runes on the callee sides
2020-11-18 19:37:12 +09:00
Hajime Hoshi
61bf10e73e
uidriver/glfw: Bug fix: Do not iconify the fullscreen window automatically
...
Fixes #1405
2020-10-27 03:14:55 +09:00
Jake Coffman
290f05060a
ebiten: Add ebitensinglethread build tag ( #1396 )
...
Updates #1367
2020-10-21 02:55:17 +09:00
Hajime Hoshi
f611b48c71
graphicsdriver/opengl: Use native GLES functions for mobiles
...
After this change, GL functions for mobiles, especially Android, are
native ones instead of golang.org/x/mobile/gl functions in order to
reduce goroutine context switches.
On gomobile-build, golang.org/x/mobile/gl functions are still used.
Fixes #1387
2020-10-19 03:51:20 +09:00