~eliasnaur/gio

1

Gio news, March 2020

Details
Message ID
<C11X6PPMHM9C.1YULATSWV7AL0@testmac>
DKIM signature
pass
Download raw message
	Direct3D 11 support

Gio depends on the GPU to draw user interfaces efficiently and at
interactive speeds. Unfortunately, there are multiple APIs for
programming and driving a GPU: OpenGL on Linux, macOS and sometimes
Windows, OpenGL ES on Linux and mobiles, Vulkan on newer desktop and
mobile devices and Metal on newer macOS/iOS devices.

Gio was released with support for OpenGL ES, which is the most portable,
in part because desktop OpenGL is so similar. However, running Gio
programs on Windows required the use of the Google ANGLE DLLs to emulate
OpenGL ES.

I'm excited to announce that Gio now supports Direct3D 11 directly, and
no longer needs extra DLLs to run on Windows. In fact, because the
Windows port doesn't use Cgo, you can build a Windows executable from
any other platform by just supplying `GOOS=windows` to the go tool:

	GOOS=windows go build -ldflags="-H windowsgui" gioui.org/example/kitchen

(the `-H windowsgui` flag is to build the executable as a Windows GUI
program so it won't display a console while running.)

Direct3D support extends to package gioui.org/app/headless, to test and
draw user interfaces without extra DLLs.

For details, see the commit

	https://gioui.org/commit/e03b3cd808b471dd3659e2169bf2d8ee65dd6951

and the many commits leading up to it.


	GPU abstraction

A large part of the effort to implement Direct3D support is creating a
suitable abstraction covering both OpenGL, Direct3D and hopefully other
future graphics APIs. That work resulted in the gpu/backend package,

	https://pkg.go.dev/gioui.org/gpu/backend

Package gioui.org/gpu no longer refers to OpenGL packages, and is
now implemented in terms of a backend.Device:

	https://pkg.go.dev/gioui.org/gpu?tab=doc#New

The GPU abstraction increases the portability of Gio, making future
support for Metal or Vulkan easier. It also enables custom renderers, so
Gio user interfaces can be embedded in environments not directly
supported by Gio itself.

With multiple GPU interfaces, it is important they behave similarly.
The new tests in package headless,

	https://git.sr.ht/~eliasnaur/gio/tree/master/app/headless/backend_test.go

ensure that backend behaviour is locked down and helps creating new
ports.


	OpenGL abstraction

If you want to embed Gio user interfaces into a larger program such as a
3D game, you can't use Gio's app package because the Window type expects
to completely own the window and graphics device. On the other hand,
using the GPU abstraction from package backend may be overkill because
you do have access to an OpenGL-like interface.

The new package `gioui.org/gl/gl` is designed to make embedding
Gio into OpenGL programs easy. By implementing the Functions interface,

	https://pkg.go.dev/gioui.org/gpu/gl#Functions

you can create a backend.Device by calling gl.NewBackend:

	https://pkg.go.dev/gioui.org/gpu/gl#NewBackend

The new example program `glfw` demonstrates how to use package `gl` with
the Go glfw and go-gl packages to render Gio interfaces in a GLFW
program:

	https://git.sr.ht/~eliasnaur/gio/tree/master/example/glfw/main.go


	Input router

The GLFW example is not complete without mouse and keyboard input. The
new package `gioui.org/io/router` accepts raw input events from an
external source and implements io.Queue for distributing them among
Gio input handlers. See how the `glfw` sample uses Router here:

	https://git.sr.ht/~eliasnaur/gio/tree/master/example/glfw/main.go#L66



	Gopher's Labyrinth

András Belicza created a small game in Go, demonstrating how to mix a
Gio user interface with custom rendering:

	https://github.com/icza/golab


	Sponsors

Hani Massoud (@HaniMassoud) joined as a new sponsor to the Gio project.

As always, my work on Gio and related open source software is funded by donations,
so if you find my work useful please consider sponsoring me through
GitHub:

	https://eliasnaur.com/sponsor
Tanguy Herrmann
Details
Message ID
<94e5b62f-65c1-44d3-869b-19f9c45ac69d@localhost>
In-Reply-To
<C11X6PPMHM9C.1YULATSWV7AL0@testmac> (view parent)
DKIM signature
pass
Download raw message
Keep them coming!
These are great news!

4 mars 2020 11:00:51 Elias Naur <mail@eliasnaur.com>:

> Direct3D 11 support
> 
> Gio depends on the GPU to draw user interfaces efficiently and at
> interactive speeds. Unfortunately, there are multiple APIs for
> programming and driving a GPU: OpenGL on Linux, macOS and sometimes
> Windows, OpenGL ES on Linux and mobiles, Vulkan on newer desktop and
> mobile devices and Metal on newer macOS/iOS devices.
> 
> Gio was released with support for OpenGL ES, which is the most portable,
> in part because desktop OpenGL is so similar. However, running Gio
> programs on Windows required the use of the Google ANGLE DLLs to emulate
> OpenGL ES.
> 
> I'm excited to announce that Gio now supports Direct3D 11 directly, and
> no longer needs extra DLLs to run on Windows. In fact, because the
> Windows port doesn't use Cgo, you can build a Windows executable from
> any other platform by just supplying `GOOS=windows` to the go tool:
> 
> GOOS=windows go build -ldflags="-H windowsgui" gioui.org/example/kitchen
> 
> (the `-H windowsgui` flag is to build the executable as a Windows GUI
> program so it won't display a console while running.)
> 
> Direct3D support extends to package gioui.org/app/headless, to test and
> draw user interfaces without extra DLLs.
> 
> For details, see the commit
> 
> https://gioui.org/commit/e03b3cd808b471dd3659e2169bf2d8ee65dd6951
> 
> and the many commits leading up to it.
> 
> 
> GPU abstraction
> 
> A large part of the effort to implement Direct3D support is creating a
> suitable abstraction covering both OpenGL, Direct3D and hopefully other
> future graphics APIs. That work resulted in the gpu/backend package,
> 
> https://pkg.go.dev/gioui.org/gpu/backend
> 
> Package gioui.org/gpu no longer refers to OpenGL packages, and is
> now implemented in terms of a backend.Device:
> 
> https://pkg.go.dev/gioui.org/gpu?tab=doc#New
> 
> The GPU abstraction increases the portability of Gio, making future
> support for Metal or Vulkan easier. It also enables custom renderers, so
> Gio user interfaces can be embedded in environments not directly
> supported by Gio itself.
> 
> With multiple GPU interfaces, it is important they behave similarly.
> The new tests in package headless,
> 
> https://git.sr.ht/~eliasnaur/gio/tree/master/app/headless/backend_test.go
> 
> ensure that backend behaviour is locked down and helps creating new
> ports.
> 
> 
> OpenGL abstraction
> 
> If you want to embed Gio user interfaces into a larger program such as a
> 3D game, you can't use Gio's app package because the Window type expects
> to completely own the window and graphics device. On the other hand,
> using the GPU abstraction from package backend may be overkill because
> you do have access to an OpenGL-like interface.
> 
> The new package `gioui.org/gl/gl` is designed to make embedding
> Gio into OpenGL programs easy. By implementing the Functions interface,
> 
> https://pkg.go.dev/gioui.org/gpu/gl#Functions
> 
> you can create a backend.Device by calling gl.NewBackend:
> 
> https://pkg.go.dev/gioui.org/gpu/gl#NewBackend
> 
> The new example program `glfw` demonstrates how to use package `gl` with
> the Go glfw and go-gl packages to render Gio interfaces in a GLFW
> program:
> 
> https://git.sr.ht/~eliasnaur/gio/tree/master/example/glfw/main.go
> 
> 
> Input router
> 
> The GLFW example is not complete without mouse and keyboard input. The
> new package `gioui.org/io/router` accepts raw input events from an
> external source and implements io.Queue for distributing them among
> Gio input handlers. See how the `glfw` sample uses Router here:
> 
> https://git.sr.ht/~eliasnaur/gio/tree/master/example/glfw/main.go#L66
> 
> 
> 
> Gopher's Labyrinth
> 
> András Belicza created a small game in Go, demonstrating how to mix a
> Gio user interface with custom rendering:
> 
> https://github.com/icza/golab
> 
> 
> Sponsors
> 
> Hani Massoud (@HaniMassoud) joined as a new sponsor to the Gio project.
> 
> As always, my work on Gio and related open source software is funded by donations,
> so if you find my work useful please consider sponsoring me through
> GitHub:
> 
> https://eliasnaur.com/sponsor
>