Commit Graph

252 Commits

Author SHA1 Message Date
Hajime Hoshi
7a0e31a23a Clean up the 'js' build tags
Updates #1129
2020-10-07 01:33:10 +09:00
Hajime Hoshi
00f3d83d4c Remove supporting GopherJS
Fixes #1129
2020-10-07 01:10:09 +09:00
Hajime Hoshi
41cf90a321 ebiten: Change the default value of IsRunningOnUnfocused to be true
Fixes #1180
2020-10-07 00:30:49 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Hajime Hoshi
9890dc51da uidriver/glfw: Bug fix: Need to call updateVsync after setWindowSize
Fixes #1363
2020-09-22 18:45:56 +09:00
Hajime Hoshi
ee52c88e98 uidriver/glfw: Bug fix: Set the correct window size when going back from fullscreen 2020-09-21 19:20:58 +09:00
Hajime Hoshi
3fc328db8d uidriver/glfw: Adjust monitor sizes with math.Ceil
deviceScaleFactor() sometimes returns an unnice value (e.g.,
1.502361). Add math.Ceil whenever the calculation involves the
device scale factor.
2020-09-21 18:52:27 +09:00
Hajime Hoshi
28ce1fc3fb uidriver/glfw: Bug fix: Compile failure 2020-09-19 01:32:33 +09:00
Hajime Hoshi
51f06139a6 uidriver/glfw: Bug fix: Treat X scale (HiDPI) correctly
Fixes #1350
2020-09-19 01:24:18 +09:00
Hajime Hoshi
40e35fa047 uidriver/glfw: Bug fix: Unscale the size for framebuffers on Linux/UNIX
Fixes #1307
2020-09-19 01:04:18 +09:00
Hajime Hoshi
97607f5779 graphicsdriver/glfw: Bug fix: Convert window size unit correctly on Linux/UNIX
Updates #1307
2020-09-19 00:31:34 +09:00
Hajime Hoshi
5278a7c6d6 uidriver/glfw: Bug fix: Use the correct scale for GLFW APIs on Linux/UNIX
Updates #1307
2020-09-19 00:21:10 +09:00
Hajime Hoshi
20ccafce4b uidriver/mobile: Bug fix: Freezing on Pixel 4a by force calling DoWork
When the two channels don't receive for a while, call DoWork forcibly to avoid
freeze.

In theory, this timeout should not be necessary. However, it looks like this
'select' statement sometimes blocks forever on some Android devices like
Pixel 4(a). Apparently workAvailable sometimes not receives even though there
are queued OpenGL functions. Call DoWork for such case as a symptomatic
treatment.

Calling DoWork without waiting for workAvailable is safe. If there are no tasks,
DoWork should return immediately.

Updates #1322
Fixes #1332
2020-09-06 14:34:12 +09:00
Hajime Hoshi
a3b41515a9 ui: Replace the native window's type (unsafe.Pointer) with uintptr
Updates #1306
2020-09-04 00:51:48 +09:00
Hajime Hoshi
8336cb6007 uidriver/mobile: Refactoring 2020-08-31 23:28:00 +09:00
Hajime Hoshi
f332fa61c1 uidriver/mobile: Refactoring 2020-08-31 01:01:36 +09:00
Hajime Hoshi
349faa0f34 thread: Use an error value instead of context.Context 2020-08-30 02:18:12 +09:00
Hajime Hoshi
1ed2b09ba0 uidriver/glfw: Ensure that canceling happens after all the queued tasks are done 2020-08-29 23:27:20 +09:00
Hajime Hoshi
deb3d4a0c3 uidriver/mobile: Bug fix: Freeze on Pixel 4
An Ebiten application often freezes on Pixel 4. Apparently adding
loggings or runtime.Gosched hides the issue, though this doesn't fix
the root cause. The root cause might be in gomobile itself, but it
seeems really hard to make a minimum case.

As a tentative fix, add runtime.Gosched to avoid freezing.

Fixes #1322
2020-08-29 22:02:54 +09:00
Hajime Hoshi
e19f38bd4f uidriver/mobile: Refactoring 2020-08-29 03:02:20 +09:00
Hajime Hoshi
12878571f6 uidriver/mobile: Refactoring 2020-08-29 02:48:06 +09:00
Hajime Hoshi
b76c34336d uidriver/mobile: Reduce mutex usages 2020-08-29 00:24:30 +09:00
Hajime Hoshi
91aa6a0f3a mobile/ebitenmobileview: Remove mutex usages 2020-08-29 00:18:42 +09:00
Hajime Hoshi
12e5617396 uidriver/glfw: Update comments 2020-08-24 04:07:08 +09:00
Hajime Hoshi
932d599c98 uidriver/glfw: Bug fix compilation failure on macOS and Windows 2020-08-24 03:31:46 +09:00
Hajime Hoshi
a7d234e3c8 uidriver/glfw: Refactoring: make currentMonitorByOS more explicit 2020-08-24 03:27:38 +09:00
Hajime Hoshi
9bff1c79be uidriver/glfw: Refactoring 2020-08-24 03:05:38 +09:00
Hajime Hoshi
af6961fc17 uidriver/glfw: Bug fix: isInitWindowMaximized didn't unlock the mutex 2020-08-24 02:55:31 +09:00
Hajime Hoshi
b1bc06935a uidriver/glfw: Update comments 2020-08-24 00:57:48 +09:00
Hajime Hoshi
ed3a4a734e uidriver/glfw: Refactoring 2020-08-24 00:34:57 +09:00
Hajime Hoshi
9f8054c2d5 uidriver/glfw: Misspelling 2020-08-24 00:10:43 +09:00
Hajime Hoshi
07480ed66d uidriver/glfw: Add better fallbacks for currentMonitorFromPosition
Updates #1119
2020-08-23 23:38:03 +09:00
Hajime Hoshi
10d6a3ad67 uidriver/glfw: Bug fix: Crash on Wine when getting a monitor 2020-08-23 02:31:52 +09:00
Hajime Hoshi
77fa0cb9ef ui: Add SetInitFocused
Fixes #769
2020-08-23 02:19:09 +09:00
Hajime Hoshi
dea716c9a6 uidriver: Remove force focusing by clicking the body
As long as the game is embedded in an iframe, this is no longer
needed.
2020-08-22 18:40:34 +09:00
Hajime Hoshi
85d172c673 uidriver/mobile: Bug fix: The context didn't recovered on gomobile-build
Updates #1176
2020-08-19 23:59:27 +09:00
Hajime Hoshi
3eaa7dd0e1 uidriver/glfw: Set No-API when creating a hidden window first
GLFW tries to create an OpenGL context by default when creating a
window. This is not necessary when OpenGL is not used. This is an
optimization by skipping to create an OpenGL context if possible.
2020-07-05 15:01:06 +09:00
Hajime Hoshi
d08f57e610 uidriver/glfw: Bug fix: Skip some special 'joysticks'
Apparently, there are some special devices that are recognized as
joysticks by GLFW, even though they are not. Such devices can have
too many 'buttons'. Skip them as a tentative solution.

Updates #1173
2020-07-03 22:58:49 +09:00
Hajime Hoshi
b7a1e85788 uidriver/glfw: Remove unused logics 2020-07-03 22:24:30 +09:00
Hajime Hoshi
d98713728a uidriver/glfw: Bug fix: SetVsyncEnabled(false) did not work before the main loop
Fixes #1197
2020-06-14 11:50:58 +09:00
Hajime Hoshi
2bdef2e8c4 restorable: Add an explicit way to detect context-lost
isTexture was used to detect context-lost and called every frame.
This was not good for performance.

This change adds a way to notify context-lost from the WebGL
handlers directly, and the package restorable uses it instead of
calling (*Image).isInvalaidated.

