How to develop GTK app with Vulkan for Linux? - linux

I'd like to develop an application targeting modern popular Linux distributions that uses GTK for its UI, but also the Vulkan API to render a 3D model. Ideally I'd like to use the gtkmm C++ wrapper for GTK, and the Vulkan C++ API.
What ways do I currently have to do this?
I know that I can get a Vulkan context using SDL2 and other similar low level libraries, and I can get an OpenGL context using GTK. But I haven't found resources for combining these two approaches.
To start, I'm not limited to developing on or targeting any particular Linux distribution. Although any insights into why a particular environment makes this easier or more difficult are appreciated.
Edit:
I'm aware of this question: What is the Vulkan equivalent of the GtkGLArea widget (GTK+)?
However, many months have passed since its most recent update. My Google searching does not indicate that the state of affairs has changed, but I would like to be proven wrong. In addition, I intentionally phrased my question more broadly. I don't necessarily want just a GtkVulkanArea widget. I want to know of any valid way to combine Gtk and Vulkan. For example, is it possible to embed a Gtk event loop and widgets in an SDL2 window? What about the other way around? Again, my Google searching has not been very helpful, and I hope someone knowledgeable on this topic will answer.

Related

Use multiple graphical windows in OCaml

OCaml comes with the Graphics module which allows the use of a graphical window.
Is it possible to open two graphical window, and switch between them ?
The Graphics module provides machine-independent tools but in case of a negative answer, perhaps it would also be interesting to have solutions for different window system, such as X11.
I looked through the Graphics module API and I don't see support for multiple windows. I would assume Graphics was intended as something useful but simple enough to be part of the base OCaml release.
For more complex graphics, it makes sense just to provide OCaml bindings to an existing library. If I go to opam.ocaml.org/packages and search for "graphics" I see a few possibilities.
I have done OpenGL coding in OCaml but in fact I had to build some wrappers for OS-native GUI functionality to create the windows. This was many years ago, however.
The Graphics module is quite limited and is more intended as a simple basic library for teaching purposes. A possible replacement for Graphics might be the tsdl package which is a thin wrapper around the SDL C library which should work on most platforms.

OpenGL directly to Linux framebuffer without X-Server

