Commit Graph

2898 Commits

Author SHA1 Message Date
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
Hajime Hoshi
e4e8e7254e graphicsdriver/metal/mtl: Refactoring: Specify struct member names explicitly 2020-11-07 23:46:07 +09:00
Hajime Hoshi
a8f96ee9af graphicsdriver/metal: Add Sync to sync CPU and GPU asynchronously
Fixes #1414
2020-11-07 04:09:47 +09:00
Hajime Hoshi
6e3cbe2e33 graphicsdriver/metal/mtl: Refactoring 2020-11-07 03:26:35 +09:00
Hajime Hoshi
e30d46e947 shareable: Reset non-updated-count at ReplacePixels
Before this change, ReplacePixels didn't affect the non-updated-count,
and an image using ReplacePixels tended to be on a shared image.
This was OK, but as lazy pixel loading is going to be introduced,
ReplacePixels also needs to reset the count.

Updates #1414
2020-11-06 02:19:02 +09:00