# OpenGL

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

From wikipedia:OpenGL:

  OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics.

Learn more at Khronos.

## Installation

To run any application that uses OpenGL you will need to install driver(s) for your hardware (either GPUs or CPUs)

- mesa is an open-source OpenGL implementation, continually updated to support the latest OpenGL specification. It has a collection of open-source drivers for Intel graphics, ATI, AMD, AMD PRO, and NVIDIA GPUs and also provides software rasterizers, The included drivers in the package are
  - `i915` : for GMA 916G as well as the i830, i845 and i865 integrated GPU series.
  - `i965` : for Intel's Gen 4 hardware and later. It's officially supported by Intel.
  - `iris` : for Intel's Gen 8 hardware and later. It's officially supported by Intel.
  - `r100` : for AMD's Radeon R100 GPU series.
  - `r200` : for AMD's Radeon R200 GPU series.
  - `r300` : for AMD's Radeon R300, R400, and R500 GPU series.
  - `r600` : for AMD's Radeon HD 2000 GPU series and later. It's officially supported by AMD.
  - `radeonsi` : for AMD's Southern Island GPUs and later. It's officially supported by AMD.
  - `nouveau` : Nouveau is the open-source driver for NVIDIA GPUs.
  - `virgl` : is a virtual GPU driver for sharing a GPU with a host for virtual machines.
  - `svga` : for VMware virtual GPUs.
  - `zink` : is a Gallium driver, it can be used to run OpenGL on vulkan.
  - `swrast` : Legacy software rasterizer.
  - `softpipe` : Software rasterizer, a reference Gallium driver.
  - `llvmpipe` : Software rasterizer, uses LLVM for x86 JIT code generation and is multi-threaded.
  - `swr` : High performance software rasterizer that uses AVX and AVX2 CPU instructions, also known as OpenSWR.

Note: The right driver for mesa should be selected automatically, you do not have to configure it, just install the package.

- nvidia-utils is proprietary driver for NVIDIA GPUs.

- amdgpu-pro-libglAUR is proprietary driver for AMD PRO GPUs.

Tip:

- For AMD (and ATI) it is recommended to use the open-source driver unless you have a very strong reason to use proprietary one.
- For NVIDIA installing the proprietary driver is mostly better for newer cards or better performance in general.

## Verification

To verify your OpenGL installation you can use mesa-demos `glxinfo` and you should get output like this :

    $ glxinfo | grep OpenGL

    OpenGL vendor string: X.Org
    OpenGL renderer string: AMD RV620 (DRM 2.50.0 / 5.10.12-arch1-1, LLVM 11.0.1)
    OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.3.4
    OpenGL core profile shading language version string: 3.30
    OpenGL core profile context flags: (none)
    OpenGL core profile profile mask: core profile
    OpenGL core profile extensions:
    OpenGL version string: 3.0 Mesa 20.3.4
    OpenGL shading language version string: 1.30
    OpenGL context flags: (none)
    OpenGL extensions:
    OpenGL ES profile version string: OpenGL ES 3.0 Mesa 20.3.4
    OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
    OpenGL ES profile extensions:

(with different values depending on your setup of course)

From the same package you can also try `glxgears`, you should see 3 rotating gears.

## Switching between drivers

For Hybrid graphics you might want to see PRIME.

Note: According to a reddit post can have 2 GPUs from different vendors working concurrently just fine.

### Mesa

You can override used driver using the following environment variable:

    MESA_LOADER_DRIVER_OVERRIDE=driver

By default mesa searches for drivers in `/lib/dri/` you can see the list of drivers by

    $ ls /lib/dri/

`driver` is the name of the driver without `_dri.so`. If it failed it will fallback to llvmpipe.

You can also use OpenGL software rasterizer drivers by setting the following environment variables:

    LIBGL_ALWAYS_SOFTWARE=true
    GALLIUM_DRIVER=driver

`driver` is one of `softpipe`, `llvmpipe`, or `swr`.

Tip: As of the time of writing this llvmpipe & swr are faster than softpipe.

## Development

Note: This section is for developers who wants to use OpenGL. End users do not need any thing from this section.

Using OpenGL in code requires functions loader, read more at Khronos.

This article or section needs expansion.

Reason: Put list of packages relevant to OpenGL and in Arch repo (Discuss in Talk:OpenGL#)

### OpenGL Hardware Database

GPUInfo provides user reported GPU/driver combinations, supported extensions, capabilities, etc.

Categories:

- Graphics
- Development

Hidden category:

- Pages or sections flagged with Template:Expansion