kusano 7d535a
kusano 7d535a
kusano 7d535a
The OpenGL Extension Wrangler Library
kusano 7d535a
Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee="" org=""></milan>
kusano 7d535a
Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org=""></mmagallo[]debian>
kusano 7d535a
Copyright (C) 2002, Lev Povalahev
kusano 7d535a
All rights reserved.
kusano 7d535a
kusano 7d535a
Redistribution and use in source and binary forms, with or without 
kusano 7d535a
modification, are permitted provided that the following conditions are met:
kusano 7d535a
kusano 7d535a
* Redistributions of source code must retain the above copyright notice, 
kusano 7d535a
  this list of conditions and the following disclaimer.
kusano 7d535a
* Redistributions in binary form must reproduce the above copyright notice, 
kusano 7d535a
  this list of conditions and the following disclaimer in the documentation 
kusano 7d535a
  and/or other materials provided with the distribution.
kusano 7d535a
* The name of the author may be used to endorse or promote products 
kusano 7d535a
  derived from this software without specific prior written permission.
kusano 7d535a
kusano 7d535a
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
kusano 7d535a
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
kusano 7d535a
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
kusano 7d535a
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
kusano 7d535a
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
kusano 7d535a
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
kusano 7d535a
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
kusano 7d535a
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
kusano 7d535a
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
kusano 7d535a
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
kusano 7d535a
THE POSSIBILITY OF SUCH DAMAGE.
kusano 7d535a
-->
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
<title>GLEW: The OpenGL Extension Wrangler Library</title>
kusano 7d535a
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type"> 
kusano 7d535a
<link href="glew.css" rel="stylesheet" type="text/css">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
Latest Release: 1.9.0
kusano 7d535a

kusano 7d535a
GLEW Logo
kusano 7d535a

kusano 7d535a
kusano 7d535a
kusano 7d535a
Download
kusano 7d535a
Usage
kusano 7d535a
Building
kusano 7d535a
Installation
kusano 7d535a
Source Generation
kusano 7d535a
Credits & Copyright
kusano 7d535a
Change Log
kusano 7d535a
Project Page
kusano 7d535a
Mailing Lists
kusano 7d535a
Bug Tracker
kusano 7d535a
kusano 7d535a

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
Last Update: 08-06-12
kusano 7d535a
kusano 7d535a
 
kusano 7d535a
height="35" border="0" alt="OpenGL Logo">
kusano 7d535a
 
kusano 7d535a
src="http://sourceforge.net/sflogo.php?group_id=67586&type=1"
kusano 7d535a
width="88" height="31" border="0" alt="SourceForge Logo">
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
href="http://sourceforge.net/donate/index.php?group_id=67586">
kusano 7d535a
src="http://images.sourceforge.net/images/project-support.jpg"
kusano 7d535a
width="88" height="32" border="0" alt="Support This Project"> -->
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

The OpenGL Extension Wrangler Library

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a

Initializing GLEW

kusano 7d535a

kusano 7d535a
First you need to create a valid OpenGL rendering context and call
kusano 7d535a
<tt>glewInit()</tt> to initialize the extension entry points.  If
kusano 7d535a
<tt>glewInit()</tt> returns <tt>GLEW_OK</tt>, the initialization
kusano 7d535a
succeeded and you can use the available extensions as well as core
kusano 7d535a
OpenGL functionality. For example:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
#include <GL/glew.h>
kusano 7d535a
#include <GL/glut.h>
kusano 7d535a
...
kusano 7d535a
glutInit(&argc, argv);
kusano 7d535a
glutCreateWindow("GLEW Test");
kusano 7d535a
GLenum err = glewInit();
kusano 7d535a
if (GLEW_OK != err)
kusano 7d535a
{
kusano 7d535a
  /* Problem: glewInit failed, something is seriously wrong. */
kusano 7d535a
  fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
kusano 7d535a
  ...
kusano 7d535a
}
kusano 7d535a
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
kusano 7d535a

kusano 7d535a
kusano 7d535a

Checking for Extensions

kusano 7d535a
kusano 7d535a

kusano 7d535a
Starting from GLEW 1.1.0, you can find out if a particular extension
kusano 7d535a
is available on your platform by querying globally defined variables
kusano 7d535a
of the form <tt>GLEW_{extension_name}</tt>:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
if (GLEW_ARB_vertex_program)
kusano 7d535a
{
kusano 7d535a
  /* It is safe to use the ARB_vertex_program extension here. */
kusano 7d535a
  glGenProgramsARB(...);
kusano 7d535a
}
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
In GLEW 1.0.x, a global structure was used for this task. To ensure
kusano 7d535a
binary compatibility between releases, the struct was replaced with a
kusano 7d535a
set of variables.
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
You can also check for core OpenGL functionality.  For example, to
kusano 7d535a
see if OpenGL 1.3 is supported, do the following:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
if (GLEW_VERSION_1_3)
kusano 7d535a
{
kusano 7d535a
  /* Yay! OpenGL 1.3 is supported! */
kusano 7d535a
}
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
In general, you can check if <tt>GLEW_{extension_name}</tt> or
kusano 7d535a
<tt>GLEW_VERSION_{version}</tt> is true or false.
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
It is also possible to perform extension checks from string
kusano 7d535a
input. Starting from the 1.3.0 release, use <tt>glewIsSupported</tt>
kusano 7d535a
to check if the required core or extension functionality is
kusano 7d535a
available:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
if (glewIsSupported("GL_VERSION_1_4  GL_ARB_point_sprite"))
kusano 7d535a
{
kusano 7d535a
  /* Great, we have OpenGL 1.4 + point sprites. */
kusano 7d535a
}
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
For extensions only, <tt>glewGetExtension</tt> provides a slower alternative
kusano 7d535a
(GLEW 1.0.x-1.2.x). Note that in the 1.3.0 release 
kusano 7d535a
<tt>glewGetExtension</tt> was replaced with 
kusano 7d535a
<tt>glewIsSupported</tt>.
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
if (glewGetExtension("GL_ARB_fragment_program"))
kusano 7d535a
{
kusano 7d535a
  /* Looks like ARB_fragment_program is supported. */
kusano 7d535a
}
kusano 7d535a

