# Building ParaView with EGL MESA

**URL:** https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016
**Category:** Tips and Tricks
**Created:** [May 3, 2023, 8:01pm UTC](https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016 "2023-05-03T20:01:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 3, 2023, 8:01pm UTC](https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016/1 "2023-05-03T20:01:29Z")

</div>

Note: This tutorial is inspired by [Building ParaView with GPU accelerated MESA](https://discourse.paraview.org/t/building-paraview-with-gpu-accelerated-mesa/1317) and relatively recent mesa improvements.

Before getting into details of Mesa graphics hardware drivers, a disclaimer. **If you have graphics hardware Mesa is _not_ your best option.** To get the best performance from your graphics card you’ll need to install the vendor provided driver. Vendor provided OpenGL drivers are typically much faster of a much higher quality than Mesa’s which can be quite buggy. Many distros now provide third-party non-opensource source drivers through specialized package repositories. The details of installing vendor provided drivers in beyond the scope of this document. Please consult distro and/or vendor-specific documentation.

If you want to build ParaView with EGL on Linux but you do not have access to a vendored EGL to use, you may want to use Mesa EGL for that !  
You probably already have access to Mesa EGL through your package manager and you can probably use that to build ParaView with EGL.  
Unfortunately, some OpenGL features may be disabled by your distro’s package maintainers to avoid patent or other licensing restrictions. If you find that this is the case and if for some reason you do not want to use your graphics hardware vendor software then you’ll likely want to build Mesa from source.

**1. Clone, Build and Install Mesa**

```bash
mkdir mesa
cd mesa
git clone https://gitlab.freedesktop.org/mesa/mesa.git src
mkdir build install
cd src
meson setup ../build \
  -D egl=enabled \ 
  -D gles1=enabled \
  -D gles2=enabled \
  -D platforms=x11 \
  -Dprefix=/absolute/path/to/mesa/install/ 
cd ../build
ninja install

```

**2. Download and Build ParaView with mesa**

```bash
mkdir paraview
cd paraview
git clone https://gitlab.kitware.com/paraview/paraview src
mkdir build
cd src
git submodule update --init --recursive
cd ../build
cmake -GNinja 
-DOPENGL_gl_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libGL.so \
-DOPENGL_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/GL \
-DOPENGL_EGL_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/EGL/ \
-DOPENGL_GLES2_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/GLES2/ \
-DOPENGL_GLES3_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/GLES3/ \
-DOPENGL_GLX_INCLUDE_DIR= \
-DOPENGL_egl_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libEGL.so \
-DOPENGL_opengl_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libGL.so \
-DOPENGL_gles2_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libGLESv2.so \ 
-DOPENGL_gles3_LIBRARY= \
-DOPENGL_glu_LIBRARY= \
-DOPENGL_glx_LIBRARY= \
-DOPENGL_opengl_LIBRARY= \
-DVTK_OPENGL_HAS_EGL=ON \
-DVTK_USE_X=OFF \
-DVTK_DEFAULT_RENDER_WINDOW_HEADLESS=ON \
-DPARAVIEW_USE_QT=OFF \
-DPARAVIEW_USE_PYTHON=ON
../src

```

Note : depending of your version of ParaView, some cmake options may be ignored. This is ok.

**3. Run pvpython to check rendering**

script.py:

```python
Sphere()
Show()
SaveScreenshot("shot.png")

openGLInfo = GetOpenGLInformation()
openGLInfo.GetVendor()
openGLInfo.GetVersion()
openGLInfo.GetRenderer()
openGLInfo.GetCapabilities()

```

```bash
 LD_LIBRARY_PATH=/path/to/mesa/install/lib LD_PRELOAD=/path/to/mesa/mesa/install/lib/libGL.so ./bin/pvpython script.py

```

You may have a warning about issues finding the right EGL device, you can select it by using the `VTK_EGL_DEVICE_INDEX` env var.

**4. Run pvserver**

```bash
LD_LIBRARY_PATH=/path/to/mesa/install/lib LD_PRELOAD=/path/to/mesa/mesa/install/lib/libGL.so ./bin/pvserver

```

Then just connect to it with another build of ParaView.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 3, 2023, 8:01pm UTC](https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016/2 "2023-05-03T20:01:40Z")

</div>

@jourdain

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [May 4, 2023, 1:30am UTC](https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016/3 "2023-05-04T01:30:18Z")

</div>

Thanks Mathieu, this is great. I will pass it around here at Sandia.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [May 4, 2023, 5:05pm UTC](https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016/4 "2023-05-04T17:05:38Z")

</div>

The common-superbuild now has a `standalone-mesa` project for building “just” Mesa. We use it to build Mesa SDKs for use in VTK wheel builds mainly, but if we can distill this down to a few flags there, that’d be great too.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 5, 2023, 7:42am UTC](https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016/5 "2023-05-05T07:42:27Z")

</div>

I may give it a go

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 11, 2023, 9:02pm UTC](https://discourse.paraview.org/t/building-paraview-with-egl-mesa/12016/6 "2023-05-11T21:02:55Z")

</div>

Here is a draft MR to add it, I will not spend more time on it I’m afraid.

[https://gitlab.kitware.com/paraview/common-superbuild/-/merge\_requests/562](https://gitlab.kitware.com/paraview/common-superbuild/-/merge_requests/562)