Fixes #1175
2020-05-30 20:29:15 +09:00
Hajime Hoshi
7b960a2df4 uidriver/glfw: Use the actual window size for the offscreen
On Windows, a specified window size might not match with the
actual window size when the size is too big. In this case, Ebiten
could not render the offscreen well and the upper side was cropped.

To avoid this, use the actual window size for the offscreen.

Fixes #1163
2020-05-22 18:18:38 +09:00
Hajime Hoshi
7ccc29e3c7 uidriver/js: Clean up 2020-05-19 04:08:33 +09:00
Hajime Hoshi
be1a8bddbf uidriver/js: Bug fix: Create goroutine for a function passed to rAF
This is necessary not to cause dead-lock.

Updates #1161
2020-05-19 03:28:20 +09:00
Hajime Hoshi
4fa52dcc56 Remove MonoGame support
Fixes #1148
2020-05-08 19:32:28 +09:00
Hajime Hoshi
0e75540f8e monogame: Add IsKeyPressed
Updates #1078
2020-04-21 22:48:57 +09:00
Hajime Hoshi
4dad044ad1 monogame: Update
Updates #1078
2020-04-16 01:10:16 +09:00
Hajime Hoshi
7f64043ba5 monogame: Implement drawing screens
Updates #1078
2020-04-06 01:51:06 +09:00
Hajime Hoshi
08ac91fb50 monogame: Refactoring 2020-04-05 20:00:53 +09:00
Hajime Hoshi
6236ba1f00 Add internal/monogame
Updates #1078
2020-04-04 22:59:13 +09:00
Hajime Hoshi
eabe4152a7 graphicsdriver/opengl: Rename Driver -> Graphics 2020-04-04 17:23:38 +09:00
Hajime Hoshi
6cbf37e855 Add graphicsdriver/monogame 2020-04-04 17:03:45 +09:00
Hajime Hoshi
8777140e91 driver: Simplify UIContext.Update 2020-04-03 00:18:27 +09:00
Hajime Hoshi
4179e6c122 Introduce 'monogame' build tag experimentally
Updates #1078
2020-04-01 23:42:17 +09:00
Hajime Hoshi
a718ddbf7e driver: Add UIDriver.Draw
This is a preparation for XNA.

Updates #1078
2020-04-01 02:55:50 +09:00
Hajime Hoshi
b09fe7157b uidriver/glfw: Update comments 2020-03-29 01:33:23 +09:00
Hajime Hoshi
e3def4ae50 uidriver/glfw: Update comments 2020-03-29 01:12:53 +09:00
Hajime Hoshi
9d5c35f029 uidriver/glfw: Bug fix: Initilizing the window position and the size in this order on Windows
It looks like the order is different on Windows from Linux. We
are not sure why.

Updates #1118
2020-03-29 00:50:19 +09:00
Hajime Hoshi
b7ab3d2df4 uidriver/glfw: Avoid using the window position before initializing
Especially in the initial phase before calling Run/RunGame, the
window position is not reliable and then getting the device scale
factor does not make sense based on the window position. Avoid
using the window position, and instead use the glfw.Monitor in
this situation.
2020-03-29 00:09:08 +09:00
Hajime Hoshi
14200eb42c uidriver/glfw: Add comments 2020-03-29 00:02:33 +09:00
Hajime Hoshi
8480f888dd Revert "uidriver/glfw: Bug fix: Do not use the window position for monitors"
Revert "uidriver/glfw: Bug fix: compile error on Linux"

This reverts commit 0a5126f776.
This reverts commit 3e244d7a7c.

Reason: GetMonitor is available only on fullscreen mode
2020-03-28 23:56:03 +09:00
Hajime Hoshi
e628350d4e uidriver/glfw: Bug fix: Initializing order mattered
Especially on Linux, the window size and the window position must
be initialized in this order.