kusano 7d535a
kusano 7d535a

Experimental Drivers

kusano 7d535a
kusano 7d535a

kusano 7d535a
GLEW obtains information on the supported extensions from the graphics
kusano 7d535a
driver.  Experimental or pre-release drivers, however, might not
kusano 7d535a
report every available extension through the standard mechanism, in
kusano 7d535a
which case GLEW will report it unsupported.  To circumvent this
kusano 7d535a
situation, the <tt>glewExperimental</tt> global switch can be turned
kusano 7d535a
on by setting it to <tt>GL_TRUE</tt> before calling
kusano 7d535a
<tt>glewInit()</tt>, which ensures that all extensions with valid
kusano 7d535a
entry points will be exposed.
kusano 7d535a

kusano 7d535a
kusano 7d535a

Platform Specific Extensions

kusano 7d535a
kusano 7d535a

kusano 7d535a
Platform specific extensions are separated into two header files:
kusano 7d535a
<tt>wglew.h</tt> and <tt>glxew.h</tt>, which define the available
kusano 7d535a
<tt>WGL</tt> and <tt>GLX</tt> extensions.  To determine if a certain
kusano 7d535a
extension is supported, query <tt>WGLEW_{extension name}</tt> or
kusano 7d535a
<tt>GLXEW_{extension_name}</tt>.  For example:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
#include <GL/wglew.h>
kusano 7d535a

kusano 7d535a
if (WGLEW_ARB_pbuffer)
kusano 7d535a
{
kusano 7d535a
  /* OK, we can use pbuffers. */
kusano 7d535a
}
kusano 7d535a
else
kusano 7d535a
{
kusano 7d535a
  /* Sorry, pbuffers will not work on this platform. */
kusano 7d535a
}
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
Alternatively, use <tt>wglewIsSupported</tt> or
kusano 7d535a
<tt>glxewIsSupported</tt> to check for extensions from a string:
kusano 7d535a

kusano 7d535a
kusano 7d535a

kusano 7d535a
if (wglewIsSupported("WGL_ARB_pbuffer"))
kusano 7d535a
{
kusano 7d535a
  /* OK, we can use pbuffers. */
kusano 7d535a
}
kusano 7d535a

kusano 7d535a
kusano 7d535a

Utilities

kusano 7d535a
kusano 7d535a

kusano 7d535a
GLEW provides two command-line utilities: one for creating a list of
kusano 7d535a
available extensions and visuals; and another for verifying extension
kusano 7d535a
entry points.
kusano 7d535a

kusano 7d535a
kusano 7d535a

visualinfo: extensions and visuals

kusano 7d535a
kusano 7d535a

kusano 7d535a
<tt>visualinfo</tt> is an extended version of <tt>glxinfo</tt>. The
kusano 7d535a
Windows version creates a file called <tt>visualinfo.txt</tt>, which
kusano 7d535a
contains a list of available OpenGL, WGL, and GLU extensions as well
kusano 7d535a
as a table of visuals aka. pixel formats. Pbuffer and MRT capable
kusano 7d535a
visuals are also included. For additional usage information, type
kusano 7d535a
<tt>visualinfo -h</tt>.
kusano 7d535a

kusano 7d535a
kusano 7d535a

glewinfo: extension verification utility

kusano 7d535a
kusano 7d535a

kusano 7d535a
<tt>glewinfo</tt> allows you to verify the entry points for the
kusano 7d535a
extensions supported on your platform. The Windows version
kusano 7d535a
reports the results to a text file called <tt>glewinfo.txt</tt>. The
kusano 7d535a
Unix version prints the results to <tt>stdout</tt>.
kusano 7d535a

kusano 7d535a
kusano 7d535a

Windows usage:

kusano 7d535a
 
glewinfo [-pf <id>]
kusano 7d535a
kusano 7d535a

where <tt><id></tt> is the pixel format id for which the

kusano 7d535a
capabilities are displayed.

kusano 7d535a
kusano 7d535a

Unix usage:

kusano 7d535a
glewinfo [-display <dpy>] [-visual <id>]
kusano 7d535a
kusano 7d535a

where <tt><dpy></tt> is the X11 display and <tt><id></tt> is

kusano 7d535a
the visual id for which the capabilities are displayed.

kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a