# Introduction

The Mesa Demos package contains a large number of OpenGL demonstration and test programs.

These programs were previously distributed as the MesaDemos-x.y.z.tar.gz package released in conjunction with the MesaLib-x.y.z.tar.gz package. The demos are separated now since they don't change often and aren't tied to a particular version of Mesa.

Note that the Mesa demos should be usable with any OpenGL implementation; not just Mesa.

# FTP site

The latest version of the Mesa demos can be found on the freedesktop.org FTP site.

# Git Repository

The Mesa demos git repository can be obtained with:

    git clone git://anongit.freedesktop.org/git/mesa/demos

Or, if you're a developer:

    git clone git+ssh://USERNAME@git.freedesktop.org/git/mesa/demos

# Building

The Mesa demos can be built with autoconf or CMake.

## Prerequisites

You'll need glew version 1.5.4 or later and glut or freeglut (runtime libraries and header files).

If you're using an RPM-based Linux distro you can install these items with:

    yum install glew glew-devel
    yum install freeglut freeglut-devel

And if you're using a Debian based Linux distro you can install these items with:

    apt-get install libglew-dev freeglut3-dev

## Autoconf

Run ./configure --help to see the options available for building the demos.

Otherwise, just run ./configure ; make to build the demos.

## CMake

See the CMake documentation for more information about CMake.

### Unix

Run:

    cmake .
    make

### MSVC

- Start the CMake GUI.
- Specify where this source is and where to build the binaries.
- Click Configure.
- Specify where GLEW and GLUT headers and libraries are; specifically via the GLEW_INCLUDE_DIR, GLEW_glew_LIBRARY, GLUT_INCLUDE_DIR, and GLUT_glut_LIBRARY variables.
- Click Generate.
- Open the generated mesademos.sln Visual Studio solution file and build the target ALL.

### MinGW cross-compilation

Create a Toolchain.cmake file containing:

    # the name of the target operating system
    set (CMAKE_SYSTEM_NAME Windows)

    # which compilers to use for C and C++
    set (CMAKE_C_COMPILER i586-mingw32msvc-gcc)
    set (CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
    set (CMAKE_RC_COMPILER i586-mingw32msvc-windres)

    # here is the target environment located
    set (CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)

    # adjust the default behaviour of the FIND_XXX() commands:
    # search headers and libraries in the target environment, search
    # programs in the host environment
    set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Create a Cache.cmake file containing:

    set (GLEW_INCLUDE_DIR "/path/to/glew/include" CACHE PATH "" FORCE)
    set (GLEW_glew_LIBRARY "/path/to/glew/lib/libglew32.a" CACHE FILEPATH "" FORCE)

    set (GLUT_INCLUDE_DIR "/path/to/glut/include" CACHE PATH "" FORCE)
    set (GLUT_glut_LIBRARY "/path/to/glut/lib/libglut32.a" CACHE FILEPATH "" FORCE)

Then do:

    cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=/path/to/Toolchain.cmake -C /path/to/Cache.cmake
    make
    make install

Read this for more information about CMake and MinGW cross compilation.

# The Demos

Look in the src/ directory for these sub-directories, among others:

- demos - the original Mesa demos, such as gears, gloss, etc.
- redbook - the OpenGL Programming Guide demos
- samples- original SGI OpenGL demos
- glsl - OpenGL Shading Language demos
- gs - Geometry shader demos
- xdemos - GLX-based demos
- egl - EGL-based demos
- wgl - WGL-based demos
- fp - fragment program tests
- vp - vertex program tests
- data - data files used by the demos
- perf - performance tests
- tests - assorted test programs
- objviewer - program to view .obj modes with a skybox

# Getting Help

If you have trouble building or using the Mesa demos, you can post to the Mesa users mailing list.

If your question is especially technical, you can try the to the Mesa dev mailing list.

# Reporting Bugs

Bugs in the demos can be reported to the Mesa bug database. Choose Component="Demos" in the drop-down list.