I have a small OpenGL application that has been developed using GLUT. What are my best options to render directly to a Linux framebuffer (fbdev) with OpenGL, without an X-Server? I understand that GLUT needs X, so I'm not looking for ways to use GLUT without X.
The framebuffer device I intend to use is confirmed working with fbi and mplayer.
I have done (or I'd like to think that I have done) a pretty exhaustive research, and found some resources and libraries that might work. But most of the info is a bit outdated, and I'm not sure what to trust.
DirectFB looks good, exactly what I'm looking for, but does not seem to be in active development.
I'm inclined to try this out on my target device: https://github.com/mcdoh/glGears-on-DirectFB-with-OpenGL-ES - but again, this is the only example code I can find, and it's six years old.
Mesa is another interesting candidate, but I can't seem to find any recent information.
This looks interesting: http://www.mesa3d.org/glfbdev-driver.html - but I can not find any example code to go from.
So, while a lot of SO answers mention DirectFB and Mesa as solutions, I can't bring myself to be confident in those options while so little material can be found.
So, if you can point me in the right direction here, give me any examples to go from, that would be highly appreciated. What am I missing?
Edit due to question being marked as duplicate:
The answer to the related question recommends using DRM. I intend to run my code on an Allwinner H3-based embedded computer that does not yet support the mainline Linux kernel. Currently, it's running on kernel version 3.14, which I believe does not have DRM support.
So, are there any alternatives?

Lowest common denominator GUI library on unix/Xserver

I want to code a primitive, DE independant application. Hence I want to be independant of Qt and GTK. What is the next lower library below Qt/GTK. I mean what is the lowest common denominator that is used by either of them and is available on every graphical linux system.
The X11/Xorg server is used by both Qt, GTK, and pretty much every GUI toolkit out there (FLTK, etc...), so it is the "lowest common denominator" you're talking about. You can use it directly with the XCB or Xlib library.
There is no such common library.
If you are writing a desktop app (i.e something you expect the user to interact with through their usual windowing system) my advice would be to use either QT or GTK - choice is yours.
There are some other reportedly simplier 'lightweight' libraries you can use such as EFL (Enlightenment) and TK (i.e. Old school tcl/tk apps haven't seen one of these for years). Or you could even use something more exotic like Motif (for that cutting edge mid 90's unix workstation CDE look and feel) - I hear that is open source now (finally).
For a full screen app like a game I believe you can use SDL or maybe ever write out directly to Linux's frame buffer device - I can't really offer anything here I have no experience.
There is no gurantee any of these libraries will be available on any given Linux installation. Thankfully package management exists to take care of this for you. Write the app publish the source and the make files. If people find it useful and want it in their distribution someone will package it for you.
If you are making a closed source binary you are left with static linking.

python3 tkinter or ncurses

I want to impliment some kind of UI for my Python programs (some simple operations, nothing advanced).
So I looked around and considered ncurses and tkinter for python. Yet I am not sure which of these two would suit best my needs for a simple interface (in the sense of easy to learn to program) with the best output possibilies. It does not have to be fancy or anything, just help me visualise my code (lets say a text based chess game).
intuitively i would take tkinter, but could you probably just summarise for me the advantages of the two UIs? (in addition ncurses does not seem to have a good tutorial for python...)
Thank you in advance!
I would like to suggest tkinter as it comes with python and compare to other GUI packages it has good tutorials. And also it will help you to improve your OOP concept for python
If you plan on using your application across platforms, Tkinter or PyQt are both good choices. If you want a GTK+ application that matches your GNOME environment and don't plan on using the application on other platforms, then I would suggest using GTK+ via gobject-introspection (from pygobject). In Fedora, you should have support for it out of the box. Other distributions may require the installation of additional packages.
For more information on the above bindings, see:
TkDocs
The Python GTK+ 3 Tutorial
(Sorry I couldn't post a link for PyQt because I don't have enough reputation to post more than 2 links.)
Additionally, it's worth noting that both PyQt and GTK+ have interface designers available so that you don't have to create your interfaces programmatically if you don't want to. For PyQt I believe Qt Creator comes with an interface designer. For GTK+ you have Glade.

How is scrolling supported in Linux graphical environments like GNOME and KDE?

I'm curious to know: is scrolling (such as in Firefox, Nautilus, etc.) handled be each application separately? Or is it done by the environment? Or by the widget toolkit?
What confuses me, is that it is possible to change to "smooth scrolling" in Firefox, which makes it seem like each application handles its scrolling separately. However, when writing software for Linux, you don't really need to specify and it seems like GTK takes care of it on its own.
The reason I'm curious is because I wanted to know if Linux could have it's own "accelerated" scrolling, much like OS X. I know this is possible by app, because Google Picasa has its own built in.
To make this possible for the entire system, does GTK need to be modified? Or something else?
Most applications rely on their toolkit for scrolling behaviors.
Firefox does a lot of stuff by itself, partly because it runs on various platforms with various toolkits (not just GTK), and partly because it has advanced needs that aren't always met by whatever toolkit it happens to be using.
GTK is far from the only toolkit used on Linux. There is also Qt (which is used in KDE), wxWidgets, Tk, FLTK, Motif clones, Xt, and you can even build applications on Xlib itself without a toolkit.
You're using two different terms, "smooth scrolling" and "accelerated scrolling". These are not the same thing, and the latter is technically ambiguous.
There is absolutely nothing preventing Linux (really X) applications from having any particular scrolling behavior. It's up to the application and/or its toolkit, if it relies on one.
Regardless of the above, keep in mind that not everyone agrees that the scrolling behaviors you allude to are good.

Resources