By default, the standard library log package outputs to stderr.
However, stderr is redirected through a pipe to the Android logger,
so recent writes may be not have been sent when os.Exit is called.
The log.Fatal family of functions does just that: write to the log
and call os.Exit.
To ensure all messages are sent, register a synchronized logger at
startup.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
According to
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html#//apple_ref/doc/uid/20000738-125024
Cocoa is by default not multithread-safe for programs that use the posix
api for creating threads:
"
For multithreaded applications, Cocoa frameworks use locks and other
forms of internal synchronization to ensure they behave correctly. To
prevent these locks from degrading performance in the single-threaded
case, however, Cocoa does not create them until the application spawns
its first new thread using the NSThread class. If you spawn threads
using only POSIX thread routines, Cocoa does not receive the
notifications it needs to know that your application is now
multithreaded. When that happens, operations involving the Cocoa
frameworks may destabilize or crash your application.
"
That includes Go programs.
The fix, as discovered by Steeve Morin, is to create and launch
an empty NSThread.
Add a package that does that, and use it everywhere Cocoa is used.
Sigh.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The macOS backend doesn't re-create contexts, holding on to the first
created instead. Make sure the GPU leaves the default framebuffer bound,
in case the context is re-used.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
While we're here,
- replace the registerFragment trampoline with a general variadic
CallVoidMethod trampoline.
- Use UTF-16 for passing strings to Java. Java's modified UTF-8 encoding differ
from Go's in corner cases.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
I've resisted relying on pkg-config in the hope that hard-coded include and
library paths would suffice. However, apart from having to work around some
distro-specific differences, building with hardcoded include paths fails when
building on a buildroot:
x86_64-buildroot-linux-gnu-gcc: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/include/wayland'
(see #91)
Andri mentions a workaround (prefixing paths with "="), but that doesn't seem
to work on the BSDs.
Let's see how pkg-config fares. It's an extra dependency, but it promises to keep
us isolated from the varying paths on Linux distrobutions.
Updates #91
Signed-off-by: Elias Naur <mail@eliasnaur.com>
EGL is window system agnostic, but its egl.h header includex X11
headers by default. Use the MESA_EGL_NO_X11_HEADERS define to avoid
it, fixing the "nox11" build for systems without X11 headers installed.
Fixes#91
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Specifying the clear color and depth at the time of clearing is
less error prone and a better for modern GPU APIs. As a bonus, we
can get rid of the BufferAttachment type.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
D3DCompile successfully compiles shaders fxc.exe doesn't. As a bonus
the DirectX SDK is no longer required (it includes fxc.exe).
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Some GPU APIs such as Direct3D can return an error after drawing
a frame indicating a transient device error. Recreate device and
retry if it happens.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>