1. Overview
OpenGL (Open Graphics Library) is a cross-platform application programming interface (API) for rendering video graphics and is used in most GPU-related video processing tasks. Therefore, it’s essential to know how to check whether it’s working correctly.
In this tutorial, we’ll learn how to check OpenGL status on a Linux machine using the glxinfo command.
2. Install the glxinfo Tool
glxinfo (Graphics Library Extension Information) provides information about the mesa driver, which is the open-source implementation of the OpenGL API.
Of course, to use the glxinfo command, we first need to install the mesa-utils package using the apt command:
$ sudo apt install mesa-utils
Once it’s installed, we can start using glxinfo.
3. Check Direct Rendering Support
To check if OpenGL works correctly on our system, we’ll need direct rendering support. For that, we use the glxinfo command, and we leverage grep to get the portion that contains the string direct rendering followed by a colon:
$ glxinfo | grep 'direct rendering:'
direct rendering: Yes
As we can see, direct rendering is supported here, This means the local system is using 3D acceleration, which tells us that OpenGL should also be working.
4. Check OpenGL Renderer
Although the above command should be sufficient in most scenarios, we may still face OpenGL performance issues in some cases.
So, we can also check if our OpenGL renderer selects the correct graphics card. For that, we use the glxinfo command, and we grep the portion that contains the text OpenGL renderer string:
$ glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: Mesa Intel(R) HD Graphics 530 (SKL GT2)
As we can see, the renderer uses Mesa Intel(R) HD Graphics 530. This is the name of the graphics card. Thus, OpenGL should work without performance issues in this case.
Let’s now look at how the output might look if there’s a problem:
$ glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: Software Rasterizer
As we can see, the renderer no longer utilizes the graphics card here, but instead uses Software Rasterizer. This means that the CPU is doing the video rendering, which may cause OpenGL performance issues.
In this case, we need to check if the graphics card is properly connected, verify that there aren’t any issues with its drivers, and confirm that the hardware acceleration components are in place.
5. Conclusion
In this article, we looked at ways to check if OpenGL works correctly on a Linux machine.
Initially, we learned how to check direct rendering support via the glxinfo command. After that, we looked at OpenGL renderer to see which graphics card it uses. Finally, we saw an example case with a failing hardware rendering.