Fun with Xorg

Chapter 5 of the FreeBSD Handbook provides an excellent overview for understanding and configuring the X Window system. Today's article goes beyond the Handbook to demonstrate some of the cool things you can do with your FreeBSD system and other systems running X.

Getting the Most out of your Video Card

While Xorg -configure does a good job of configuring video cards, the X drivers don't provide automatic support for DRI (Direct Rendering Interface), DRM (Direct Rendering Manager), or OpenGL (OPEN Graphics Library)--meaning you're probably not getting the most out of your video hardware.

The dri and linux_dri packages provide these missing features by installing FreeBSD kernel loadable modules for several cards:

Card/Chipset

Module Name

Intel i810

i810

Intel i830

i830 (not available in linux_dri)

Intel i915

i915

ATI Mach64

mach64

Matrox Gxxx

mga

ATI Rage128

r128

ATI Rage200

r200

ATI Rage300

r300

ATI Radeon

radeon

S3 Savage

savage

SiS 3xx

sis

Voodoo 3dfx

tdfx

Note: if you have a NVidia card and want to use the binary-only driver, instead make installthe nvidia-driver port as it needs to compile against your kernel.

Depending upon the software you have installed, these DRI modules may already be on your system. Check with the command:

# pkg_info | grep dri

If you receive your prompt back with no output, or the output mentions only linux_dri, install the dri package:

# pkg_add -r dri

Once you have it installed, add a few lines to the end of /etc/X11/xorg.conf:

Section "DRI"
Mode 0666
EndSection

Note: if that file doesn't exist, then:

# cp /root/xorg.conf.new /etc/X11/xorg.conf

Finally, double-check that Xorg will load dri and glx; if these lines don't exist, add them to the Section "Module" portion of /etc/X11/xorg.conf:

Once your driver successfully loads, start an X session as a regular user and check the OpenGL rendering capabilities from within the GUI:

% glxinfo | grep rendering
direct rendering: Yes

Once you have rendering enabled, add a line to /boot/loader.conf as the superuser so the driver automatically loads when the system boots. My line looks like:

r128_load="YES"

Replace r128 with the module name for your video card and double-check the file for typos.

3d-Desktop is an xgl-ish desktop switcher and a cool way to test your DRI:

# pkg_add -r 3ddesktop

Once installed, run it from the GUI as a regular user:

% 3ddesk

Use your arrow keys to rotate the cube of desktops and Enter or Space to bring a desktop into the foreground.

Nesting Xservers

When you install X, you get a whole suite of interesting utilities, many of which you may not be aware of. One of these is Xnest, which allows you to run multiple window managers simultaneously. Confirm that you have Xnest installed with: