Commit Graph

1351 Commits

Author SHA1 Message Date
Hajime Hoshi
bc3ca38f76 opengl: Rename ResetGLState -> Reset and other functions 2018-11-01 03:02:08 +09:00
Hajime Hoshi
b8aa35373a graphicscommand: Remove unneeded type conversion 2018-10-31 10:54:45 +09:00
seebs
74e204d952 graphics: Speed up DrawTriangles (#723)
DrawTriangles is expensive and slow because of massive memory
allocation and garbage collection costs. This patch moves from ~47TPS
on my laptop (with ~24k triangles) to 60TPS. The first part
is just allocating the right size of vertex buffer up front; that
got to about 55TPS. The second part replaces the frequent
allocations of []float32 in Vertex() calls with writing the
desired values into a provided destination slice.

Time spent in drawing triangles for 1,000 frames:
	13.07s	baseline
	11.09s	preallocate whole buffer to avoid resizing
	6.13s	use new PutVertex function

This might need some cleanup, but I think it's good evidence that
the design change is viable.
2018-10-31 10:53:17 +09:00
Hajime Hoshi
45017213a7 opengl: Unexport (Element)ArrayBufferSubData 2018-10-31 00:59:44 +09:00
Hajime Hoshi
5be08cac19 opengl: Unexport BindBuffer 2018-10-30 23:59:20 +09:00
Hajime Hoshi
23a832c0a7 opengl: Unexport consts 2018-10-30 22:41:05 +09:00
Hajime Hoshi
99594fe732 opengl: Remove type mode 2018-10-30 22:36:12 +09:00
Hajime Hoshi
b2b09ccec0 restorable: Avoid memory allocating when an entire image is cleared 2018-10-30 11:08:38 +09:00
Hajime Hoshi
bb0b8ca83b opengl: Unexport (*Context).Reset() 2018-10-30 02:18:10 +09:00
Hajime Hoshi
ac7bf354a9 opengl: Unexport types 2018-10-30 02:13:51 +09:00
Hajime Hoshi
e4179aee37 opengl: Unexport functions 2018-10-30 01:50:30 +09:00
Hajime Hoshi
6b95a5140c opengl: Move program.go and shader.go to opengl 2018-10-30 01:27:31 +09:00
Hajime Hoshi
6b02f0ae9e graphicscommand: Move OrthoProjectionMatrix to opengl package 2018-10-29 01:08:51 +09:00
Hajime Hoshi
ce1c616f69 Merge graphics and graphicsutil 2018-10-28 23:03:06 +09:00
Hajime Hoshi
395b46d8da graphicsutil: Remove dependency on graphicscommand 2018-10-28 23:00:10 +09:00
Hajime Hoshi
7767bcfdd8 graphicsutil: Better allocation of vertices 2018-10-28 22:54:36 +09:00
Hajime Hoshi
fde9fd2d0e graphicsutil: Remove dependency on opengl 2018-10-28 22:01:59 +09:00
Hajime Hoshi
ff54d3b681 Move CompositeMode to graphics package 2018-10-28 21:49:47 +09:00
Hajime Hoshi
06f2052817 Add graphics package and move Filter to graphics 2018-10-28 20:25:52 +09:00
Hajime Hoshi
2da5192510 Rename graphics -> graphicscommand 2018-10-28 20:10:05 +09:00
Hajime Hoshi
7e29a81177 ui: Refactoring 2018-10-14 18:28:27 +09:00
Hajime Hoshi
0c4ef7ee8e ui: Bug fix: fix the initial window position on multiple monitors 2018-10-14 16:59:14 +09:00
Hajime Hoshi
b56061281d ui: Add comments 2018-10-13 22:41:21 +09:00
Hajime Hoshi
a073f48faf input: Bug fix: keypress event were not fired
This change suspends to 'preventDefault' on keydown events.

Now preventing navigation by pressing backspace is deprecated in
Chrome. For other keys, it looks like keyup's preventDefault is
enough to disable the browser default behavior.
2018-10-13 19:18:13 +09:00
Hajime Hoshi
faf32b9d37 devicescale: Plan 9 support 2018-10-13 04:08:40 +09:00
Hajime Hoshi
34596bb1cf ui: Bug fix: IsVsyncEnabled can cause deadlock 2018-10-10 23:17:45 +09:00
Hajime Hoshi
b4a4b87b56 ui: Bug fix: ScreenSizeInFullscreen returned wrong scaled values
Fixes #708
2018-10-10 03:10:18 +09:00
Hajime Hoshi
e971f6d41c ui: Avoid glfw.GetCurrentContext for threading issues 2018-10-10 01:45:39 +09:00
Hajime Hoshi
b5344bc994 ui: glfwScale must be called on the main thread 2018-10-10 01:07:47 +09:00
Hajime Hoshi
c758a1f8c6 ui: Rename MonitorSize -> ScreenSizeInFullscreen (#708) 2018-10-09 23:42:03 +09:00
Hajime Hoshi
dbe71e81bd ui: Bug fix: currentMonitorPos returned wrong values on macOS
[NSScreen mainScreen] sometimes returned a wrong screen for the
window. Use [[NSApp mainWindow] screen] when possible.

Fixes #703
2018-10-08 05:40:07 +09:00
Hajime Hoshi
c4a066ecd0 ui: Fix wrong comments about Windows 2018-10-08 04:06:44 +09:00
Hajime Hoshi
8d2820efb0 ui: Bug fix: the window is shown on the current monitor on Windows
Fixes #704
2018-10-08 03:24:14 +09:00
Hajime Hoshi
96a657025f ui: Bug fix: DeviceScaleFactor and MonitorSize were not correct on Windows 2018-10-08 03:18:24 +09:00
Hajime Hoshi
9264e38324 ui: Add comments 2018-10-08 01:45:07 +09:00
Hajime Hoshi
f6c2d899f1 ui: Bug fix: compile error on browsers and mobiles 2018-10-08 01:26:05 +09:00
Hajime Hoshi
4a5548a4a0 ui: MonitorSize should return the 'current' monitor size instead of the primary monitor size 2018-10-08 01:15:57 +09:00
Hajime Hoshi
f3b7148564 ui: Bug fix: DeviceScaleFactor should return the current monitor's scale 2018-10-08 01:11:13 +09:00
Hajime Hoshi
16a9bac487 ui: Remove deviceScale struct 2018-10-08 01:03:18 +09:00
Hajime Hoshi
effd530026 ui: Show the window on the current monitor (#704)
Tested on macOS. This doesn't work on Windows yet since there are
some codes that depends on the primary monitor.
2018-10-08 00:46:01 +09:00
Hajime Hoshi
fb7a3f2736 ui: Bug fix: Call SetPos multiple times to render correctly (#703) 2018-10-08 00:25:21 +09:00
Hajime Hoshi
e0d2d5e753 ui: Bug fix: wrong scaling when a window move across monitors
Fixes #701
2018-10-07 23:05:20 +09:00
Hajime Hoshi
0e7dab3707 ui: Fix comment 2018-10-06 20:04:48 +09:00
Hajime Hoshi
f9edfd7d57 ui: Remove unused variables 2018-10-06 19:55:10 +09:00
Hajime Hoshi
cc336a4c38 ui: Use more stable way to determine the current monitor 2018-10-06 19:53:43 +09:00
Hajime Hoshi
55a397bd65 devicescale: Specify the monitor to get the scale
Fixes #695
2018-10-06 19:43:23 +09:00
Hajime Hoshi
b99cc6ca8e ui: Bug fix: compile error on mobiles 2018-10-06 18:26:22 +09:00
Hajime Hoshi
8771d27d64 devicescale: Rename variables 2018-10-06 17:29:40 +09:00
Hajime Hoshi
d08ae0dd66 graphicsutil: Fix comments 2018-10-06 15:01:12 +09:00
Hajime Hoshi
ca2fe22e4a ui: Bug fix: Set the proper window position when coming back from fullscreen 2018-10-06 03:53:34 +09:00
Hajime Hoshi
7ea1ab6b58 ui: Bug fix: currentMonitor should not return nil
Fixes #700
2018-10-06 03:22:33 +09:00
Hajime Hoshi
cae9e39453 ui: Use the best suitable monitor for fullscreen
This change also changes the definition of MonitorSize.
2018-10-06 02:59:38 +09:00
Hajime Hoshi
16f6aeaa4a ui: Refactoring: Use the current monitor 2018-10-06 02:38:02 +09:00
Hajime Hoshi
bd1fc4439a graphicsutil: Avoid passing NaN to shaders experimentally (#696) 2018-10-04 02:02:19 +09:00
Hajime Hoshi
1807a3f530 devicescale: Rename function 2018-10-04 01:28:53 +09:00
Hajime Hoshi
10b49bb0a3 ui: Don't call devicescale.DeviceScale too often 2018-10-03 04:29:12 +09:00
Hajime Hoshi
11d23bafa9 devicescale: Bug fix: the active window can't be passed to ReleaseDC 2018-10-03 04:16:28 +09:00
Hajime Hoshi
02a2fc2d44 ui: Bug fix: Force to adjust window size when scale is changed
Fixes #644
2018-10-03 03:26:11 +09:00
Hajime Hoshi
eef9c01735 gofmt -s -w 2018-10-03 03:25:44 +09:00
Hajime Hoshi
cf41e0aa0a devicescale: Rename logPixelSx -> logPixelsX 2018-10-03 03:13:36 +09:00
Hajime Hoshi
399317a2cf devicescale: Get the current monitor's scale on Windows (#644) 2018-10-03 03:09:42 +09:00
Hajime Hoshi
c494b53822 ui: Refactoring: Add deviceScale struct 2018-10-02 23:06:56 +09:00
Hajime Hoshi
635d624b77 ui: Update device scale on browsers (#644) 2018-10-02 11:43:45 +09:00
Hajime Hoshi
21c1ee5dfb ui: Cache devicescale value on mobiles 2018-10-02 03:51:13 +09:00
Hajime Hoshi
9906c935f6 ui: Remove unnecessary lock protection 2018-10-02 03:25:30 +09:00
Hajime Hoshi
fce82e1502 ui: Use frame counter to update device scale 2018-10-02 03:21:59 +09:00
Hajime Hoshi
78f2946797 ui: Bug fix: timer condition was wrong 2018-10-02 02:53:17 +09:00
Hajime Hoshi
bf850e12a4 ui: Recalc device scale repeatedly for multiple displays (#644) 2018-10-02 02:49:08 +09:00
Hajime Hoshi
308c8091cd ui: Fix comments 2018-09-30 18:53:38 +09:00
Hajime Hoshi
8df596396c input: Bug fix: wheel direction is opposite on browsers 2018-09-30 17:14:52 +09:00
Hajime Hoshi
0224858b7b examples/wheel: Improve message 2018-09-30 17:13:22 +09:00
Hajime Hoshi
803e42714e input: Implement wheel event on browsers
Fixes #630
2018-09-30 17:08:18 +09:00
Hajime Hoshi
237f6a2014 input: Rename MouseWheel -> Wheel 2018-09-30 17:01:45 +09:00
Hajime Hoshi
b6f0ea0100 input: Remove unused variables 2018-09-30 15:40:16 +09:00
Hajime Hoshi
25a5f1dd83 ui: Sleep when vsync doesn't work (#692) 2018-09-30 14:44:54 +09:00
Hajime Hoshi
15260537a2 graphics: Bug fix: fullscreen rendering was wrong
After fad65f2f5d, the viewport size
is always same as the framebuffer size. The 'screen' image size
was the actual rendering region size, and padding was not
considered in the size. The padding is added on the fullscreen
mode.

This fix adds the extra padding values to the 'screen' image size
so that the 'screen' framebuffer will be same size as the monitor
size.

Fixes #693
2018-09-29 21:47:41 +09:00
Hajime Hoshi
fad65f2f5d graphics: Use the viewport size same as the framebuffer size
Fixes #691
2018-09-29 19:53:22 +09:00
Hajime Hoshi
c4abed0a22 opengl: Add coments about #629 2018-09-29 02:20:23 +09:00
Hajime Hoshi
ce8d9df647 graphics: Update glTexImage2D signature 2018-09-10 12:44:42 +09:00
Hajime Hoshi
3d24ffe3e0 clock: Bug fix: function registerd OnStart might not be called
Fixes #645
2018-09-03 00:35:55 +09:00
Hajime Hoshi
42757b735b internal/png: Update 2018-09-02 23:09:08 +09:00
Hajime Hoshi
8827520d4a graphics: Bug fix: avoid jaggy rendering on macOS by adjusting texels (#669) 2018-08-30 00:17:03 +09:00
Hajime Hoshi
2360b2930f graphics: Add DrawTriangles
Fixes #624
2018-08-14 01:23:14 +09:00
Hajime Hoshi
690c3cf981 graphics: Embed 'scale' part of the color matrix
If the color matrix includes only 'scale' part, they are embedded
into vertices in order to reduce draw calls.

Fixes #662
2018-08-10 23:20:55 +09:00
Hajime Hoshi
e46f9c6305 graphics: Bug fix: compile error 2018-08-10 03:10:57 +09:00
Hajime Hoshi
a03b335c24 graphics: Add logging when 'ebitendebug' tag is specified
Fixes #563
2018-08-10 02:39:07 +09:00
Hajime Hoshi
1aabdd58f1 restorable: Fix comments 2018-08-09 01:27:38 +09:00
Hajime Hoshi
3daaef2cab restorable: Refactoring: Use ReplacePixels(nil, ...) for clearing an image 2018-08-09 01:16:46 +09:00
Hajime Hoshi
a988082be1 shareable: Bug fix: disable tests 2018-08-09 00:19:55 +09:00
Hajime Hoshi
c68c36b0b7 restoreable: Add ClearState to clear the state explicitly
Fixes #566
2018-08-09 00:12:45 +09:00
Hajime Hoshi
cdc408d2c2 shareable: Suspend re-using shared images
Fixes #661
2018-08-08 18:40:52 +09:00
Hajime Hoshi
ed99719fdb devicescale: Use app.RunOnJVM and remove internal/jni 2018-08-06 23:50:37 +09:00
Hajime Hoshi
77e905eb25 Revert "graphics: Embed color matrices values to vertices (#655)"
This reverts commit 5a9235aaf9.
2018-08-06 01:44:31 +09:00
Hajime Hoshi
9af8e621bd Revert "affine: Refactoring: Unify two element slices into one"
This reverts commit da662b384c.
2018-08-06 01:44:31 +09:00
Hajime Hoshi
af77a17aaa devicescale: Use mainScreen instead of screens[0] to get the 'current' screen state 2018-08-05 19:18:40 +09:00
Hajime Hoshi
063edfcc4a opengl: Use the safer way to pass Go string to C 2018-08-04 05:22:59 +09:00
Hajime Hoshi
18d77d3f6e shareable: Rename variables 2018-08-03 02:50:11 +09:00
Hajime Hoshi
0956ca0ea6 graphicsutil: Add MipmapLevel 2018-07-31 01:47:03 +09:00
Hajime Hoshi
d7d02e6d6a Reland: graphics: mipmap images should be volatile when the base image is volatile
This is not a bug fix, but should improve performance.
2018-07-30 00:26:36 +09:00
Hajime Hoshi
5be58086b5 Revert "graphics: Bug fix: mipmap images should be volatile when the base image is volatile"
This reverts commit 0f82330009.
2018-07-29 23:58:46 +09:00