Commit Graph

618 Commits

Author SHA1 Message Date
Hajime Hoshi
ee124baf60 internal/ui: bug fix: WindowSize returned a wrong value on fullscreen on macOS
Closes #2062
2022-04-08 14:57:51 +09:00
Hajime Hoshi
6710808cd1 ebiten: compile shaders at NewShader
Closes #2035
2022-04-04 02:52:57 +09:00
Hajime Hoshi
4b0967be42 internal/ui: gofmt 2022-04-04 01:48:15 +09:00
Hajime Hoshi
f1f9f74e5c internal/ui: bug fix: force to refresh the framebuffer by resizing the window very quickly
Closes #2050
2022-04-03 18:43:22 +09:00
Hajime Hoshi
f75a70dc40 internal/graphicscommand: treat []float32 instead of interface{} for uniform variables 2022-04-03 03:51:52 +09:00
Hajime Hoshi
b52a02a178 internal/ui: bug fix: crash when Image.MarkDisposed is called multiple times
Closes #2048
2022-04-03 00:21:26 +09:00
Hajime Hoshi
5c7917897c internal/ui: refactoring: move the logic in gameForUI to context 2022-04-01 22:33:31 +09:00
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