NVIDIA Jetson Linux Developer Guide
32.4.3 Release


Graphics Sample Application

NVIDIA Graphics Sample Applications
Building the Samples
Starting the Graphics System
Running the Sample Applications
Upstream Sample Application: Gears
This topic contains information about several sample applications that are provided with NVIDIA® Jetson™ Linux Driver Package (L4T).

NVIDIA Graphics Sample Applications

NVIDIA graphics samples are included in L4T. This topic gives detailed steps for building and running these samples on the target.

Building the Samples

The sample source files are available in the directory /usr/src/nvidia/graphics_demos. The samples currently provided are:
The sample applications may be built on either the host or the target. The file /usr/src/nvidia/graphics_demos/README contains instructions for building the sample applications on either system.
L4T also provides pre-built binaries for all of the sample applications under all three supported graphics systems. The pre-built binaries are at:

Starting the Graphics System

This section describes the procedure for starting your preferred graphics system as a prerequisite for running sample applications.
X11 (X Window System)
Before you can run X11 graphics sample applications you must start the X server in the background. You must also export the DISPLAY variable, which the X driver uses to launch sample applications on the selected display.
1. Enter these commands to export the DISPLAY environment variable and start the X server.
$ export DISPLAY=:0
$ xinit &
2. After you start the X server, open a terminal window (i.e. launch an instance of xterm).
Before you can run the Wayland graphics sample applications, you must first stop the X server (which is running by default) and then launch Weston either by running the Weston binary (/usr/bin/weston) from the root user or by running the Weston-launch binary (/ usr /bin/ weston -launch).
To run the Wayland graphics sample applications
1. Enter these commands to stop the X server:
$ sudo systemctl stop gdm
$ sudo loginctl terminate-seat seat0
$ sudo pkill -9 X
2. Enter these commands to run Weston from the root user:
$ sudo su
$ unset DISPLAY
$ mkdir /tmp/xdg
$ chmod 700 /tmp/xdg
$ export XDG_RUNTIME_DIR=/tmp/xdg
$ weston --idle-time=0 &
3. Enter these commands to run Weston using weston-launch as a non-root user. These commands need be entered only once after booting:
$ sudo groupadd weston-launch
$ sudo usermod -a -G weston-launch $USER
$ sudo chown root /usr/bin/weston-launch
$ sudo chmod +s /usr/bin/weston-launch
$ weston-launch
Before you can run EGLDevice graphics sample applications you must ensure that no display server or compositor is running, since EGLDevice applications are started by default on the default CRTC plane and communicate directly with the display using EGLOutput Ext. For more information, see:
If you want to start sample applications on an overlay plane, use the sample applications’ ‑layer option.

Running the Sample Applications

To run a sample built on the target, run the sample from the appropriate subdirectory of the samples directory for your chosen graphics system.
For example, to run the pre-built version of gears:
$ cd /usr/src/graphics_demos/prebuilts/bin/<graphics>
$ ./bubble
Where <graphics> is x11, wayland, or egldevice.
The sample application presents a rendered screen on the display and prints a run log on the terminal that shows the display rate in frames/second:
Alpha value specified for constant blending is not in range [0, 1]. Using alpha 1.0.
Demo Mode: 1920 x 1080 @ 59
running for 5.000000 seconds...
To stop a sample application, press Ctrl+C.

Upstream Sample Application: Gears

The Gears application is an example of an upstream graphics sample application. It is not an NVIDIA application, and distinct from the NVIDIA sample applications in some ways.
To install and run the Gears application
1. Boot the target system with an Ethernet connection.
2. Enable package download from the “universe” repository by editing /etc/apt/sources.list as root:
$ sudo vi /etc/apt/sources.list
3. Uncomment the following line in the file by removing the leading # character:
# deb http://ports.ubuntu.com/ubuntu-ports/ bionic universe
4. Update the repository:
$ sudo apt-get update
5. Install the mesa-utils and mesa-utils-extra packages:
$ sudo apt-get install -y mesa-utils
$ sudo apt-get install –y mesa-utils-extra
6. Run the application with these steps:
$ export DISPLAY=:0
$ X&
$ /usr/bin/es2gears
$ /usr/bin/glxgears