Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting to learn OpenGL. On modern Linux, how are all these concepts related?

I'm starting to learn OpenGL since that's a part of my chosen master's degree program. In class, accelerated 3D graphics is practiced on MS Windows (maybe DX3d is actually used instead of OpenGL, not sure). However, I've been using Linux for years now, and I'm positive that it's the right development environment to use, when you're free to choose. But, as far as I know, accelerated 3D, in particular the drivers and hardware support, are a mess on Linux. So, please help me to organise the following pile of concepts into a reasonable structure, since that's about the only way I can see and understand things.

  1. First, there are the drivers. NVIDIA and AMD proprietary, plus "nouveau" and some open Radeon driver, as well as an experimental AMD open but still official one. That seems to be clear.

  2. Second, there is something called "mesa". What is that? Is it only defined for the free drivers, is it a part of the free driver project, or is it defined and required regardless of the kind of driver used?

  3. In development of 2), what exactly is "opengl" and where is it contained: mesa, drivers, something else? Can it be proprietary?

  4. Finally, given all the three points above, what does it mean "to obtain and install OpenGL on a modern Linux system?

like image 451
iksemyonov Avatar asked Mar 13 '23 14:03

iksemyonov


1 Answers

OpenGL is an interface. To use it, you need an implementation. There are many implementations of OpenGL. Because each implementation is different, your program will behave differently when you run it with different implementations, even though your program is the same. A typical OpenGL implementation with a hardware renderer will consist of some code that runs in user space (a dynamic library), code that runs in the kernel (the device driver), code that runs in your X.org server (the DDX driver), and code that runs on the graphics card itself (the firmware). That's four different pieces of code!

AMD and nVidia provide proprietary OpenGL implementations for Linux. These implementations have closed-source drivers which taint the kernel, which means that if something goes wrong, the Linux developers can't help you. They support recent OpenGL versions (e.g. 4.5, if your hardware is capable) with the full compatibility profile support.

Mesa provides an open-source OpenGL implementation for Linux. This implementation can use the Noveau or Radeon open-source drivers, which do not taint the kernel. Mesa also has a software implementation, called llvmpipe, which runs on your CPU only and doesn't need drivers. It's impressively fast for what it is, but it is much slower than even an outdated hardware implementation. Mesa recently started supporting OpenGL 4.x series, but it will take some time before it filters through distro release cycles, so you're more likely to see OpenGL 3.3--and that's only for the core profile, you're limited to 3.0 with the compatibility profile (similar to how it works on OS X).

Because Mesa developers have limited access to documentation about the graphics cards, and limited development resources, the Mesa implementation on your AMD or nVidia card is usually slower than the vendor's implementation, and it usually supports fewer OpenGL extensions. However, the Mesa implementation is very solid, it doesn't taint your kernel, and some of the Mesa implementations are even Valgrind-clean.

Installing OpenGL just means installing an OpenGL implementation on your system (you know, with dnf or apt or whatever). This usually means a choice between the vendor implementation and the Mesa implementation... except for Intel integrated graphics, where Mesa is the vendor implementation.

like image 186
Dietrich Epp Avatar answered Apr 06 '23 23:04

Dietrich Epp