1

So I would like to create a compositor for wayland which supports 3D effects for windows(something resembling compiz, but on wayland). I already saw this question: Where do I start if I want to write a wayland compositor? but the only answer points to SWC(https://github.com/michaelforney/swc), which is not applicable in my case as I want to use OpenGL and because SWC doesn't support 3D easily. So is there some project/library/book/tutorial/etc where I can learn the necessary things for writing my own WM on wayland? Thanks in advance.

Community
  • 1
  • 1
thefunkyjunky
  • 492
  • 4
  • 15
  • That's quite a broad question. I guess you'll have to directly use libwayland and combine it with some OpenGL magic. As wayland uses EGL, this may be possible. – PatJ Oct 26 '15 at 15:07
  • Yeah I suspected as much. But how can I create an OpenGL context through EGL and how do I "start" EGL? – thefunkyjunky Oct 26 '15 at 15:46
  • I don't know, but if you try stuff don't hesitate to answer yourself with your results (even if they are bad). – PatJ Oct 27 '15 at 13:51
  • You might also be interested in [WLC](https://github.com/Cloudef/wlc) that is mentioned on the project page of SWC – eyelash Dec 22 '15 at 16:17
  • It would be great if there was a book, but there isn't. You'll have to spend time with source code. Take a look at [motorcar](https://github.com/evil0sheep/motorcar). – ybakos Mar 26 '16 at 15:32

1 Answers1

4

The only purpose of the wayland protocol is the communication between client and server. The server provides the client with input events and the client provides the server with a buffer (that can be mapped to an OpenGL texture). Where the server/compositor gets its input events from and what it does with the buffer is completely up to the compositor.

So the compositor itself needs a source for input events and a way to draw its result. That's why many wayland compositors have multiple backends: they can run on top of X11, directly on top of the Linux kernel or even on top on another wayland server.

The answer to your question really depends on where you want to run your compositor. Writing a compositor that runs on top of X11 might be the easiest way to get started if you're already familiar with how to get an OpenGL app up and running there. If you want to run your compositor directly on top of the Linux kernel you'd probably want to look into evdev and libinput for input and DRM/KMS together with EGL on top of GBM in order to create an OpenGL context and show the result on your monitor. There are also rendering libraries (e.g. evas) that can run directly on top of the Linux kernel but I don't know how far they let you inject your own OpenGL code.

Once you have decided where you want to run your compositor you can start by just writing a regular OpenGL app and then go on and integrate a wayland server in order to display and interact with actual client windows.

eyelash
  • 3,197
  • 25
  • 33
  • And where can I find how to integrate this wayland server(for example, for a x window manager I have seen some tutorials and some very simple window managers which can be used as a reference code)? – thefunkyjunky Dec 22 '15 at 15:51
  • 2
    I just wrote a [minimal wayland compositor that runs on top of X11](https://github.com/eyelash/tutorials/tree/master/wayland-compositor) that might be helpful. There really don't seem to be many tutorials or examples around. You'd have to look at the source code of other compositors. – eyelash Dec 22 '15 at 16:06
  • Seems interesting. Thank you! – thefunkyjunky Dec 22 '15 at 16:10