7

Background: I want to write a CAD application. I want to implement all rendering with Vulkan. And I want to use GTK+.

I don't want a (visible) different window for the rendered image of the object.

So I researched and found the GtkGLArea widget, which seems to do what I want, but for OpenGL.

Is there an equivalent to GTKGLArea? If not, is there another way to implement what I'm thinking of?

le_me
  • 3,089
  • 3
  • 26
  • 28

2 Answers2

6

There is a GdkWindow which I believe is behind many Gtk graphic types such as GtkWindow and GtkWidget and obtainable with gtk_*_get_window(). GdkWindow has gdk_window_create_vulkan_context(). With GdkVulkanContext you can get raw Vulkan types and theoretically should be able to render to with Vulkan.

krOoze
  • 12,301
  • 1
  • 20
  • 34
  • 5
    this function/method targets Gtk/Gdk 3.90 (a pre 4.0 version) which is in the working (shown as stable though). This being said, the function/method it's not available on the more common Gtk/Gdk 3.22 version. – José Fonte Jul 19 '17 at 16:31
  • 1
    @JoséFonte That goes without saying. Vulkan (the spec) was released only 3.2016. Though Vulkan accepts Xlib, XCB or Wayland widgets. Something could be hacked up with the [X Window System Interaction](https://developer.gnome.org/gdk3/stable/gdk3-X-Window-System-Interaction.html) – krOoze Jul 19 '17 at 18:22
  • My comment was just a note. +1 ;) – José Fonte Jul 19 '17 at 18:28
  • 1
    The note is important, though: Vulkan support was only added in GTK+ 4. If you want to use Vulkan with GTK+ 3, you'll have to backport the support over yourself. I'm not sure if you can just use Vulkan directly with GTK+ 3 on a backend-by-backend basis using the public APIs (in the same way tegtkgl or whatever it was called does so with pre-3.16 GTK+ 3) or if you'll have to modify GDK itself... I'm also not sure if GTK+ 4 adds a `GtkVulkanArea` or not. – andlabs Jul 20 '17 at 04:32
  • 2
    thank you for these insights. does anybody know if a GtkVulkanArea widget or similar is planned? – le_me Jul 23 '17 at 12:32
  • I'll accept this answer, because there doesn't seem to exist a more highlevel approach (yet). – le_me Jul 23 '17 at 12:33
  • The links in this answer have bitrotted. – totaam Jan 31 '23 at 12:17
0

Lol that's simple trick with backend with X11 and Xlib_Create_Vulkan_Surface() on Gtk+3 like it works fine with Gtk+4.

Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51