Commit Graph

811 Commits

Author SHA1 Message Date
Hajime Hoshi
9c448d207a internal/ui: remove an unnecessary alias 2022-04-01 21:17:26 +09:00
Hajime Hoshi
b53cb2acd6 internal/ui, internal/mipmap, internal/graphicscommand: fix a wrong panic message 2022-04-01 20:12:12 +09:00
Hajime Hoshi
8e40b2562e internal/ui: remove an error returning value from Game.Draw 2022-04-01 19:10:10 +09:00
Hajime Hoshi
ea1c18d124 internal/ui: rename contextImpl -> context 2022-04-01 17:59:44 +09:00
Hajime Hoshi
09a548e055 internal/ui: consider the case when currentMonitor() returns nil
Closes #1887
2022-04-01 03:51:28 +09:00
Hajime Hoshi
b5a9ff007c internal/ui: bug fix: WindowPosition/SetWindowPosition didn't work on macOS fullscreen
Updates #1590
Closes #2043
2022-03-30 12:10:48 +09:00
Hajime Hoshi
172da82aa7 internal/ui: optimization: reduce u.t.Call 2022-03-30 03:28:18 +09:00
Hajime Hoshi
f2860bebed internal/ui: remove an unnecessary hack to resize the window
The bug (#1606) is no longer reproducible even without the hack.

Updates #1606
Updates #1609
2022-03-30 02:48:39 +09:00
Hajime Hoshi
feb70963c6 internal/ui: force to put the window in the initial monitor
To make things simple, let's not put the window outside the initial
monitor.

Updates #1351
Closes #1575
2022-03-30 01:56:35 +09:00
Hajime Hoshi
07d6419dc6 internal/ui: bug fix: DeviceScaleFactor was not concurrent-safe before the main loop
Updates #1575
Closes #2042
2022-03-29 00:27:44 +09:00
Hajime Hoshi
79e93d3b12 internal/graphicsdriver: introduce the DirectX driver
Closes #1007
2022-03-26 20:09:34 +09:00
Hajime Hoshi
9bfbbb6e9e internal/ui: add graphicsDriverGetter.getDirectX()
Updates #1007
2022-03-25 19:43:38 +09:00
Hajime Hoshi
c61be3c532 internal/ui: bug fix: getMetal might return a nil pointer as a non-nil interface 2022-03-24 13:36:53 +09:00
Hajime Hoshi
eeb5687b73 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to pointers
On second thought, returning pointers is more natural. Handling
nil is a caller's responsibility.
2022-03-24 13:20:36 +09:00
Hajime Hoshi
3074dca670 internal/ui: add the EBITEN_GRAPHICS_LIBRARY environment variable
The `ebitengl` build tag is gone instead.

Closes #2007
2022-03-24 02:23:37 +09:00
Hajime Hoshi
85daef7436 internal/ui: bug fix: OpenGL must be used when gomobile-build is used
Now the logic of graphicsDriver() is updated, this can return a Metal
graphics driver on iOS even when gomobile-build is used.

This change fixes this issue.
2022-03-23 02:58:56 +09:00
Hajime Hoshi
09b0a0ffaf internal/ui: refactoring: simplify the selection of graphics libraries 2022-03-23 02:21:53 +09:00
Hajime Hoshi
7e6e022065 cmd/ebitenmobile: support Metal for iOS simulators 2022-03-23 01:34:58 +09:00
Hajime Hoshi
8e6907c64a internal/ui: reduce the calls of graphicsDriver() 2022-03-22 02:17:41 +09:00
Hajime Hoshi
15548b4c74 internal/ui: add userInterfaceImpl.graphicsDriver 2022-03-22 00:13:22 +09:00
Hajime Hoshi
be1836339b internal/ui: define the common struct UserInterface for all the environments
The existing UserInterface structs became userInterfaceImpl structs.
2022-03-21 23:10:27 +09:00
Hajime Hoshi
99437944bc internal/ui: remove graphicsDrivre() calls from image.go 2022-03-21 22:49:47 +09:00
Hajime Hoshi
81b9f91f86 internal/graphicscommand: compile shaders lazily
With DirectX, the graphics driver cannot be determined until the
main loop starts, as a transparent window cannot be treated with
DirectX so far. On the other hand, compiling shaders requires a
graphics driver as it requires information about Y directions of
NDCs and framebuffers.

This change delays compiling shaders until the graphics commands
are actually executed in the main loop.

Updates #1007
Updates #2019
2022-03-21 21:09:02 +09:00
Hajime Hoshi
b5bb576a58 internal/ui: refactoring: unexport ConvertUniforms 2022-03-21 17:05:50 +09:00
Hajime Hoshi
f4ad12987d internal/ui: bug fix: compile error with the cbackend tag 2022-03-21 16:59:53 +09:00
Hajime Hoshi
12ce5ae83a internal/ui: remove the call of graphicsDriver() from the context 2022-03-21 16:48:33 +09:00
Hajime Hoshi
c316aaae72 internal/buffered: simplify the API 2022-03-21 15:19:06 +09:00
Hajime Hoshi
29f7a45ccc internal/buffer: remove the graphics-driver argument from ReplacePartialRegionPixels
This is necessary to remove the graphics driver usage from
(*ebiten.Image).At. And this is necessary to determine the graphics
driver after the window becomes transparent or not.

Unfortunately, it is not obvious to make a transparent window with
DirectX. Then, the determination of a graphics driver should be delayed.

Updates #1007
2022-03-21 05:59:43 +09:00
Hajime Hoshi
14c327c89b internal/atlas: replace Pixels with At to reduce unnecessary slice allocations 2022-03-20 18:39:17 +09:00
Hajime Hoshi
11ff0ab48c internal/atlas: refactoring: remove arguments from Pixels 2022-03-20 18:28:57 +09:00
Hajime Hoshi
54b4e87506 internal/restorable: bug fix: ReplacePixels on a sub-image might panic on Android
If regions by ReplacePixel are overlapped, this can panics. This can
happen only on Android, where a context lost can happen.

Thus, a sub-image cannot call a direct ReplacePixels. internal/buffer
has to care this.
2022-03-20 18:01:37 +09:00
Hajime Hoshi
696bbc088f internal/ui: rename variables 2022-03-20 16:51:23 +09:00
Hajime Hoshi
c3e855ab02 internal/buffered: refactoring 2022-03-20 16:44:11 +09:00
Hajime Hoshi
673556d03f internal/ui: move the error handlings to the ui package 2022-03-20 16:26:26 +09:00
Hajime Hoshi
cc574ad67e internal/atlas: rename functions: Area -> Region 2022-03-20 04:20:23 +09:00
Hajime Hoshi
b59dd45239 internal/buffered: separate ReplacePixels with the large-area and small-area versions
For the large-area version, this doesn't require a graphics driver.
This is necessary to ensure that ReplacePixels never needs a graphics
driver.
2022-03-20 04:13:31 +09:00
Hajime Hoshi
4cbce71b2b internal/graphicscommand: move the choice of graphics drivers to internal/ui 2022-03-20 02:51:31 +09:00
Hajime Hoshi
1d9982ee6d internal/ui: move the dependency on graphicscommand from ebiten to ui 2022-03-20 02:00:44 +09:00
Hajime Hoshi
e78f34aa26 internal/ui: add Image
This is a preparation for a refactoring. Image will be a proxy to
pass a graphics driver to the lower layer.
2022-03-20 01:39:05 +09:00
Hajime Hoshi
e4fba8b047 bug fix: compile error with Go 1.16 and older 2022-03-08 00:08:53 +09:00
Hajime Hoshi
86ba7719eb internal/ui: bug fix: use CompareAndSwap 2022-03-07 23:51:10 +09:00
Hajime Hoshi
9c6b7aaca3 internal/ui: catch the error at At correctly 2022-03-05 01:44:59 +09:00
Hajime Hoshi
dd8900ea48 internal/graphicsdriver: refactoring: choose the graphics driver at this package 2022-02-27 23:51:19 +09:00
Hajime Hoshi
99f8e335ee ebiten: refactoring 2022-02-27 22:21:57 +09:00
Hajime Hoshi
77f765d483 internal/testing: bug fix: considering the case when Y is inverted
Closes #2003
2022-02-27 22:14:32 +09:00
Hajime Hoshi
1cb7633ff6 internal/ui: bug fix: atomic.Value.Store cannot be called when a differnet type value is already stored 2022-02-27 17:41:19 +09:00
Hajime Hoshi
566957dc1c internal/graphicsdriver/metal: invert Y at the vertex shader
Instead of using a negative height in the viewport, invert the Y direction
at the vertex shader. This is a little more readable as a negative height
is hacky.

This is a preparation for DirectX 12. DirectX 12's coodination system
is very similar to Metal, but doesn't treat a negative height in its
viewport unfortunately.

Updates #1007
2022-02-27 01:53:03 +09:00
divVerent
ea35296be7
ebiten: provide SetScreenFilterEnabled, a way to disable the default screen filter (#1997)
Using FilterNearest rather than filterScreen or FilterLinear speeds up a
Dell E6500 from 23fps->36fps and 27fps->48fps.

Updates #1772
2022-02-24 03:46:27 +09:00
Hajime Hoshi
4949c49cd0 internal/ui: refactoring 2022-02-14 03:39:02 +09:00
Hajime Hoshi
871121abe3 internal/ui: refactoring: remove (*contextImpl).layout 2022-02-14 02:59:02 +09:00
Hajime Hoshi
cffa123405 internal/ui: refactoring: remove sizeChanged for js
It is safe to call Layout every frame.
2022-02-14 02:50:32 +09:00
Hajime Hoshi
e2f0878a4c internal/ui: refactoring: remove sizeChanged
It is safe to call Layout every frame.
2022-02-14 02:17:52 +09:00
Hajime Hoshi
e09c1bf8f1 internal/ui: refactoring: remove an error value from runOnAnotherThreadFromMainThread 2022-02-14 00:55:58 +09:00
Hajime Hoshi
ce3f83958e internal/graphicscommand: rename RunOnMainThread -> RunOnRenderingThread 2022-02-14 00:20:49 +09:00
Hajime Hoshi
b695cb928a internal/ui: remove RunWithoutMainLoop in non-mobile environments 2022-02-13 22:31:48 +09:00
Hajime Hoshi
82b9f7dc56 ebiten: refactoring: remove setScreenClearedEveryFrame 2022-02-13 20:40:46 +09:00
Hajime Hoshi
0c1c40995c internal/ui: rename types and members: uiContext -> gameForUI 2022-02-13 20:20:46 +09:00
Hajime Hoshi
29382b424b internal/ui: refactoring: remove some exposed functions 2022-02-13 20:09:13 +09:00
Hajime Hoshi
08defeeded internal/ui: move more logics to internal/ui 2022-02-13 20:02:49 +09:00
Hajime Hoshi
9b2f0b6c56 internal/ui: rename ResetForFrame -> ResetForTick
Resetting happens every tick, not every frame.
2022-02-13 19:54:40 +09:00
Hajime Hoshi
a2cb9fda82 internal/ui: make adjustPosition concurrent-safe 2022-02-13 19:52:39 +09:00
Hajime Hoshi
31aa01131d ebiten: refactoring: reduce call of ui.Get() 2022-02-13 19:40:48 +09:00
Hajime Hoshi
6a8e45e6c1 internal/ui: refactoring: simplify ResetForFrame
Updating the layout is already done every frame, so doing this in
ResetForFrame is not needed.

Updates #490
2022-02-13 19:31:35 +09:00
Hajime Hoshi
7b164882fc internal/ui: refactoring: move AdjustPosition to the package internal/ui 2022-02-13 19:14:29 +09:00
Hajime Hoshi
08ae7006ef internal/ui: refactoring: move some logics to internal/ui 2022-02-13 19:02:59 +09:00
Hajime Hoshi
2609d73a1a internal/ui: refactoring: move some logics to internal/ui 2022-02-13 18:01:18 +09:00
Hajime Hoshi
b282b1805b internal/ui: refactoring: add ui.SetError
This is a preparation to move uiContext to the package internal/ui.
2022-02-13 17:17:08 +09:00
Hajime Hoshi
ab1ad2c72f .github/workflow: add a test to build with the build tag ebitencbackend 2022-02-13 16:57:48 +09:00
Hajime Hoshi
73d995740f internal/ui: bug fix: compile error with ebitencbackend 2022-02-13 16:48:30 +09:00
Hajime Hoshi
e9cfbc1630 internal/ui: refactoring: remove Graphics() 2022-02-13 04:17:39 +09:00
Hajime Hoshi
ab5daa0f90 internal/ui: separate graphics_ios.go to each archtecture
This change removes the support of 32bit iOS. 32bit iOS is no longer
supported by Go 1.15.
2022-02-12 02:14:32 +09:00
Hajime Hoshi
176e984a58 internal/ui: refactoring: remove dependency on the package mtl 2022-02-11 23:11:49 +09:00
Hajime Hoshi
76848f48e6 internal/ui: simplify build tags 2022-02-11 20:47:14 +09:00
Hajime Hoshi
2c2c4bc428 ebiten: add WindowResizingModeType and its constants and functions
This allows a new state to disallow resizing the window but allow
making the window fullscreen on macOS by a user.

This change adds the new type WindowResizingModeType. There are
these constants of this type:

 * WindowResizingModeDisabled
 * WindowResizingModeOnlyFullscreenEnabled
 * WindowResizingModeEnabled

Closes #1819
2022-02-11 04:59:04 +09:00
Hajime Hoshi
f1987cae10 internal/ui: refactoring 2022-02-10 19:35:51 +09:00
Hajime Hoshi
35b9dd0846 internal/ui: give up SetWindowAspectRatioFixed
Unfortunately, it is almost impossible to provide a consistent behavior
to keep the aspect ratio of the window on Windows. Instead of having an
incomplete API, let's remove this.

Closes #1988
2022-02-10 18:35:00 +09:00
Hajime Hoshi
0291986658 internal/ui: bug fix: make the window resizable after the window is created
Making the window resizable BEFORE the window is created doesn't
work correctly, especially when switching to enable resizing later.

Closes #1987
2022-02-10 00:53:22 +09:00
Hajime Hoshi
5899470511 internal/ui: enable vsync even when resizing the window
Now I couldn't see the issue. Probably the implementation of
internal/graphicsdriver/metal has changed since the last fix, but
I am not sure.

Updates #1740
Closes #1954
2022-02-09 23:59:38 +09:00
Hajime Hoshi
edca32e520 internal/ui: bug fix: do not set the minimum window width for macOS
Shrinking a window size by a cursor sometimes makes a smaller window
than 126px. To avoid such flaky behavior, do not set the limitation of
the minimum window width.

On Linux/UNIX, there should not be reasons to limit the window width.

Updates #165
2022-02-09 23:30:26 +09:00
Hajime Hoshi
ad675640b1 internal/ui: bug fix: the aspect ratio should update the window size limits
Updates #1804
2022-02-09 23:18:41 +09:00
Hajime Hoshi
f2da62a175 internal/ui: refactoring 2022-02-09 22:22:14 +09:00
Hajime Hoshi
57c123a412 internal/ui: add comments
Updates #1804
2022-02-09 22:16:31 +09:00
Hajime Hoshi
891ca2a08d ebiten: add IsWindowAspectRatioFixed
This also updates examples/windowsize.

Closes #1804
2022-02-09 20:06:18 +09:00
Hajime Hoshi
7482cae978 internal/ui: bug fix: the aspect ratio must be updated whenever the window size is forcibly updated
This also adds a new flag -aspectratiofixed to examples/windowsize

Updates #1804
2022-02-09 19:56:50 +09:00
Hajime Hoshi
740dfd5aed internal/glfw: refactoring: keep the original API when possible
Updates #1804
2022-02-09 19:36:47 +09:00
Hajime Hoshi
623c050537 ebiten: rename SetKeepWindowAspectRatio -> SetWindowAspectRatioFixed
Updates #1804
2022-02-09 19:29:55 +09:00
Tom Lister
18659ef4ab
internal/ui: add SetWindowKeepAspectRatio (#1985)
Updates #1804
2022-02-09 19:11:25 +09:00
Hajime Hoshi
180eb483bb internal/ui: make currentMonitor return initMonitor when the window is not initialized yet 2022-02-09 00:26:49 +09:00
Hajime Hoshi
b2872f216a internal/ui: update comments
Updates #1575
2022-02-08 20:27:46 +09:00
Hajime Hoshi
cd2ef6771a internal/ui: bug fix: a wrong monitor was used at setWindowPositionInDIP 2022-02-08 20:20:36 +09:00
Hajime Hoshi
9f581327fa intetrnal/ui: remove recreating a window after the fullscreen mode
As macOS's fullscreen is a native fullscreen, this hack is no longer
needed.

Updates #1004
2022-02-08 19:41:09 +09:00
Hajime Hoshi
f8097eb45d internal/ui: give an initial window size at createWindow
This enables to skip setWindowSizeInDIPImpl in most cases.

Updates #1651
Updates #1914
2022-02-08 19:36:30 +09:00
Hajime Hoshi
320e7037f6 internal/ui: update comments 2022-02-08 19:23:38 +09:00
Hajime Hoshi
6dbc5ba558 internal/ui: refactoring: call updateWindowSizeLimits in createWindow 2022-02-08 16:06:12 +09:00
Hajime Hoshi
4c6c31e384 all: reorder build tags in an alphabetical order 2022-02-08 15:49:15 +09:00
Hajime Hoshi
9c8b4db81f internal/ui: separate 'vibrate' part to internal/vibrate 2022-02-08 14:48:55 +09:00
Hajime Hoshi
d2d3673bd2 internal/ui: remove a redundant call of SetTitle 2022-02-08 04:30:58 +09:00
Hajime Hoshi
2fc09c7fcb internal/ui: use the cursor position to choose the initial monitor for Linux/UNIX
Updates #1918
Closes #1982
2022-02-08 03:20:45 +09:00
Hajime Hoshi
294ee43716 internal/ui: remove a special logic for UNIX
The issue #1118 can no longer be reproduced.

Updates #1118
Updates #1982
2022-02-08 01:29:22 +09:00
Hajime Hoshi
cb4085277b internal/ui: bug fix: adjust the window position correctly
Updates #1982
2022-02-07 23:52:16 +09:00
Hajime Hoshi
ed04021151 internal/ui: use the cursor position to choose the initial monitor for Windows
Updates #1918
Updates #1982
2022-02-07 23:31:46 +09:00
Hajime Hoshi
cafb71719c internal/ui: use the cursor position to choose the initial monitor
Updates #1982
2022-02-07 22:37:10 +09:00
Hajime Hoshi
126dc81a96 internal/ui: add a comment 2022-02-07 00:51:48 +09:00
Hajime Hoshi
b78160262c internal/ui: rename files 2022-02-07 00:37:32 +09:00
Hajime Hoshi
f18aef2b08 ebiten: refactoring: move the caller of SetGraphicsDriver to the package ui 2022-02-06 22:01:25 +09:00
Hajime Hoshi
df60c4c92d internal/driver: rename to internal/graphicsdriver 2022-02-06 20:41:32 +09:00
Hajime Hoshi
52f4c409ac internal/ui: refactoring: make Graphics a global function 2022-02-06 20:29:49 +09:00
Hajime Hoshi
0f09ddfbd2 internal/driver: remove Window
Closes #1983
2022-02-06 20:12:40 +09:00
Hajime Hoshi
80c03792cb internal/driver: move the key definitions to internal/ui
Updates #1983
2022-02-06 19:14:18 +09:00
Hajime Hoshi
887a3ff749 internal/cbackend: bug fix: compile error again 2022-02-06 19:07:17 +09:00
Hajime Hoshi
2fbfa5444b internal/driver: remove Input 2022-02-06 18:34:31 +09:00
Hajime Hoshi
6f72b15912 internal/driver: move some definitions to internal/ui
Updates #1983
2022-02-06 18:13:45 +09:00
Hajime Hoshi
149736c3cf internal/uidriver/*: integrate the packages into internal/ui
Updates #1983
2022-02-06 17:23:04 +09:00
Hajime Hoshi
7e5085f15b Add uidriver package and move UI implementation to this packaage 2019-04-07 18:21:16 +09:00
Hajime Hoshi
a4a129e3af ui: Rename currentUI -> theUI 2019-04-07 11:10:55 +09:00
Hajime Hoshi
6b8516c7a5 driver: Move ui.RegularTermination to driver 2019-04-07 10:54:05 +09:00
Hajime Hoshi
1b8d4abfdb driver: Move ui.GraphicsContext to driver 2019-04-07 10:48:18 +09:00
Hajime Hoshi
b579bd7fd0 graphics: Remove GraphicsContext.Invalidated 2019-04-07 10:08:55 +09:00
Hajime Hoshi
6cdcd1ee62 input: Refactoring: Remove input dependencies from ui 2019-04-06 23:42:55 +09:00
Hajime Hoshi
a980de8326 ui: Take the Input driver 2019-04-06 23:29:13 +09:00
Hajime Hoshi
de9f54fd9d driver: Add Input 2019-04-06 21:48:54 +09:00
Hajime Hoshi
80dcec865d ui: Refactoring: Remove pollEvents 2019-03-31 19:51:53 +09:00
Hajime Hoshi
c21fb4d390 input: Move Touch to driver package 2019-03-31 18:58:43 +09:00
Hajime Hoshi
e273618081 input: Rename Reset -> ResetForFrame 2019-03-31 18:49:00 +09:00
Hajime Hoshi
64d3e26fb0 input: Rename UpdateTouches -> SetTouches 2019-03-31 16:30:03 +09:00
Hajime Hoshi
0536efd95f ui: Remove AdjustedCursorPosition 2019-03-31 02:06:42 +09:00
Hajime Hoshi
dec6be1a11 ui: Remove AdjustedTouches 2019-03-31 02:03:59 +09:00
Hajime Hoshi
5d6f66935a ui: Remove UpdateTouches 2019-03-31 01:54:38 +09:00
Hajime Hoshi
43ec1e7fb3 input: Refactoring: Make Touch a struct 2019-03-31 01:14:49 +09:00
Hajime Hoshi
853dbdf19d input: Refactoring 2019-03-31 00:45:52 +09:00
Hajime Hoshi
7445144194 Move graphicsdriver.GrapahicsDriver to driver.Graphics 2019-03-30 22:38:02 +09:00
Hajime Hoshi
f2e42c3ea1 ui: Remove dependencies on driver package 2019-03-30 21:59:11 +09:00
Hajime Hoshi
d6d57fdadf ui: Refactoring 2019-03-28 03:36:31 +09:00
Hajime Hoshi
8ec7ae4c08 Rename drivers -> driver 2019-03-28 01:48:45 +09:00
Hajime Hoshi
5e38f81462 Create packages drivers having actual drivers 2019-03-25 00:29:56 +09:00
Hajime Hoshi
dbc3461628 ui: Use flexbox for centering 2019-03-20 01:44:36 +09:00
Hajime Hoshi
a3882dbc37 ui: Bug fix: devicescale.GetAt must be called on the main thread 2019-03-12 00:28:37 +09:00
Hajime Hoshi
f56c3bd096 ui: Unexport SetWindowResizable (#320) 2019-02-25 02:19:47 +09:00
Hajime Hoshi
ea7c2f8da3 ui: Bug fix: Wrong assumption that the position was always >= 0 2019-02-24 23:34:36 +09:00
Hajime Hoshi
ba59cdbc5f ui: Bug fix: The window must be shown on the current monitor (#829) 2019-02-24 23:26:07 +09:00
Hajime Hoshi
288e0a33ba ui: Bug fix: SetSizeCallback must be effective only when the window is resizable
This is not a perfect solution but at least this fixes the
regression.

Fix #819
2019-02-24 03:25:38 +09:00
Hajime Hoshi
a3eddeb50f Improve panic messages 2019-02-06 23:43:03 -10:00
Hajime Hoshi
5be567d58f ui: Implement restoring context lost on browsers correctly
Fixes #734
2019-02-01 01:20:40 +09:00
Hajime Hoshi
ba47a19b17 mobile: Bug fix: error must be received without waiting for renderCh
Even when error happens, the error was not received when renderCh
received. This was the cause of freezing when error happens.
2019-01-28 12:32:48 +09:00
Hajime Hoshi
248f51cc02 ui: Fix comments 2019-01-17 23:40:33 +09:00
Hajime Hoshi
645b94de5f ui: Bug fix: actualScreenScale must be called on the main thread 2019-01-16 23:32:47 +09:00
Hajime Hoshi
6ed4bbc0a2 ui: Fix comments 2019-01-13 22:51:24 +09:00
Hajime Hoshi
607186859d ui: Run returns immediately on GopherJS
Fixes #778
2019-01-13 22:16:33 +09:00
Hajime Hoshi
5514a9c6ac ui: Bug fix: Changing screen size didn't work correctly on Windows
Fixes #775
2019-01-09 11:08:27 +09:00
Hajime Hoshi
ae84e79d16 ui: Add IsWindowResizable and SetWindowResizable (again)
Fixes #320
2019-01-09 00:24:16 +09:00
Hajime Hoshi
0d4e903b7a Revert "ui: Add IsWindowResizable and SetWindowResizable"
This reverts commit f403e0716f.

Reason: Compilation error on browsers
2019-01-09 00:12:57 +09:00
Hajime Hoshi
f403e0716f ui: Add IsWindowResizable and SetWindowResizable
Fixes #320
2019-01-08 23:52:53 +09:00
Hajime Hoshi
7f656f11d6 ui: Bug fix: Minimum window width should be 1 when the window is not decorated 2019-01-07 00:46:41 +09:00
Hajime Hoshi
f2840bb0dc ui: Remove 'syscall' package usages (#766) 2019-01-04 05:28:46 +09:00
Hajime Hoshi
90f82de5ef glfw: Separate glfw-dependent part and the other part 2018-12-30 20:45:50 +09:00
Hajime Hoshi
55c2fa4de1 Use internal/glfw 2018-12-30 02:35:46 +09:00
Hajime Hoshi
83787123ac ui: Refactoring 2018-12-28 14:08:44 +09:00
Hajime Hoshi
b349efaa0a graphicsdriver/metal: Make main-thread usages more explicit 2018-12-28 02:43:00 +09:00
Hajime Hoshi
532488ac5c mainthread: RunLockOSThread is mainthread package's responsibility 2018-12-28 02:20:53 +09:00
Hajime Hoshi
c76ce28065 Revert "ui: Bug fix: SetVsyncEnabled before Run didn't work on macOS"
This reverts commit 042b30a516.
2018-12-28 02:18:38 +09:00
Hajime Hoshi
042b30a516 ui: Bug fix: SetVsyncEnabled before Run didn't work on macOS 2018-12-28 02:11:48 +09:00
Hajime Hoshi
4d0cc623fb ui: Rename functions 2018-12-22 02:32:02 +09:00
Hajime Hoshi
ff62876552 Add Metal implementation
Fixes #621
2018-12-20 02:37:10 +09:00
Hajime Hoshi
294bf855af ui: Fix logic: [NSApp mainWindow] can be nil when borderless 2018-12-19 02:25:12 +09:00
Hajime Hoshi
db4395d71b ui: Bug fix: ScreenSizeFullscreen before Run crashes on Linux 2018-12-19 01:21:00 +09:00
Hajime Hoshi
6ef5cc5857 ui: Bug fix: SetWindowDecorated didn't work
Fixes #753
2018-12-19 01:01:18 +09:00
Hajime Hoshi
b3ce89aab1 ui: Bug fix: SetWindowIcon before Run didn't work
Fixes #755
2018-12-18 23:16:09 +09:00
Hajime Hoshi
241ccc307f ui: Add comments about #753 2018-12-18 03:34:45 +09:00
Hajime Hoshi
eac00c3d83 ui: Bug fix: SetCursorVisible before Run didn't work
Fixes #754
2018-12-18 03:07:16 +09:00
Hajime Hoshi
2fd0daec10 ui: Fix comments 2018-12-04 03:10:54 +01:00
Hajime Hoshi
d2595c5be7 ui: Refactoring 2018-11-15 01:08:36 +09:00
Hajime Hoshi
e24f6b7848 graphicsdriver/opengl: Rename GetDriver -> Get 2018-11-13 00:01:26 +09:00
Hajime Hoshi
aff77d98e4 graphicsdriver/opengl: Bug fix: compile error on browsers and mobiles 2018-11-11 04:51:17 +09:00
Hajime Hoshi
241716d0e6 Add package graphicsdriver; Move opengl to graphicsdriver/opengl 2018-11-10 22:52:37 +09:00
Ben Echols
5e70fce639 Added monitor cache and scale cache (#731) 2018-11-07 20:54:37 +09:00
Hajime Hoshi
07ae1db0dd opengl: Add Driver 2018-11-07 01:43:07 +09:00
Hajime Hoshi
2c7017534f ui: Remove opengl dependency from ui package (desktop) 2018-11-05 01:24:53 +09:00
Hajime Hoshi
4090258904 opengl: Remove Init (except for mobile) 2018-11-05 00:21:39 +09:00
Hajime Hoshi
97a9e99112 opengl: Rename: BindScreenFramebuffer -> BeforeSwapping 2018-11-03 04:08:00 +09:00
Hajime Hoshi
7e29a81177 ui: Refactoring 2018-10-14 18:28:27 +09:00
Hajime Hoshi
0c4ef7ee8e ui: Bug fix: fix the initial window position on multiple monitors 2018-10-14 16:59:14 +09:00
Hajime Hoshi
b56061281d ui: Add comments 2018-10-13 22:41:21 +09:00
Hajime Hoshi
a073f48faf input: Bug fix: keypress event were not fired
This change suspends to 'preventDefault' on keydown events.

Now preventing navigation by pressing backspace is deprecated in
Chrome. For other keys, it looks like keyup's preventDefault is
enough to disable the browser default behavior.
2018-10-13 19:18:13 +09:00
Hajime Hoshi
34596bb1cf ui: Bug fix: IsVsyncEnabled can cause deadlock 2018-10-10 23:17:45 +09:00
Hajime Hoshi
b4a4b87b56 ui: Bug fix: ScreenSizeInFullscreen returned wrong scaled values
Fixes #708
2018-10-10 03:10:18 +09:00
Hajime Hoshi
e971f6d41c ui: Avoid glfw.GetCurrentContext for threading issues 2018-10-10 01:45:39 +09:00
Hajime Hoshi
b5344bc994 ui: glfwScale must be called on the main thread 2018-10-10 01:07:47 +09:00
Hajime Hoshi
c758a1f8c6 ui: Rename MonitorSize -> ScreenSizeInFullscreen (#708) 2018-10-09 23:42:03 +09:00
Hajime Hoshi
dbe71e81bd ui: Bug fix: currentMonitorPos returned wrong values on macOS
[NSScreen mainScreen] sometimes returned a wrong screen for the
window. Use [[NSApp mainWindow] screen] when possible.

Fixes #703
2018-10-08 05:40:07 +09:00
Hajime Hoshi
c4a066ecd0 ui: Fix wrong comments about Windows 2018-10-08 04:06:44 +09:00
Hajime Hoshi
8d2820efb0 ui: Bug fix: the window is shown on the current monitor on Windows
Fixes #704
2018-10-08 03:24:14 +09:00
Hajime Hoshi
96a657025f ui: Bug fix: DeviceScaleFactor and MonitorSize were not correct on Windows 2018-10-08 03:18:24 +09:00
Hajime Hoshi
9264e38324 ui: Add comments 2018-10-08 01:45:07 +09:00
Hajime Hoshi
f6c2d899f1 ui: Bug fix: compile error on browsers and mobiles 2018-10-08 01:26:05 +09:00
Hajime Hoshi
4a5548a4a0 ui: MonitorSize should return the 'current' monitor size instead of the primary monitor size 2018-10-08 01:15:57 +09:00
Hajime Hoshi
f3b7148564 ui: Bug fix: DeviceScaleFactor should return the current monitor's scale 2018-10-08 01:11:13 +09:00
Hajime Hoshi
16a9bac487 ui: Remove deviceScale struct 2018-10-08 01:03:18 +09:00
Hajime Hoshi
effd530026 ui: Show the window on the current monitor (#704)
Tested on macOS. This doesn't work on Windows yet since there are
some codes that depends on the primary monitor.
2018-10-08 00:46:01 +09:00
Hajime Hoshi
fb7a3f2736 ui: Bug fix: Call SetPos multiple times to render correctly (#703) 2018-10-08 00:25:21 +09:00
Hajime Hoshi
e0d2d5e753 ui: Bug fix: wrong scaling when a window move across monitors
Fixes #701
2018-10-07 23:05:20 +09:00
Hajime Hoshi
0e7dab3707 ui: Fix comment 2018-10-06 20:04:48 +09:00
Hajime Hoshi
f9edfd7d57 ui: Remove unused variables 2018-10-06 19:55:10 +09:00
Hajime Hoshi
cc336a4c38 ui: Use more stable way to determine the current monitor 2018-10-06 19:53:43 +09:00
Hajime Hoshi
55a397bd65 devicescale: Specify the monitor to get the scale
Fixes #695
2018-10-06 19:43:23 +09:00
Hajime Hoshi
b99cc6ca8e ui: Bug fix: compile error on mobiles 2018-10-06 18:26:22 +09:00
Hajime Hoshi
ca2fe22e4a ui: Bug fix: Set the proper window position when coming back from fullscreen 2018-10-06 03:53:34 +09:00
Hajime Hoshi
7ea1ab6b58 ui: Bug fix: currentMonitor should not return nil
Fixes #700
2018-10-06 03:22:33 +09:00
Hajime Hoshi
cae9e39453 ui: Use the best suitable monitor for fullscreen
This change also changes the definition of MonitorSize.
2018-10-06 02:59:38 +09:00
Hajime Hoshi
16f6aeaa4a ui: Refactoring: Use the current monitor 2018-10-06 02:38:02 +09:00
Hajime Hoshi
1807a3f530 devicescale: Rename function 2018-10-04 01:28:53 +09:00
Hajime Hoshi
10b49bb0a3 ui: Don't call devicescale.DeviceScale too often 2018-10-03 04:29:12 +09:00
Hajime Hoshi
02a2fc2d44 ui: Bug fix: Force to adjust window size when scale is changed
Fixes #644
2018-10-03 03:26:11 +09:00
Hajime Hoshi
c494b53822 ui: Refactoring: Add deviceScale struct 2018-10-02 23:06:56 +09:00
Hajime Hoshi
635d624b77 ui: Update device scale on browsers (#644) 2018-10-02 11:43:45 +09:00
Hajime Hoshi
21c1ee5dfb ui: Cache devicescale value on mobiles 2018-10-02 03:51:13 +09:00
Hajime Hoshi
9906c935f6 ui: Remove unnecessary lock protection 2018-10-02 03:25:30 +09:00
Hajime Hoshi
fce82e1502 ui: Use frame counter to update device scale 2018-10-02 03:21:59 +09:00
Hajime Hoshi
78f2946797 ui: Bug fix: timer condition was wrong 2018-10-02 02:53:17 +09:00
Hajime Hoshi
bf850e12a4 ui: Recalc device scale repeatedly for multiple displays (#644) 2018-10-02 02:49:08 +09:00
Hajime Hoshi
308c8091cd ui: Fix comments 2018-09-30 18:53:38 +09:00
Hajime Hoshi
803e42714e input: Implement wheel event on browsers
Fixes #630
2018-09-30 17:08:18 +09:00
Hajime Hoshi
25a5f1dd83 ui: Sleep when vsync doesn't work (#692) 2018-09-30 14:44:54 +09:00
Hajime Hoshi
15260537a2 graphics: Bug fix: fullscreen rendering was wrong
After fad65f2f5d, the viewport size
is always same as the framebuffer size. The 'screen' image size
was the actual rendering region size, and padding was not
considered in the size. The padding is added on the fullscreen
mode.

This fix adds the extra padding values to the 'screen' image size
so that the 'screen' framebuffer will be same size as the monitor
size.

Fixes #693
2018-09-29 21:47:41 +09:00
Hajime Hoshi
eb68cdad6e ui: Bug fix: Freezing on calling SetVsyncEnabled 2018-07-17 02:37:22 +09:00
Hajime Hoshi
09c93ac86d ui: Avoid using eval 2018-07-14 23:47:31 +09:00
Hajime Hoshi
e25c237a01 Add IsVsyncEnabled / SetVsyncEnabled
This enables the game to work more efficiently (but consume much
more CPU).

Fixes #405.
2018-07-14 21:43:55 +09:00
Hajime Hoshi
6e51d31524
Use new GopherWasm API (#634)
I plan to merge this right after
https://github.com/gopherjs/gopherwasm/pull/3 is merged.
2018-06-30 00:02:15 +09:00
Hajime Hoshi
f19e349d38 web: Remove IsNodeJS
gjbt now creates a pseudo-Node environment by creating
window.process object, and this conflicted with an assumption that
Ebiten doesn't nothing on Node environment. See
https://github.com/myitcv/gjbt/pull/13 for the detail.

This change allows Ebiten work on pseudo-Node environment. Even
after this change, Ebiten doesn't work on real Node environment
due to lack of DOM.
2018-06-28 00:12:24 +09:00
Hajime Hoshi
a9359e4ef8 Use GopherJS/GopherWasm 2018-06-24 16:10:24 +09:00
Hajime Hoshi
8d644479cc opengl: Initialize consts first to avoid 'Get' calls 2018-06-19 04:02:56 +09:00
Hajime Hoshi
62bd35e412 Avoid 'Get' call if possible
(*js.Value).Get has some overhead especially on Wasm.
2018-06-19 03:43:24 +09:00
Philipp Steinhaus
39b3170185 input: Enable mouse wheel input (#628) 2018-06-18 00:38:30 +09:00
Hajime Hoshi
b87a851c0e ui: New GopherWASM API 2018-06-16 00:26:28 +09:00
Hajime Hoshi
be665a3526 ui: Better way to avoid blocking
Fixes #625
2018-06-09 13:36:35 +09:00
Hajime Hoshi
6e12f287b0 ui: Use goroutine to avoid blocking on GopherJS 2018-06-09 03:05:37 +09:00
Hajime Hoshi
311788dfe2 ui: Remove warnings of deadlock
Now gopherwasm fixed this problem by avoiding js.MakeFunc.

See also: 3fe87b73c0
2018-05-27 04:10:14 +09:00
Hajime Hoshi
8e9c3bd304 ui: Use gopherwasm 2018-05-27 02:35:17 +09:00
Hajime Hoshi
5976e4bbbc audio: More intellegent suspending/resuming (#617)
Before this change, the audio is suspended when the game stops for
1/12[s]. However, as game often stops for more than 1/12[s]
especially on mobiles, this implemntation caused some audio
glitches.

This change fixes this problem by re-implementing suspending/
resumeing audio by detecting the window is active/focused or not.
2018-05-26 23:31:04 +09:00
Hajime Hoshi
d88d1be4ad mobile: Refactoring 2018-05-26 22:51:30 +09:00
Hajime Hoshi
c2df8326fc ui: Refactoring: Use IsNodeJS 2018-05-16 22:02:33 +09:00
Hajime Hoshi
3ccfe087d9 Refactoring 2018-05-12 15:25:01 +09:00
Hajime Hoshi
453921f1d3 ui: Bug fix: sizeChange must be set after updateFullscreenScaleIfNeeded 2018-05-12 02:11:37 +09:00
Hajime Hoshi
d8dba69b47 ui: Add MonitorSize
Fixes #470
2018-05-05 02:42:45 +09:00
Hajime Hoshi
d41f959b96 ui: Initialize GLFW before Run 2018-05-04 23:55:23 +09:00
Hajime Hoshi
9efccea31c ui: Add SetWindowTitle
Fixes #595
2018-05-02 19:21:17 +09:00
Hajime Hoshi
899f007fd0 ui: Panic when error is found on mobile 2018-04-07 03:33:20 +09:00
Hajime Hoshi
2d3c6ab5b8 ui: Remove build tag 'gomobilebuild'
Fixes #573
2018-04-07 02:14:54 +09:00
Hajime Hoshi
fcf4657a70 ui: Adjust touch positions at ui package (mobile) 2018-04-03 01:50:07 +09:00
Hajime Hoshi
76cb43a7f8 input: Refactoring: Remove unused arguments 2018-04-03 01:21:52 +09:00
Hajime Hoshi
0f2beab260 ui: Adjust touch positions in ui package (js) 2018-04-03 00:53:09 +09:00
Hajime Hoshi
c540d0fc0d ui: Add AdjustedTouches for consistency 2018-04-02 01:54:44 +09:00
Hajime Hoshi
7d2fd9654a input: Adjust mouse cursor position in ui package 2018-04-01 23:53:26 +09:00
Hajime Hoshi
4de2dc0240 Add input package 2018-04-01 23:20:45 +09:00
Hajime Hoshi
2110191794 mobile: Accept gomobile build (#249) 2018-03-24 02:52:42 +09:00
Hajime Hoshi
5ec5cf2450 ui: Add comments 2018-03-17 18:34:20 +09:00
Hajime Hoshi
526fbd3619 ui: Implement SetWindowDecorated and IsWindowDecorated
Fixes #430.
2018-03-17 18:30:55 +09:00
Hajime Hoshi
ef5de62780 Follow the standard comment rule
See https://golang.org/s/generatedcode
2018-03-08 02:47:59 +09:00
Hajime Hoshi
4c1cc9e699 ui: Bug fix: exit update function once when the context is lost (#526) 2018-03-02 01:05:54 +09:00
Hajime Hoshi
0cc456b534 ui: Rename sizeChanged -> toChangeSize 2018-02-25 00:44:45 +09:00
Hajime Hoshi
04341a014c ui: Add comments 2018-02-25 00:44:41 +09:00
Hajime Hoshi
a644e92298 restorable: Better calculation to clear restorable.Image 2018-02-24 21:16:30 +09:00
Hajime Hoshi
692f36f664 graphics: Add comments 2018-02-24 20:40:26 +09:00
Hajime Hoshi
78a58fd1ae ui: Bug fix: userInterface.fullscreen() must be called from the main thread 2018-02-24 18:10:39 +09:00
Hajime Hoshi
a87f197c1b ui: Add TODO 2018-02-24 14:50:45 +09:00
Hajime Hoshi
d4b8b99784 ui: Bug fix: return is needed for Edge case
Fixes #507
2018-02-21 21:53:49 +09:00
Hajime Hoshi
cc423c276d ui: Avoid creating empty slice at Touches 2018-02-12 20:23:24 +09:00
Hajime Hoshi
7d9b901ab3 ui: Avoid creating empty slice at GamepadIDs 2018-02-12 20:20:39 +09:00
Hajime Hoshi
e3023889ac ui: Change RegularTermination to a value 2018-02-04 00:22:38 +09:00
Hajime Hoshi
8b2ed6cddd ui: Update GraphicsContext every frame (#490) 2018-02-02 02:08:03 +09:00
Hajime Hoshi
38c72faf95 ui: Deprecate SetCursorVisibility and add SetCursorVisible (#407) 2018-01-09 02:01:33 +09:00
Hajime Hoshi
0a911b28b2 ui: Remove unneeded variable deviceScale 2018-01-07 14:51:25 +09:00
Hajime Hoshi
34d2e9a3fb ui: Remove unused function 2018-01-07 05:25:29 +09:00
Hajime Hoshi
0469ef386b ui: Fix comment 2018-01-06 23:53:35 +09:00
Hajime Hoshi
9ec0785203 Rename files _xwindow.go to _unix.go 2018-01-03 23:38:47 +09:00
Hajime Hoshi
a64367f906 ui: Refactoring: remove an unneeded member 2018-01-03 17:35:34 +09:00
Hajime Hoshi
c82809867d Add internal/devicescale 2018-01-03 05:22:56 +09:00
Hajime Hoshi
9578307d7b ui: Organize members 2018-01-03 00:23:18 +09:00
Hajime Hoshi
9478801076 ui: Implement SetScreenSize/Scale for mobiles
Fixes #250
2017-12-31 21:01:48 +09:00
Hajime Hoshi
473aeaa8b1 ui: Remove unneeded early return 2017-12-31 18:37:04 +09:00
Hajime Hoshi
362f002d36 ui: Delete local variables asap on Android 2017-11-13 01:30:08 +09:00
Hajime Hoshi
cea9bd5a19 input: Bug fix: runeBuffer should be reset on each frame 2017-11-10 01:21:15 +09:00
Hajime Hoshi
4b83a060fe ui: Add more keys not for charCode 2017-11-10 00:46:37 +09:00
Hajime Hoshi
fb8bef99c3 ui: Bug fix: key event on Edge browser 2017-11-10 00:39:46 +09:00
Hajime Hoshi
37ca48dc38 ui: Rename functions from Safari to Edge 2017-11-10 00:35:46 +09:00
Hajime Hoshi
0c0cd7e9d6 ui: Bug fix: call preventDefault for arrow keys
Fixes #450
2017-11-10 00:32:47 +09:00
Hajime Hoshi
ededc5874b ui: Bug fix: Scale was wrong when magnifier is enabled
Fixes #244
2017-11-09 02:06:35 +09:00
Hajime Hoshi
7bcc9ee79f ui: Add GamepadIDs and remove IsGamepadPresent (#447) 2017-10-26 23:59:09 +09:00
Hajime Hoshi
600baf2cc7 ui: Add IsGamepadPresent
Fixes #447
2017-10-26 02:59:33 +09:00
Hajime Hoshi
05e220e105 ui: Allow smaller window width (#444) 2017-10-20 03:25:21 +09:00
Hajime Hoshi
414170b138 ui: Refactoring 2017-10-20 02:50:39 +09:00
Hajime Hoshi
b590005c7a opengl: BindFramebuffer no longer returns error 2017-09-25 00:14:25 +09:00
Hajime Hoshi
835d199f02 ui: Rename SetIcon to SetWindowIcon (#386) 2017-09-23 17:40:09 +09:00
Hajime Hoshi
dacda0d176 ui: Add SetIcon (#386) 2017-09-23 04:28:57 +09:00
Hajime Hoshi
0dcba7844b ui: Bug fix: SetScreenSize didn't work on browsers
This fixes #427
2017-09-07 11:58:04 +09:00
1l0
5d2393c3c1 glfw: Add StickyModes to window.InputMode (resolve #314 #399) (#423) 2017-08-28 23:29:19 +09:00
Hajime Hoshi
99d170b454 ui: Remove isSafari that is not used anywhere 2017-08-27 02:14:23 +09:00
Hajime Hoshi
bb6dfeefd4 ui: Add comments on Touches 2017-08-22 00:58:38 +09:00
Jake
0d703ca3d4 InputChars (#403)
This implements #400
2017-08-15 04:11:51 +09:00
Hajime Hoshi
5f538bff82 ui: Bug fix: initCursorVisible must be true by default 2017-08-12 18:32:51 +09:00
Hajime Hoshi
783e57d3f2 ui: Remove 'fullscreen' member variable 2017-08-12 18:31:16 +09:00