~eliasnaur/gio-example

34293554705ce4073cacad29ecfd9b2985143261 — Elias Naur 2 months ago 256666b
opengl,glfw: update to latest Gio version

Remove depth buffers since they're no longer needed by any Gio
renderer.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
5 files changed, 16 insertions(+), 21 deletions(-)

M glfw/main.go
M go.mod
M go.sum
M kitchen/kitchen.go
M opengl/main.go
M glfw/main.go => glfw/main.go +6 -6
@@ 91,11 91,11 @@ func main() {
	var queue router.Router
	var ops op.Ops
	th := material.NewTheme(gofont.Collection())
	gpu, err := gpu.New(gpu.OpenGL{ES: !desktopGL})
	gpuCtx, err := gpu.New(gpu.OpenGL{ES: !desktopGL})
	if err != nil {
		log.Fatal(err)
	}
	defer gpu.Release()
	defer gpuCtx.Release()

	registerCallbacks(window, &queue)
	for !window.ShouldClose() {


@@ 116,8 116,8 @@ func main() {
		}
		drawOpenGL()
		draw(gtx, th)
		gpu.Collect(sz, gtx.Ops)
		gpu.Frame()
		gpuCtx.Collect(sz, gtx.Ops)
		gpuCtx.Frame(gpu.OpenGLRenderTarget{})
		queue.Frame(gtx.Ops)
		window.SwapBuffers()
	}


@@ 133,10 133,10 @@ var (
func drawOpenGL() {
	if desktopGL {
		gl.ClearColor(0, float32(green), 0, 1)
		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		gl.Clear(gl.COLOR_BUFFER_BIT)
	} else {
		gles2.ClearColor(0, float32(green), 0, 1)
		gles2.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		gles2.Clear(gl.COLOR_BUFFER_BIT)
	}
}


M go.mod => go.mod +1 -1
@@ 3,7 3,7 @@ module gioui.org/example
go 1.16

require (
	gioui.org v0.0.0-20210804105805-1efe68c1540b
	gioui.org v0.0.0-20210816162232-c7ea90c4e213
	gioui.org/x v0.0.0-20210804152830-6815ab60d717
	gioui.org/x/haptic v0.0.0-20210120222453-b55819bc712b
	gioui.org/x/notify v0.0.0-20210120222453-b55819bc712b

M go.sum => go.sum +6 -3
@@ 34,10 34,13 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20210116085804-99bfa6a33cdf/go.mod h1:Y+uS7hHMvku1Q+ooaoq6fYD5B2LGoT8JtFgvmYmRzTw=
gioui.org v0.0.0-20210729070555-8cec7e04eb71/go.mod h1:N4QK6T0gTQc7ogB7rniAyYQb8/klqI6hQkqV+HAh5Mw=
gioui.org v0.0.0-20210804105805-1efe68c1540b h1:WoK7TEkeZdluAyzsuGnqod+/PTyrUVoF81Fyhsb4R/k=
gioui.org v0.0.0-20210804105805-1efe68c1540b/go.mod h1:N4QK6T0gTQc7ogB7rniAyYQb8/klqI6hQkqV+HAh5Mw=
gioui.org/cpu v0.0.0-20210727122813-41509bcd3462 h1:JZyB+d8tPExZHNZwMiGKeeAVd0mkFTc3Zsmegdn178M=
gioui.org v0.0.0-20210816162232-c7ea90c4e213 h1:03HXLQj+ojkqxJgzfqUgUQ443CYZj+oNCdPHiTrsO/E=
gioui.org v0.0.0-20210816162232-c7ea90c4e213/go.mod h1:9eROMr3ULdKcO1qCQTTbs9ZSuzCBQdyD6SIVFaM4z14=
gioui.org/cpu v0.0.0-20210727122813-41509bcd3462/go.mod h1:DkhBDuHokSMOUxX5LZQ7IcxyJJzs3OON8Z5ojaXUXxo=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334 h1:1xK224B5DnjlPKCfVDTl7+olrzgAXn4ym6dum3l34rs=
gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ=
gioui.org/shader v0.0.0-20210816161847-c12352edbd45 h1:tWCgnOK33iYKNvQ4ctNHBknZ6r273Na82wcTOFc29ZM=
gioui.org/shader v0.0.0-20210816161847-c12352edbd45/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
gioui.org/x v0.0.0-20210804152830-6815ab60d717 h1:iRI8QLSxwEkJJI+WdpMvUYNP3wavU5GVkijmmFzjLdo=
gioui.org/x v0.0.0-20210804152830-6815ab60d717/go.mod h1:+BOtudS1JLP5YKhna9BFi32SrO/Hm7IkBPjFQJQrn6g=
gioui.org/x/haptic v0.0.0-20210120222453-b55819bc712b h1:3lHNKrTHXJCXhtmCVdTInlNuay3jSQ0SVi9JNQTj5yM=

M kitchen/kitchen.go => kitchen/kitchen.go +1 -0
@@ 67,6 67,7 @@ func main() {
		for {
			time.Sleep(time.Second)
			progressIncrementer <- 0.1
			//pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
		}
	}()


M opengl/main.go => opengl/main.go +2 -11
@@ 52,12 52,6 @@ type eglContext struct {
	surf C.EGLSurface
}

const (
	// needDepthBuffer must be true when the program needs a depth buffer, or
	// when using the old non-compute Gio renderer.
	needDepthBuffer = true
)

func main() {
	go func() {
		// Set CustomRenderer so we can provide our own rendering context.


@@ 145,7 139,7 @@ func loop(w *app.Window) error {

				// Render drawing ops.
				gioCtx.Collect(e.Size, gtx.Ops)
				gioCtx.Frame()
				gioCtx.Frame(gpu.OpenGLRenderTarget{})

				if ok := C.eglSwapBuffers(ctx.disp, ctx.surf); ok != C.EGL_TRUE {
					log.Fatal(fmt.Errorf("swap failed: %v", C.eglGetError()))


@@ 184,7 178,7 @@ func screenshot(ctx gpu.GPU, size image.Point, ops *op.Ops) error {
	}
	drawGL()
	ctx.Collect(size, ops)
	if err := ctx.Frame(); err != nil {
	if err := ctx.Frame(gpu.OpenGLRenderTarget{}); err != nil {
		return fmt.Errorf("screenshot: %w", err)
	}
	r := image.Rectangle{Max: size}


@@ 248,9 242,6 @@ func createContext(view C.EGLNativeWindowType) (*eglContext, error) {
		// Some drivers need alpha for sRGB framebuffers to work.
		attribs = append(attribs, C.EGL_ALPHA_SIZE, 8)
	}
	if needDepthBuffer {
		attribs = append(attribs, C.EGL_DEPTH_SIZE, 16)
	}
	attribs = append(attribs, C.EGL_NONE)
	var (
		cfg     C.EGLConfig