Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between X-Windows, wxWidgets, GTK/Qt and OpenGL? [closed]

I've been doing console programming for a few years, and now it's about time that I learned a little about the fascinating world of GUIs. I've dabbled a little in wxWidgets; compiled a Hello World program, played around with it a little, etc.

Now I'm one of those people who have the "low-level curse": I'm not happy with knowing how to use something to good effect - I want to know what's going on under the hood, even if it's of little or no practical value.

So I've been reading up on the subject (e.g. here), but I'm finding it hard to wrap my head around all the different systems, toolkits and what they do. So far I've figured out that (please correct me if I'm wrong):

  • Linux itself is "just" a Kernel; it does not provide GUI support (?).
  • The X Window system is at the base of GUIs on most UNIX-like systems.
  • GTK is a GUI toolkit, Qt contains a GUI toolkit. GTK and Qt are at the same "level" (?).
  • Gnome is a desktop environment built on GTK, KDE is built on Qt.
  • wxWidgets is a library that wraps around (?) lower-level toolkits, like GTK, thus providing cross-platform benefits.
  • OpenGL is an API for rendering 2- and 3-D vector graphics.

Now for some questions: sticking to UNIX-like systems:

  1. Who's at the bottom of it all?, i.e. which component renders the bitmap that is eventually displayed on the screen?
  2. Is this done through OpenGL? If so, who calls OpenGL? And how was it done on older PCs without graphics cards?
  3. If you wanted to be really stubborn, how low can you go? What's the most primitive API that you could program a GUI at? X11? OpenGL? (please don't say logic gates :)).

For a bonus, maybe what about the Windows OS? Does it follow similar structure at all, or does it go completely its own way?

like image 303
MGA Avatar asked Apr 23 '14 19:04

MGA


People also ask

Which is better Qt or GTK?

After a rewrite, the toolkit became GTK+ and saw release in 1998. Unlike Qt, people had the freedom to edit, modify, and share GTK+ from the beginning. While Qt is in some ways a more versatile and adaptable toolkit, a community consolidated around GTK+ during these early years.

Does GTK use OpenGL?

now that GTK+ supports OpenGL natively (at least on Linux and Windows) it's probably a good time to show how to properly use OpenGL with GTK+.

Does Windows use Qt or GTK?

Windows does not use either QT or GTK+. These are Open Source graphics/UI toolkits and Windows as we all know very well is not open source.

Does wxWidgets use GTK?

wxWidgets/GTK+ requires the GTK+ library to be installed on your system. It has to be a stable version, preferably GTK+ 2. x.y, where x is an even number. GTK+ version 1.2 is highly discouraged, but if you decide to still use it, please use version 1.2.


1 Answers

  1. The X server, explaining that itself would take more than 10k words. Not suitable for an SO answer. Read the code and have your eyes explode. Bare X is applicable for software rendering. OpenGL can be used in two different ways in that context (see image below).

  2. No. This depends on X. X is just yet another library which can implement its drawing primitives as its developers desire. But X itself is a hugely complex beast with its ridiculous number of extension which makes today's X function as it does (without there would be no OpenGL support, just as an example, no xrandr).

  3. It depends on how much pain you are willing to take. You surely can draw X primitives or OpenGL primitives on your screen, but its not the 80s anymore.

Gtk+/Qt are abstractions of OS specific APIs (X/Wayland/W*) to lessen the pain creating GUIs and reduce the amount of code to write. These abstractions themselves are of high complexity and spane thousands of lines of code (just have a look at GtkTreeView Klass which Gtk+ provides). So instead of drawing pixels you can now just define Buttons and Layouts and Packing of Widgets.


So from this wiki article you can get a basic overview of just the GLX extension to the X proto:

GLX

Also have a look at the overview of how drawing is done with X

Be warned that this will hopefully be obsolete a couple of years from now, if wayland and or Mir do jumpstart. Those are totally different stories to tell.

like image 181
drahnr Avatar answered Oct 13 '22 19:10

drahnr