Commit Graph

525 Commits

Author SHA1 Message Date
Hajime Hoshi
f7c44f086f replace Ebiten with Ebitengine in comments 2022-08-29 11:17:17 +09:00
Hajime Hoshi
ec68534c73 internal/graphicsdriver/opengl: introduce EBITENGINE_OPENGL replacing ebitenginewebgl1
This change inroduces a new environment variable `EBITENGINE_OPENGL`
to replace the build tag `ebitenginewebgl1`.
2022-08-28 01:45:58 +09:00
Hajime Hoshi
b2f874a244 image/rectangle: read pixels only for necessary parts
Closes #2274
2022-08-27 23:23:33 +09:00
Hajime Hoshi
5bb70f485e internal/graphics: remove FilterScreen and use an original Kage program instead
Updates #2046
2022-08-26 17:41:29 +09:00
Hajime Hoshi
e7c0a121c4 all: remove the build tag 'ebitencbackend'
This also automatically enables 'egl' when 'nintendosdk' is specified.

Updates #2242
2022-08-12 13:15:39 +09:00
Hajime Hoshi
dac6548c0c all: rename ebitenginecbackend to nintendosdk
Updates #2242
2022-08-12 02:05:29 +09:00
Hajime Hoshi
70f5e84098 internal/graphicsdriver: rename ReplacePixels to WritePixels
Updates #2236
2022-08-08 03:05:04 +09:00
Hajime Hoshi
72d5002e72 remove go2cpp support
Closes #2126
2022-08-07 22:17:53 +09:00
mattn
2bacecca24
fix typos (#2227) 2022-08-03 22:40:39 +09:00
mattn
3cd0daac67
go generate ./... with Go 1.19 (#2228) 2022-08-03 20:48:02 +09:00
Hajime Hoshi
90ac7d047d internal/graphicsdriver/opengl/gl: bug fix: wrong build tag syntax 2022-07-15 23:34:09 +09:00
Hajime Hoshi
16ff5c5039 internal/shaderir: change the naming convention: Num -> Count 2022-07-13 02:02:48 +09:00
Hajime Hoshi
afed6a83c6 internal/graphics: change the naming convention: Num -> Count
This change also renames ebiten.MaxIndicesNum -> ebiten.MaxIndicesCount.
2022-07-13 02:02:44 +09:00
Hajime Hoshi
55c7a2df6c internal/graphicsdriver/opengl/gl: bug fix: wrong build tags 2022-07-09 16:15:56 +09:00
Hajime Hoshi
28fd3ec9e5 add the ebitengine version build tags besides the ebiten version
Closes #2111
Updates #2190
2022-07-09 15:38:03 +09:00
Hajime Hoshi
428b1263d9 add ebitenginecbackend build tag besides ebitencbackend
Updates #2111
Updates #2190
2022-07-09 15:23:52 +09:00
Hajime Hoshi
a6d415ebf2
internal/graphicsdriver/opengl: replace Get with NewGraphics (#2146)
This is a prepartion to return an error when a graphics driver, especially
DirectX, fails to initialize.

Updates #2142
2022-06-17 02:02:29 +09:00
Hajime Hoshi
4a19d645b7 internal/graphicsdriver/opengl: remove a comment 2022-06-11 15:36:10 +09:00
Hajime Hoshi
71a32d2036 internal/ui: pass the canvas element directly instead of an ID 2022-06-11 15:34:17 +09:00
Hajime Hoshi
95628ee5f7 internal/ui: add a unique ID to the canvas for browsers 2022-06-11 15:24:50 +09:00
Hajime Hoshi
abef203a70 rename github.com/ebitne/purego -> github.com/ebitengine/purego 2022-06-10 21:59:01 +09:00
Hajime Hoshi
ad380a32f4 internal/glfwwin: split GDK part to a new package internal/microsoftgdk
Updates #1162
2022-05-29 19:25:26 +09:00
Hajime Hoshi
d577cc5e7d internal/graphicsdriver/opengl/gl: rename files
Updates #1162
2022-05-27 18:31:40 +09:00
TotallyGamerJet
726e88e520
internal/graphics/opengl/gl: remove CGO in openGL on macOS (#2104)
Updates #1162
2022-05-27 18:26:53 +09:00
Hajime Hoshi
7030840efa internal/graphicsdriver/opengl/gl: refactoring 2022-05-25 02:24:40 +09:00
Hajime Hoshi
3745c0a2e0 internal/graphicsdriver/opengl/gl: remove an unused function GetBufferSubData
This is basically a revert of 86a0c7aa82
2022-05-24 20:45:45 +09:00
Hajime Hoshi
a1370a4791 internal/graphicsdriver/opengl: remove an unused member gl.getBufferSubData 2022-05-24 20:40:53 +09:00
Hajime Hoshi
f888b7868b internal/graphicsdriver/opengl: fix the error message when GenFramebufferEXT fails 2022-05-23 22:25:40 +09:00
Hajime Hoshi
4396785829 Revert "internal/graphicsdriver/opengl: remove CGO in opengl for macOS (#2091)"
This reverts commit f7e21983cf.

Reason: test failures (#2102)

Closes #2102
2022-05-22 01:24:48 +09:00
TotallyGamerJet
f7e21983cf
internal/graphicsdriver/opengl: remove CGO in opengl for macOS (#2091)
Updates #1162
2022-05-22 00:58:45 +09:00
Hajime Hoshi
736d77e0d2 internal/graphicsdriver: remove Graphics.NDCYDirection 2022-04-04 03:03:44 +09:00
Hajime Hoshi
02db3bad53 internal/graphicscommand: remove the dependency on a graphics driver from compileShader
Updates #2035
2022-04-04 02:09:08 +09:00
Hajime Hoshi
3fafc05411 internal/graphicsdriver: remove Graphics.HasHighPrecisionFloat
Updates #879
2022-04-02 05:19:30 +09:00
Hajime Hoshi
79e93d3b12 internal/graphicsdriver: introduce the DirectX driver
Closes #1007
2022-03-26 20:09:34 +09:00
Hajime Hoshi
eeb5687b73 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to pointers
On second thought, returning pointers is more natural. Handling
nil is a caller's responsibility.
2022-03-24 13:20:36 +09:00
Hajime Hoshi
7bb7e45522 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to interface
Converting a nil with a pointer type to an interface type is no longer
a nil-nil interface, and then comparing with nil causes an unexpected
results.
2022-03-24 03:24:58 +09:00
Hajime Hoshi
cd57bccbfc internal/graphicsdriver: let some functions return an error
This is a preparation for the DirectX driver.

Updates #1007
2022-03-21 22:23:12 +09:00
Hajime Hoshi
7d0f95e9be internal/graphicsdriver: refactoring: replace Uniform with []float32
Closes #2016
2022-03-13 03:42:13 +09:00
Hajime Hoshi
35a5c88901 internal/graphics: rename constants 2022-03-12 04:01:48 +09:00
Hajime Hoshi
d4d4b9c070 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: more efficient modulo 2022-03-04 03:47:55 +09:00
Hajime Hoshi
b22309a0e5 internal/graphicsdriver: replace Pixels with ReadPixels
Now preparing a byte slice is the caller's responsibility.
2022-02-27 20:03:13 +09:00
Hajime Hoshi
566957dc1c internal/graphicsdriver/metal: invert Y at the vertex shader
Instead of using a negative height in the viewport, invert the Y direction
at the vertex shader. This is a little more readable as a negative height
is hacky.

This is a preparation for DirectX 12. DirectX 12's coodination system
is very similar to Metal, but doesn't treat a negative height in its
viewport unfortunately.

Updates #1007
2022-02-27 01:53:03 +09:00
divVerent
f2209a0b51
internal/atlas: optimization: send premultiplied alpha from vertex to fragment shader. (#1996)
Note that this applies only to the builtin shaders - interface for Kage stays
unchanged for compatibility.

Minor compatibility delta: when interpolating alpha values, previous code has
created nonsense values, such as, when interpolating from
fully-transparent-black (0,0,0,0) to opaque-white (1,1,1,1), something like
half-transparent-grey (0.25,0.25,0.25,0.5) where half-transparent-white
(0.5,0.5,0.5,0.5) is used by the new code.

I assume this is a strict improvement, however this may warrant some testing.

Possible later improvement could be moving the premultiplication from fragment
shader to CPU. Did not do this as it makes the code rather inconsistent of Kage
vs built-in shader usage.

Updates #1772
2022-02-24 02:27:50 +09:00
Hajime Hoshi
8b7273b74a internal/graphicsdriver/metal: call PresentDrawable only when necessary 2022-02-22 01:37:13 +09:00
Hajime Hoshi
ab1ad2c72f .github/workflow: add a test to build with the build tag ebitencbackend 2022-02-13 16:57:48 +09:00
Hajime Hoshi
4c6c31e384 all: reorder build tags in an alphabetical order 2022-02-08 15:49:15 +09:00
Hajime Hoshi
df60c4c92d internal/driver: rename to internal/graphicsdriver 2022-02-06 20:41:32 +09:00
Hajime Hoshi
84e53d4c61 internal/graphicsdriver/opengl, internal/uidriver/glfw: treat Win32 API errors correctly
The returned errors from syscall.Syscall* and windows.LazyProc.Call come
from GetLastError. The value of GetLastError is not reliable when the
function succeeds.

This change fixes the usages of error values. The error value is now
used only when the API explicitly fails.
2022-01-30 15:54:24 +09:00
Hajime Hoshi
cdf2335f5a refactoring: better error handlings on Windows 2022-01-23 18:30:40 +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
6b34ddecfa internal/graphicsdriver/opengl/gles: add GLES_SILENCE_DEPRECATION to suppress warnings 2022-01-05 01:54:00 +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
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
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
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
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
3f5d1762bb internal/graphicsdriver/opengl: Return an error when initializing OpenGL fails
Updates #1838
2021-10-06 00:38:47 +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
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
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
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
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
15ac69b8d5 internal/graphicsdriver/metal: Bug fix: Disable presentsWithTransaction on fullscreen
Closes #1745
2021-08-08 17:40:37 +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
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
7e5b259dd2 internal/affine: Use a pointer of an array for UnsafeElements 2021-07-26 21:19:53 +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
6213c17abc internal/driver: Add Graphics.Initialize 2021-07-07 13:58:42 +09:00
Hajime Hoshi
38ce325958 internal/graphicsdriver/metal: Skip clearing the screen on Metal 2021-07-07 01:45:51 +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
f6e210e086 internal/graphicsdriver/opengl: Refactoring: Remove redundant conversions 2021-07-03 22:39:48 +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
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
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
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
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
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
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
969964cb46 internal/graphicsdriver/opengl/gl: Bug fix: Remove unsafe reflect usage
Closes #1495
2021-02-14 21:27:30 +09:00
Hajime Hoshi
b8694aa66a internal/graphicsdriver/opengl: Optimization 2021-01-26 00:45:17 +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
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
718273c2d7 ebiten: Add a new shader function imageDstRegionOnTexture
Updates #1428
2020-12-09 11:36:29 +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
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
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
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
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
86a0c7aa82 graphicsdriver/opengl: Use PBO when retrieving pixels 2020-11-13 09:10:56 +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
ed028110cf ebiten: Allow rendering on a sub-image by scissor test
Fixes #1255
2020-11-08 00:58:44 +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
f611b48c71 graphicsdriver/opengl: Use native GLES functions for mobiles
After this change, GL functions for mobiles, especially Android, are
native ones instead of golang.org/x/mobile/gl functions in order to
reduce goroutine context switches.

On gomobile-build, golang.org/x/mobile/gl functions are still used.

Fixes #1387
2020-10-19 03:51:20 +09:00
Hajime Hoshi
2740938460 graphicsdriver/opengl: Fix the error message again 2020-10-18 22:55:37 +09:00
Hajime Hoshi
b755a1f970 graphicsdriver/opengl: Fix the error message 2020-10-18 22:12:39 +09:00
Hajime Hoshi
cac4b43ddd graphicsdriver/opengl/gles: Add copyright comments 2020-10-18 18:18:08 +09:00
Hajime Hoshi
55af18a178 graphicsdriver/opengl: Use a new package gles
Updates #1387
2020-10-18 18:16:11 +09:00
Hajime Hoshi
eed619ad0f graphicsdriver/metal, graphicsdriver/opengl: Reland: Remove the thread usages for performance
Instead, graphicscommand package has a thread.

Updates #1367
2020-10-13 02:46:31 +09:00
Hajime Hoshi
713eee1117 Revert "graphicsdriver/metal, graphicsdriver/opengl: Remove the thread usages for performance"
This reverts commit 2942f10d9d.

Reason: Compile error on mobiles and runtime error on browsers
2020-10-13 02:12:02 +09:00
Hajime Hoshi
2942f10d9d graphicsdriver/metal, graphicsdriver/opengl: Remove the thread usages for performance
Instead, graphicscommand package has a thread.

Updates #1367
2020-10-13 01:50:54 +09:00
Hajime Hoshi
dc288d37f8 Bug fix: Compile error for Wasm 2020-10-07 02:23:45 +09:00
Hajime Hoshi
ee4ebaaa95 Clean up the 'js' build tags
Updates #1129
2020-10-07 02:07:03 +09:00
Hajime Hoshi
7a0e31a23a Clean up the 'js' build tags
Updates #1129
2020-10-07 01:33:10 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Bui Quoc Trong
0d29979296
Fix the comment style cause heading in pkgsite (#1369) 2020-09-29 16:55:39 +09:00
Hajime Hoshi
3dab49fc39 graphicsdriver/opengl: Better error message 2020-09-17 20:35:57 +09:00
Hajime Hoshi
68c43bb4fb graphicsdriver/opengl: Enable to compile with gldebug tag for gomobile 2020-09-04 15:08:40 +09:00
Hajime Hoshi
bd888f62b9 graphicsdriver/opengl: Exclude bytes.go from non-mobile environments
This requires reflect and reflect prevents Ebiten from being compiiled
with TinyGo.

Updates #747
2020-08-20 22:24:21 +09:00
Hajime Hoshi
c921a63c21 graphicsdriver/opengl/gl: Bug fix: Crash on Parallels
Fixes #1310
2020-08-18 04:33:59 +09:00
Hajime Hoshi
609a3c4e22 ebiten: Bug fix: Fix the texel calculation
In shaders, texCoord is always in texture0's texels. Convert them
at imageNTextureAt functions correctly.

Fixes #1290
2020-08-11 04:15:07 +09:00
Hajime Hoshi
69f87d5fd1 ebiten: Add new shader builtin functions: image[N]TextureBoundAt
Fixes #1287
2020-08-11 03:24:54 +09:00
Hajime Hoshi
b4046a795e graphics: Reduce the usage of InternalImageSize 2020-08-08 16:01:33 +09:00
Hajime Hoshi
28c638cb5b graphicsdriver/opengl: Unexpose NewShader 2020-08-08 03:12:44 +09:00
Hajime Hoshi
8bac08cbd9 Add internal/shaderir/glsl 2020-08-03 23:27:27 +09:00
Hajime Hoshi
38dcadb233 graphicsdriver/opengl: Add program error info to the error 2020-08-01 18:58:05 +09:00
Hajime Hoshi
a4334c5464 shader: Use arrays at uniform variables
Fixes #1274
2020-08-01 17:22:10 +09:00
Hajime Hoshi
073fd329f2 graphicsdriver/opengl: Enable to pass any type of uniform variables
Updates #1274
2020-08-01 05:11:24 +09:00
Hajime Hoshi
a50ef46ed0 graphicsdriver/opengl: Do not allow nil value for uniform variables 2020-08-01 02:01:51 +09:00
Hajime Hoshi
da5642cd0e graphicsdriver/opengl: Add type checks of uniform variables 2020-08-01 02:01:51 +09:00
Hajime Hoshi
a0197d4c2f graphicsdriver/opengl: Bug fix: Build error on Android
Fixes #1266
2020-07-26 17:01:11 +09:00
Hajime Hoshi
ca3fd4eaa4 ebiten: Add texture[ID]Size functions for shaders
Fixes #1239
2020-07-26 15:18:01 +09:00
Hajime Hoshi
d08a04a635 ebiten: Refactoring 2020-07-26 15:05:00 +09:00
Hajime Hoshi
75d34ab585
graphicsdriver/opengl: Forbids PBO on Raspberry Pi 4 (#1261)
Fixes #1208
2020-07-23 19:15:34 +09:00
Hajime Hoshi
29d53edf1d graphicsdriver/opengl: Bug fix: Rename the attribute variables along with custom shaders 2020-07-20 04:06:35 +09:00
Hajime Hoshi
5506491c03 graphicsdriver/opengl: Bug fix: Binding the same texture multiple times did not work
Updates #1193
2020-07-19 04:34:53 +09:00
Hajime Hoshi
36e9803cea shader: Enable to get pixels from multiple images
Updates #1193
2020-07-19 02:33:43 +09:00
Hajime Hoshi
fe79bb27af graphicscommand: Refactoring 2020-07-18 23:25:16 +09:00
nanoslayer
72babcd420
ebiten: Add CompositeModeMultiply (#1251)
This change adds a new composite mode called `CompositeModeMultiply`,
which multiplies the source color with the destination color.

This is tested on Linux and Windows only.

Fixes #410
2020-07-18 21:37:17 +09:00
Hajime Hoshi
e0d5763a60 shader: Use the fixed number of images for shaders
This changes uses arrays rather than slices in order to avoid heap
allocations.

Updates #1193
2020-07-18 18:27:47 +09:00
Hajime Hoshi
7f70797a6d ebiten: Rename DrawTriaglesWithShaderOptions.Textures to Images 2020-07-15 03:49:05 +09:00
Hajime Hoshi
d217bc6033 ebiten: Sparate textures from uniforms at DrawTrianglesWithShader
Updates #1193
Updates #1239
2020-07-09 01:59:21 +09:00
Hajime Hoshi
4021c24534 shader: Separate uniform variables and texture variabls
Textures cannot be treated as a regular variable, then they should
be treated differently from other uniform variables.

Add a new function texture0At replacing texture2D.

Updates #1239
2020-07-08 01:12:07 +09:00
Hajime Hoshi
b83f0acc4d Remove source-region information from vertices
Fixes #1210
2020-07-02 23:38:39 +09:00
Hajime Hoshi
71c9e7ac40 driver: Add Region and sourceRegion parameter at Draw
This is a preparation to remove source-region information from
vertices.

Updates #1210
2020-07-02 03:26:05 +09:00
Hajime Hoshi
d3613e13af graphicsdriver/opengl: Fix comments 2020-06-25 01:06:30 +09:00
Hajime Hoshi
2a63512c6e driver: Add AddressUnsafe
This skips the source-region check and reduces 'if' branches from
shader programs.

AddressUnsafe is internal only so far. We might expose this value
later.

Updates #1210
2020-06-25 01:00:38 +09:00
Hajime Hoshi
bfc2fffba6 graphicsdriver/opengl: Move comments 2020-06-24 23:52:39 +09:00
Hajime Hoshi
20b5be0886 graphicsdriver: Bug fix: Tie-breaking when picking a texel
When a texel is picked on texel-borders of a texture, the behavior
(tie-breaking) depends on GPU and unexpected. This change fixes this
issue by shifting 1/512 [texel] when picking a texel up.

Updates #1212
2020-06-24 20:51:16 +09:00
Hajime Hoshi
1785b6a670 examples/moire: Add a smaller scale, and remove AdjustTexel function from shaders
This can reproduce the bug reported at #669.

Apparently, the fix (8827520d4a) is
no longer required after 3550abef7a.
That's pretty odd, but examples/moire proves this fact.

Updates #669
Updates #759
2020-06-15 00:29:34 +09:00
Hajime Hoshi
f39c591252 shader: Enable more Go syntax 2020-06-11 01:13:03 +09:00
Hajime Hoshi
e25a6f4d46 graphicsdriver/opengl: Remove isTexture on desktops 2020-05-30 20:56:13 +09:00
Hajime Hoshi
2bdef2e8c4 restorable: Add an explicit way to detect context-lost
isTexture was used to detect context-lost and called every frame.
This was not good for performance.

This change adds a way to notify context-lost from the WebGL
handlers directly, and the package restorable uses it instead of
calling (*Image).isInvalaidated.

Fixes #1175
2020-05-30 20:29:15 +09:00
Hajime Hoshi
1c980a16f5 graphicsdriver/opengl: Ignore non-existent uniform locations
Shader users should not have to care about the existence of uniform
variables.

Updates #1168
2020-05-27 11:39:11 +09:00
Hajime Hoshi
f80719ef9a driver: Use slices for uniform variables instead of maps
Fixes #1172
2020-05-26 23:50:11 +09:00
Hajime Hoshi
1cfc1964bf graphicsdriver/opengl: Bug fix: fmt arguments 2020-05-25 02:36:45 +09:00
Hajime Hoshi
85730b433e graphicsdriver: Bug fix: Pass texture natives as uniform variables correctly 2020-05-25 02:31:54 +09:00
Hajime Hoshi
9bf24ba545 graphicsdriver/opengl: Remove println and add error messages 2020-05-24 23:15:00 +09:00
Hajime Hoshi
521f9dcac5 graphicsdriver/opengl: Bug fix: deleted a wrong shader program
Updates #482
2020-05-23 22:40:49 +09:00
Hajime Hoshi
1a0d92267b driver: Add shader API and implement it on OpenGL
Updates #482
2020-05-23 22:09:12 +09:00
Hajime Hoshi
8fd377f1e3 driver: Add ImageID and use this
This is a preparation to introduce shaders. Shader programs
require images as uniform variables, but the current way would make
API complex unnecessarily.
2020-05-20 00:11:08 +09:00
Hajime Hoshi
7f2092f964 graphicsdriver/opengl: Enable to bind multiple textures (in theory) 2020-05-17 23:57:42 +09:00
Hajime Hoshi
733c463e26 graphicsdriver/opengl: Treat a texture as a uniform variable 2020-05-17 23:25:49 +09:00
Hajime Hoshi
68ef41e256 graphicsdriver/opengl: Integrate uniform variables 2020-05-17 20:20:29 +09:00
Hajime Hoshi
ff311dd564 graphicsdriver/opengl: Pass uniform values to useProgram 2020-05-17 19:43:01 +09:00
Hajime Hoshi
84e2c6f994 graphicsdriver/opengl/gl: Bug fix: misuse of unsafe.Pointer 2020-05-17 19:42:23 +09:00
Hajime Hoshi
8ab12827c0 graphicsdriver/opengl: Refactoring 2020-05-17 19:01:46 +09:00
Hajime Hoshi
9cc128fb40 graphicsdriver/opengl: Integrate last uniform values 2020-05-17 18:36:33 +09:00
Hajime Hoshi
d12b406e0a graphicsdriver/opengl: Remove unused variables 2020-05-17 18:15:27 +09:00
Hajime Hoshi
f4a1f90d92 graphicsdriver/opengl/gl: Reduce reflect usage 2020-05-17 14:28:13 +09:00
Hajime Hoshi
8029dc352a driver: Use framebuffer's Y directions 2020-05-08 16:49:19 +09:00
Hajime Hoshi
7b77164710 restorable: Ignore the error when restoring failed due to being not ready
(driver.Graphics).BeginFrame tries to restore the images, but
the context might be lost at that time yet. If the attempt to
restore the context because the driver is not ready, return
silently.

Fixes #1133
2020-04-12 20:01:18 +09:00
Hajime Hoshi
eabe4152a7 graphicsdriver/opengl: Rename Driver -> Graphics 2020-04-04 17:23:38 +09:00
Hajime Hoshi
b4a9538e1d graphicsdriver/opengl/gl: Remove a misspelled unused const 2020-02-26 12:06:47 +09:00
Hajime Hoshi
59431e1cad graphicsdriver/opengl: Leave comments why we don't use PBO on Android
Unfotunately, PBO might slow Android applications expecially when
coming back from context lost. Ebiten sends a lot of draw calls to
replace pixels in such case.

Until we find a good solution, let's not use PBO on Android.

Fixes #988
2020-01-19 17:02:34 +09:00
Hajime Hoshi
6eb05a0203 graphicsdriver/opengl: Enable to compile with gldebug 2020-01-13 18:55:30 +09:00
Hajime Hoshi
9be3495077 driver: Remove Graphics.SetWindow
Fixes #1026
2020-01-03 19:04:48 +09:00
Hajime Hoshi
e66f1fb71e graphicsdriver/opengl: Use glBufferSubData instead of glTexSubImage2D on browsers
Updates #988
2020-01-02 16:27:51 +09:00
Hajime Hoshi
de48a13a6e graphicsdriver/opengl/gl: Remove unused functions 2020-01-02 00:17:39 +09:00
Hajime Hoshi
38815ba801 graphicsdriver/opengl: Use glBufferSubData instead of glMapBuffer
We have confirmed that this does not slow down ReplacePixels.

Fixes #993
Fixes #1040
2020-01-02 00:01:27 +09:00
Hajime Hoshi
51f4ba1320 graphicsdriver/opengl: Refactoring 2020-01-01 01:57:12 +09:00
Hajime Hoshi
815afe6670 graphicsdriver/opengl: Reduce calls of glBindTexture 2020-01-01 01:39:45 +09:00
Hajime Hoshi
8285fbfac9 graphicsdriver/opengl: Add error checks 2019-12-31 04:22:28 +09:00
Hajime Hoshi
85cbc7e56b Enable to compile Ebiten on js/wasm with Go 1.14
Fixes #1024
2019-12-19 00:45:53 +09:00
Hajime Hoshi
a3343afc36 graphicsdriver/opengl/gl: Use pkg-config instead of LDFLAGS
Updates #1012
2019-12-11 03:00:25 +09:00
Hajime Hoshi
c9bc5913fd driver: Refactoring: Remove Graphics.Flush
Updates #226
2019-12-06 08:56:55 +09:00
Hajime Hoshi
0ec447e0d0 ui: Add SetScreenTransparent / IsScreenTransparent
Fixes #1001
2019-12-01 03:31:32 +09:00
Hajime Hoshi
a040aae83b glfw: Update to GLFW 3.3
Fixes #1000
2019-11-26 01:19:20 +09:00
Hajime Hoshi
21ba42325c graphicsdriver/opengl: Use smaller PBOs 2019-11-24 18:32:35 +09:00
Hajime Hoshi
78e912e30b graphicsdriver/opengl: Fix comments 2019-11-24 18:11:45 +09:00
Hajime Hoshi
3d3a1be1c4 graphicsdriver/opengl: Use glTexSubImage2D instead of glTexImage2D 2019-11-24 18:07:21 +09:00
Hajime Hoshi
9f483ddc60 graphicsdriver/opengl: Adopt WRITE_ONLY for PBOs
It looks like it is safe to use WRITE_ONLY:
https://stackoverflow.com/questions/30248594/write-only-glmapbuffer-what-if-i-dont-write-it-all
2019-11-24 17:42:28 +09:00
Hajime Hoshi
4c4f67197f graphicsdriver/opengl/gl: Bug fix: compile error on non-Windows (again) 2019-11-24 03:05:14 +09:00
Hajime Hoshi
ac6a3f0900 graphicsdriver/opengl/gl: Bug fix: compile error on non-Windows 2019-11-24 02:02:40 +09:00
Hajime Hoshi
0ef8009c11 graphicsdriver/opengl: Use uintptr whenever possible instead of unsafe.Pointer 2019-11-20 02:00:02 +09:00
Hajime Hoshi
4296c11256 graphicsdriver/opengl: Refactoring 2019-11-24 00:08:38 +09:00
Hajime Hoshi
3df198f68e graphicsdriver/opengl: Use GL_READ_WRITE at glMapBuffer
Updates #993
2019-11-22 00:27:20 +09:00
Hajime Hoshi
65fdf48cbf graphicsdriver: Refactoring: ReplacePixels takes multiple arguments
This reduces the number of graphics commands, and this works more
efficiently if the driver has an efficient way.
2019-11-21 23:52:12 +09:00
Hajime Hoshi
161771cc99 graphicsdriver/opengl: Refactoring 2019-11-20 12:23:45 +09:00
Hajime Hoshi
52f6be2639 graphicsdriver/opengl: Fix suspicious GL function calls
Before this change, the pixel object buffer is unbound just after
getting a pointer by glMapBuffer. This seemed suspicious.

This change fixes to do all pixel manipulations once between
glMapBuffer and glUnmapBuffer without changing a bound buffer.

This might fix a wrong rendering on some machines, but I am not
sure.

Updates #993
2019-11-20 02:41:34 +09:00
Hajime Hoshi
4120e868be graphicsdriver/opengl: Remove unused functions 2019-11-17 05:10:22 +09:00
Hajime Hoshi
acc933b7c3 graphicsdriver/opengl: Experimental PBO implementation
This change is an experimental implementation to use Pixel Buffer
Objects. This reduces calls of glTexSubImage2D.

This works only on desktops. Unfortunately WebGL does not have
this features. Mobiles can have PBO as of OpenGL ES 3.

Updates #976
2019-11-17 05:01:43 +09:00
Hajime Hoshi
8c54cf639a graphicsdriver/opengl: Reduce glFlush calls
Fixes #981
2019-11-14 01:21:08 +09:00
Hajime Hoshi
3c29fbdce2 jsutil: Refactoring: SliceToTypedArray -> CopySliceToJS
This unifieslocations of the temporary buffer.
2019-10-30 00:35:48 +09:00
Hajime Hoshi
4088de5349 graphicsdriver/opengl/gl: Fix go-vet errors on Windows
Updates #889
2019-10-06 23:19:59 +09:00
Hajime Hoshi
3a0f8655e6 graphicsdriver/opengl/gl: Indentation 2019-10-06 23:02:15 +09:00
Hajime Hoshi
378be6be80 graphicsdriver/opengl/gl: Remove unused functions
This improves `go vet` results.

Updates #889
2019-10-06 22:49:38 +09:00
Hajime Hoshi
0d56207672 graphicsdriver/opengl/gl: Remove unnecessary consts 2019-10-06 04:27:57 +09:00
Hajime Hoshi
38ee9113ee graphicsdriver/opengl/gl: Remvoe PtrOffset
Updates #889
2019-10-01 01:48:42 +09:00
Hajime Hoshi
899fc38d23 Add wasm test with wasmbrowsertest
Fixes #881
2019-09-23 02:45:37 +09:00
Hajime Hoshi
33c7f39f0f graphicsdriver/opengl/gl: Exclude all the files for Wasm
Fixes #938
2019-09-23 00:42:54 +09:00
Hajime Hoshi
3a0dbd3977 graphicsdriver/opengl: Use sync.Once for concurrent safety 2019-07-04 01:15:51 +09:00
Hajime Hoshi
6b7f21f0c8 driver: Add Graphics.MaxImageSize and use it
There are some devices that cannot accept 4096x4096 pixels
textures. Get the maximum size and use it.

Fixes #892
2019-07-04 01:10:11 +09:00