Commit Graph

4158 Commits

Author SHA1 Message Date
Hajime Hoshi
9e9cec249a ebiten: make some MouseButton definitions explicit
This change redefines named mouse button consts like MouseButtonLeft
to use MouseButton0, so that users can know which enums are the same
and different.

Updates #2445
2022-11-23 04:41:11 +09:00
Kacper Drobny
6e12fd13e4
ebiten: add additional MouseButtons (#2467)
Closes #2445
2022-11-23 04:28:34 +09:00
Hajime Hoshi
5356b44286 internal/graphicsdriver/opengl: add comments about Firefox
Updates #2077
2022-11-23 00:57:16 +09:00
Hajime Hoshi
67430362cc internal/graphicsdriver/directx: add EBITENGINE_DIRECTX_FEATURE_LEVEL
A fix for #2447 was a breaking-change as the DirectX driver was no longer
available for some old graphics card.

To support such old cards, provide a new environment variable
EBITENGINE_DIRECTX_FEATURE_LEVEL to specify a feature level.
The possible values are 11_0, 11_1, 12_0, 12_1, and 12_2. The default
value is 12_0.

Closes #2466
2022-11-21 02:46:07 +09:00
Hajime Hoshi
f129c23393 all: update URLs in comments 2022-11-21 01:46:50 +09:00
Hajime Hoshi
e9e5d27d2c internal/shader: bug fix: % operators for integer vecs didn't work
Closes #1911
2022-11-21 01:39:20 +09:00
Hajime Hoshi
0b9cbaa1ed internal/shader: introduce integer vectors (ivec2, ivec3, ivec4)
Closes #1911
2022-11-21 00:31:23 +09:00
TotallyGamerJet
f09c4a624e
internal/gamepad: use RegisterLibFunc (#2465)
RegisterLibFunction is typesafe and now supports float arguments.

Updates #1162
2022-11-21 00:24:27 +09:00
TotallyGamerJet
fb612ab443
internal/cocoa, internal/graphicsdriver/mtl: remove usages of NSInvocations to directly call ID.Send (#2464)
purego now supports using floats as arguments.
We can remove these instances of NSInvocation that
only existed to circumvent that feature.

Updates #1162
2022-11-20 23:48:22 +09:00
Hajime Hoshi
9a75e266d4 internal/graphicsdriver: fix comments 2022-11-20 23:18:40 +09:00
Hajime Hoshi
7961654927 internal/graphicsdriver/metal: bug fix: wrong alignment for vec3 2022-11-20 23:14:09 +09:00
Hajime Hoshi
5aecd6762c internal/shader: refactoring 2022-11-20 18:25:08 +09:00
Hajime Hoshi
dc1df824a5 internal/shader: more strict type checks with built-in functions 2022-11-20 17:47:53 +09:00
Hajime Hoshi
5d8216def3 internal/shader: stricter const type check 2022-11-20 15:52:33 +09:00
Hajime Hoshi
5f4e3a0348 internal/shader: add swizzling check 2022-11-19 22:39:17 +09:00
Hajime Hoshi
bba196d1ec ebiten: allow array types for uniform variables
Closes #2448
2022-11-18 14:08:31 +09:00
Hajime Hoshi
90213d5d80 internal/graphicsdriver/opengl: refactoring 2022-11-18 13:32:09 +09:00
Hajime Hoshi
95b4e67c77 internal/graphicsdriver/opengl: reduce context functions 2022-11-18 03:18:30 +09:00
Hajime Hoshi
4de6da0a50 internal/graphicsdriver/opengl: use an appropriate stencil buffer format 2022-11-17 13:31:36 +09:00
Hajime Hoshi
21670691b1 internal/graphicsdriver/opengl: remove duplicated code 2022-11-17 13:22:48 +09:00
Hajime Hoshi
d6027a9357 internal/graphicsdriver/opengl: remove duplicated code 2022-11-17 13:13:15 +09:00
Hajime Hoshi
8cc6fa82fd internal/graphicsdriver/opengl: remove fnIsContextLost
As restoring from context lost doesn't happen on browsers, isContextLost
doesn't have to be called.
2022-11-17 12:43:26 +09:00
Hajime Hoshi
c768860f3f internal/graphicsdriver/opengl: remove fnGetExtension 2022-11-17 12:40:56 +09:00
Hajime Hoshi
bae5aa7732 internal/graphicsdriver/opengl: move initGL to NewGraphics
As restoring from context lost doesn't happen on browsers, initilizing
GL doesn't have to be done at reset.
2022-11-17 12:34:55 +09:00
Hajime Hoshi
4082223aec internal/graphicsdriver/opengl: remove webGLVersion 2022-11-17 12:27:32 +09:00
Hajime Hoshi
74d9515345 internal/graphicsdriver/opengl: refactoring: move gl_js to gl/context_js.go
This unifies the OpenGL context interface for all the platforms.
2022-11-17 12:22:46 +09:00
Hajime Hoshi
f08983e14d internal/graphicsdriver/opengl: remove unused variables
It should be safe to assume 0 is an invalid texture ID in OpenGL.

https://registry.khronos.org/OpenGL-Refpages/gl4/html/glIsTexture.xhtml
> If texture is zero, or is a non-zero value that is not currently the
> name of a texture, or if an error occurs, glIsTexture returns GL_FALSE.
2022-11-17 10:53:28 +09:00
Hajime Hoshi
de3702e4c2 internal/graphicsdriver/opengl: reduce unnecessary slice allocations 2022-11-17 03:01:31 +09:00
Hajime Hoshi
9df4770d20 internal/graphicsdriver/opengl/gl: make Context closer to gomobile's Context 2022-11-17 01:23:27 +09:00
Hajime Hoshi
49fc1cfdc0 internal/graphicsdriver/opengl/gl: refactoring: replace some *iv functions with *i 2022-11-17 00:26:33 +09:00
Hajime Hoshi
098fed65d5 internal/graphicsdriver/opengl/gl: refactoring: replace GetIntegerv -> GetInteger 2022-11-16 23:59:28 +09:00
Hajime Hoshi
c7c9500ba6 internal/graphicsdriver/directx: bug fix: a software adaptor was unexpectedly chosen
Closes #2459
2022-11-16 15:46:17 +09:00
Hajime Hoshi
4c389c1752 internal/graphicsdriver/opengl/gl: bug fix: compile error 2022-11-15 02:41:59 +09:00
Hajime Hoshi
056042ca92 internal/graphicsdriver/opengl/gl: refactoring 2022-11-15 02:38:38 +09:00
Hajime Hoshi
0d8912e7ae internal/graphicsdriver/opengl/gl: bug fix: failed to load OpenGL(ES).framework on iOS
This change also fixes the issue that *EXT functions are missing
in OpenGLES.framework.

Closes #2456
2022-11-15 02:33:45 +09:00
Hajime Hoshi
7d146fb70b internal/ui: bug fix: IsGL / SetUIView can be called before initialization is done
The functions in the package `mobile/ebitenmobileview` could be invoked
from EbitenViewController even before the graphics driver initialization
is done in theory.

This change fixes this issue by waiting the initialization by
channels. Also, this change adds error handlings at these functions.

Closes #2455
2022-11-15 01:53:20 +09:00
Hajime Hoshi
f4e63602d3 internal/graphicsdriver/opengl/gl: dynamic function loading for Android
Closes #2450
2022-11-14 23:23:50 +09:00
Hajime Hoshi
31af27b926 internal/graphicsdriver/opengl/gl: fix error message 2022-11-14 13:19:19 +09:00
Hajime Hoshi
f6f7ed3e3d internal/graphicsdriver/opengl/gl: automatically choose OpenGL and OpenGL ES
Updates #292
2022-11-14 12:50:53 +09:00
Hajime Hoshi
fcf454ef20 internal/graphicsdriver/opengl/gl: use RTLD_LAZY instead of RTLD_NOW
See the discussion at #2453.
2022-11-14 04:46:11 +09:00
TotallyGamerJet
56ec19caa1
all: use RTLD_LAZY in dlopen for darwin (#2453)
dlopen requires either RTLD_LAZY or RTLD_NOW but there was neither.

Updates #1162
2022-11-14 04:44:51 +09:00
Hajime Hoshi
072e91d67f internal/graphicsdriver/opengl/gl: dynamic-load functions with GLX
Updates #292
Updates #2450
2022-11-14 03:21:42 +09:00
Hajime Hoshi
f093996284 internal/graphicsdriver/opengl/gl: refactoring 2022-11-14 03:14:21 +09:00
Hajime Hoshi
1e86e7fa18 internal/ui: refactoring: reduce opengles build tags
Updates #292
2022-11-14 02:46:34 +09:00
Hajime Hoshi
114a8aa6ea internal/graphicsdriver/opengl/gl: reland: refactoring: reduce opengles build tags
Updates #292
2022-11-14 02:33:23 +09:00
Hajime Hoshi
e8810495cf internal/graphicsdriver/opengl/gl: reland: refactoring: reduce opengles build tags
This is a reland of c9cff69dcb.

Updates #292
2022-11-14 02:21:18 +09:00
Hajime Hoshi
e87e4ffbd2 Revert "internal/graphicsdriver/opengl/gl: refactoring"
This reverts commit c9cff69dcb.

Reason: compmile error for browsers
2022-11-14 02:17:27 +09:00
Hajime Hoshi
c9cff69dcb internal/graphicsdriver/opengl/gl: refactoring 2022-11-14 02:13:32 +09:00
Hajime Hoshi
94291ecb17 internal/graphicsdriver/opengl/gl: update copyrights
These files are already completely different from the original files.
2022-11-14 01:56:30 +09:00
Hajime Hoshi
39b8a66359 internal/graphicsdriver/opengl/gl: dynamic function load for OpenGL ES
Updates #292
Updates #2450
2022-11-13 08:48:26 -08:00
Hajime Hoshi
d09fd90963 internal/ui: use EGL for OpenGL ES
Updates #292
2022-11-13 06:23:30 -08:00
Hajime Hoshi
e5e7ceb688 internal/graphicsdriver/opengl/gl: refactoring 2022-11-13 23:10:20 +09:00
Hajime Hoshi
144d2374bf internal/graphicsdriver/opengl/gl: remove 'egl' build tag
Probably nobody uses this.
2022-11-13 22:50:21 +09:00
Hajime Hoshi
5b96d93d13 internal/graphicsdriver/opengl/gl: refactoring 2022-11-13 22:26:13 +09:00
Hajime Hoshi
78f8ddbda8 internal/graphicsdriver/opengl/gl: load OpenGLES.framework if possible on Darwin
Closes #2449
2022-11-13 19:51:43 +09:00
Hajime Hoshi
b6ed95750b internal/graphicsdriver/opengl: unify context_gl.go and context_gles.go
Closes #2451
2022-11-13 19:42:21 +09:00
Hajime Hoshi
f69beffc6c internal/graphicsdriver/opengl: bug fix: initialization was too early on Windows
Closes #2452
2022-11-13 18:00:40 +09:00
Hajime Hoshi
b536b82109 internal/graphicsdriver/opengl/gl: hide concrete context types 2022-11-13 17:13:52 +09:00
Hajime Hoshi
b66cf74c99 internal/graphicsdriver/opengl: bug fix: compile error 2022-11-13 16:16:19 +09:00
Hajime Hoshi
656a2d758e internal/graphicsdriver/opengl: bug fix: compile error 2022-11-13 15:55:33 +09:00
Hajime Hoshi
8393211ed7 internal/graphicsdriver/opengl: bug fix: compile error 2022-11-13 15:44:15 +09:00
Hajime Hoshi
8c49c88b08 internal/graphicsdriver/opengl: refactoring 2022-11-13 15:27:37 +09:00
Hajime Hoshi
42566c6c9a internal/graphicsdriver/opengl: refactoring: remove SetCanvas 2022-11-13 15:18:44 +09:00
Hajime Hoshi
a0a5f2b301 internal/graphicsdriver/opengl: remove SetGomobileGLContext
This change is needed to initialize the context at opengl.NewGraphics.

Updates #2451
2022-11-13 15:07:14 +09:00
Hajime Hoshi
5cfb7c9469 internal/graphicsdriver/opengl: make context_gles.go closer to context_gl.go
Updates #2451
2022-11-13 14:20:47 +09:00
Hajime Hoshi
0c5a77eaa4 internal/graphicsdriver/opengl/gles: integrate gles and glconst into gl
Updates #2451
2022-11-13 14:15:22 +09:00
Hajime Hoshi
c4abaa32f5 internal/graphicsdriver/opengl: initialize gl at init()
This changes context_gl.go a little closer to context_gles.go.

Updates #2451
2022-11-13 04:13:18 +09:00
Hajime Hoshi
bb30b85d29 internal/graphicsdriver/opengl/gl: simplify C code 2022-11-13 03:35:40 +09:00
Hajime Hoshi
879cf50aaf internal/graphicsdriver/opengl: remove unused functions 2022-11-13 02:54:34 +09:00
Hajime Hoshi
fad9f1592c internal/graphicsdriver/opengl/gles: remove unused functions 2022-11-13 02:45:53 +09:00
Hajime Hoshi
c5fb6fa23f internal/graphicsdriver/opengl/gl: remove unused functions 2022-11-13 02:35:45 +09:00
Hajime Hoshi
1ecac8d834 all: allow integer uniform variables for Kage shaders
Closes #2305
Updates #2448
2022-11-13 01:49:24 +09:00
Hajime Hoshi
4ff9a12930 internal/graphicscommand: refactoring 2022-11-12 22:26:28 +09:00
Hajime Hoshi
a406904a51 internal/graphicsdriver: refactoring 2022-11-12 21:03:54 +09:00
Hajime Hoshi
419bb4c1e9 all: use uint32 instead of float32 for uniform values
This is a preparation for other types of uniform values.

Updates #2305
2022-11-12 20:28:07 +09:00
Hajime Hoshi
0db2318a8d internal/graphicsdriver/opengl: update comments 2022-11-12 19:31:16 +09:00
Hajime Hoshi
cee948048d internal/graphicsdriver/opengl: remove unused functions 2022-11-12 19:28:14 +09:00
Hajime Hoshi
4ae84c2232 internal/packing: bug fix: wrong logic for extending a page
Before this fix, 0-sized node could be created when extending the
page.

Updates #2327
2022-11-12 17:42:17 +09:00
Hajime Hoshi
2deceaa0af internal/graphicsdriver/directx: specify DX level 12
The DirectX initialization passed but crashed later on some old machines
supporting the feature level 11 but not 12.

This change fixes the issue by changing the required feature level from
11 to 12 so that the initialization fails and OpenGL is used as the
fallback.

Closes #2447
2022-11-12 12:25:24 +09:00
Hajime Hoshi
c72fd7ffcf internal/packing: enable non-square page size
Closes #2327
2022-11-11 23:11:05 +09:00
Hajime Hoshi
fde964312c internal/packing: reland: refactoring
This change basically relands these commits:

 * e08078d84a
 * 8fa36cc7ef

but with a fix internal/restorable not to create too many images.

Updates #2327
2022-11-11 21:55:11 +09:00
Hajime Hoshi
f593725bf9 Revert "internal/packing: refactoring"
This reverts these commits

* 8fa36cc7ef.
* e08078d84a

Reason: test failures

Updates #2327
2022-11-11 19:35:13 +09:00
Hajime Hoshi
8fa36cc7ef internal/packing: improve test
Updates #2327
2022-11-11 19:26:00 +09:00
Hajime Hoshi
e08078d84a internal/packing: refactoring
Now pages are automatically extended by Alloc.

Updates #2327
2022-11-11 19:12:23 +09:00
Hajime Hoshi
303965e1a9 all: remove unnecessary copying
Copying []byte to string should copy the data if necessary, as the
Go specification assures that strings are immutable.
2022-11-11 00:28:47 +09:00
Hajime Hoshi
097adcf8b6 internal/graphicsdriver/opengl/gl: reladn: refactoring
This is a reland of a1ad87a262
2022-11-09 21:02:31 +09:00
Hajime Hoshi
96298bb59d Revert "internal/graphicsdriver/opengl/gl: refactoring"
This reverts commit a1ad87a262.

Reason: compile error
2022-11-09 18:27:06 +09:00
Hajime Hoshi
a1ad87a262 internal/graphicsdriver/opengl/gl: refactoring 2022-11-09 16:07:30 +09:00
Hajime Hoshi
915fff96f8 all: reduce reflect usages 2022-11-09 13:24:31 +09:00
Hajime Hoshi
0d6b42fedd internal/ui: refactoring: keep screen/offscreen sizes as float64
Updates #2285
2022-11-09 01:18:41 +09:00
TotallyGamerJet
8c5f525ac2
internal/ui: use RegisterClass API (#2442)
Updates #1162

This change uses purego's new RegisterClass API to clean up the
EbitengineWindowDelegate ObjC class. Doing so makes the code
easier to read and more efficient since it directly get the origResizable
and origDelegate fields.
2022-11-07 14:31:39 +09:00
Hajime Hoshi
262ff351f4 internal/graphicsdriver/directx: bug fix: ScheduleFrameEventX might not return S_OK on Xbox One 2022-11-05 15:09:38 +09:00
Hajime Hoshi
58f95dd1e0 internal/ui: clean-up 2022-11-05 14:20:48 +09:00
Hajime Hoshi
cff99106b6 internal/ui: bug fix: fullscreening didn't work correctly on macOS 13
As of macOS 13, a retrieved collectionBehavior included
NSWindowCollectionBehaviorFullScreenNone and this prevented the window
from being fullscreen.

This change fixes this issue by removing the flag
NSWindowCollectionBehaviorFullScreenNone when necessary.

Closes #2437
2022-11-05 14:07:02 +09:00
Hajime Hoshi
a6e121613f internal/graphicsdriver/directx: bug fix: wrong SDK version for Xbox One 2022-11-05 02:31:28 +09:00
Hajime Hoshi
50021ef3e4 internal/graphicscommand: use buffers for []float32 to reduce allocations 2022-11-04 21:55:44 +09:00
Hajime Hoshi
d73e8f785d internal/graphicsdriver: render various destination regions as one command
Closes #2232
2022-11-04 20:49:44 +09:00
Hajime Hoshi
1ce29e2afa internal/graphicsdriver/directx: reduce rendering paths for even-odd rendering 2022-11-04 18:18:08 +09:00
Hajime Hoshi
0afb6fd22a internal/graphicsdriver/metal: reduce rendering paths for even-odd rendering 2022-11-04 16:17:51 +09:00
Hajime Hoshi
1839dd0b9b internal/graphicscommand: bug fix: test failures on Linux 2022-11-04 03:55:05 +09:00
Hajime Hoshi
005e87a917 internal/ui: prepare extra capacities for uniform variables 2022-11-04 03:18:49 +09:00
Hajime Hoshi
80e3baae9f internal/graphicscommand: reduce allocations of float32 slices 2022-11-04 02:34:44 +09:00
Hajime Hoshi
c4e4e55d75 internal/shaderir: cache reachable uniform variables
Updates #2232
2022-11-04 01:28:24 +09:00
Hajime Hoshi
384dee7160 internal/graphicscommand: remove unused uniform variables
This improves possibility of merging graphics commands by reducing
uniform variables.

Updates #2232
2022-11-03 22:45:17 +09:00
Hajime Hoshi
0762db3b3e internal/shaderir: refactoring 2022-11-03 18:16:54 +09:00
Hajime Hoshi
7dbb078a9e internal/shaderir: refactoring 2022-11-03 17:44:11 +09:00
Hajime Hoshi
e2c25dbc6d internal/shaderir: rename functions 2022-11-03 17:14:49 +09:00
Artem Yadelskyi
10415d417a
all: replace interface{} with any (#2430)
Closes #2429
2022-11-03 15:33:09 +09:00
Artem Yadelskyi
5b53cef59e
all: remove old // +build comments (#2431)
Closes #2325
2022-11-03 12:55:14 +09:00
Hajime Hoshi
8aacf067dd all: use x/sys/execabs instead of os/exec
Closes #2418
2022-11-01 23:36:57 +09:00
Hajime Hoshi
1b3696a7ff internal/graphicsdriver/opengl: fix comments 2022-10-31 12:59:27 +09:00
Hajime Hoshi
a5993f09a2 internal/graphicscommand: refactoring: add preserved uniform variables at the graphicscommand package
This is a preparation to skip setting unnecessary uniform variables
like dstRegion.

Updates #2232
2022-10-30 22:30:52 +09:00
Hajime Hoshi
690e73c11b all: replace reflect.SliceHeader with unsafe.Slice
Closes #2420
2022-10-30 12:25:30 +09:00
Hajime Hoshi
ac61126473 internal/graphicscommand: always flush buffers
After #2423 is fixed, buffers should be able to be flushed safely
anytime.

Updates #2391
Updates #2423
2022-10-30 10:51:41 +09:00
Hajime Hoshi
b096ba700a internal/graphicscommand: bug fix: clear buffers when disposing an image
Closes #2423
2022-10-30 03:38:53 +09:00
Hajime Hoshi
5eceabd172 Revert "internal/graphicscommand: bug fix: flush image buffers"
This reverts commit d6910eb9ab.

Reason: The wasm flakiness occured again

Updates #2391
Updates #2423
2022-10-30 02:32:28 +09:00
Hajime Hoshi
d6910eb9ab internal/graphicscommand: bug fix: flush image buffers
This is basically a revert for 4d5b608d0c.
This caused a crash on Windows.

Even after this fix, the browser tests seem no longer flaky, but
I am not 100% sure.

Updates #2391
Closes #2423
2022-10-30 02:21:56 +09:00
Hajime Hoshi
ee595659e7 Revert "internal/gamepad: remove dependency on golang.org/x/sys/unix"
This reverts commit 046f7e52a3.

Reason: As we drop Go 1.16, we no longer have to remove this dependency.

Updates #2421
2022-10-29 23:23:13 +09:00
Hajime Hoshi
046f7e52a3 internal/gamepad: remove dependency on golang.org/x/sys/unix 2022-10-29 21:42:08 +09:00
Hajime Hoshi
ac08ebe080 internal/ui: set SwapInterval(0) when resizing the window
This mitigates flickering at least on macOS with OpenGL.

Updates #2144
2022-10-29 17:49:32 +09:00
Hajime Hoshi
066029539e internal/ui: clean-up code
A callback is preferred to a dirty flag.

Updates #2341
2022-10-28 19:07:37 +09:00
Hajime Hoshi
b019a3723a internal/ui: optimize GPU usages when the screen doesn't have to be updated
This change skips rendering when 1) the screen is not cleared every frame
(`SetScreenClearedEveryFrame(false)`) and 2) Draw doesn't draw anything
onto the screen. The GPU usages decreased on some machines (e.g. GPU usage
was 10% with an empty Ebitengine project and became 2-3 % on a Windows
machine).

Updates #2341
2022-10-28 18:51:06 +09:00
Hajime Hoshi
2cf651bed8 internal/graphicsdriver/directx: resize the swap buffer chain at the end of a frame
Updates #2144
2022-10-25 00:35:09 +09:00
Nathan Levett
f220eb729c
internal/graphicsdriver/opengl: move OpenGL constants to seperate package (#2408)
Closes #2389
2022-10-24 23:22:14 +09:00
Hajime Hoshi
3b7bc2fc57 internal/ui: remove unnecessary comments 2022-10-23 00:39:37 +09:00
Hajime Hoshi
fc2f999ebf internal/ui: refactoring: separate globalState into a new file 2022-10-23 00:11:35 +09:00
Hajime Hoshi
422de70d59 internal/ui: bug fix: screenshot didn't include antialias renderings 2022-10-22 14:19:24 +09:00
Hajime Hoshi
c49db07e75 internal/ui: bug fix: wrong property name was used
Closes #2400
2022-10-21 21:37:27 +09:00
Hajime Hoshi
f04e391cb4 all: rename emptyImage -> whiteImage 2022-10-21 15:26:56 +09:00
Hajime Hoshi
a990d79905 internal/ui: refactoring 2022-10-21 03:11:13 +09:00
Hajime Hoshi
9ec23ddeb4 ebiten: add DrawTrianglesOptions.AntiAlias and DrawTrianglesShaderOptions.AntiAlias
Closes #2385
2022-10-21 02:07:41 +09:00
Hajime Hoshi
da5f5ea327 ebiten: add blend factors
Updates #2382
2022-10-18 00:21:13 +09:00
Hajime Hoshi
d2a99afa44 internal/graphicsdriver/opengl: bug fix: lastBlend was not updated correctly on GLES 2022-10-17 16:05:09 +09:00
Hajime Hoshi
46a218c278 internal/graphicsdriver/metal/mtl: bug fix: wrong renaming
Updates #2382
2022-10-17 01:11:54 +09:00
Hajime Hoshi
871a8869db ebiten: bug fix: wrong renaming
Updates #2382
2022-10-17 01:00:23 +09:00
Hajime Hoshi
180e456a8e ebiten: rename members of Blend
Updates #2382
2022-10-17 00:51:55 +09:00
Hajime Hoshi
e03825bf08 ebiten: add BlendOperationSubtract and BlendOperationReverseSubtract
Updates #2382
2022-10-17 00:30:24 +09:00
Hajime Hoshi
06c53c1445 internal/grphicsdriver/opengl: bug fix: wrong consntant was used for blend operations
Updates #2382
2022-10-17 00:21:12 +09:00
Hajime Hoshi
b79495761e ebiten: add Blend and deprecate CompositeMode
Updates #2382
2022-10-16 22:47:00 +09:00
Hajime Hoshi
bd0d43f98f internal/graphicsdriver: use byte for blending members 2022-10-16 20:49:12 +09:00
Hajime Hoshi
b6987b6312 internal/graphicsdriver/opengl: bug fix: needed to reset lastBlend 2022-10-16 20:44:09 +09:00
Hajime Hoshi
7c459c152b internal/atlas: bug fix: compile error 2022-10-16 20:02:42 +09:00
Hajime Hoshi
2855095ac9 all: unify terms for buffers and flushing 2022-10-16 19:47:00 +09:00
Hajime Hoshi
4d5b608d0c internal/graphicscommand: bug fix: suppress test flakiness on browsers
Closes #2391
2022-10-16 17:55:23 +09:00
Hajime Hoshi
475dc6394f internal/atlas: remove an unnecessary mutex
Updates #2390
2022-10-16 15:29:02 +09:00
Hajime Hoshi
27cb149475 internal/graphicscommand: bug fix: resolve unsent WritePixels commands
(*Image).WritePixels doens't send a command to the queue immediately
but caches commands internally. However, the package atlas assumed
that pixel data was sent to the cache every end of a frame. Then, byte
slices for pixels were corrupted.

This change fixes the issue by resolving all the images when flushing
commands.

Closes #2390
2022-10-16 15:19:25 +09:00
Hajime Hoshi
aa81a6cc7d internal/processtest/testdata: add a test file
Updates #2362
2022-10-16 15:17:09 +09:00
Hajime Hoshi
09a7d39874 internal/graphicsdriver: add Blend struct
This is a preparation to specify blend factors and blend operators.

Updates #2382
2022-10-16 01:08:26 +09:00
Hajime Hoshi
2f146d5e4f internal/graphicsdriver/opengl: bug fix: build failure for browsers 2022-10-15 23:29:22 +09:00
Hajime Hoshi
257f05883c internal/graphicsdriver/opengl: enable to compiile for browsers with the 'opengles' tag
The 'opengles' tag is just ignored for browsers.
2022-10-15 22:22:28 +09:00
Hajime Hoshi
37c5f53890 internal/graphicsdriver/opengl: refactoring 2022-10-15 22:14:21 +09:00
Hajime Hoshi
1d9f1474e9 internal/graphicsdriver: rename constants 2022-10-15 21:14:59 +09:00
Hajime Hoshi
272d0c6a3f internal/graphicsdriver: rename Operator -> BlendFactor
Updates #2382
2022-10-15 17:34:03 +09:00
Hajime Hoshi
e42ee8c506 internal/graphicscommand: bug fix: call End even if an error causes
Without calling End, the graphics driver (especially Metal) state
might be stale and might cause another error.

Closes #2388
2022-10-15 15:23:04 +09:00
Hajime Hoshi
35e9f26681 internal/graphicsdriver/directx: refactoring 2022-10-15 12:16:41 +09:00
Hajime Hoshi
e796646abd internal/graphicscommand: rename arguments 2022-10-15 03:36:25 +09:00
Hajime Hoshi
bf6a5415cf internal/graphicscommand: bug fix: test failures on Windows 2022-10-15 02:56:40 +09:00
Hajime Hoshi
32a2a705c0 internal/ui: flush the cache of the final screen after DrawScreen
The screen image might have a cache in the future.

Updates #2385
2022-10-15 01:59:53 +09:00
Hajime Hoshi
daf349ab72 internal/graphicscommand: bug fix: present at the end of the frame explicitly
Before this change, presenting happened when the rendering destination
was the final screen. Now this assumption is wrong as the final screen
might be used in the middle of the commands due to DrawFinalScreen.

Instead, this change adds a new argument `present` to FlushCommands to
present the screen explicitly at the end of the frame.

Closes #2386
2022-10-15 01:54:46 +09:00
Hajime Hoshi
f15536e8de ebiten: refactoring: remove imageDumperGame
This enables passing the user's Game to internal/ui without wrapping.

This is necessary to check whether the user's Game implements an
optional function or not.

Updates #2046
2022-10-14 02:58:31 +09:00
Hajime Hoshi
25ae96db89 internal/ui: move screenScaleAndOffsets to the ebiten package
Updates #2046
2022-10-14 01:58:07 +09:00
Hajime Hoshi
03621e22c6 internal/ui: remove unnecessary mutex
Now (*context).updateFrame and (*context).adjustPosition are not called
in parallel even though the goroutines might be different.
2022-10-14 01:47:52 +09:00
Hajime Hoshi
4bd3a9ef8f internal/ui: refactoring: move the screen rendering logic to ebiten package
Updates #2046
2022-10-14 00:34:40 +09:00
Hajime Hoshi
08e6f5af86 internal/graphicsdriver: remove FramebufferYDirection 2022-10-14 00:05:59 +09:00
Hajime Hoshi
c23af8fa3a internal/ui: remove unnecessary comments 2022-10-13 12:28:32 +09:00
Hajime Hoshi
30088cf602 internal/ui: refactoring: reduce uniform variable
This might degrade performance, but can demonstrate how to get the
scale of the screen.

Updates #2046
2022-10-13 00:59:51 +09:00
Hajime Hoshi
91275e8fc2 internal/ui: add comments
Updates #1431
2022-10-12 02:46:08 +09:00
Hajime Hoshi
99e777b0c5 internal/atlas: do not adjust pixels for DrawTriangles(Shader)
Adjusting pixels is needed to avoid strainge rendering to avoid unexpected
rendering (#1171). However, this adjustment caused unexpected holes
especially in a thick stroke.

This change moves the logic of adjusting pixels from atlas to
graphics.QuadVertices so that adjusting works only for DrawImage and
DrawRectShader.

Updates #1171
Updates #1843
2022-10-11 02:09:20 +09:00
Hajime Hoshi
a310b7c5bb internal/builtinshader: fix comments 2022-10-10 13:14:37 +09:00
Hajime Hoshi
cb79e4eabe internal/restorable: improve pixelsForRestore usages
Updates #2375
2022-10-06 15:54:54 +09:00
Hajime Hoshi
c6b37e9809 internal/restorable: use pixelsForRestore only when restoring is needed
Updates #2375
2022-10-06 15:09:21 +09:00
Hajime Hoshi
34562c3337 internal/restorable: clear pixelsForRestore at Dispose
Updates #2375
2022-10-06 15:04:12 +09:00
Hajime Hoshi
e66bac5c3f internal/restorable: reuse byte slices for restoring
Updates #2375
2022-10-06 14:52:20 +09:00
Hajime Hoshi
85d8a5889a Revert "internal/restorable: reuse bytes instead of allocations"
This reverts commit 8cf3c31cf6.

Reason: This didn't improve the situation.

Updates #2375
2022-10-06 14:11:09 +09:00
Hajime Hoshi
8cf3c31cf6 internal/restorable: reuse bytes instead of allocations
Updates #2375
2022-10-06 12:41:47 +09:00
Hajime Hoshi
69cdd2b178 internal/graphicsdriver/metal: refactoring 2022-10-04 00:29:18 +09:00
Hajime Hoshi
b489548963 internal/builtinshader: fix comments 2022-10-03 01:09:28 +09:00
Hajime Hoshi
61cabbf2e7 internal/atlas: optimization 2022-10-03 00:06:50 +09:00
Hajime Hoshi
72983d966b all: remove unused conditions
Now Kage shaders are always used.

The situtation is different from when we fixed for #1355, so we removed
the fast path for #1335. We have to re-check the current performance.

Updates #1355
2022-10-02 23:50:48 +09:00
Hajime Hoshi
534d82c17d internal/builtinshader: move Filter and Address from internal/graphicsdriver 2022-10-02 23:24:15 +09:00
Hajime Hoshi
9c07b20f2b internal/ui: remove an odd cast 2022-10-02 23:20:16 +09:00
Hajime Hoshi
efd91c8b86 internal/ui: remove unused arguments from DrawTriangles
Closes #2369
2022-10-02 23:10:27 +09:00
Hajime Hoshi
d823e22bed internal/mipmap: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 23:06:32 +09:00
Hajime Hoshi
361a1059ee internal/buffered: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 23:06:29 +09:00
Hajime Hoshi
3da30b3b78 internal/atlas: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 23:06:27 +09:00
Hajime Hoshi
de8f85651d internal/restorable: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 22:51:34 +09:00
Hajime Hoshi
0ae2b1bc24 all: remove unnecessary conditions
Now a Kage shader is always used.
2022-10-02 22:30:59 +09:00
Hajime Hoshi
6fca8edc1b internal/graphicscommand: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 22:21:11 +09:00
Hajime Hoshi
080d936d42 internal/graphics: remove unused arguments from DrawTriangles
Updates #2369
2022-10-02 22:13:31 +09:00
Hajime Hoshi
6fc9d9316d internal/graphicscommand: remove unnecessary conditions
Now a Kage shader is always used.
2022-10-02 22:11:20 +09:00
Hajime Hoshi
a9574627e8 internal/graphicsdriver/directx: remove the built-in shaders
Updates #2369
2022-10-02 21:35:23 +09:00
Hajime Hoshi
033997d928 internal/graphicsdriver/opengl: remove the built-in shaders
Updates #2369
2022-10-02 21:26:13 +09:00
Hajime Hoshi
5f7db485f2 internal/graphicsdriver/metal: remove the built-in shaders
Updates #2369
2022-10-02 20:34:38 +09:00
Hajime Hoshi
0b45ca7057 ebiten: reduce duplicated shader compilations 2022-10-02 20:33:50 +09:00
Hajime Hoshi
ff72898b85 internal/builtinshader: use a struct instead of a map
With a map, we might miss typos.
2022-10-02 20:17:47 +09:00
Hajime Hoshi
311aa7dcf8 all: use Kage shaders in internal packages
Updates #2369
2022-10-02 19:17:09 +09:00
Hajime Hoshi
f293a03ab6 internal/mipmap: reland: do not consider filter to determine mipmap level
This is a reland of 42833614fb.

Now the filter argument is not used (a4e9a05b14),
the filter value can be the nearest filter even though the shader is
for the linear filter.

As long as `canSkipMipmap` is set correctly, we don't have to consider
the parameter `filter`. We should ignore it.

Updates #2364
2022-10-02 19:14:23 +09:00
Hajime Hoshi
bcb9844395 Revert "internal/mipmap: bug fix: do not consider filter to determine mipmap level"
This reverts commit 42833614fb.

Reason: test failure: TestImageEdge
2022-10-02 18:53:28 +09:00
Hajime Hoshi
42833614fb internal/mipmap: bug fix: do not consider filter to determine mipmap level
Now the filter argument is not used (a4e9a05b14),
the filter value can be the nearest filter even though the shader is
for the linear filter.

As long as `canSkipMipmap` is set correctly, we don't have to consider
the parameter `filter`. We should ignore it.

Updates #2364
2022-10-02 18:44:06 +09:00
Hajime Hoshi
4b2a9c3243 internal/testing: add the default exit code 1
This confirms that Update is really called.
2022-10-02 18:16:16 +09:00