Integration of wxWidgets with VulkanSceneGraph (vsg)

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
Steevithak
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Oct 24, 2020 8:10 pm

Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by Steevithak »

Has anyone attempted to create a multiplatform program (Linux/Mac/Win) using wxWidgets and VulkanSceneGraph? Vsg is the successor to OpenSceneGraph. I was hoping maybe there was an open source application out there already doing this so I could see a working example. If not, any pointers on how it might be done? I believe Vsg needs to get access to the Vulkan surface (VkSurfaceKHR) of the underlying, platform-specific window. Are there any wxWidgets functions related to Vulkan? Maybe a boolean to indicate if the underlying platform supports it and a function to retrieve the Vulkan surface info? Any suggestions or a link to existing code appreciated!

-Steve
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by doublemax »

Are there any wxWidgets functions related to Vulkan? Maybe a boolean to indicate if the underlying platform supports it and a function to retrieve the Vulkan surface info?
No, there is nothing Vulkan related in wxWidgets.

Usually the link between wxWidgets and another API that needs access to a window is a platform specific window handle. E.g. wxWindow::GetHandle() returns a HWND under Window, and a GtkWidget under GTK.

Googling found that you need a HWND and HMODULE to create a Vulkan surface under Windows:
https://vulkan-tutorial.com/Drawing_a_t ... e-creation

I assume similar methods exist for GTK and OSX.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by ONEEYEMAN »

Hi,
You might also take a look at wxNativeWindow and see how it can be inserted in the wxWindow.

Thank you
Steevithak
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Oct 24, 2020 8:10 pm

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by Steevithak »

ONEEYEMAN wrote: Mon Nov 02, 2020 4:52 am You might also take a look at wxNativeWindow and see how it can be inserted in the wxWindow.
That's an interesting idea, thanks! Can I use wxNativeWindow to place the native window used by VulkanSceneGraph into my wxFrame window or would wxNativeWindow have to be a second wxWindow inside of wxFrame (or on top of it) ?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by ONEEYEMAN »

Hi,
You can certainly try it.

Thank you.
Steevithak
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Oct 24, 2020 8:10 pm

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by Steevithak »

Turns out wxNativeWindow doesn't seem to be available in the version of wxWidgets that I've got (Fedora 32 includes wxWidgets v3.0.4). From what I found in the roadmap, it looks like I need wxWidgets v3.2 to try this. Looks like 3.2 has support for some other cool stuff too and is expected by the end of the year, so I'll probably come back to this issue then and work on it some more.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by ONEEYEMAN »

Hi,
The documentation states that it is available since 3.1.0.

You can try to compile the latest release (3.1.4) and try it, so you will know whether it will work or not.
It is very simple.

1. Download the archive and unpack it inside ~/wxWidgets for example.
2. Open the Terminal and do:

Code: Select all

  cd wxWidgets
  mkdir buildGTK
  cd buildGTK
  ../configure --enable-debug
  make
  sudo make install
  
3.Change all you wxWidgets to point to /usr/local/include and /usr/local/lib.
4. Compile and test.

Thank you.
Steevithak
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Oct 24, 2020 8:10 pm

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by Steevithak »

I installed and compiled wxWidgets 3.1.* to try this out. Looks like wxNativeWindow could work with VulkanSceneGraph for Windows and MacOS but not Linux. The problem is that vsg creates an x window, whereas wxNativeWindow seems to expect a GTK+ window handle. Unfortunately I haven't found a way to create a GTK+ window to wrap the x window so I can pass to wxNativeWindow. I think I'm stuck on this approach.

I'm switching back to plan A, where I let wxWidgets create the initial window and then retrieve the underlying native window handle from the wxFrame window and pass that over to vsg so it can grab the vulkan surface info and use it. This approach requires me to do some hacking on the vsg code but otherwise seems hopeful. But I've hit one snag, again on Linux. Vsg is expecting an x window but when I run the GTK test functions GDK_IS_X11_DISPLAY() and GDK_IS_WAYLAND_DISPLAY(), it indicates that I'm on Wayland. So my question is, does that mean the wx GetHandle() function is going to return a Wayland window handle or will I always get an X window handle regardless of display's X11 vs Wayland type?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Integration of wxWidgets with VulkanSceneGraph (vsg)

Post by ONEEYEMAN »

Hi,
You could try to ask on the GTK forum: discourse.gnome.org.

Thank you.
Post Reply