Commit Graph

162 Commits

Author SHA1 Message Date
Elias Naur 3a5a2cff6b app/internal/glimpl: add gl functions for uniform buffers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:37 +01:00
Elias Naur 5cd5d49108 gpu/backend: move backend interface types to a separate package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 50e98d1e13 app/headless: handle error from Framebuffer.ReadPixels
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 2df50dda8e app/headless: remove unusued parameters to newContext
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur b4c163e437 gpu: Move Bind methods to Backend
Having Backend.Bind* methods better matches both opengl and d3d.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 055fa97343 app/headless: Release Window after testing it
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur f305f71b20 app/headless: re-implement Screenshot on top of Backend
The new Framebuffer.ReadPixels method is enough to implement
Window.Screenshot. Use that instead of the OpenGL-specific
implementation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 1f43bfa0e4 app/internal/egl: remove Windows error message dialog when EGL fails to load
The error message is not appropriate where there are multiple backends,
and there's a much better chance Gio will run with the direct3d backend
where no external DLLs are required.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur cf7d702a39 app/internal/window: remove unsafe cast
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur 05485a79a6 app/internal/srgb: rename NewSRGBFBO to New and SRGBFBO to FBO
The srgb package was recently created to contain just the sRGB
emulation, but the names weren't shortened accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:22 +01:00
Elias Naur b34216c124 app/headless: remove OpenGL assumptions
To prepare package headless for multiple backends, refactor the common headless
driver to no longer assume an OpenGL context. Instead, introduce a headless
backend type and the OpenGL implementation, glBackend.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:21 +01:00
Elias Naur 94fdc26cb5 app,app/headless: expose Backends from window and headless contexts
This is a refactoring change to prepare for another gpu.Backend
implementations.

Notably, app/loop.go no longer imports gpu/gl.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 20:34:21 +01:00
Elias Naur e3f8d1a1af app/internal/window: (Windows) report pressed buttons for Move events
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-26 10:57:30 +01:00
Roy Lee ae6161dfb6 app/internal/wayland: Added header dir for wayland in openSUSE
Added a cflag -I to provide wayland header files in openSUSE.

Fixes gio#76

Signed-off-by: Roy Lee <royyhlee@gmail.com>
2020-02-16 21:44:29 +01:00
Elias Naur adb950cbf3 app/internal/srgb: move sRGB emulation to new internal package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-10 18:22:58 +01:00
Elias Naur 3ae5a37c24 gpu,gpu/gl: introduce Backend
A recent change made the OpenGL functions an interface of the functions
required for the implementation of GPU, a renderer for Gio operations.
That allowed for running Gio on external systems where OpenGL is
available.

However, to allow for non-OpenGL flavored backends such as Vulkan,
Metal and Direct3D, this change introduces Backend for the high-level
operations required by GPU. This change also adds a concrete backend
to package gl.

Type Backend is a first cut heavily based on OpenGL. Future changes will add
more backends, where the Backend interface quite possibly will need refinement.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-10 18:22:57 +01:00
Elias Naur 1f422ef960 all: gofmt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-08 00:04:15 +01:00
Elias Naur d2d495416a gpu: rename method GPU.Frame to BeginFrame and drop redundant argument
The viewport size was already specified in the call to Collect.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 21:35:19 +01:00
Elias Naur 3b6646933d gpu: expose the rendering implementation
The rendering implementation is needed for using Gio UI with external
window libraries such as GLFW. Expose it in the new package gpu.

Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 21:21:38 +01:00
Elias Naur 34c6a2f735 io/router: expose the event router
For integrating with external window implementations (replacing
package app), access to the event router is required. Extract it
and put it into the new package router.

Router may belong in package io/event, but can't without introducing
import cycles.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 20:41:04 +01:00
Elias Naur 6e98132ebb app/internal/gpu: extract profile in separate method, Profile
Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 20:08:50 +01:00
Elias Naur 81f958fc70 app/internal/gpu: remove profile flag
Automatically determine whether to profile GPU operations from
the existence of a profiling op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 20:00:52 +01:00
Elias Naur 320535a978 app/internal/input: remove AddProfile method
Merge it into the general Add method.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 19:41:39 +01:00
Elias Naur 251c075093 app/internal/gl/impl: extract platform dependent opengl bindings
We'd like to support Gio using a different renderer binding than
the builtin. A first step is to define the Functions interface
in package gl, and extract the concrete implementations to a
separate package.

Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 19:22:30 +01:00
Greg Pomerantz 72cb36c5f9 app/internal/gpu: make the zero value of paint.ImageOp useful
Do not panic when drawing the zero value of paint.ImageOp.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2020-01-29 15:58:45 +01:00
Daniel Martí 54ed198cb0 app: don't discard android touch events of unknown tool type
This is the kind of event one gets when using 'adb shell input tap x y',
which I am trying to use for the end-to-end tests.

Right now, we only have two pointer source types: mouse and touch.
On Android, emulated touch events tend to simulate the touchscreen, not
a mouse, so let's go with that as a fallback.

