Commit Graph

2740 Commits

Author SHA1 Message Date
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