How does the graphical interface work from the application to the hardware level?

I do GUI programming and do some research. Now everything is not clear to me. If I use GTK + as a toolkit, how does it interact with a graphics card?

On a Linux system, I assume it will be GTK -> X Server - (OpenGL) -> graphics card. Is it correct?

I read that some GUIs directly draw OpenGL (like Blender3D), so how do other applications draw their GUIs?

If only Direct3D and OpenGL APIs (which I know) are available for graphics cards, what is the difference between software rendering and hardware acceleration?

Can software that performs “software rendering” write directly to the framebuffer of the video card so that OpenGL is not affected?

PS: sorry for many questions, but I really don't understand how it all works, thanks for every answer :)

+7
source share
2 answers

On a Linux system, I assume it will be GTK -> X Server - (OpenGL) -> graphics card. Is it correct?

Not. GTK + on Linux goes

/-[ if direct context ]---\ /--> OpenGL >-+---------/ \ / \-> GLX -+--------------\ \ / \ \ \ GTK+ -+-> cairo >-+---> XRender >--------+----+-> Xlib/xcb >-+-> X server >-+-> Kernel Module >-> GPU \ \–-> pixmap buffer >–/ \ / \―---------------------------/ 

I read that some GUIs directly draw OpenGL (like Blender3D), so how do other applications draw their GUIs?

It's just a Blender (no 3D trailing). The Blender GUI tool uses OpenGL as the only backend, yes. But the GUI is not directly drawn using OpenGL, which will be simply burdensome to work with (draw each button using OpenGL calls. The blender has its own toolkit. GTK + is another toolkit but not tied to Blender (in fact, one of my home projects extracts the Blender GUI toolkit so that it can be used in independent projects).

Tool kits such as GTK + and Qt are designed for maximum portability. A blender has the luxury of knowing that OpenGL will be available. Applications developed for GTK + or Qt can work on systems that do not support 3D, so the design of GTK + and Qt allows you to work on multiple servers. GTK + now in version 3 uses the Cairo graphics engine as a graphics server. Cairo again has its own servers, namely a software rasterizer, drawing in pixel images (pixel images) or proxy drawing commands in a basic graphics architecture. In the case of Cairo on Linux, it can be either OpenGL or X11 (kernel extensions and XRender protocols).

If only Direct3D and OpenGL APIs (which I know) are available for graphics cards, what is the difference between software rendering and hardware acceleration?

Neither OpenGL nor Direct3D talk to the graphics card. They are talking to the drivers of the video card. Thus, you would have the choice of talking to the drivers themselves, bypassing OpenGL and Direct3D. But why do you have to do this? This is tiring.

On Windows, you also have GDI and / or WPF (Windows Presentation Foundation) for drawing files and Direct2D.

On Linux, you get the X11 protocol and the XRender extension protocol for drawing beautiful images.

Another growing API is OpenVG, which aims to standardize all of these 2D drawing APIs. And, at least on Linux, OpenGL and OpenVG were chosen to be the only long-term abstract drawing APIs available, with some window system for managing the framebuffer and user input. There Wayland in development (which I don’t like at all) and X11, which, in my opinion, has the best design (this is a network system that allows distributed execution, which I consider very important in the future), but needs a complete review of which “X12” - cleans up obsolete toughness, includes it in the contact color space, switches connections (so that you can transfer clients between X servers, which would allow a much more elegant way to block X sessions by moving all connections to some shadow Server X, instead of trying to block access using a screen saver).

Can software that performs “software rendering” write directly to the framebuffer of the video card so that OpenGL is not affected?

Not in a modern operating system. However, the OS can provide you with abstract access to the graphics card through some framebuffer API (/ dev / fb0 on Linux). However, the framebuffer is unmanageable, so if there is an X server or Wayland, any of them are in the task of managing the FB, and then it's not your business.

+11
source

Can software that performs “software rendering” write directly to the framebuffer of the video card so that OpenGL is not affected?

Not entirely or more accurately, depends on the driver. This is not that display systems such as XServer or equivalents of Windows and OSX actually use the API, but rather describe the API (more precisely, the driver model or, in the case of XServers, one of several models such as XAA, EXA, UXA and DRI) which display driver should satisfy.

Everything that is not defined in these models must be performed in the "software" and calculated on the processor, in addition, some of the operations defined by the models can also be calculated on the processor by the driver.

OpenGL was a completely separate standard from these models, and graphics drivers did not have to implement OpenGL at all to use the OS. But with the constant integration of 3D graphics and a complex layout in modern OSs, driver models began to rely on the same paradigms as OpenGL and DirectX. For example, ouright WDDM requires DirectX9 support.

+1
source

All Articles