Fixes #1118
2020-03-28 23:37:21 +09:00
Hajime Hoshi
34acf788d2 uidriver/glfw: Bug fix: Call Maximize explictly instead of the hint
Fixes #1117
2020-03-28 22:34:01 +09:00
Hajime Hoshi
4fe5acd711 ui: Panic on MaximizeWindow when the window is not resizable
On Windows, the window could be maximized even when the window was
not resizable. This behavior is confusing. Forbid it so that the
behavior will be clearer.
2020-03-28 22:08:48 +09:00
Hajime Hoshi
3e244d7a7c uidriver/glfw: Bug fix: compile error on Linux 2020-03-28 21:29:24 +09:00
Hajime Hoshi
8cca713d74 uidriver/glfw: Bug fix: adjustWindowPosition should consider the monitor position 2020-03-28 21:26:57 +09:00
Hajime Hoshi
0a5126f776 uidriver/glfw: Bug fix: Do not use the window position for monitors
Especially in the initial phase before calling Run/RunGame, the
window position is not reliable and then getting the device scale
factor does not make sense based on the window position. Avoid
using the window position, and instead use the glfw.Monitor.
2020-03-28 21:13:30 +09:00
Hajime Hoshi
7b5fb0a0d0 ui: Bug fix: The window was not shown on the secondary monitor on launching
This change changes the behavior of WindowPosition /
SetWindowPosition. The window position is now a relative position
and the origin position is the left-upper of the current monitor.

Fixes #1115
2020-03-28 19:51:47 +09:00
Hajime Hoshi
4ec49dd4cf mobile/ebitenmobileview: Implement Android gamepad axes
Updates #1083
2020-03-25 01:15:43 +09:00
Hajime Hoshi
8fcee54849 mobile/ebitenmobileview: Implement Android gamepad buttons
This is still work in progress.

Updates #1083
2020-03-23 01:30:17 +09:00
Hajime Hoshi
f317f3b5fd ui: Add fuctions to maximize or minimize the window
This change adds these functions:

  * MaximizeWindow
  * IsWindowMaximized
  * MinimizeWIndow
  * IsWindowMinimized
  * RestoreWindow

Fixes #994
2020-03-21 22:13:58 +09:00
Hajime Hoshi
978ee26898 ui: Add function aliases *OnUnfocused for *InBackground
Now a window can be floating with SetWindowFloating, the functions
that have suffix 'IsBackground' seems misleading. However, we
cannot rename them due to backward compatibility. Then, let's add
aliases and revisit them when updating the major version of Ebiten.

Fixes #1102
2020-03-21 00:42:00 +09:00
Hajime Hoshi
56358fd0c4 ui: Rename IsForeground -> IsFocused
Updates #1102
2020-03-21 00:12:47 +09:00
Hajime Hoshi
4ef3b3e804 ui: Add SetWindowFloating / IsWindowFloating
Fixes #880
2020-03-20 22:16:27 +09:00
Hajime Hoshi
6bc62b8f17 uidriver/glfw: Update comments 2020-03-15 15:42:05 +09:00
Hajime Hoshi
3af869732c uidriver/mobile: Implement InputChars for gomobile-build
This change also fixes InputChars to return only printable Unicode
chars on Android.

