Commit Graph

3502 Commits

Author SHA1 Message Date
Hajime Hoshi
cdf2335f5a refactoring: better error handlings on Windows 2022-01-23 18:30:40 +09:00
Hajime Hoshi
a049c403cf internal/gamepad: bug fix: go-vet failed (misuse of unsafe.Pointer)
Updates #1452
2022-01-23 02:08:30 +09:00
Hajime Hoshi
580307f150 internal/gamepad: bug fix: go-vet failed
Updates #1452
2022-01-23 01:56:14 +09:00
Hajime Hoshi
ff24f7718c internal/uidriver/glfw: use an original implementation for macOS
Updates #1452
2022-01-23 01:48:24 +09:00
Hajime Hoshi
84c680c6ed internal/shader: ban the operator div on a matrix
The operator div on a matrix doesn't work on Metal.
2022-01-21 03:37:34 +09:00
Hajime Hoshi
2e5b4954f3 internal/shader: bug fix: forbid mat + float
mat + float doesn't work on Metal.
2022-01-21 02:42:22 +09:00
Hajime Hoshi
99f003a17a internal/shader: bug fix: mat *= vec is not allowed
Updates #1971
2022-01-21 02:03:50 +09:00
Hajime Hoshi
0415773b94 internal/shader: bug fix: allow the *= operator for a vector and a matrix
Updates #1971
2022-01-21 01:59:58 +09:00
Hajime Hoshi
8b8b96c9e7 internal/shader: bug fix: wrong test (int*float) 2022-01-21 01:31:46 +09:00
Hajime Hoshi
8d2bf6525c internal/shader: bug fix: wrong type checkings for operator *
Updates #1971
2022-01-21 01:06:02 +09:00
Hajime Hoshi
8321cecfdd internal/atlas: typo 2022-01-19 23:44:59 +09:00
Hajime Hoshi
0a537b7ad2 internal/shader: bug fix: a number literal must be represented as floats in some contexts 2022-01-17 21:14:07 +09:00
Hajime Hoshi
4940159e5b internal/shader: bug fix: operators between vec/mat and float should work
Closes #1963
2022-01-17 20:52:44 +09:00
Hajime Hoshi
f5edc189e6 internal/uidriver/glfw: bug fix: wrong lock usages 2022-01-17 01:29:29 +09:00
Elias Daler
12c144070f
internal/uidriver/glfw: fix window float enable/disable (#1962)
Closes #1960
2022-01-17 00:28:25 +09:00
Bertrand Jung
c4fbcdd1ae
internal/uidriver/glfw: use FreeConsole instead of hiding (#1961)
Closes #485
2022-01-16 22:31:17 +09:00
Hajime Hoshi
260f7e07df internal/shader: bug fix: deduction checks for the % operator were lacked 2022-01-14 03:51:04 +09:00
Hajime Hoshi
bf48a0b11a internal/shaderir: bug fix: test failures 2022-01-12 01:57:06 +09:00
Hajime Hoshi
08ddb4233b internal/shaderir/glsl: bug fix: % was not available on old GLSLs
Use a new utility function modInt instead.

Closes #1951
2022-01-12 01:41:09 +09:00
Hajime Hoshi
d110716dc0 internal/shader: bug fix: check types correctly for assign operators
Closes #1950
2022-01-12 00:39:39 +09:00
Hajime Hoshi
83bd0772d4 internal/shader: bug fix: % should be valid only for integers
Closes #1947
2022-01-11 23:53:09 +09:00
Hajime Hoshi
ca3f84fdd6 internal/uidriver/cbackend: rename an argument
Updates #1452
2022-01-11 04:12:08 +09:00
Hajime Hoshi
eb6e2026dc internal/uidriver/glfw: remove unused go:generate comments 2022-01-10 22:05:17 +09:00
Hajime Hoshi
d4b722eb06 ebiten: rename VibrateOptions.Intensity -> Magnitude
Updates #1452
2022-01-10 16:02:26 +09:00
Hajime Hoshi
edff1f0dd9 internal/gamepaddb: enable mappings for iOS
Updates #1557
Closes #1722
2022-01-09 17:57:09 +09:00
Hajime Hoshi
8334ca9a18 iternal/gamepaddb: update TODO comments 2022-01-09 04:02:00 +09:00
Hajime Hoshi
4106fb15fe internal/gamepaddb: implement the mappings for Android
Updates #1557
2022-01-09 03:29:19 +09:00
Hajime Hoshi
1b498a03cc Revert "internal/graphicsdriver/metal: Bug fix: Vsync didn't work on macOS"
This reverts commit 1dd13ae06e.

Reason: This caused FPS drop on macOS 12.0.1

Updates #1885
Closes #1939
2022-01-09 01:02:53 +09:00
Hajime Hoshi
d1a5a161d7 internal/atlas: typo 2022-01-08 23:33:59 +09:00
Hajime Hoshi
e66d87e03d internal/buffered, interal/mipmap: typo 2022-01-08 23:32:58 +09:00
Hajime Hoshi
9d72d8c65a internal/buffered, interal/mipmap: typo 2022-01-08 23:31:20 +09:00
Hajime Hoshi
0680ca413d internal/atlas: bug fix: the offscreen must be an independent image
Closes #1938
2022-01-08 23:25:06 +09:00
Hajime Hoshi
3b0ce21a56 Revert "internal/graphicsdriver: bug fix: render semi-transparent vectors correctly"
This reverts commit 202f642395.

Reason: TestImageEvenOdd failed

Updates #1933
2022-01-06 03:19:46 +09:00
Hajime Hoshi
202f642395 internal/graphicsdriver: bug fix: render semi-transparent vectors correctly
Closes #1933
2022-01-06 03:00:25 +09:00
Hajime Hoshi
116203c5a5 cmd/ebitenmobile: update gomobile version (reland)
This switches from .framework to .xcframwork for iOS.

Closes #1922
2022-01-05 17:31:46 +09:00
Hajime Hoshi
c67e4385de internal/thread: bug fix: do not close 'terminate' channel
The `terminate` channel is resued on mobiles (see (*UserInterface).Update
in internal/uidriver/mobile). The channel must not be closed.

Closes #1932
2022-01-05 17:21:53 +09:00
Hajime Hoshi
6b34ddecfa internal/graphicsdriver/opengl/gles: add GLES_SILENCE_DEPRECATION to suppress warnings 2022-01-05 01:54:00 +09:00
Hajime Hoshi
ebb4851a32 internal/uidriver/js: bug fix: context might be nil before the loop starts
Closes #1928
2022-01-03 15:17:30 +09:00
Changkun Ou
626c91e360
ebiten: add RunOnMainThread(func()) (#1927)
Closes #1926
2022-01-03 03:30:29 +09:00
Hajime Hoshi
220a8f48ac internal/uidriver/glfw: refactoring: remove initTitle 2021-12-29 22:26:56 +09:00
Hajime Hoshi
5ee2ff56ca interna/uidriver: refactoring: remove initFPSMode 2021-12-29 22:21:27 +09:00
Hajime Hoshi
374871c031 internal/shader: bug fix: a meaningless statement should raise an error (a non-call expression statement)
Updates #1898
2021-12-27 23:14:05 +09:00
Hajime Hoshi
481a2145ae internal/shader: bug fix: a meaningless statement should raise an error
Closes #1898
2021-12-27 22:05:58 +09:00
Hajime Hoshi
dd4d2f6aa0 internal/glfw/glfw: update for GLFW 3.3.6
Closes #1896
2021-12-27 01:57:55 +09:00
Hajime Hoshi
a89e9d9368 internal/gamepaddb: update the database file
Updates #1903
2021-12-27 01:18:03 +09:00
Hajime Hoshi
f182b185d9 internal/graphicscommand: bug fix: overflow when len(vertices) > len(indices)
Closes #1913
2021-12-26 06:15:12 +09:00
Hajime Hoshi
011e5061df internal/cbackend: simplify the audio API 2021-12-23 22:20:04 +09:00
Hajime Hoshi
e6131894a7 internal/cbackend: add AudioBufferSizeInSeconds 2021-12-23 02:55:54 +09:00
Hajime Hoshi
1799ed0b28 add a build tag 'ebitencbackend' and internal/cbackend
This enables to create a C archive with Ebiten without an actual driver
implementation. This enables Ebiten work on a platform Go doesn't support.
See also Hitsumabushi project: github.com/hajimehoshi/hitsumabushi.

The backend C API is not stable and might change later. Then, the build
tag 'ebitencbackend' is not documented on purpose.

Closes #1900
2021-12-22 21:12:48 +09:00
Hajime Hoshi
b0b52c6297 internal/driver: typo 2021-12-22 18:47:52 +09:00
Hajime Hoshi
39ef252c2e
ebiten: Add VibrationOptions to specify intensity (#1891)
Updates #1452
2021-12-04 22:14:02 +09:00
Hajime Hoshi
bdf78dab27 internal/uidriver/glfw: Clean up build tags 2021-11-27 18:52:33 +09:00
Hajime Hoshi
ef5f8a9018 internal/uidriver/glfw: Adjusting the view size is not needed on macOS 12
Updates #1745
2021-11-27 18:47:05 +09:00
Hajime Hoshi
e6f2764d08 internal/uidriver/glfw: Refactoring: Remove toChangeSize
Updates #1884
2021-11-27 18:00:39 +09:00
Hajime Hoshi
22e64c7df0 internal/uidriver/glfw: Bug fix: Rendering should be updated after restoring from fullscreen
u.toChangeSize affects the result of u.updateSize. When the callback
for WindowSetSize is invoked, toChangeSize should be true.

In order to simplify the logic, we have to remove toChangeSize later.

Closes #1884
2021-11-27 17:53:40 +09:00
Hajime Hoshi
1dd13ae06e internal/graphicsdriver/metal: Bug fix: Vsync didn't work on macOS
This fix works only for Metal. There is not a good solution for
OpenGL so far unfortunately.

Closes #1885
2021-11-27 02:52:48 +09:00
Hajime Hoshi
73bf7a0939 internal/uidriver/glfw: Bug fix: Return a tentative scale when glfw.GetPrmaryMonitor returns 1
Updates #1878
2021-11-24 22:35:10 +09:00
Hajime Hoshi
b4f87f9651 internal/uidriver/mobile: Implement Vibrate for Android
This change also adds AndroidManifest.xml for the example. This is
used for `gomobile install` command.

Updates #1452
2021-11-19 01:49:22 +09:00
Hajime Hoshi
8ae6793d4d internal/shader: Check the number of arguments 2021-11-14 17:34:06 +09:00
Hajime Hoshi
9be4ce928b internal/shader: Add more tests for const
Updates #1847
2021-11-14 17:06:54 +09:00
Hajime Hoshi
36ce3b836e internal/shader: Bug fix: Treat a non-typed consntat argument as a float
Closes #1874
2021-11-14 15:47:59 +09:00
Hajime Hoshi
ee414ed849 Revert "internal/uidriver/glfw: Refactoring"
This reverts commit c4df397d87.

Reason: Compile error
2021-11-12 22:29:03 +09:00
Hajime Hoshi
c4df397d87 internal/uidriver/glfw: Refactoring 2021-11-12 22:19:32 +09:00
Hajime Hoshi
b6cf95f5bb internal/uidriver/js: Optimization: Reduce the call of js.Value.Get 2021-11-12 02:48:58 +09:00
Hajime Hoshi
1f7e7e2816 internal/uidriver/mobile: Remove the warnings
Closes #1872
2021-11-11 02:28:05 +09:00
Hajime Hoshi
5d5ce370f1 internal/uidriver/mobile: Implement Vibrate on iOS
Updates #1452
2021-11-11 00:50:02 +09:00
Hajime Hoshi
00e2b15e2a shaderir: Bug fix: A wrong argument for fmt.Sprintf
This change also improves the result of espcae analysis.

Closes #1863
2021-11-02 00:05:07 +09:00
Hajime Hoshi
7661147e31 internal/graphicsdriver/opengl: Avoid allocations by escaping to heap 2021-10-31 22:34:14 +09:00
Hajime Hoshi
113796efae internal/uidriver/glfw: Bug fix: Crashed a transparent button with the green button
Updates #1822
Closes #1857
2021-10-31 18:21:19 +09:00
Hajime Hoshi
0238549cfb internal/atlas, initernal/graphics: Better buffer size calculation 2021-10-31 17:20:39 +09:00
Hajime Hoshi
d236d73a1f internal/atlas, initernal/graphics: Bug fix: Needed to reset 'notFullyUsedTime' 2021-10-31 17:18:07 +09:00
Hajime Hoshi
15f62bfeb5 internal/graphicsdriver/opengl: Optimization: Cache texture variable names 2021-10-31 05:40:44 +09:00
Hajime Hoshi
9d51356eef internal/graphicsdriver/opengl: Optimization 2021-10-31 05:17:23 +09:00
Hajime Hoshi
b74a4a0275 internal/graphicsdriver/opengl: Optimization: Avoid heap allocations 2021-10-31 02:10:44 +09:00
Hajime Hoshi
7b7791156c internal/graphicsdriver/opengl: Remove unreached return 2021-10-31 01:38:01 +09:00
Hajime Hoshi
98083ccd0a internal/graphicsdriver/opengl: Avoid heap allocation of a local variable
If a variable is passed to an argument interface{}, the variable might be
allocated on the heap unexpectedly.
2021-10-31 01:11:12 +09:00
Hajime Hoshi
a082db04fd internal/jsutil: Optimization: Avoid using empty interface{} conversions 2021-10-30 18:53:21 +09:00
Hajime Hoshi
a826ecb29b internal/jsutil: Move a function to internal/graphicsdriver/opengl 2021-10-30 18:33:43 +09:00
Hajime Hoshi
06f4142ca0 internal/driver: Optimization: Replace interface{} with driver.Uniform
Converting a value from/to interface{} can create a value in heap
and this is not efficient.
2021-10-30 02:58:28 +09:00
Hajime Hoshi
1f82bb297c internal/graphicsdriver/opengl: Optimization: Avoid the empty interface 2021-10-30 02:28:57 +09:00
Hajime Hoshi
60f2c7ace6 internal/graphicsdriver/opengl: Optimization: Avoid creating slices for every frame (uniform variables) 2021-10-30 00:22:31 +09:00
Hajime Hoshi
b4f45edff8 internal/graphicsdriver/opengl: Optimization: Avoid creating slices for every frame 2021-10-30 00:13:57 +09:00
Hajime Hoshi
76324254c1 internal/graphicsdriver/opengl: Avoid creating objects for debugging 2021-10-30 00:04:03 +09:00
Hajime Hoshi
b1a442f86a internal/graphicscommand: Optimization: Pool drawTrianglesCommand objects 2021-10-29 23:41:47 +09:00
Hajime Hoshi
d3ac199aa9 internal/graphicsdriver/opengl: Optimization: Avoid fmt.Sprintf 2021-10-29 21:43:40 +09:00
Hajime Hoshi
3c1f8da7f8 internal/graphicsdriver/opengl: Optimization: Avoid interface conversion 2021-10-29 21:35:40 +09:00
Hajime Hoshi
5b7724f575 internal/uidriver/mobile: Bug fix: Compile error 2021-10-25 03:01:33 +09:00
Hajime Hoshi
2aa232878d ebiten: Add VibrateGamepad and implement this on browsers
Updates #1452
2021-10-25 02:30:42 +09:00
Hajime Hoshi
dde53df6ae internal/uidriver/glfw: Bug fix: Compile error 2021-10-24 15:23:25 +09:00
Hajime Hoshi
99bfdef416 internal/graphicsdriver/opengl/gl: Support OpenBSD 2021-10-24 15:09:16 +09:00
Hajime Hoshi
ef62f407d1 Clean up build tags 2021-10-24 15:05:36 +09:00
Hajime Hoshi
878831b842 internal/graphicsdriver/opengl: Bug fix: compile error 2021-10-24 14:55:50 +09:00
Hajime Hoshi
a5198275fa internal/graphicsdriver/opengl/gl: Remove an unused file 2021-10-24 14:46:38 +09:00
Hajime Hoshi
7c6f2fd799 ebiten: Vibrate takes time durations instead of the options
Android and browsers can specify only a time duration for vibration.

VibrateOptions is renamed to GamepadVibrateOptions for gamepads.

Updates #1452
2021-10-24 05:02:49 +09:00
Hajime Hoshi
f96d0a97a8 internal/uidriver/mobile: Bug fix: Compile error 2021-10-24 01:22:02 +09:00
Hajime Hoshi
b8a5ea7bd6 ebiten: Add Vibrate and VibrateOptions, and implement this on browsers
Updates #1452
2021-10-24 01:05:33 +09:00
Hajime Hoshi
96dc80fd08 internal/restorable: Remove needsDisposingWhenRestoring
Now restoring from context lost doesn't work on browsers. Then,
the constant needsDisposingWhenRestoring is actually always true.
2021-10-23 23:46:29 +09:00
Hajime Hoshi
dddfe73604 internal/uidriver/mobile: Bug fix: iOS with ebitengl build tag didn't work correctly 2021-10-23 23:32:57 +09:00
Hajime Hoshi
b11f17b281 internal/uidriver/mobile: Support gamepads on iOS
Closes #1105
2021-10-19 19:04:12 +09:00
Hajime Hoshi
a70be6e2f8 internal/uidriver/mobile: Refactoring
Updates #1105
2021-10-16 23:46:14 +09:00
Hajime Hoshi
2d9349824f internal/uidriver/mobile: Separate UpdateInput into UpdateInput and UpdateGamepads 2021-10-16 20:37:01 +09:00
Hajime Hoshi
ce86a9940c internal/uidriver/mobile: Fix the package name in a panic message 2021-10-16 20:13:36 +09:00
Hajime Hoshi
c3b4b92fa2 internal/uidriver/mobile: Reduce calling make 2021-10-16 20:09:36 +09:00
Hajime Hoshi
efdb31a524 internal/uidriver/mobile: Refactoring 2021-10-16 19:59:30 +09:00
Hajime Hoshi
ad3115b347 mobile/ebitenmobileview: Avoid creating slices every frame 2021-10-16 18:39:47 +09:00
Hajime Hoshi
8b775cf0dd internal/glfw: Add a new build tag ebitenexternaldll to requrie external DLLs
Embedding a DLL file and extrating it on the fly can be problematic.
The application might be unexpectedly recognized as a virus by some
virus checkers.

To mitigate this issue, Ebiten adds a new build mode `ebitenexternaldll`
which prevents Ebiten from embedding DLL files. Instead, the application
will require DLL files for GLFW.

Closes #1832
2021-10-14 02:44:25 +09:00
Hajime Hoshi
bce2e83565 internal/glfw: Update Dockerfile 2021-10-14 00:03:43 +09:00
Hajime Hoshi
6f79185b2c internal/glfw/glfw: Update documents 2021-10-13 23:48:53 +09:00
Hajime Hoshi
6f29e57378 internal/uidriver/glfw: Wait for a FramebufferSize callback for the initial temporary window
Updates #1847
2021-10-13 00:16:18 +09:00
Hajime Hoshi
2f2ccbbe55 internal/uidriver/glfw: Bug fix: Wait for FramebufferSize callback after a window creation
Closes #1847
2021-10-13 00:04:14 +09:00
Hajime Hoshi
fa9a08b3d0 internal/uidriver/glfw: Remove unnecessary comments 2021-10-10 16:02:41 +09:00
Hajime Hoshi
0eb6c846c7 internal/uidriver/glfw: Refactoring: Remove unused functions 2021-10-10 16:02:01 +09:00
Hajime Hoshi
4604a00e39 internal/uidriver/glfw: Refactoring: Rename functions 2021-10-10 15:50:12 +09:00
Hajime Hoshi
4580f9fa16 internal/uidriver/glfw: Refactring: Rename InDP -> InDIP
This change also renames some functions and variables.
2021-10-10 15:47:15 +09:00
Hajime Hoshi
da6b75bc6d internal/uidriver/glfw: Bug fix: Adjust the window size along with the device scale
After this change, UserInterface's windowWidth and windowHeight are
now windowWidthInDP and windowHeightInDP in device-independent pixels.

Closes #1844
2021-10-10 14:29:34 +09:00
Hajime Hoshi
d4b5d17e75 internal/uidriver/glfw: Remove an unused function
Updates #1844
2021-10-09 21:11:44 +09:00
Hajime Hoshi
fcd8a6c653 internal/uidriver/glfw: Bug fix: Get the correct initial monitor and its scale
Before this fix, Win32API is used to get the current monitor. This
might not work and return an unexpected monitor on some machines after
the runloop starts.

Instead, use the current window to get the current monitor correctly
instead of the Win32APIs. To get the initial monitor, the API
ForegroundWindow is still used.

Updates #1584
Updates #1844
2021-10-09 18:18:22 +09:00
Hajime Hoshi
3f5d1762bb internal/graphicsdriver/opengl: Return an error when initializing OpenGL fails
Updates #1838
2021-10-06 00:38:47 +09:00
r3vit
57c45a13e4
Remove dot imports from tests - Remove dot imports (#1837)
Closes #1824
2021-10-02 19:58:48 +09:00
Hajime Hoshi
78cdb94552 internal/uidriver/glfw: Bug fix: Do not hide the window after its creation
Closes #1829
2021-09-29 01:00:17 +09:00
Hajime Hoshi
56c5bec908 internal/gamepaddb: Do not fetch the database file on go:generate
This is too aggressive and sometimes risky to update the database
file always when go-generate is executed.
2021-09-25 04:03:19 +09:00
Hajime Hoshi
9ab6758b7a internal/gamepaddb: Remove some hacks for wrong formats 2021-09-25 03:56:06 +09:00
Hajime Hoshi
52d917eff0 go generate 2021-09-25 03:45:17 +09:00
Hajime Hoshi
77664ff057 internal/uidriver/glfw: Use the correct initial monitor on Linux/UNIX
Closes #1827
2021-09-25 02:48:13 +09:00
Hajime Hoshi
23566a7d2e internal/uidriver/glfw: Refactoring 2021-09-25 02:14:14 +09:00
Hajime Hoshi
a0be4a302c internal/gamepaddb: Bug fix: A mapping for an axis/button might be missing
Closes #1825
2021-09-25 00:58:06 +09:00
Hajime Hoshi
a7b5db6f65 internal/uidriver/glfw: Use GLFW's fullscreen when the window is transparent on macOS
Closes #1822
2021-09-24 03:22:09 +09:00
Hajime Hoshi
f64a946052 internal/gamepaddb: Use XInput's trigger threshold 2021-09-23 15:25:27 +09:00
Hajime Hoshi
226378da88 internal/gamepaddb: Bug fix: ButtonValue must return [0, 1] 2021-09-23 15:18:16 +09:00
Hajime Hoshi
263276c5ab internal/uidriver/glfw: Refactoring 2021-09-23 02:48:22 +09:00
Hajime Hoshi
422387c7cd internal/uidriver/glfw: Refactoring 2021-09-23 02:03:37 +09:00
Hajime Hoshi
4b64eadfe5 internal/mipmap, internal/atlas: Integrate for-loops for color scaling 2021-09-23 00:28:20 +09:00
Hajime Hoshi
8063f2050c internal/graphicscommand: Optimize flush 2021-09-23 00:03:41 +09:00
Hajime Hoshi
7675e2735b internal/graphicscommand: Refactoring: Do not you 'int' as a variable name 2021-09-22 23:39:56 +09:00
Hajime Hoshi
f79acf9569 internal/mipmap: Bug fix: nil should be meaningful for a mipmap map 2021-09-21 00:46:11 +09:00
Hajime Hoshi
81fd7ab8f6 internal/mipmap: Create a mipmap map lazily 2021-09-20 23:27:14 +09:00
Hajime Hoshi
9dbff2cddd internal/uidriver/glfw: Make SetFullscreen more responsive on macOS 2021-09-20 21:01:17 +09:00
Hajime Hoshi
0ac4c7323f internal/uidriver/glfw: Bug fix: Potential crash when xgb.NewConn fails 2021-09-19 18:23:51 +09:00
Hajime Hoshi
8ed55ef42d internal/uidriver/glfw: Use the window size on a native fullscreen
Updates #1745
2021-09-19 00:35:18 +09:00
Hajime Hoshi
f0395dd329 internal/uidriver/glfw: Skip adjusting the view size with OpenGL 2021-09-18 23:59:37 +09:00
Hajime Hoshi
188e80d2f7 internal/uidriver/glfw: Bug fix: FPS is dropped when pressing the green button
Updates #1745
2021-09-18 22:16:21 +09:00
Hajime Hoshi
1a7cf7b3b8 internal/glfw/glfw: Modify GLFW for Windows to make the window non-floating
Closes #1506
2021-09-18 20:47:26 +09:00
Hajime Hoshi
7be00d79e8 internal/uidriver/glfw: Fix unstable FPS on fullscreen on macOS
FPS was unstable on fullscreen mode i.e., when the view size is the
same as the monitor size.

By using a little different size view, FPS becomes stable.

Updates #1745
2021-09-18 19:22:09 +09:00
Hajime Hoshi
11b9a4b161 internal/graphicsdriver/metal: Refactoring 2021-09-18 17:24:03 +09:00
Hajime Hoshi
e98e371bb4 internal/uidriver: Bug fix: Compile error on Linux/UNIX 2021-09-18 16:58:30 +09:00
Hajime Hoshi
428c079e52 internal/uidriver/glfw: Make a 'native' fullscreen on macOS
This is a breaking change. On macOS, `SetFullscreen` creates a new
independent space and maximize the size of the window there.

Updates #1506
Closes #1579
2021-09-18 16:31:22 +09:00
Hajime Hoshi
2a390c18c1 internal/uidriver/glfw: Do not iconify the fullscreen window on Linux
Updates #1506
2021-09-18 00:52:04 +09:00
Hajime Hoshi
ec2f823420 internal/uidriver/glfw: Clear the device scale cache when monitors are changed 2021-09-15 13:04:38 +09:00
divVerent
5bc7b93e6f
Move VideoModeScaleAt into internal/uidriver/glfw. (#1812)
It's only used by GLFW, and has been in devicescale only to ease migration
to separate video mode vs content scaling.

Updates #1774
2021-09-15 12:47:04 +09:00
divVerent
923c84a3d6
Split the concept of device scale and screen scale (#1811)
We now set deviceScale to always the mapping from logical window system pixels
to device independent pixels (which is what Ebiten API users expect), and
introduce a new concept of videoModeScale that maps from video mode to logical
window system pixels.

videoModeScale is now only used for computing full-screen resolutions, while
deviceScale is used for any other conversion.

Fixes window sizes on X11, should be a NOP otherwise.

Closes #1774.
2021-09-15 01:03:04 +09:00
divVerent
60df512352
Switch out the devicescale implementation by one that relies on glfw/xrandr. (#1800)
This should fix fullscreen mode on Linux/X11 systems in general,
while not affecting other systems.

Note that this deletes a bunch of OS X specific and Windows specific code,
as GLFW already provides this functionality.

This change is not expected to cause regressions, however,
the current behavior is still wrong and leads to wrong/unintended window sizes.
To be fixed in further PRs.

Updates #1774
2021-09-14 12:35:02 +09:00
Hajime Hoshi
cc1ac47387 internal/uidriver: Fix comments 2021-09-13 21:53:02 +09:00
Hajime Hoshi
64a0577c26 internal/affine: Optimize Scale and Translate 2021-09-13 02:18:07 +09:00
Hajime Hoshi
39e7f71ccb internal/uidriver/glfw: Bug fix: Forbide Maximize/MinimizeWindow on the native fullscreen on macOS
Closes #1810
2021-09-12 23:38:44 +09:00
Hajime Hoshi
ea12ede127 ebiten: Add StandardGamepadButtonValue
Closes #1721
2021-09-12 21:00:48 +09:00
Hajime Hoshi
f23dadb8ae
Add internal/gamepaddb (#1805)
This is basically a revert of 93a156a718.
This implements parsing the SDL gamepad mappings by Ebiten instead
of GLFW, so that Ebiten can handle parsing errors completely.

Closes #1802
2021-09-11 22:46:05 +09:00
Hajime Hoshi
28963a66ee internal/uidriver/glfw: Update the game controller DB 2021-09-11 19:12:48 +09:00
Hajime Hoshi
37771717cc internal/uidriver: Bug fix: Potential memory leak by [:0]
Updates #1803
2021-09-10 02:17:29 +09:00
Hajime Hoshi
dbe101a8ef internal/restorable: Remove draw-triangles-history items explicitly
Updates #1803
2021-09-09 12:57:50 +09:00
Hajime Hoshi
106ff7a84b internal/ui: Reduce calls of glfw.GetMonitors
Updates #1803
2021-09-09 11:14:08 +09:00
Hajime Hoshi
5ac357959c internal/graphicscommand: Bug fix: memory leak at q.commands
Apparently, the part of a slice between len and cap-1 still holds
references. Release them explicitly.

Closes #1803
2021-09-09 04:28:31 +09:00
Hajime Hoshi
8f857daf3e internal/restorable: Bug fix: Forbid NewImage before the graphics driver is ready 2021-09-09 03:58:58 +09:00
Hajime Hoshi
a3570331dd internal/restorable: Delay initializing emptyImage
Now NeedsRestorable can always return a correct value.
2021-09-09 03:27:22 +09:00
Hajime Hoshi
65943d4bad internal/graphicsdriver/metal: Disable presentsWithTransaction on iOS
Closes #1799
2021-09-07 00:02:58 +09:00
Hajime Hoshi
f7738b812b internal/mipmap: Skip color scaling when possible 2021-09-06 12:11:52 +09:00
Hajime Hoshi
7f3bd1bbd5 internal/jsutil: Remove unused functions 2021-09-04 21:01:21 +09:00
Hajime Hoshi
64ec626ca6 internal/uidriver/js: Optimize isFocused() by using bind 2021-09-04 19:20:24 +09:00
Hajime Hoshi
58ea710a84 internal/affine: Rename UnsafeElements -> Elements as this is no longer unsafe 2021-09-04 18:08:27 +09:00
Hajime Hoshi
8c9ec8fc9f interna/affine: Avoid UnsafeElements at At
Updates #1796
2021-09-04 17:55:51 +09:00
Hajime Hoshi
df710a5c63 internal/affine: Change UnsafeElements to take arguments
This will enable to suppress unnecessary array allocations in the
future.

Updates #1796
2021-09-04 17:38:30 +09:00
Hajime Hoshi
65e148700f internal/jsutil: Optimize byteLength calls by using bind 2021-09-04 16:51:35 +09:00
Hajime Hoshi
e5c051a437 internal/affine: Refactoring: UnsafeScaleElements -> scaleElements 2021-09-03 23:56:55 +09:00
Hajime Hoshi
d5ce0dbd90 internal/uidriver/glfw: Bug fix: Disable the sticky mode on FPSModeVsyncOffMinimum
Closes #1791
2021-08-31 11:43:11 +09:00
Hajime Hoshi
0e5dca9453 .github/workflows, internal/uidriver/glfw: Use curl's --remote-name 2021-08-28 16:37:10 +09:00
Hajime Hoshi
eae40c90bb internal/uidriver/glfw: Enable to update gamecontrollerdb.txt 2021-08-28 16:09:14 +09:00
Hajime Hoshi
fa0efea4a4 internal/png: Regenerate 2021-08-28 03:14:54 +09:00
Hajime Hoshi
91a7288027 internal/atlas: Better pixel allocations
Updates #1681
Updates #1788
2021-08-26 03:35:21 +09:00
Hajime Hoshi
40d2dd3ba7 internal/uidriver/glfw: Update comments
Updates #1787
2021-08-26 02:05:30 +09:00
Hajime Hoshi
9c321375c9 internal/atlas: Bug fix: pix was reset at a wrong timing
Closes #1788
2021-08-25 22:10:57 +09:00
Hajime Hoshi
d1c764640d internal/glfw, internal/graphicsdriver/opengl/gl: Use the last byte to detect a bool
When a C function returns a bool value, only the first byte of a
uintptr value matters. When we want to get a bool value from a C
function, filter this for sefety.
2021-08-25 02:09:55 +09:00
divVerent
7b11377bce
ebiten: Support updating the gamepad mapping (#1775)
This is only supported on desktops yet (on mobile standard layout isn't
implemented yet, and on the web this is the browser's responsibility).

Closes #1723
2021-08-23 21:44:49 +09:00
Hajime Hoshi
35deb53624 internal/graphicsdriver/metal: Rename files to remove +build comments 2021-08-23 02:06:09 +09:00
Hajime Hoshi
aec74aa39b Remove flock from the tests 2021-08-22 18:34:35 +09:00
Hajime Hoshi
d5150a194c internal/shaderir/glfw: Insert a dummy function to touch uniform array variables
Closes #1754
2021-08-15 18:06:41 +09:00
Hajime Hoshi
6c8a7d1079 internal/graphicsdriver/opengl: Bug fix: A location cache map must be reset when a program is deleted
Closes #1753
2021-08-15 04:54:20 +09:00
Hajime Hoshi
7586f1ca5e internal/atlas: Bug fix: Disable a test resetting the backend
Closes #1756
2021-08-15 00:02:59 +09:00
Hajime Hoshi
1e062a4245 internal/atlas: Bug fix: Fix test 2021-08-14 23:07:27 +09:00
Hajime Hoshi
8a6302f9dc internal/atlas: Add tests to call DrawTriangles twice
Updates #1755
2021-08-14 21:42:07 +09:00
Hajime Hoshi
da08577095 internal/graphicsdriver/opengl: Refactoring 2021-08-14 04:05:18 +09:00
Hajime Hoshi
ce8fc39451 internal/graphicsdriver/opengl: Bug fix: the current program must be reset
Updates #1751
2021-08-13 23:44:30 +09:00
Hajime Hoshi
797f42b839 internal/glfw: Use a more stable version of MinGW
Closes #1750
2021-08-13 03:35:51 +09:00
Hajime Hoshi
c6dd349338 internal/glfw: Refactoring 2021-08-09 14:55:10 +09:00
Hajime Hoshi
4482301882 internal/uidriver/glfw: Better implementation of isNativeFullscreen
The old implementation can return false when the window is not active.
2021-08-08 17:45:48 +09:00
Hajime Hoshi
15ac69b8d5 internal/graphicsdriver/metal: Bug fix: Disable presentsWithTransaction on fullscreen
Closes #1745
2021-08-08 17:40:37 +09:00
Hajime Hoshi
ec26b1a43b internal/graphicsdriver/metal: Refactoring: Remove vsyncInited 2021-08-08 15:30:13 +09:00
Hajime Hoshi
cc1accc32a internal/uidriver/glfw: Bug fix: Disable vsync when resizing the window
Closes #1740
2021-08-06 03:08:04 +09:00
Hajime Hoshi
0bc5166a36 driver: Refactoring: Rename functions 2021-08-05 01:29:45 +09:00
Hajime Hoshi
60b8f82bfd graphicscommand: Dump internal image info on the debug mode
Closes #1714
2021-08-05 01:16:42 +09:00
Hajime Hoshi
8967384dac internal/graphicsdriver: Bug fix: getting a WebGL2 context might fail even though WebGL2RenderingContext exists
Closes #1738
2021-08-01 22:00:47 +09:00
Hajime Hoshi
4e6a5a9fa2 internal/atlas: Bug fix: Wrong screenshot size
Updates #1736
2021-07-29 16:33:54 +09:00
Hajime Hoshi
18903db1c6 internal/atlas: Bug fix: Unexpected padding in screenshots
Closes #1736
2021-07-29 16:09:29 +09:00
Hajime Hoshi
59aa41a3c2 internal/affine: Improve ColorM Scale's performance
The benchmark result comparing the previous commit and this commit is this:

```
name           old time/op    new time/op    delta
ColorMScale-8    9.75µs ± 6%    1.30µs ±22%  -86.67%  (p=0.000 n=10+9)

name           old alloc/op   new alloc/op   delta
ColorMScale-8   1.34kB ±100%    1.19kB ±19%     ~     (p=0.421 n=10+8)

name           old allocs/op  new allocs/op  delta
ColorMScale-8      3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=10+10)
```

Updates #1658
2021-07-27 13:45:09 +09:00
Hajime Hoshi
bcb30f8595 Update go-gl/glfw for GLFW 3.3.4 2021-07-27 12:54:11 +09:00
Hajime Hoshi
e4329d0349 internal/driver: Refactoring: Reduce dependencies on affine 2021-07-27 12:19:50 +09:00
Hajime Hoshi
21aa96f9f5 internal/affine: Refactoring: Make ColorM interface 2021-07-27 12:10:22 +09:00
Hajime Hoshi
5f03f4f195 internal/affine: Add coloMImpl interface and colorMImplScale
Closes #1658
2021-07-26 22:18:10 +09:00
Hajime Hoshi
7e5b259dd2 internal/affine: Use a pointer of an array for UnsafeElements 2021-07-26 21:19:53 +09:00
Hajime Hoshi
2c26e85183 internal/affine: Replace isInited with isIdentity 2021-07-26 21:07:51 +09:00
Hajime Hoshi
d0ae73084b internal/affine: Separate ColorM implementation
Updates #1658
2021-07-26 15:21:12 +09:00
Hajime Hoshi
e84506dfc3 internal/affine: Add String 2021-07-26 14:26:59 +09:00
Hajime Hoshi
18757cff16 internal/affine: Refactoring 2021-07-25 22:10:38 +09:00
Hajime Hoshi
1706d9436a ebiten: Add FPSModeType, FPSMode, SetFPSMode, and ScheduleFrame
This change adds these APIs:

  * type FPSModeType
  * func FPSMode
  * func SetFPSMode
  * func ScheduleFrame

and deprecates these APIs:

  * func SetVsyncEnabled
  * func IsVsyncEnabled

Closes #1556
2021-07-24 16:09:13 +09:00
Hajime Hoshi
fee004c28d internal/uidriver/js: Remove unnecessary event handlers 2021-07-23 11:23:01 +09:00
Hajime Hoshi
0ec5b7b857 internal/uidriver/js: Bug fix: Suppress warnings on SetFullscreen
Closes #1727
2021-07-23 02:15:46 +09:00
Hajime Hoshi
2503323557 internal/driver: Add FPSMode
Updates #1556
2021-07-23 00:47:09 +09:00
Hajime Hoshi
c28bcc26fc internal/clock: Rename UncappedTPS -> SyncWithFPS
Closes #1726
2021-07-22 22:46:24 +09:00
Hajime Hoshi
50320eeb5b internal/glfw: Bug fix: Crash after disconnecting a gamepad on Windows (Wine) 2021-07-21 17:50:47 +09:00
Hajime Hoshi
d7bedd165a internal/driver: Bug fix: Compile error for browsers 2021-07-21 17:20:09 +09:00
Hajime Hoshi
93a156a718 internal/uidriver/glfw: Use glfwGameGamepadState
This change replaces the usage of gamepaddb package with glfwGetGamepadState.

Updates #1557
2021-07-21 16:09:30 +09:00
Hajime Hoshi
ee4ec5047e internal/gamepaddb: Support general XInput devices 2021-07-21 14:38:47 +09:00
Hajime Hoshi
1fce527414 internal/uidriver/js: Use the same gamepad API on go2cpp 2021-07-20 23:10:56 +09:00
Hajime Hoshi
8656786721 internal/uidriver/js: Refactoring: Detect the standard layout at update 2021-07-20 21:56:15 +09:00
Hajime Hoshi
f192971080 ebiten: Rename HasGamepadStandardLayoutMapping -> IsStandardGamepadLayoutAvailable
Updates #1557
2021-07-20 02:46:12 +09:00
Hajime Hoshi
aa694be6f6 ebiten: Add the standard gamepad layout
This change introduces the standard gamepad layout. This changes adds
these APIs:

  * func HasGamepadStandardLayoutMapping
  * func IsGamepadStandardButtonPressed
  * func GamepadStandardAxisValue
  * type StandardGamepadButton
  * type StandardGamepadAxis

The standard gamepad layout is based on the web standard. See
https://www.w3.org/TR/gamepad/#remapping.

On desktops, the SDL's gamecontrllerdb.txt is used. If the gamepad is
listed in the text file, the mapping works. GLFW's mapping featrue is
not used.

On browsers, the property of a gamepad 'mapping' is used. When the
mapping value is 'standard', the gamepad is recognized to have the
standard mapping.

On mobiles, the implementation is still WIP.

Updates #1557
2021-07-20 01:32:28 +09:00
Hajime Hoshi
fcfdf9b2ba Update URLs 2021-07-19 23:09:27 +09:00
Hajime Hoshi
a6fe7801ff internal/uidriver/glfw: Rename gamePad -> gamepad 2021-07-19 22:25:43 +09:00
Hajime Hoshi
dbcb220742 ebiten: Add GamepadAxisValue replacing GamepadAxis
Updates #1718
Closes #1719
2021-07-19 01:22:35 +09:00
Hajime Hoshi
342bf6ae7e Update GLFW: suppress joystick issue at PollEvents
Updates #1229
2021-07-15 11:19:39 +09:00
Hajime Hoshi
ec5b034cbf Update GLFW: suppress joystick issue (again)
Updates #1229
2021-07-15 01:02:57 +09:00
Hajime Hoshi
66dbca7fdd Update GLFW: suppress joystick issue
Updates #1229
2021-07-14 23:54:48 +09:00
Hajime Hoshi
50d2d7ed61 internal/graphicsdriver/opengl: Remove unused code using PBO
Updates #1678
2021-07-14 21:51:27 +09:00
Hajime Hoshi
99a6b1b03e internal/driver: Change some functions to Append*
Updates #1692
2021-07-10 01:52:21 +09:00
Hajime Hoshi
5d2c8ad9be internal/uidriver/mobile: Bug fix: Use mutex at RuneBuffers 2021-07-10 01:39:32 +09:00
Hajime Hoshi
853c1f2b92 internal/shaderir/glsl: Bug fix: Remove uncalled functions
Some built-in functions like dFdx is not available in a vertex shader,
then a function that calls such built-in function should not be in
a vertex shader.

Closes #1701
2021-07-09 20:22:40 +09:00
Hajime Hoshi
b0106e95b9 internal/restorable: Bug fix: Test failed on macOS (Metal) 2021-07-09 20:21:04 +09:00
Hajime Hoshi
4573883b03 internal/graphicsdriver/metal: Make FPS stable by 'presentsWithTransaction'
Closes #1196
2021-07-08 18:11:19 +09:00
Hajime Hoshi
ae0e30196b internal/graphicsdriver/metal: Bug fix: The store action must always be 'store'
Closes #1700
2021-07-08 17:39:37 +09:00
Hajime Hoshi
337d8d5113 internal/graphicsdriver/metal: Separate GCing the buffers
Updates #1196
2021-07-08 02:10:26 +09:00
Hajime Hoshi
edc2f8b961 internal/graphicsdriver/metal: Delay to get a texture for nextDrawable
See https://developer.apple.com/documentation/quartzcore/cametallayer

> To avoid stalls in your app, request a new drawable only when you
> need it, and release any references to it as quickly as possible
> after you’re done with it.

Updates #1196
2021-07-08 01:56:14 +09:00
Hajime Hoshi
b314b6b9b6 Revert "internal/graphicsdriver/metal: Do not retain MTLCommandBuffer for MTLBuffer"
This reverts commit e0fbfc2bb0.

Reason: Rendering issue

Closes #1699
2021-07-08 00:27:33 +09:00
Hajime Hoshi
6213c17abc internal/driver: Add Graphics.Initialize 2021-07-07 13:58:42 +09:00
Hajime Hoshi
519363930a internal/uidriver/glfw: Bug fix: Memory leak in Objective-C code
Use an autorelease pool block.

Closes #1698
2021-07-07 04:34:21 +09:00
Hajime Hoshi
e0fbfc2bb0 internal/graphicsdriver/metal: Do not retain MTLCommandBuffer for MTLBuffer
Before this change, a command buffer is retained indirectly by
a buffer, and this might extend the life of drawable unexpectedly.

This change stops using command buffers as a key of the buffers pool,
and use a counter increated by nextDrawable calls.

Updates #1196
2021-07-07 02:52:04 +09:00
Hajime Hoshi
80ac0646d5 internal/graphicsdriver/metal: Optimize the screen writing 2021-07-07 02:07:09 +09:00
Hajime Hoshi
5e83f409e6 internal/graphicscommand: Add a missing colon to a command string 2021-07-07 01:54:22 +09:00
Hajime Hoshi
38ce325958 internal/graphicsdriver/metal: Skip clearing the screen on Metal 2021-07-07 01:45:51 +09:00
Hajime Hoshi
9cb1ff9cea internal/graphicsdriver/metal: Set framebufferOnly true
Updates #1196
2021-07-07 00:38:55 +09:00
Hajime Hoshi
bd3f16dbba internal/graphicsdriver/metal: Change the order of GCed buffers
As a big buffer is likely reused, we should remove smaller buffers
first.

Updates #1196
2021-07-06 21:56:27 +09:00
Hajime Hoshi
09bd8b6f4a internal/graphicsdriver/metal: Remove println
Updates #1196
2021-07-06 21:51:57 +09:00
Hajime Hoshi
ee2f891fcc internal/graphicsdriver/metal: Reuse MTLBuffer objects
In Metal, MTLBuffer objects are not 'transient' and are expensive
to create. Reuse them whenever possible.

See also: https://developer.apple.com/library/archive/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Cmd-Submiss/Cmd-Submiss.html

Updates #1196
2021-07-06 21:48:54 +09:00
Hajime Hoshi
be1a0e90e7 internal/graphicsdriver/metal: Bug fix: TestImageEvenOdd failed
RenderCommandEncoder must be reset whenever the stencil mode is
'prepareStencil' in order to clear the stencil buffer.
2021-07-06 15:11:23 +09:00
Hajime Hoshi
3670b7dd62 internal/graphicsdriver/metal: Reuse DepthStencilState objects
In Metal, *State objects are not 'transient' and are expensive to
create. Reuse them whenever possible.

See also: https://developer.apple.com/library/archive/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Cmd-Submiss/Cmd-Submiss.html
2021-07-06 15:10:05 +09:00
Hajime Hoshi
ab26312108 internal/graphicsdriver/metal: Release objects appropriately 2021-07-06 14:20:19 +09:00
Hajime Hoshi
17d8cb5311 internal/graphicsdriver/metal: Bug fix: Crashed with METAL_DEVICE_WRAPPER_TYPE=1
Closes #1697
2021-07-06 14:06:06 +09:00
Hajime Hoshi
59fa689f22 internal/graphicscommand: Misspelling 2021-07-05 23:32:19 +09:00
Hajime Hoshi
5e1d6c06f1 internal/graphicscommand: Merge even-odd draw-triangles commands when possible
Closes #1685
2021-07-05 23:28:33 +09:00
Hajime Hoshi
63a00f6171 internal/graphicsdriver/metal/mtl: Bug fix: Test failure
Closes #1696
2021-07-05 21:28:25 +09:00
Hajime Hoshi
92b3dab33c internal/graphicscommand: Refactoring: Use type assesion instead of interface
This was an optimization in GopherJS era. This change removes this
to simplify the implementation.
2021-07-05 21:16:04 +09:00
Hajime Hoshi
b2d4521e22 internal/graphicscommand: Log 'even-odd' property 2021-07-05 19:35:34 +09:00
Hajime Hoshi
674802d2f5 ebiten: Bug fix: Draw commands with EvenOdd should not be merged
Updates #1684
2021-07-05 18:08:55 +09:00
Hajime Hoshi
daa883d799 ebiten: Bug fix: Stencil buffers should not be cleared until all the vertices are rendered
Updates #1684
2021-07-05 17:41:06 +09:00
Hajime Hoshi
b466a0cbd7 ebiten: Add EvenOdd to DrawTrianglesOptions and DrawShaderTrianglesOptions
Updates #844
Closes #1684
2021-07-05 03:35:55 +09:00
Hajime Hoshi
5c4d3325f6 internal/graphicsdriver/opengl: Add APIs for stencil buffers
Updates #1684
2021-07-05 00:24:44 +09:00
Hajime Hoshi
b8bf277825 internal/graphicsdriver/metal/mtl: Add APIs for stencil buffers
Updates #1684
2021-07-05 00:11:25 +09:00
Hajime Hoshi
19f034e818 internal/graphicsdriver/metal: Refactoring 2021-07-04 20:35:56 +09:00
Hajime Hoshi
3ec02f767b internal/graphicsdriver/metal: Refactoring 2021-07-04 18:37:14 +09:00
Hajime Hoshi
7f86761dde internal/graphicsdriver/metal: Reuse RenderCommandEncoder when possible 2021-07-04 18:13:18 +09:00
Hajime Hoshi
7668052a6b internal/graphicsdriver/metal: Update the view only when necessary 2021-07-04 17:24:39 +09:00
Hajime Hoshi
f6e210e086 internal/graphicsdriver/opengl: Refactoring: Remove redundant conversions 2021-07-03 22:39:48 +09:00
Hajime Hoshi
b0b7a24f89 internal/uidriver: Remove invalid comments 2021-07-03 19:49:12 +09:00
Hajime Hoshi
56f4e6b2d0 internal/graphicsdriver/opengl: Refactoring: Rename a variable 2021-07-03 02:41:37 +09:00
Hajime Hoshi
269ea7c489 internal/graphicsdriver/opengl: Refactoring: Reorder functions
glPixelStorei affects the result of glTexImage2D. This change makes
this fact more explicit.
2021-07-03 02:09:47 +09:00
Hajime Hoshi
6b95dd0d4d internal/graphicsdriver/metal: Refactoring: Unify two drawTriangles* functions 2021-07-02 00:25:43 +09:00
Hajime Hoshi
ff2dd6fe7e internal/graphicsdriver/opengl: Refactoring: Unify two drawTriangles* functions 2021-07-02 00:02:21 +09:00
Hajime Hoshi
e9b6237f61 internal/driver: Refactoring: Merge two Draw* functions 2021-07-01 15:55:48 +09:00
Hajime Hoshi
b9d52c0267 internal/driver: Change InvalidImageID/InvalidShaderID to 0 2021-07-01 14:58:55 +09:00
Hajime Hoshi
73bf1f36e5 internal/driver: Define InvalidImageID / InvalidShaderID 2021-07-01 13:56:42 +09:00
Enrico
3ef1d04935
internal/uidriver/glfw: Bug fix: do not execute loop function if init failed (#1689)
In `internal/uidriver/glfw/run_notsinglethread.go`, if the `UserInterface.init()` function returns an error, the `loop` is
executed regardless and the error is discarded. This behavior will hide the error returned by `init()` and might trigger
some crashes (see #1688).

A partial fix was implemented in 6c4edf8 , however that commit alone is not enough: the code now is correctly returning
the error via the `ch` channel, but it still executes the `loop()` function. This merge request skips `loop()` call if `init()`
had an error.

Updates #1688
2021-06-29 23:51:25 +09:00
Hajime Hoshi
6c4edf8605 internal/uidriver/glfw: Bug fix: Abort the game immediately on error
Updates #1688
2021-06-29 02:23:17 +09:00
Hajime Hoshi
9c5b7b56b2 internal/graphics: Reafctoring 2021-06-28 23:28:43 +09:00
Hajime Hoshi
817d176994 internal/graphicscommand: Misspelling at newShaderCommand.String 2021-06-27 23:20:27 +09:00
Hajime Hoshi
c725937cc6 internal/graphics: Reuse the vertices backend
This is basically a reland of 9cb631e30f.
This change locks the vertices backend at the end-frame phase to
protect from vertices usages by other goroutines.

Updates #1546
Closes #1681
2021-06-27 02:31:01 +09:00
Hajime Hoshi
699bb095c3 internal/atlas: Better algorithm to release the temporary pixels 2021-06-26 23:29:45 +09:00
Hajime Hoshi
067e3c004d Remove internal/web 2021-06-26 17:04:00 +09:00
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
38ce46328a internal/atlas: Reuse byte array for ReplacePixels
This reduces memory allocation at ReplacePixels.

Updates #1681
2021-06-26 03:48:25 +09:00
Hajime Hoshi
414a64ce78 internal/atlas: Allow extending a texture atlas
As PBO is no longer used (#1678), using a big atlas with
ReplacePixels is no longer problematic.

Closes #1674
Updates #1675
2021-06-24 21:35:36 +09:00
Hajime Hoshi
2a8e8d0eb6 internal/graphicsdriver/opengl: Stop using PBO
PBO was introduced to improve the performance at ReplacePixels,
but we found that PBO can degrades the performance. Also, now
multiple glTexImage2Ds are called successively like a batch, so
the situation is now different from that time when PBO was
introduced.

Let's remove PBO usages and wait and see.

Closes #1678
2021-06-24 21:20:58 +09:00
Hajime Hoshi
7f60cd41eb internal/graphicsdriver/opengl: Refactoring: Remove unused arguments from texSubImage2D 2021-06-24 12:06:28 +09:00
Hajime Hoshi
fa8e271f2a internal/atlas: Bug fix: Set the minimum texture size to 8192px
Closes #1675
Updates #1674
2021-06-19 18:52:08 +09:00
Hajime Hoshi
43c964a3b8 internal/thread: Refactoring 2021-06-15 00:43:48 +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
bceb512e78 internal/glfw: Bug fix: build failure with GOOS=js
Updates #1672
2021-06-13 22:59:57 +09:00
Hajime Hoshi
ed6756662a internal/glfw: Clean up the code
Updates #1672
2021-06-13 22:48:27 +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
0cea5f2f1a internal/glfw: Remove one of go-vet warnings 2021-06-13 14:41:39 +09:00
Hajime Hoshi
584c6524ee internal/graphicsdriver/opengl: Refactring 2021-06-13 14:19:33 +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
040fcd930f Revert "Revert 2 commits using ColorM cache"
This reverts commit dd7a8bc497.

Reason: DrawTriangles worked fine for the reporter's purpose.

Updates #1655
2021-05-30 15:17:11 +09:00
Hajime Hoshi
dd7a8bc497 Revert 2 commits using ColorM cache
This reverts commit 87c8625692.
This reverts commit a6dd6196b4.

Reason: Performance regression (#1655)

Closes #1655
2021-05-30 03:10:00 +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
b6364c46fe internal/clock: Misspelling 2021-04-24 23:24:11 +09:00
Hajime Hoshi
2534b78755 internal/clock: Simplify the logic to calculate tick per frame
Updates #1444
Updates #1597
2021-04-24 23:06:27 +09:00
Hajime Hoshi
2e6ecc766d internal/clock: Integrate 'now' implementations
The Go runtime already uses QueryPerformanceCounter at runtime.nanotime.
2021-04-24 22:32:47 +09:00
Hajime Hoshi
011a524ac7 internal/clock: Update comments 2021-04-24 22:10:00 +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
corfe83
d24313e236
internal/devicescale: Fallback to simpler logic when trying to get DPI from monitor and failing (#1600)
Closes #1612
2021-04-21 11:43:23 +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
61c0908b13 internal/glfw: Refactoring 2021-04-18 03:33:01 +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
f62576d88d internal/glfw: Add tools.go to keep go.sum 2021-04-17 20:24:39 +09:00
Hajime Hoshi
855edcd2ff internal/glfw: Update Dockerfile and regenerate DLLs 2021-04-17 20:11:10 +09:00
Hajime Hoshi
6df87a0383 internal/uidriver: Add comments
Updates #1575
2021-04-17 18:17:26 +09:00
Hajime Hoshi
1ca0ecc10f internal/devicescale: Add comment about #1573
Updates #1573
2021-04-17 18:14: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
7934c3b22b internal/driver: Clean CursorMode values up 2021-04-11 03:29:14 +09:00
Hajime Hoshi
77b51e4707 internal/shader: Add more tests and improve the comment
Updates #1192
2021-04-09 01:25:37 +09:00
Hajime Hoshi
1cdc6ea72b internal/shader: Bug fix: Treat multiple constant definitions in one statement correctly
Updates #1192
2021-04-09 01:18:38 +09:00
Hajime Hoshi
3b6fa891ac internal/shader: Bug fix: Error on duplicated const/var names
Updates #1192
2021-04-09 00:12:17 +09:00
Hajime Hoshi
59a80cf953 internal/shader: Implement basic constants
Updates #1192
2021-04-09 00:00:49 +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
6fe6543b4b internal/graphicsdriver/opengl: Bug fix: getBufferSubData was available only with WebGL2 2021-04-06 00:11:51 +09:00
Hajime Hoshi
bd8367588e internal/graphicsdriver/opengl: Prepare function objects by bind
Passing a Go string to the JS world is expensive. This change reduces
this cost by preparing function objects by bind.

Closes #1438
2021-04-05 23:53:21 +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
9dd00114c5 internal/devicescale: Remove a Unicode space 2021-03-28 23:39:06 +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
24973da123 internal/jsutil: Restrict the build environment 2021-03-22 03:50:05 +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
41f060b1d2 ebiten: Use the common vertices backend at DrawTriangles 2021-03-20 20:25:42 +09:00
Hajime Hoshi
15a0c53918 internal/graphics: Refactoring 2021-03-20 20:18:02 +09:00
Hajime Hoshi
26b9fa20c1 internal/graphics: Bug fix: Race condition at QuadVertices
QuadVertices or verticesBackend.slice reused its backend slice.
This caused a race condition. QuadVertices can be accessed from
multiple goroutines, and resetting the head and copying the data
at internal/graphicscommand might not be synced.

This change fixes this issue by basically reverting
9cb631e30f.

Closes #1546
2021-03-20 16:32:13 +09:00
Humphrey Shotton
21cfe362c8
internal/graphicscommand: fix missing graphicscommand log (#1543)
Closes #1544
2021-03-15 02:14:03 +09:00
Hajime Hoshi
3e7217cb86 internal/atlas: Add comments to moveTo 2021-03-12 00:26:38 +09:00
Hajime Hoshi
ec677a258f Rename internal/shareable -> internal/atlas
Also the terms are renamed:

 * shared -> on an atlas
 * not shared -> isolated

Closes #1529
2021-03-12 00:22:08 +09:00
Hajime Hoshi
df3e74533b internal/shareable: Use an exponential way to determine the image sharing
When an image was used in both ways source and destination, Ebiten
worked ineffectively since Ebiten tried to make the image on a texture
atlas after the image was used as a source for a while, which tried to
create a new internal texture every time.

This fix mitigates this issue by using an exponential way to determine
whether the image should be on a texture atlas again or not, so that
an image often used as a destination will require much longer time to
become on a texture atlas again.

Updates #1464
2021-03-10 02:30:33 +09:00
Hajime Hoshi
052947d7b7 internal/glfw: Update GLFW to 3.3.3 for Windows
Closes #1523
2021-03-09 02:19:34 +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
c8b98f13fb internal/graphics: Always use the vertex backend to reduce GC
Closes #1521
2021-03-03 22:23:15 +09:00
Hajime Hoshi
cb3fc3c51c Revert "shareable: Limit the texture size to 8192"
This reverts commit c92ccfff79.

Reason: This should no longer be needed after #1517 is fixed.
2021-02-27 13:55:13 +09:00
Hajime Hoshi
77b198211c internal/graphicsdriver/metal: Add a comment 2021-02-27 04:04:25 +09:00
Hajime Hoshi
53352cf2b3 internal/graphicsdriver/metal: Use the smallest temporary texture
Updates #1517
2021-02-27 03:45:19 +09:00
Hajime Hoshi
673627c4d4 internal/graphicsdriver/metal: Optimization 2021-02-27 02:30:20 +09:00
Hajime Hoshi
6b3c51921c internal/driver: Remove Image.Sync
Syncing is no longer needed for Metal, and additionally, OpenGL's sync
implementation was mock.

Updates #1508
2021-02-26 23:16:28 +09:00
Hajime Hoshi
9341d21614
internal/shareable: Call DrawTriangles instead of ReplacePixels at makeShared (#1513)
When context losts never happen, reading pixels and call replace-pixels command are not needed.

Closes #1508
2021-02-26 12:56:22 +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
969964cb46 internal/graphicsdriver/opengl/gl: Bug fix: Remove unsafe reflect usage
Closes #1495
2021-02-14 21:27:30 +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
ec843ce92c internal/web: Consider the case when navigator exists but userAgent doesn't
This can happen on go2cpp.
2021-02-09 23:59:39 +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
5f81065d78 internal/shader: Make function duplications error
Closes #1430
2021-02-07 22:24:23 +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
acb8bcae38 cmd/ebitenmobile, internal/devicescale: Experimental fix of the display density
Closes #1481
2021-02-07 14:07:06 +09:00
Hajime Hoshi
44bb004cb7 internal/restorable: Avoid allocating new slices for drawTrianglesHistory 2021-01-30 19:13:03 +09:00
Hajime Hoshi
87c8625692 Remove internal/colormcache 2021-01-28 03:28:29 +09:00
Hajime Hoshi
256adfff9d internal/affine: Add tests
Updates #1474
2021-01-28 02:24:24 +09:00
Hajime Hoshi
a6dd6196b4 internal/affine: Cache scaling ColorM for heuristic optimization
Closes #1474
2021-01-28 02:23:22 +09:00
Hajime Hoshi
14abc28d3a internal/color: Remove Add 2021-01-27 02:37:56 +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
b8694aa66a internal/graphicsdriver/opengl: Optimization 2021-01-26 00:45:17 +09:00
Hajime Hoshi
e60e6ca5ac internal/shareable: Optimization 2021-01-26 00:43:45 +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
34695dc845 shareable: Refactoring 2021-01-18 00:35:09 +09:00
Hajime Hoshi
0c578f1670 shareable: Rename notUpdatedCount -> usedAsSourceCount and modify implementation
Before this change, the image automatically becomes on a shareable
texture again when the image is not modified for a while. This was
problematic when an offscreen is not updated for a while, but used
as a render target again, as an independent image for the image is
created every time when the image is used as a render target.

After this change, the count is updated only when the image is used
as a rendering source.

Closes #1465
2021-01-17 19:00:16 +09:00
Hajime Hoshi
f77c514598 graphicsdriver/opengl: Refactoring 2021-01-05 02:07:30 +09:00
Hajime Hoshi
b7abde7f00 graphicsdriver/opengl: Bug fix: getBufferSubData did not work correctly on JS 2021-01-03 19:44:29 +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
c92ccfff79 shareable: Limit the texture size to 8192
Closes #1453
2020-12-31 17:52:18 +09:00
Hajime Hoshi
b6bc683991 packing: Bug fix: Extend could create a too big page
Closes #1454
2020-12-31 17:33:27 +09:00
Hajime Hoshi
2ea360b921 Revert "driver: Increase gamepad buttons to 64"
This reverts commit 62b199f9eb.

Reason: This seems my misunderstanding.
2020-12-29 02:49:58 +09:00
Hajime Hoshi
62b199f9eb driver: Increase gamepad buttons to 64
e.g. Nintendo Switch controller can have more than 32 buttons.
2020-12-27 21:56:08 +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
3d48922d8c jsutil: Bug fix: byteLenght must be accessed every time to get the latest value 2020-12-26 17:04:12 +09:00
Hajime Hoshi
e95cccad21 jsutil: Reduce calls of (js.Value).Get
(js.Value).Get invokes the string conversion from UTF-8 to UTF-16.
This is related to #1438, though this is not a fix in the OpenGL
driver.

Updates #1438
2020-12-26 05:12:04 +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
59567993c2 clock: Bug fix: High TPS didn't work well due to the timer precision
When the TPS is high (e.g., 300), the count might be unreliable
since the timer might not be precise on some machines. In this
case, calculate the factor and multiply the count by it.

Fixes #1444
2020-12-21 00:23:29 +09:00
Hajime Hoshi
53d0e1eae0 clock: Add comment 2020-12-20 21:59:09 +09:00
Hajime Hoshi
aef104203d clock: Refactoring 2020-12-20 21:54:28 +09:00
Hajime Hoshi
4215678f4c clock: Bug fix: Syncing with the system clock happens more often than expected
When the specified TPS is too big (e.g., 300), the time threshold
to determine whether the clock should be synchronized with the
system clock can be too small, and the decision can be wrong too
often. To fix this, prepare another time assuming the TPS was 60
and use the bigger one.

Fixes #1443
2020-12-20 21:23:40 +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
d3fbf377ef shader: Bug fix: A wrong usage of a pointer 2020-12-20 13:32:22 +09:00
Hajime Hoshi
de14a44c01 restorable: Replace a potentially dangerous pointer usage
Getting a poniter to a loop variable is potentially dangerous.
2020-12-20 13:28:17 +09:00
Hajime Hoshi
2106e0fa6a devicescale: Use devicePixelRatio property for go2cpp 2020-12-20 00:45:13 +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
e856b236f3 jsutil: Refactoring 2020-12-16 02:41:06 +09:00
Hajime Hoshi
7e32075abd jsutil: Avoid creating Uint8Array when copying bytes from Go to JS
Updates #1435
2020-12-16 01:50:05 +09:00
Hajime Hoshi
49b86843c3 jsutil: Avoid creating Uint8Array at TemporaryUint8Array
Updates #1435
2020-12-16 01:21:13 +09:00
Hajime Hoshi
146357c298 jsutil: Enable to specify length at Uint8ArrayToSlice 2020-12-15 01:13:15 +09:00
Hajime Hoshi
e5c1151cc5 jsutil: Avoid creating Float32Array at TemporaryFloat32Array
Updates #1435
2020-12-15 00:40:43 +09:00
Hajime Hoshi
f440e368b3 graphicsdriver/opengl: Use WebGL2 API on go2cpp 2020-12-14 02:02:45 +09:00
Hajime Hoshi
547621ddad clock: Bug fix: The game was frozen when TPS is <= 4
Fixes #1417
2020-12-13 15:14:15 +09:00
Hajime Hoshi
692460c5aa testing: Bug fix: Lack of uniform variables 2020-12-09 11:52:45 +09:00
Hajime Hoshi
718273c2d7 ebiten: Add a new shader function imageDstRegionOnTexture
Updates #1428
2020-12-09 11:36:29 +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
66d12722ae graphicsdriver/opengl: Remove comments 2020-12-06 03:24:08 +09:00
Hajime Hoshi
2c31156a34 graphicsdriver/opengl: Reduce allocations of Float32Array on go2cpp
Updates #1426
2020-12-06 03:23:09 +09:00
Hajime Hoshi
2bf4a3bb6e jsutil: Use Equal for Go 1.13 2020-12-06 03:14:25 +09:00
Hajime Hoshi
469dc31765 jsutil: Reduce allocating Uint8Array on go2cpp
Updates #1426
2020-12-06 03:00:50 +09:00
Hajime Hoshi
2ca0f3f300 jsutil: Remove println 2020-12-06 02:58:52 +09:00
Hajime Hoshi
7a86238c9a jsutil: Remove ArrayBufferToSlice 2020-12-06 02:28:14 +09:00
Hajime Hoshi
b326b76d60 jsutil: Use a 'writable' TypedArray on go2cpp 2020-12-06 02:25:04 +09:00
Hajime Hoshi
410766c984 restorable: Add more detailed information to the panic message
Updates #1427
2020-12-05 19:56:06 +09:00
Hajime Hoshi
d4a2433643 Revert "graphicsdriver/opengl: Reduce creation of Float32Array"
This reverts commit 3c28bcf3c4.

Reason: Tests failed: https://github.com/hajimehoshi/ebiten/runs/1496602911
2020-12-04 12:10:15 +09:00
Hajime Hoshi
3c28bcf3c4 graphicsdriver/opengl: Reduce creation of Float32Array
Updates #1426
2020-12-02 22:58:36 +09:00
Hajime Hoshi
44e2455c65 graphicsdriver/opengl: Avoid unnecessary creation of Uint16Array/Float32Array
Updates #1426
2020-12-02 20:40:28 +09:00
Hajime Hoshi
5897e1ab7c Implement some preparation code for go2cpp
Updates #744
2020-11-30 23:18:42 +09:00
Hajime Hoshi
912e13071f graphicsdriver/opengl: Refactoring 2020-11-29 23:04:00 +09:00
Hajime Hoshi
9a69c3ea9c graphicscommand: Add 'dst-region' to String of DrawTriangles command 2020-11-27 01:48:17 +09:00
Hajime Hoshi
e7fafb5527 ebiten: Add a new log to dump update count
Fixes #1425
2020-11-24 22:36:32 +09:00
Hajime Hoshi
526a92256b graphicsdriver/opengl: Refactoring: Remove shaderType 2020-11-21 23:33:25 +09:00
Hajime Hoshi
8dba7b7722 graphicsdriver/opengl: Refactoring: Remove dataType 2020-11-21 23:14:43 +09:00
Hajime Hoshi
c9060d2fa8 graphicsdriver/opengl: Remove bufferType 2020-11-21 23:07:11 +09:00
Hajime Hoshi
9c014a281a graphicsdriver/opengl: Refactoring 2020-11-21 23:00:57 +09:00
Hajime Hoshi
859d247093 graphicsdriver/opengl: Refactoring 2020-11-21 22:49:49 +09:00
Hajime Hoshi
ddc8115b51 graphicsdriver/opengl: Refactoring: remove ensureGL 2020-11-21 22:09:58 +09:00
Hajime Hoshi
dd46221968 graphicsdriver/opengl: Enable dFdx for mobiles
Fixes #1404
2020-11-21 19:40:11 +09:00
Hajime Hoshi
b72848dc97 shaderir: Bug fix: Test failures
Updates #1404
2020-11-21 19:17:31 +09:00
Hajime Hoshi
b1d7a5f595 shaderir/glsl: Enable dFdx for WebGL
With WebGL1, an extension is required for dFdx. On the other hand,
with WebGL2, GLSL ES 300 is required and the extension is forbidden.
This change fixes shaderir/glsl to switch the output depends on the
WebGL version.

This change also adds a new build tag 'ebitenwebgl1' forcing WebGL 1.

Updates #1404
2020-11-21 19:07:54 +09:00
Hajime Hoshi
2097312a8b graphicsdriver/opengl: Refactoring 2020-11-21 16:44:49 +09:00
Hajime Hoshi
4df958c9fd Avoid comparing to js.Undefined() for consistency 2020-11-21 14:25:17 +09:00
Hajime Hoshi
5d8c39028c web: Remove unused functions 2020-11-21 01:33:09 +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
ed494dbf59 restorable: Reland: Do not record pixels if restoring is not requried
This change also remove the restrictions of operations on
graphicscommand.Image. For example, now DrawTriangles and
ReplacePixels can be mixed on the same image.

Fixes #1022
2020-11-14 15:00:16 +09:00
Hajime Hoshi
257d747f7d shareable: Refactoring 2020-11-14 13:15:42 +09:00
Hajime Hoshi
d179dab314 shareable: Refactoring 2020-11-14 01:03:18 +09:00
Hajime Hoshi
86a0c7aa82 graphicsdriver/opengl: Use PBO when retrieving pixels 2020-11-13 09:10:56 +09:00
Hajime Hoshi
0366103b2e shareable: Bug fix: Crash when syncing pixels of a disposed image
When an image was disposed, the image was not unregistered from the
set of 'imagesToMakeShared'. This caused a crash when trying to sync
the pixel data of the disposed image.

This change fixes the issue by unregistering the image when the
image is disposed.

Fixes #1421
2020-11-12 23:37:51 +09:00
Hajime Hoshi
ddfb8adbc4 graphicsdriver/metal: Asynchronous sending pixels
Fixes #1418
2020-11-10 22:48:03 +09:00
Hajime Hoshi
5705dc79fb graphicsdriver/metal: Do not need to wait until flushing at Sync 2020-11-10 22:12:26 +09:00
Hajime Hoshi
99b4a3096a graphicsdriver/opengl: Use Go const values instead of getting them dynamically 2020-11-08 19:23:32 +09:00
Hajime Hoshi
e09f3aa286 graphicsdriver/metal/mtl: Bug fix: Fix the guard range 2020-11-08 04:44:43 +09:00
Hajime Hoshi
aaff18ecf7 graphicsdriver/metal/mtl: Bug fix: Guard the handler map by a mutex
The handler is invoked in another thread than the main thread.
2020-11-08 04:40:13 +09:00
Hajime Hoshi
c7330883ef restorable: Remove Fill and make (*ebiten.Image).Fill available for sub-images
Now a scissor (a clipping region) can be specified, we don't have to
worry about the rendering results out of the specified region.
Replace the implmenetation of the Fill with just a DrawTriangles with
an empty white image.

As a side effect, SubImage is avilable for Fill.

Fixes #1416
2020-11-08 02:50:06 +09:00
Hajime Hoshi
ed028110cf ebiten: Allow rendering on a sub-image by scissor test
Fixes #1255
2020-11-08 00:58:44 +09:00