OpenGL within Xgl???

Xgl is the layer between your X-Server and your Compositing Window Manager (Beryl or Compiz) that allows you to enjoy fancy 3D and true transparency effects. The whole is processed by your Graphic card (instead of your CPU when using xcompmgr for example).

That all sounds good, until you try to start an OpenGL game within Xgl. Personnaly, I’m using Compiz in Ubuntu, and when I start for example Enemy Territory, it will never go full screen, whatever the options or the resolution you define. Moreover, OpenGL applications will only run via Indirect Rendering where they normally use DRI (Direct Rendering Interface) to bypass slow X commands. Because the desktop is already using DRI for himself, he is blocking it for other applications, meaning slower performance.

A simple workaround is to start another X-Server (:1 for example), and start your OpenGL applications directly within that X-Server (it will then be able to use that DRI stuff). The following script will do that for you:

#!/bin/bash

# Name: Xgames
# What: this script starts an additional Xserver within
#	which the command in argument will be started
#	The goal is to play full screen OpenGL games
#	when using Beryl or Compiz
# Author: harck - jerome.harckmans.be
# Date: 29 Apr 2007

# Check arguments
if [ $# -lt 1 ]; then
	echo "USAGE: $0 <command to start> ( <arguments to command> )"
	echo "Exiting..."
	exit 1
else
	echo "Starting. Press CTRL-ALT-DELETE after exiting the game"
	sleep 2
fi

# Start additional Xserver
# An alternate config file is used to load
# game dependent settings
sudo X :1 -ac -br -config /etc/X11/xorg_games.conf &
# Give some time to the user to enter password...
while [ ! -f "/tmp/.X1-lock" ]; do
	sleep 1
done

# Set the new started Xserver as default display
export DISPLAY=localhost:1
sleep 1

# Start the commands given in arguments
# We go until $5 because some games need arguments too
$1 $2 $3 $4 $5
sleep 1

# Exiting
exit 0

Comments are closed.