kusano 7d535a

Installation

kusano 7d535a
kusano 7d535a

kusano 7d535a
To use the shared library version of GLEW, you need to copy the
kusano 7d535a
headers and libraries into their destination directories. On Windows
kusano 7d535a
this typically boils down to copying:
kusano 7d535a

kusano 7d535a
kusano 7d535a
kusano 7d535a
<tt>bin/glew32.dll</tt>    to    
kusano 7d535a
<tt>%SystemRoot%/system32</tt>
kusano 7d535a
<tt>lib/glew32.lib</tt>    to    
kusano 7d535a
<tt>{VC Root}/Lib</tt>
kusano 7d535a
<tt>include/GL/glew.h</tt>    to    
kusano 7d535a
<tt>{VC Root}/Include/GL</tt>
kusano 7d535a
<tt>include/GL/wglew.h</tt>    to    
kusano 7d535a
<tt>{VC Root}/Include/GL</tt>
kusano 7d535a
kusano 7d535a

kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
where <tt>{VC Root}</tt> is the Visual C++ root directory, typically
kusano 7d535a
<tt>C:/Program Files/Microsoft Visual Studio/VC98</tt> for Visual
kusano 7d535a
Studio 6.0 or <tt>C:/Program Files/Microsoft Visual</tt>
kusano 7d535a
Studio .NET 2003/Vc7/PlatformSDK for Visual Studio .NET.
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
On Unix, typing <tt>make install</tt> will attempt to install GLEW
kusano 7d535a
into <tt>/usr/include/GL</tt> and <tt>/usr/lib</tt>.  You can
kusano 7d535a
customize the installation target via the <tt>GLEW_DEST</tt>
kusano 7d535a
environment variable if you do not have write access to these
kusano 7d535a
directories.
kusano 7d535a

kusano 7d535a
kusano 7d535a

Building Your Project with GLEW

kusano 7d535a

kusano 7d535a
There are two ways to build your project with GLEW.
kusano 7d535a

kusano 7d535a

Including the source files / project file

kusano 7d535a

kusano 7d535a
The simpler but less flexible way is to include <tt>glew.h</tt> and
kusano 7d535a
<tt>glew.c</tt> into your project.  On Windows, you also need to
kusano 7d535a
define the <tt>GLEW_STATIC</tt> preprocessor token when building a
kusano 7d535a
static library or executable, and the <tt>GLEW_BUILD</tt> preprocessor
kusano 7d535a
token when building a dll.  You also need to replace
kusano 7d535a
<tt><GL/gl.h></tt> and <tt><GL/glu.h></tt> with
kusano 7d535a
<tt><glew.h></tt> in your code and set the appropriate include
kusano 7d535a
flag (<tt>-I</tt>) to tell the compiler where to look for it.  For
kusano 7d535a
example:
kusano 7d535a

kusano 7d535a

kusano 7d535a
#include <glew.h>
kusano 7d535a
#include <GL/glut.h>
kusano 7d535a
<gl, glu, and glut functionality is available here>
kusano 7d535a

kusano 7d535a

kusano 7d535a
Depending on where you put <tt>glew.h</tt> you may also need to change
kusano 7d535a
the include directives in <tt>glew.c</tt>. Note that if you are using
kusano 7d535a
GLEW together with GLUT, you have to include <tt>glew.h</tt> first.
kusano 7d535a
In addition, <tt>glew.h</tt> includes <tt>glu.h</tt>, so you do not
kusano 7d535a
need to include it separately.
kusano 7d535a

kusano 7d535a

kusano 7d535a
On Windows, you also have the option of adding the supplied project
kusano 7d535a
file <tt>glew_static.dsp</tt> to your workspace (solution) and compile
kusano 7d535a
it together with your other projects.  In this case you also need to
kusano 7d535a
change the <tt>GLEW_BUILD</tt> preprocessor constant to
kusano 7d535a
<tt>GLEW_STATIC</tt> when building a static library or executable,
kusano 7d535a
otherwise you get build errors.
kusano 7d535a

kusano 7d535a

kusano 7d535a
Note that GLEW does not use the C
kusano 7d535a
runtime library, so it does not matter which version (single-threaded,
kusano 7d535a
multi-threaded or multi-threaded DLL) it is linked with (without
kusano 7d535a
debugging information). It is, however, always a good idea to compile all
kusano 7d535a
your projects including GLEW with the same C runtime settings.
kusano 7d535a

kusano 7d535a
kusano 7d535a

Using GLEW as a shared library

kusano 7d535a
kusano 7d535a

kusano 7d535a
Alternatively, you can use the provided project files / makefile to
kusano 7d535a
build a separate shared library you can link your projects with later.
kusano 7d535a
In this case the best practice is to install <tt>glew.h</tt>,
kusano 7d535a
<tt>glew32.lib</tt>, and <tt>glew32.dll</tt> / <tt>libGLEW.so</tt> to
kusano 7d535a
where the OpenGL equivalents <tt>gl.h</tt>, <tt>opengl32.lib</tt>, and
kusano 7d535a
<tt>opengl32.dll</tt> / <tt>libGL.so</tt> are located.  Note that you
kusano 7d535a
need administrative privileges to do this.  If you do not have
kusano 7d535a
administrator access and your system administrator will not do it for
kusano 7d535a
you, you can install GLEW into your own lib and include subdirectories
kusano 7d535a
and tell the compiler where to find it. Then you can just replace
kusano 7d535a
<tt><GL/gl.h></tt> with <tt><GL/glew.h></tt> in your
kusano 7d535a
program:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
#include <GL/glew.h>
kusano 7d535a
#include <GL/glut.h>
kusano 7d535a
<gl, glu, and glut functionality is available here>
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
or:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
#include <GL/glew.h>
kusano 7d535a
<gl and glu functionality is available here>
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
Remember to link your project with <tt>glew32.lib</tt>,
kusano 7d535a
<tt>glu32.lib</tt>, and <tt>opengl32.lib</tt> on Windows and
kusano 7d535a
<tt>libGLEW.so</tt>, <tt>libGLU.so</tt>, and <tt>libGL.so</tt> on
kusano 7d535a
Unix (<tt>-lGLEW -lGLU -lGL</tt>).
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
It is important to keep in mind that <tt>glew.h</tt> includes neither
kusano 7d535a
<tt>windows.h</tt> nor <tt>gl.h</tt>.  Also, GLEW will warn you by
kusano 7d535a
issuing a preprocessor error in case you have included <tt>gl.h</tt>,
kusano 7d535a
<tt>glext.h</tt>, or <tt>glATI.h</tt> before <tt>glew.h</tt>.
kusano 7d535a

kusano 7d535a