GTK4 GSK Vulkan for drawing area - Kotlin

Hi @lb90

I am trying to to a simple drawing using GTK4 DrawingArea using Vulkan renderer

I am using MSYS2 with gtk 3.96.0

But I want to initialize vulkan after the window is successfully rendered and draw using custom shader

is this possible in GTK4

No. GTK can use Vulkan to render its contents (even though the Vulkan renderer is considered experimental), but you don’t have access to the Vulkan pipeline from outside GTK itself.

You would need to write the equivalent of GtkGLArea for Vulkan, i.e. a widget that creates a Vulkan pipeline integrated with GTK’s own, and then renders to a target that GTK can use when drawing itself.

@ebassi ok, but when I set “GSK_RENDERER” as “vulkan” in windows 10 environment variables the window stays at the system tray and never launches, same application works proper for cairo

when I right click the system tray, it says “Posix Thread” when I click on it, the window replicates, but never shows

The Vulkan rendering code is, as I said, experimental. It’s not guaranteed to be working on every platform, at the moment. Additionally, since you’re referring to GTK 3.96.0, unless you’re building GTK from Git’s master branch, you’re using a development snapshot that was released >6 months ago.

In any case, even if you’re using Vulkan as the rendering API for GTK, it does not imply that you can use your own Vulkan rendering code for your application.

@ebassi it is only few lines

gtk_init
gtk_window_set_default_size
gtk_widget_show
gtk_main

thats only this three line, no signal, no component

It doesn’t really matter how many lines of code you have: the Vulkan renderer in GTK is responsible for drawing the whole of the application. If there’s a bug in the Vulkan code inside GTK, or if the driver isn’t working as expected, then you won’t see anything.

In general, it’s not recommended to use the Vulkan renderer for GTK, unless you’re planning to contribute to GTK itself—in which case, you need to be familiar with Vulkan and the internals of GTK; as I said above, the Vulkan renderer is experimental, and only tested on Linux. There’s a reason why it’s not the default renderer to begin with.

Hi @dickensas! First make sure that your system supports vulkan. You can try running VulkanSDK\bin\vkcube.exe and see whether it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.