Skip to content
Patricio Gonzalez Vivo edited this page Mar 14, 2024 · 24 revisions

1. Install dependencies

Ubuntu

sudo apt install git build-essential cmake xorg-dev libglu1-mesa-dev libncurses5-dev libncursesw5-dev

For video support (using FFMpeg library LIBAV), also do:

sudo apt install ffmpeg libavcodec-dev libavcodec-extra libavfilter-dev libavfilter-extra libavdevice-dev libavformat-dev libavutil-dev libswscale-dev libv4l-dev libjpeg-dev libpng-dev libtiff-dev

For supporting thumbnails creation of 3D models through GlslViewer:

sudo apt install xvfb

RaspberryPi OS (with X11/Wayland Window Manager)

sudo apt install git cmake xorg-dev libglu1-mesa-dev libncurses5-dev libncursesw5-dev 

RaspberryPi OS (without X11/Wayland Window Manager)

sudo apt install git cmake libgbm-dev libdrm-dev libegl1-mesa-dev libgles2-mesa-dev libncurses5-dev libncursesw5-dev libxcb-randr0-dev

Fedora

sudo dnf install git gcc-c++ cmake mesa-libGLU-devel libXi-devel libXxf86vm-devel libXrandr-devel libXinerama-devel libXcursor-devel ncurses-compat-libs ncurses-static libatomic
sudo yum install libXdamage-devel ncurses-devel
sudo ldconfig -v

For video support (using FFMpeg library LIBAV), also do:

sudo dnf install ffmpeg ffmpeg-devel

For supporting thumbnails creation of 3D models through GlslViewer:

sudo yum install xorg-x11-server-Xvfb

Arch

sudo pacman -S glu ncurses 

For video support (using FFMpeg library LIBAV), also do:

sudo pacman -S ffmpeg

For supporting thumbnails creation of 3D models through GlslViewer:

sudo pacman -S xorg-server-xvfb

2. Clone repository and submodules

git clone https://github.com/patriciogonzalezvivo/glslViewer.git
cd glslViewer
git submodule init
git submodule update

3. Compile

For any Linux X11 environment (uses of GLFW 3.0)

mkdir build
cd build
cmake ..
make
sudo make install

Note: If you are installing in WSL2, other users have pointed to this article as a useful resource

For NO X11 context (uses BROADCOM legacy drivers or DRM on Raspberry PI v4)

mkdir build
cd build
cmake -DNO_X11=TRUE ..
make
sudo make install

Note 1: Newer RaspberryPi distribution do have BROADCOM drivers but work only on DRM for that use -DFORCE_DRM=TRUE instead.

Note 2: If you are using GBM make sure on your /boot/config.txt you have the following lines present and/or un-commented:

dtoverlay=vc4-fkms-v3d
max_framebuffers=2
hdmi_force_hotplug=1

Note 3:: If you get this error:

Unable to get DRM resources
Unable to get DRM resources
Unable to get DRM resources
Fail to initialize EGL context from display /dev/dri/card0 try another.
glslViewer: glslViewer/deps/vera/src/window.cpp:645: int vera::initGL(WindowProperties): Assertion `EGL_FALSE != result' failed.
Aborted

Means it's using the wrong display. Raspberry Pi 4 and up have two of them you need to use the other through the -d or --display arguments to /dev/dri/card1. Like this

glslViewer test.frag -d /dev/dri/card1

Install GlslViewer as a screenSaver

Add GlslScreenSaver to run at the beginning of your session. Here you have two options:

Run gnome-session-properties, Click on Add and then fill the following data

Name:    GlslScreenSaver
Command: glslScreenSaver daemon

Should look like this 01

Or run gnome-tweaks, Click on Startup Applications then the + button and search for glslScreenSaver.

02

If you want to customize your own screensaver shaders copy /usr/share/glslViewer/glslScreenSaver.yaml to your home folder ~/.glslScreenSaver.yaml. Then edit it to choose how much time and what shader (o list of shaders) should run:

cp /usr/share/glslViewer/glslScreenSaver.yaml ~/.glslScreenSaver.yaml
nano ~/.glslScreenSaver.yaml

Make your own screensaver

  1. Duplicate any of the default shaders under ~/.glslScreenSaver/
  2. Edit it with your favorite code editor and then add it to ~/.glslScreenSaver.yaml
  3. Try it out by running:
glslScreenSaver

Note: If you are new to glsl shader you probably want to take a look to https://thebookofshaders.com/ to learn how to code them