Commit Graph

1226 Commits

Author SHA1 Message Date
Hajime Hoshi
408cc1e833 internal/clock: Refactoring
Update now returns 0 when tps is 0, and 1 when tps is negative.
2018-07-17 00:29:10 +09:00
Hajime Hoshi
88e6768a30 Use the term 'TPS' ticks per second 2018-07-16 04:36:47 +09:00
Hajime Hoshi
bbb777eecc internal/clock: Use constant time to detect if the game is delayed too much 2018-07-16 03:02:55 +09:00
Hajime Hoshi
18ec1d8265 internal/clock: Update takes FPS 2018-07-16 01:03:23 +09:00
Hajime Hoshi
09c93ac86d ui: Avoid using eval 2018-07-14 23:47:31 +09:00
Hajime Hoshi
e25c237a01 Add IsVsyncEnabled / SetVsyncEnabled
This enables the game to work more efficiently (but consume much
more CPU).

Fixes #405.
2018-07-14 21:43:55 +09:00
Hajime Hoshi
6c8b7f8e9c graphics: Refactoring: Reduce error propagations 2018-07-12 03:08:50 +09:00
Hajime Hoshi
a9a21132ae graphics: Refactoring: Add pixelCommand 2018-07-12 02:40:06 +09:00
Hajime Hoshi
8f12dfc496 Use js.TypedArray
This is still WIP. There is a rendering issue on Wasm.
2018-07-06 02:48:51 +09:00
Hajime Hoshi
e4f157d9cd opengl: Remove unused code 2018-06-30 12:34:40 +09:00
Hajime Hoshi
2c0f3d4302 opengl: Bug fix: wrong argument to js.Value.Call 2018-06-30 12:32:15 +09:00
Hajime Hoshi
6e51d31524
Use new GopherWasm API (#634)
I plan to merge this right after
https://github.com/gopherjs/gopherwasm/pull/3 is merged.
2018-06-30 00:02:15 +09:00
Hajime Hoshi
abdf52bc74 shareable: Bug fix: Call SetFinalizer whenever a new image is created
Fixes #637
2018-06-28 22:23:07 +09:00
Hajime Hoshi
f765966742 web: Remove unused variables 2018-06-28 00:17:05 +09:00
Hajime Hoshi
f19e349d38 web: Remove IsNodeJS
gjbt now creates a pseudo-Node environment by creating
window.process object, and this conflicted with an assumption that
Ebiten doesn't nothing on Node environment. See
https://github.com/myitcv/gjbt/pull/13 for the detail.

This change allows Ebiten work on pseudo-Node environment. Even
after this change, Ebiten doesn't work on real Node environment
due to lack of DOM.
2018-06-28 00:12:24 +09:00
Hajime Hoshi
dec921809b shareable: Refactoring 2018-06-26 01:59:12 +09:00
Hajime Hoshi
a9359e4ef8 Use GopherJS/GopherWasm 2018-06-24 16:10:24 +09:00
Hajime Hoshi
8c9a11ddf4 opengl: Rely on gopherwasm for typed-array creation 2018-06-24 02:02:39 +09:00
Hajime Hoshi
ff86f8bd93 opengl: Refactoring 2018-06-23 04:43:56 +09:00
Hajime Hoshi
33e4f82d7c graphicsutil: Optimization to avoid boundary checks 2018-06-23 03:18:54 +09:00
Hajime Hoshi
6c1c60d40d opengl: Make Program struct to avoid Get() 2018-06-22 01:45:25 +09:00
Hajime Hoshi
55d832fc63 shareable: Don't extend textures on macOS
Fixes #593
2018-06-20 11:57:39 +09:00
Hajime Hoshi
d83799acf8 opengl: Bug fix: mobile build failure 2018-06-20 11:16:21 +09:00
Hajime Hoshi
8d644479cc opengl: Initialize consts first to avoid 'Get' calls 2018-06-19 04:02:56 +09:00
Hajime Hoshi
62bd35e412 Avoid 'Get' call if possible
(*js.Value).Get has some overhead especially on Wasm.
2018-06-19 03:43:24 +09:00
Hajime Hoshi
702a429afb opengl: Faster conversion from []float32 to Float32Array 2018-06-19 03:31:53 +09:00
Hajime Hoshi
840c4d24df graphicsutil: Accept matrix parameters directly for performance 2018-06-19 00:19:32 +09:00
Philipp Steinhaus
39b3170185 input: Enable mouse wheel input (#628) 2018-06-18 00:38:30 +09:00
Hajime Hoshi
a3c754d2cc graphics: Restrict QuadVertices to allow only power of 2 sizes
Now QuadVertices can skip calculating power of 2 values.
2018-06-17 23:05:19 +09:00
Hajime Hoshi
12287a8382 graphicsutil: Reduce multiplying 2018-06-17 20:11:31 +09:00
Hajime Hoshi
ac24a8382f graphicsutil: Extract matrix applying for performance 2018-06-17 19:45:09 +09:00
Hajime Hoshi
1849b59741 graphicsutil: Refactoring 2018-06-17 17:29:36 +09:00
Hajime Hoshi
5d37c331bb graphicsutil: Remove unused arguments 2018-06-17 16:38:21 +09:00
Hajime Hoshi
95561bbf6b affine: Use float32 values for GeoM
float32 was slow on GopherJS, but not slow on Wasm.
2018-06-17 15:38:10 +09:00
Hajime Hoshi
4c2fc30311 graphicsutil: Don't allow nil GeoM 2018-06-17 01:48:56 +09:00
Hajime Hoshi
f6b7a6be73 graphics: Use copy function in appendVertices 2018-06-17 01:09:05 +09:00
Hajime Hoshi
b4ace53596 affine: Remove GeoM to avoid GeoM allocations on the heap 2018-06-17 00:59:50 +09:00
Hajime Hoshi
460c47a9eb opengl: Pass slices to js.Value 2018-06-16 02:19:18 +09:00
Hajime Hoshi
3fbe8d8ecb opengl: Change Shader/Program/Buffer to js.Value 2018-06-16 00:30:16 +09:00
Hajime Hoshi
2497b64cf7 opengl: Change uniformLocation to js.Value 2018-06-16 00:30:16 +09:00
Hajime Hoshi
17ccf06755 opengl: Change Texture/Framebuffer to js.Value 2018-06-16 00:30:16 +09:00
Hajime Hoshi
48e2c2aba9 opengl: Use gopherwasm 2018-06-16 00:30:16 +09:00
Hajime Hoshi
b87a851c0e ui: New GopherWASM API 2018-06-16 00:26:28 +09:00
Hajime Hoshi
a90b7efdf4 shareable: Refactoring 2018-06-11 01:02:25 +09:00
Hajime Hoshi
3ee76ffd8e graphicsutil: Move vertices.go to graphicsutil 2018-06-10 23:08:22 +09:00
Hajime Hoshi
9745ccee47 restorable: Make (*Image).DrawImage accept vertices and indices 2018-06-10 22:59:00 +09:00
Hajime Hoshi
97a54548df restorable: Rename vertices -> quadVertices 2018-06-10 20:41:17 +09:00
Hajime Hoshi
600983e028 restorable: Record indices for restoring 2018-06-10 20:17:48 +09:00
Hajime Hoshi
2e5e7e6e24 restorable: Remove merging commands for code simplicity 2018-06-10 20:06:17 +09:00
Hajime Hoshi
03079ba067 restorable: Refactoring 2018-06-10 18:40:46 +09:00
Hajime Hoshi
c782380a1c restorable: Specify indices from restorable package 2018-06-10 18:17:58 +09:00
Hajime Hoshi
2853895e6b graphics: Refactoring: Rename functions 2018-06-10 17:53:57 +09:00
Hajime Hoshi
32ac3840a7 graphics: Add comments 2018-06-10 17:10:11 +09:00
Hajime Hoshi
4e21bfd005 graphics: Rename elements -> indices 2018-06-10 17:06:40 +09:00
Hajime Hoshi
8a268e871f graphics: Specify indices before commands 2018-06-10 17:04:58 +09:00
Hajime Hoshi
be665a3526 ui: Better way to avoid blocking
Fixes #625
2018-06-09 13:36:35 +09:00
Hajime Hoshi
6e12f287b0 ui: Use goroutine to avoid blocking on GopherJS 2018-06-09 03:05:37 +09:00
Hajime Hoshi
e6d0943366 graphics: Rename color_matrix -> color_matrix_body 2018-06-06 02:46:54 +09:00
Hajime Hoshi
b86860abcc graphics: Call BindBuffer only when the program was null 2018-06-04 00:13:23 +09:00
Hajime Hoshi
fac639f9b7 graphics: Refactoring: Remove drawImageCommand.quadsNum 2018-06-03 23:58:08 +09:00
Hajime Hoshi
c9dd04d471 graphics: Refactoring: Remove command groups 2018-06-03 23:13:01 +09:00
Hajime Hoshi
9d87622a19 graphics: Set elements for every EnqueueDrawImageCommand 2018-06-03 20:42:45 +09:00
Hajime Hoshi
525ad04568 graphics: Split the notion of vertices and elements 2018-06-03 16:07:26 +09:00
Hajime Hoshi
25f2dfc677 graphics: Refactoring 2018-06-03 01:43:10 +09:00
Hajime Hoshi
03e3f0f5f7 graphics: Call glBufferSubData for element array buffer every frame
This is a preparation for more flexible drawing commands.
2018-05-31 00:53:05 +09:00
Hajime Hoshi
5e93d75ae0 graphics: Fix comments 2018-05-28 02:38:26 +09:00
Hajime Hoshi
399f965729 opengl: Add BindBuffer accepting both element-array-buffer and array-buffer
This change is a pure refactoring to clarify that array buffer is
binded before its usage.
2018-05-28 00:34:00 +09:00
Hajime Hoshi
311788dfe2 ui: Remove warnings of deadlock
Now gopherwasm fixed this problem by avoiding js.MakeFunc.

See also: 3fe87b73c0
2018-05-27 04:10:14 +09:00
Hajime Hoshi
8e9c3bd304 ui: Use gopherwasm 2018-05-27 02:35:17 +09:00
Hajime Hoshi
faaf391619 audio: Give up syncing audio timer and game timer (#617)
Syncing was already incomplete (e.g. decoding takes more than one
frame and delays can happen in this case). Giving up syncing audio
timer and game timer should not affect the game experience so much.
Instead, clock implementation will be much simpler.
2018-05-27 00:30:12 +09:00
Hajime Hoshi
5976e4bbbc audio: More intellegent suspending/resuming (#617)
Before this change, the audio is suspended when the game stops for
1/12[s]. However, as game often stops for more than 1/12[s]
especially on mobiles, this implemntation caused some audio
glitches.

This change fixes this problem by re-implementing suspending/
resumeing audio by detecting the window is active/focused or not.
2018-05-26 23:31:04 +09:00
Hajime Hoshi
d88d1be4ad mobile: Refactoring 2018-05-26 22:51:30 +09:00
Hajime Hoshi
980055e07a devicescale: Use gopherwasm 2018-05-25 02:00:41 +09:00
Hajime Hoshi
d894a13698 web: Use gopherwasm 2018-05-25 01:59:50 +09:00
Hajime Hoshi
2ec075004a clock: Use gopherwasm 2018-05-25 01:14:31 +09:00
Hajime Hoshi
4c5613d73c opengl: Remove unneeded casts 2018-05-23 01:29:16 +09:00
Hajime Hoshi
b84dc0585d opengl: Remove dependencies on gopherjs/webgl
This is a preparation for #528
2018-05-23 00:48:24 +09:00
Hajime Hoshi
81a1fd4744 testflock: Use just sync.Mutex on browsers (#615) 2018-05-19 21:10:34 +09:00
Hajime Hoshi
0637a812bc web: Fix detecting mobile browsers for NodeJS 2018-05-16 22:29:19 +09:00
Hajime Hoshi
a5eb1b84ab web: Better way to detect NodeJS 2018-05-16 22:10:35 +09:00
Hajime Hoshi
c2df8326fc ui: Refactoring: Use IsNodeJS 2018-05-16 22:02:33 +09:00
Hajime Hoshi
d7d892f2d6 graphics: Allow a little margin for edge pixels 2018-05-13 23:00:06 +09:00
Hajime Hoshi
a1dd7b39a3 graphics: Remove roundTexel function
Actually, at least 704d4cf464,
examples/moire doesn't work well without roundTexel on MacBook Pro.
However, now other parts are fixed (e.g. highp is used), it looks
like roundTexel is no longer needed.
2018-05-13 22:30:22 +09:00
Hajime Hoshi
b402cddd01 graphics: Bug fix: wrong refactoring in shader 2018-05-13 14:20:54 +09:00
Hajime Hoshi
efaa5aa17a graphics: Refactor shader 2018-05-13 03:31:28 +09:00
Hajime Hoshi
3ccfe087d9 Refactoring 2018-05-12 15:25:01 +09:00
Hajime Hoshi
453921f1d3 ui: Bug fix: sizeChange must be set after updateFullscreenScaleIfNeeded 2018-05-12 02:11:37 +09:00
Hajime Hoshi
f5336ce7bc opengl: Use 'EXT' functions for framebuffers
Some pretty old machines don't support OpenGL 3.x or later, and in
such environment, some framebuffer functions like glGenFramebuffers
are not available. Instead, EXT versions can be used even on
machines that don't support OpenGL 3.x.

After this change, Ebiten always tries to use EXT version of
framebuffer functions. I believe EXT version is always available
when non-EXT version is available, so this chang eshould be safe.

Fixes #602
2018-05-10 02:11:23 +09:00
Hajime Hoshi
92631e64ed Remove internal/sync
nosync package for GopherJS is problematic since nosync's mutex
assumes that Lock call is never duplicated, which is not true in
actual applications.

See also #603.
2018-05-09 23:41:08 +09:00
Hajime Hoshi
167d21ec46 devicescale: Panic on Android when called from init funcs 2018-05-05 03:16:29 +09:00
Hajime Hoshi
d8dba69b47 ui: Add MonitorSize
Fixes #470
2018-05-05 02:42:45 +09:00
Hajime Hoshi
9a06b31556 ui: Don't panic at DeviceScaleFactor in init
Fixes #597
2018-05-05 01:28:29 +09:00
Hajime Hoshi
d41f959b96 ui: Initialize GLFW before Run 2018-05-04 23:55:23 +09:00
Hajime Hoshi
f1927d8aca shareable: Add tests 2018-05-03 14:10:43 +09:00
Hajime Hoshi
03dcd94884 shareable: Bug fix: Don't mark disposed when the image becomes not shared 2018-05-03 11:49:55 +09:00
Hajime Hoshi
9efccea31c ui: Add SetWindowTitle
Fixes #595
2018-05-02 19:21:17 +09:00
Hajime Hoshi
0e19aa558a graphics: Remove unneeded GL calls 2018-05-02 01:12:17 +09:00
Hajime Hoshi
6a34b87a6c opengl: Refactoring 2018-05-02 01:01:04 +09:00
Hajime Hoshi
ea1444ea7e shareable: Add checks at operations for disposed images 2018-04-30 03:34:35 +09:00
Hajime Hoshi
9df977dff8 shareable: Add 'disposed' state instead of 'allocated' state 2018-04-30 03:30:10 +09:00