Updates #237
2020-02-23 01:01:40 +09:00
Hajime Hoshi
de52eb75e4 mobile/ebitenmobileview: Implement InputChars on Android / ebitenmobile
Updates #237
2020-02-23 00:51:49 +09:00
Hajime Hoshi
a208a026f6 uidriver/mobile: Implement keyboard key inputs for gomobile-build
Updates #237
2020-02-22 23:57:16 +09:00
Hajime Hoshi
5b7151595b mobile/ebitenmobileview: Handle keyboard keys on Android (ebitenmobile)
Updates #237
2020-02-20 01:53:51 +09:00
Hajime Hoshi
682f454fc2 input: Refactoring: Rename variables 2020-02-19 10:52:58 +09:00
corfe83
61c2d7cfe8
Simple optimization in IsKeyPressed (#1080)
Simple optimization on IsKeyPressed to avoid iterating through whole map of possible keys.
2020-02-16 02:02:05 +09:00
Hajime Hoshi
883b25f257 uidriver/mobile: Refactoring 2020-02-12 00:36:34 +09:00
Hajime Hoshi
d59aea1db1 driver: Remove the return value from RunWithoutMainLoop 2020-02-11 23:56:53 +09:00
Hajime Hoshi
aef4b4ba53 uidriver/mobile: Refactoring: Give a default outside size 2020-02-11 23:29:52 +09:00
Hajime Hoshi
c927d33457 mobile/ebitenmobileview: Use the common uiContext for layouting
This means that the whole offscreen is cleared correctly.

This change is a little breaking change: SetScreenSize or other
functions no longer works on ebitenmobile. Use Layout instead.

Fixes #1019
2020-02-11 19:40:47 +09:00
Hajime Hoshi
a303487328 uidriver/mobile: Add comments 2020-02-11 14:45:50 +09:00
Hajime Hoshi
099ce1b3b4 Revert "ui: Add SetInitFocused"
This reverts commit bb04fc8a29.

Reason: glfw.Focused / glfw.FocusOnShow did not work

Updates #769
2020-02-10 01:10:40 +09:00
Hajime Hoshi
bb04fc8a29 ui: Add SetInitFocused
Updates #769
2020-02-09 23:45:59 +09:00
Hajime Hoshi
32471af18f uidriver/js: Ensure that the checking-audio loop is finished when the game is finished
After the game loop is finished, any goroutines should not exist.
Otherwise, 'Go program has already exited' error can happen on
Wasm.

This change ensures that the goroutines are finished when the game
is finished. Note that time.Sleep was required to ensure that the
(*time.Ticker) ends.

Fixes #1027
2020-02-09 03:39:08 +09:00
Hajime Hoshi
d6d17a7e85 uidriver/js: Implement GamepadSDLID
Fixes #1053
2020-02-05 00:00:00 +09:00
Hajime Hoshi
802693fa20 uidriver/mobile: Implement IsForeground
This adds hooks on resuming/suspending the application, and
switches the foreground state there. This change also updates
the logic to suspend the game loop to be clearer.

Fixes #1037
2020-01-23 02:08:31 +09:00
Hajime Hoshi
38f49c3768 uidriver/js: Implement IsForeground
Updates #1037
2020-01-21 23:56:57 +09:00
Hajime Hoshi
5c285de3db uidriver/mobile: Prevent non-mobile environments from compiling 2020-01-18 21:15:56 +09:00
Hajime Hoshi
2b9cd5aed6 uidriver/mobile: Bug fix: Compile error
TravisCI doesn't compile for mobiles, so we missed this error.

Updates #1037
2020-01-18 17:39:36 +09:00
Zachary Burkett
6686044452 ui: Add IsForeground API to glfw driver (#1058)
Updates #1037
2020-01-16 10:47:23 +09:00
Hajime Hoshi
e797aed6c9 uidriver/glfw: Refactoring 2020-01-13 18:23:18 +09:00
Hajime Hoshi
c1adf60e69 uidriver/glfw: Rename files 2020-01-13 18:15:39 +09:00
Hajime Hoshi
b4819c4523
input: Rename GamepadGUID -> GamepadSDLID (#1049)
Gamepad GUID is a SDL specific notion and, strictly speaking,
they are not GUID (UUID) since they don't follow UUID's
specifications.

Renaming the function makes the situation clearer.

Updates #1048
2020-01-11 15:50:37 +09:00
Jake Bentvelzen
c17946bb82 ui: Add GamepadGUID and GamepadName functions (#1035)
Fixes #1034
2020-01-09 22:11:32 +09:00
hiroebe
6ee587301c Fix multiple close for channel (#1047) 2020-01-08 12:50:57 +09:00