Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build for wayland #212

Merged
merged 6 commits into from
Apr 26, 2018
Merged

Fix build for wayland #212

merged 6 commits into from
Apr 26, 2018

Conversation

r0l1
Copy link
Contributor

@r0l1 r0l1 commented Nov 26, 2017

This is a work in progress pull request to get the wayland issue fixed as soon as possible.
This is based on #199 work.

Right now the build progress fails with:

# github.com/go-gl/glfw/v3.2/glfw
In file included from ./c_glfw_linbsd.go:16:0:
./glfw/src/wayland-relative-pointer-unstable-v1-client-protocol.c:34:35: error: redefinition of ‘types’
 static const struct wl_interface *types[] = {
                                   ^~~~~
In file included from ./c_glfw_linbsd.go:15:0:
./glfw/src/wayland-pointer-constraints-unstable-v1-client-protocol.c:37:35: note: previous definition of ‘types’ was here
 static const struct wl_interface *types[] = {
                                   ^~~~~

Any hints how to fix this?

Thanks!

@r0l1
Copy link
Contributor Author

r0l1 commented Nov 28, 2017

Fixed it. I also removed the generate steps and added a generate script. This is only required for developers. I would update the wiki, if this pull request gets merged.

@pwaller pwaller mentioned this pull request Apr 12, 2018
@r0l1
Copy link
Contributor Author

r0l1 commented Apr 14, 2018

The wayland developer wiki should be updated to following content if this pull request gets merged.

Generating wayland source/header files

A helper script located at scripts/generate-wayland-protocols.sh should be used to update the wayland source/header files. The wayland-scanner utility is required.

scripts/generate-wayland-protocols.sh ./v3.2/glfw/glfw/src

@r0l1
Copy link
Contributor Author

r0l1 commented Apr 14, 2018

Testing

Install the xorg-xeyes utility and run it with:

xeyes

X11

go build

Move the mouse over the window and the xeyes should move, because glfw uses X11.

Wayland

go build -tags wayland

Move the mouse over the window and the xeyes should not move, because glfw uses wayland.

Code

package main

import (
	"log"
	"runtime"
	"time"

	"github.com/go-gl/gl/v3.2-core/gl"
	"github.com/r0l1/glfw/v3.2/glfw"
)

const (
	winWidth  = 400
	winHeight = 500
	fps       = time.Second / 30
)

func init() {
	runtime.LockOSThread()
}

func main() {
	if err := glfw.Init(); err != nil {
		log.Fatalln(err)
	}
	glfw.WindowHint(glfw.ContextVersionMajor, 3)
	glfw.WindowHint(glfw.ContextVersionMinor, 2)
	glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
	glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)

	win, err := glfw.CreateWindow(winWidth, winHeight, "Nuklear Demo", nil, nil)
	if err != nil {
		log.Fatalln(err)
	}
	win.MakeContextCurrent()

	width, height := win.GetSize()
	log.Printf("glfw: created window %dx%d", width, height)

	if err := gl.Init(); err != nil {
		log.Fatalln("opengl: init failed:", err)
	}
	gl.Viewport(0, 0, int32(width), int32(height))

	for !win.ShouldClose() {
		win.SwapBuffers()
		glfw.PollEvents()
		time.Sleep(fps)
	}
}

@tapir
Copy link
Member

tapir commented Apr 15, 2018

Works as intended for me. Though I get this error: PlatformError: Wayland: Focusing a window requires user interaction

@r0l1
Copy link
Contributor Author

r0l1 commented Apr 16, 2018

I have the same problem and after some research I found two possible causes:

  1. glew with EGL required
  2. No window decorations or close callback on Wayland

It seams, that glfw's wayland support has improved a lot in the new upcoming 3.3 release and that we'll have to wait for it's first public release. Nevertheless I suggest to add initial wayland support to this package as initial base for 3.3.

@tapir
Copy link
Member

tapir commented Apr 16, 2018

I'm OK with merging this one so at least we have 'some' wayland support for 3.2
Any comments @shurcooL @pwaller ?

Copy link
Member

@dmitshur dmitshur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use Linux on desktop day to day, so I can't review this very thoroughly.

However, from a general look, I don't see any major issues (just minor things that aren't worth blocking the PR for). The changes are isolated to Wayland, and it currently doesn't work, so I don't have objections to moving forward with this.

LGTM.

@tapir tapir merged commit 46a8d53 into go-gl:master Apr 26, 2018
@dmitshur
Copy link
Member

Thanks @r0l1 and @thomasruiz for working on this, and @tapir for reviewing!

@r0l1
Copy link
Contributor Author

r0l1 commented Apr 26, 2018

Thanks for merging! Hope we'll have full wayland support in 3.3...

@@ -24,8 +24,6 @@
//
//========================================================================

#define _GNU_SOURCE

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r0l1 I'm late to this party - is there are reason to diverge from upstream and remove _GNU_SOURCE here?

Context is: #271.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I'm reinstating _GNU_SOURCE here, which documents what you should do if you want to remove it again: bac7f0e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants