What is the difference between OpenGL and XRender in KDE Desktop Effects?

Nejat picture Nejat · Mar 11, 2014 · Viewed 40.7k times · Source

In KDE environment when you go to Desktop Effects and in the Advanced tab there is an option named "Compositing type" which can be set to OpenGL or XRender.

  1. What is the difference between these two options?

  2. What's the use case of each option?

Answer

datenwolf picture datenwolf · Mar 11, 2014

OpenGL and XRender are both drawing APIs that allow for applications of certain geometrical transformations while doing so.

OpenGL is targeted at drawing operations to be executed by a dedicated graphics processing unit (GPU) and provides many features that make generating a 3D-looking image very easy (depth buffer, depth testing, 4×4 homogenous transformation matrices). But you can do 2D looking graphics as well with OpenGL.

XRender is an extension to the X11, to support methods of rendering (antialiasing, alpha blending) that are not possible to do with the core X11 drawing functions. The XRender-API is optimized for 2D looking graphics, though (no depth buffer/test, 3×3 transformation matrices).

Note that XRender is not perfectly orthogonal to OpenGL. Epecially if you need antialiasing in OpenGL you have to use a few functions from XRender to enable it.

What's the use case of each option?

The option of XRender is there to support systems for which there is no proper OpenGL support (lack of stable drivers), but acceptable support for XRender operations. Also XRender is a bit easier to setup (from a programmers point of view) than OpenGL.

In general OpenGL is more flexible than XRender from a programmers perspective. If you're asking which of each you should choose: Start with OpenGL and if everything works acceptable stick with it. The XRender option is a fallback if OpenGL doesn't work properly (however since nowadays in the drivers XRender shares a large part with OpenGL, or is actually implemented using OpenGL it makes no practical difference any more).