Perhaps in the future we will have another special pointer source for
this kind of event, such as "unknown" or "virtual".

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-27 11:17:47 +01:00
Aaron Bieber fdaf891732 app: Enable building on OpenBSD
Currently the golang.org/x/sys package is missing the Pipe2 call for OpenBSD.
The call exists on OpenBSD, it just isn't exposed.

This diff was tested buy adding the Pipe2 call and setting:

   go mod edit -replace=golang.org/x/sys=/pat/to/modified/sys

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
2020-01-24 14:32:54 +01:00
mural a7dc7c01c0 app/internal/log: add logger for Windows DebugView
Signed-off-by: mural <mural@ctli.io>
2020-01-13 21:48:13 +01:00
Elias Naur f176cbfe88 app/internal/egl: try EGL_DEFAULT_DISPLAY is eglGetDisplay fails
Fixes #77

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-11 23:21:27 +01:00
Elias Naur bc30683588 Revert "app/internal/egl: accept zero EGLDisplay values as valid"
This reverts commit 66138e7890.

Reason: According to #77, it didn't work and the proposed fix
(retry when EGL_NO_DISPLAY is returned) is correct.
2020-01-11 23:15:23 +01:00
Elias Naur 66138e7890 app/internal/egl: accept zero EGLDisplay values as valid
Issue #77 seems to be caused by eglGetDisplay returning a zero
EGLDisplay, yet eglGetError returns EGL_SUCCESS. Since EGLDisplay
is not necessary a pointer type, the zero value may be valid.

Updates #77

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-08 13:28:12 +01:00
Elias Naur 95903aafda app/internal/window: add errno to wl_display_connect errors
Updates #40

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-03 11:28:53 +01:00
Greg Pomerantz 8a4d0007f3 app: clarify documentation of app.Main()
Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-12-16 19:06:05 +01:00
Elias Naur 9114dbe759 app/internal/gl: gofmt -w -s
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur 4a628d1c2c app/internal/gpu: re-add check for GL_EXT_color_buffer_half_float
As noted in #49, GL_EXT_color_buffer_half_float is required for
GL_OES_texture_half_float to be useful for FBOs.

Updates #49

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-11 15:12:57 +01:00
Elias Naur 8a44ac11d8 app/internal/gpu: use single channel floating point FBO if possible
Remove dependency on EXT_color_buffer_half_float, it's not clear it's
necessary. In any case the following FBO sanity check will catch invalid
FBO format combinations.

Updates #49

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-11 13:54:24 +01:00
Elias Naur 86d69859b9 app/internal/gpu: query GL_EXTENSIONS correctly on macOS
macOS supports the OpenGL core profiles where glGetString(GL_EXTENSIONS)
is not supported. Use glGetStringi(GL_EXTENSIONS, <index>) instead.

The wrong query didn't make any practical difference because Gio doesn't
need any extensions on OpenGL 3 and better.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:29:43 +01:00
Elias Naur d9212263aa app/headless: prepare OpenGL context on macOS
The macOS backend uses a desktop OpenGL context, not a OpenGL ES
context. The main difference is that sRGB have to be enabled and
a vertex buffer must be bound.

Do that and fix Window.Screenshot for scenes more complex than a
glClear.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:29:43 +01:00
Elias Naur fddb0af6f6 app/internal/gpu: default to color material
Before this change the default material were a texture, which leads
to a crash when no texture is current.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-03 16:48:48 +01:00
Elias Naur 6fbdefa21f app/headless: compensate for OpenGL's lower left origin
The origin of image.Images is the upper left corner. Convert the
ReadPixels result by flipping the image the y-direction.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:59:34 +01:00
Elias Naur 41116b5cb8 app/headless: add package docs
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 00:05:30 +01:00
Elias Naur 0b84137f40 app/headless: implement headless windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:40:02 +01:00
Elias Naur 9df3c76aa2 app/internal/egl: don't exit if EGL dlls fails to load
We want a useful error instead of a hard exit for headless windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:40:02 +01:00
Elias Naur 06a2228798 app/internal/windows: split out Windows syscalls from package window
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 9b4176c475 app/internal/egl,app/internal/window: move Lock/Unlock methods
EGL contexts don't need locking, so their Lock and Unlock methods
are empty. Remove them and add them where necessary instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 15a1261cfc app/internal/egl: only create a compatibility FBO if there is a surface
While here, only refresh the FBO if needed to make MakeCurrent faster.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur f25f647a66 app/internal/window,app/internal/gl: move gl.Context to package window
Package gl now only defines opengl types and functions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 5fa3dbc70d app,app/internal/gpu: split render loop from GPU
The policy of rendering on a separate goroutine is separate from
the actual rendering. Reflect that by introducing the RenderLoop
type for driving a GPU from a separate goroutine.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 8cec7d1a40 app/internal/window: move context refresh to window
Instead of calling from the low level context into the window
for its surface and dimensions, add a Context.MakeCurrent method
that does it directly.

The result is simpler and clearer logic. For example, synchronization
is obviously no longer needed. It wasn't necessary before, but the
reason was unclear.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 3199ae7600 app/internal/window: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00