~ubuntu-branches/ubuntu/trusty/glew/trusty

« back to all changes in this revision

Viewing changes to doc/basic.html

  • Committer: Bazaar Package Importer
  • Author(s): Joost Yervante Damad
  • Date: 2009-05-11 17:48:06 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090511174806-hpbwcimkr4ir0mfl
Tags: 1.5.1-4
make sure mx library really is MX (closes: #528232)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--
 
2
The OpenGL Extension Wrangler Library
 
3
Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
 
4
Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>
 
5
Copyright (C) 2002, Lev Povalahev
 
6
All rights reserved.
 
7
 
 
8
Redistribution and use in source and binary forms, with or without 
 
9
modification, are permitted provided that the following conditions are met:
 
10
 
 
11
* Redistributions of source code must retain the above copyright notice, 
 
12
  this list of conditions and the following disclaimer.
 
13
* Redistributions in binary form must reproduce the above copyright notice, 
 
14
  this list of conditions and the following disclaimer in the documentation 
 
15
  and/or other materials provided with the distribution.
 
16
* The name of the author may be used to endorse or promote products 
 
17
  derived from this software without specific prior written permission.
 
18
 
 
19
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 
20
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 
21
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
22
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 
23
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 
24
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 
25
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
26
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
27
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
28
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
29
THE POSSIBILITY OF SUCH DAMAGE.
 
30
-->
 
31
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html/4/loose.dtd">
 
32
<!-- &nbsp;<img src="new.png" height="12" alt="NEW!"> -->
 
33
<html>
 
34
<head>
 
35
<title>
 
36
GLEW: The OpenGL Extension Wrangler Library
 
37
</title>
 
38
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 
 
39
<link href="glew.css" type="text/css" rel="stylesheet">
 
40
</head>
 
41
<body bgcolor="#fff0d0">
 
42
<table border="0" width="100%" cellpadding="12" cellspacing="8" style="height:100%">
 
43
<tr>
 
44
<td bgcolor="#ffffff" align="left" valign="top" width="200">
 
45
<table border="0" width="100%" cellpadding="0" cellspacing="0" align="left">
 
46
<tr>
 
47
<td valign="top">
 
48
<table border="0" width="100%" cellpadding="0" cellspacing="0" align="left">
 
49
<tr><td align="center"><i>Latest Release: <a href="https://sourceforge.net/project/showfiles.php?group_id=67586&amp;package_id=67942&amp;release_id=637800">1.5.1</a></i></td></tr>
 
50
<tr><td align="center"><br></td></tr>
 
51
<tr><td align="center"><img src="./glew.png" alt="GLEW Logo" width="97" height="75"></td></tr>
 
52
<tr><td align="center"><br></td></tr>
 
53
<tr><td align="center">
 
54
<table border="0" cellpadding="0" cellspacing="0" align="center">
 
55
<tr><td align="center"><a href="index.html">Download</a></td></tr>
 
56
<tr><td align="center"><a href="install.html">Installation</a></td></tr>
 
57
<tr><td align="center"><b>Basic Usage</b></td></tr>
 
58
<tr><td align="center"><a href="advanced.html">Advanced Usage</a></td></tr>
 
59
<tr><td align="center"><a href="credits.html">Credits & Copyright</a></td></tr>
 
60
<tr><td align="center"><a href="log.html">Change Log</a></td></tr>
 
61
<tr><td align="center"><a href="http://sourceforge.net/projects/glew/">Project Page</a></td></tr>
 
62
<tr><td align="center"><a href="https://sourceforge.net/mail/?group_id=67586">Mailing Lists</a></td></tr>
 
63
<tr><td align="center"><a href="http://sourceforge.net/tracker/?group_id=67586">Bug Tracker</a></td></tr>
 
64
</table>
 
65
<tr><td align="center"><br></tr>
 
66
</table>
 
67
</td>
 
68
</tr>
 
69
<tr>
 
70
<td valign="bottom">
 
71
<table border="0" width="100%" cellpadding="5" cellspacing="0" align="left">
 
72
<tr><td align="center"><i>Last Update: 11-03-08</i></td></tr>
 
73
<tr><td align="center">
 
74
<a href="http://www.opengl.org"> <img src="./ogl_sm.jpg" width="68"
 
75
height="35" border="0" alt="OpenGL Logo"></a>
 
76
<a href="http://sourceforge.net"> <img
 
77
src="http://sourceforge.net/sflogo.php?group_id=67586&amp;type=1"
 
78
width="88" height="31" border="0" alt="SourceForge Logo"></a>
 
79
</td>
 
80
</tr>
 
81
<tr><td align="center"><a
 
82
href="http://sourceforge.net/donate/index.php?group_id=67586"><img
 
83
src="http://images.sourceforge.net/images/project-support.jpg"
 
84
width="88" height="32" border="0" alt="Support This Project"></a></td></tr>
 
85
</table>
 
86
</td>
 
87
</tr>
 
88
</table>
 
89
</td>
 
90
 
 
91
<td bgcolor="#ffffff" align="left" valign="top">
 
92
 
 
93
<h1>The OpenGL Extension Wrangler Library</h1>
 
94
 
 
95
<h2>Initializing GLEW</h2>
 
96
<p>
 
97
First you need to create a valid OpenGL rendering context and call
 
98
<tt>glewInit()</tt> to initialize the extension entry points.  If
 
99
<tt>glewInit()</tt> returns <tt>GLEW_OK</tt>, the initialization
 
100
succeeded and you can use the available extensions as well as core
 
101
OpenGL functionality. For example:
 
102
</p>
 
103
 
 
104
<p class="pre">
 
105
#include &lt;GL/glew.h&gt;<br>
 
106
#include &lt;GL/glut.h&gt;<br>
 
107
...<br>
 
108
glutInit(&amp;argc, argv);<br>
 
109
glutCreateWindow("GLEW Test");<br>
 
110
GLenum err = glewInit();<br>
 
111
if (GLEW_OK != err)<br>
 
112
{<br>
 
113
&nbsp;&nbsp;/* Problem: glewInit failed, something is seriously wrong. */<br>
 
114
&nbsp;&nbsp;fprintf(stderr, "Error: %s\n", glewGetErrorString(err));<br>
 
115
&nbsp;&nbsp;...<br>
 
116
}<br>
 
117
fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));<br>
 
118
</p>
 
119
 
 
120
<h2>Checking for Extensions</h2>
 
121
 
 
122
<p>
 
123
Starting from GLEW 1.1.0, you can find out if a particular extension
 
124
is available on your platform by querying globally defined variables
 
125
of the form <tt>GLEW_{extension_name}</tt>:
 
126
</p>
 
127
 
 
128
<p class="pre">
 
129
if (GLEW_ARB_vertex_program)<br>
 
130
{<br>
 
131
&nbsp;&nbsp;/* It is safe to use the ARB_vertex_program extension here. */<br>
 
132
&nbsp;&nbsp;glGenProgramsARB(...);<br>
 
133
}<br>
 
134
</p>
 
135
 
 
136
<p>
 
137
<b>In GLEW 1.0.x, a global structure was used for this task. To ensure
 
138
binary compatibility between releases, the struct was replaced with a
 
139
set of variables.</b>
 
140
</p>
 
141
 
 
142
<p>
 
143
You can also check for core OpenGL functionality.  For example, to
 
144
see if OpenGL 1.3 is supported, do the following:
 
145
</p>
 
146
 
 
147
<p class="pre">
 
148
if (GLEW_VERSION_1_3)<br>
 
149
{<br>
 
150
&nbsp;&nbsp;/* Yay! OpenGL 1.3 is supported! */<br>
 
151
}<br>
 
152
</p>
 
153
 
 
154
<p>
 
155
In general, you can check if <tt>GLEW_{extension_name}</tt> or
 
156
<tt>GLEW_VERSION_{version}</tt> is true or false.
 
157
</p>
 
158
 
 
159
<p>
 
160
It is also possible to perform extension checks from string
 
161
input. Starting from the 1.3.0 release, use <tt>glewIsSupported</tt>
 
162
to check if the required core or extension functionality is
 
163
available:
 
164
</p>
 
165
 
 
166
<p class="pre">
 
167
if (glewIsSupported("GL_VERSION_1_4&nbsp;&nbsp;GL_ARB_point_sprite"))<br>
 
168
{<br>
 
169
&nbsp;&nbsp;/* Great, we have OpenGL 1.4 + point sprites. */<br>
 
170
}<br>
 
171
</p>
 
172
 
 
173
<p>
 
174
For extensions only, <tt>glewGetExtension</tt> provides a slower alternative
 
175
(GLEW 1.0.x-1.2.x). <b>Note that in the 1.3.0 release </b>
 
176
<tt>glewGetExtension</tt> <b>was replaced with </b>
 
177
<tt>glewIsSupported</tt>.
 
178
</p>
 
179
 
 
180
<p class="pre">
 
181
if (glewGetExtension("GL_ARB_fragment_program"))<br>
 
182
{<br>
 
183
&nbsp;&nbsp;/* Looks like ARB_fragment_program is supported. */<br>
 
184
}<br>
 
185
</p>
 
186
 
 
187
<h2>Experimental Drivers</h2>
 
188
 
 
189
<p>
 
190
GLEW obtains information on the supported extensions from the graphics
 
191
driver.  Experimental or pre-release drivers, however, might not
 
192
report every available extension through the standard mechanism, in
 
193
which case GLEW will report it unsupported.  To circumvent this
 
194
situation, the <tt>glewExperimental</tt> global switch can be turned
 
195
on by setting it to <tt>GL_TRUE</tt> before calling
 
196
<tt>glewInit()</tt>, which ensures that all extensions with valid
 
197
entry points will be exposed.
 
198
</p>
 
199
 
 
200
<h2>Platform Specific Extensions</h2>
 
201
 
 
202
<p>
 
203
Platform specific extensions are separated into two header files:
 
204
<tt>wglew.h</tt> and <tt>glxew.h</tt>, which define the available
 
205
<tt>WGL</tt> and <tt>GLX</tt> extensions.  To determine if a certain
 
206
extension is supported, query <tt>WGLEW_{extension name}</tt> or
 
207
<tt>GLXEW_{extension_name}</tt>.  For example:
 
208
</p>
 
209
 
 
210
<p class="pre">
 
211
#include &lt;GL/wglew.h&gt;<br>
 
212
<br>
 
213
if (WGLEW_ARB_pbuffer)<br>
 
214
{<br>
 
215
&nbsp;&nbsp;/* OK, we can use pbuffers. */<br>
 
216
}<br>
 
217
else<br>
 
218
{<br>
 
219
&nbsp;&nbsp;/* Sorry, pbuffers will not work on this platform. */<br>
 
220
}<br>
 
221
</p>
 
222
 
 
223
<p>
 
224
Alternatively, use <tt>wglewIsSupported</tt> or
 
225
<tt>glxewIsSupported</tt> to check for extensions from a string:
 
226
</p>
 
227
 
 
228
<p class="pre">
 
229
if (wglewIsSupported("WGL_ARB_pbuffer"))<br>
 
230
{<br>
 
231
&nbsp;&nbsp;/* OK, we can use pbuffers. */<br>
 
232
}<br>
 
233
</p>
 
234
 
 
235
<h2>Utilities</h2>
 
236
 
 
237
<p>
 
238
GLEW provides two command-line utilities: one for creating a list of
 
239
available extensions and visuals; and another for verifying extension
 
240
entry points.
 
241
</p>
 
242
 
 
243
<h3>visualinfo: extensions and visuals</h3>
 
244
 
 
245
<p>
 
246
<tt>visualinfo</tt> is an extended version of <tt>glxinfo</tt>. The
 
247
Windows version creates a file called <tt>visualinfo.txt</tt>, which
 
248
contains a list of available OpenGL, WGL, and GLU extensions as well
 
249
as a table of visuals aka. pixel formats. Pbuffer and MRT capable
 
250
visuals are also included. For additional usage information, type
 
251
<tt>visualinfo -h</tt>.
 
252
</p>
 
253
 
 
254
<h3>glewinfo: extension verification utility</h3>
 
255
 
 
256
<p>
 
257
<tt>glewinfo</tt> allows you to verify the entry points for the
 
258
extensions supported on your platform. The Windows version
 
259
reports the results to a text file called <tt>glewinfo.txt</tt>. The
 
260
Unix version prints the results to <tt>stdout</tt>.
 
261
</p>
 
262
 
 
263
<p>Windows usage:</p>
 
264
 <blockquote><pre>glewinfo [-pf &lt;id&gt;]</pre></blockquote>
 
265
 
 
266
<p>where <tt>&lt;id&gt;</tt> is the pixel format id for which the
 
267
capabilities are displayed.</p>
 
268
 
 
269
<p>Unix usage:</p>
 
270
<blockquote><pre>glewinfo [-display &lt;dpy&gt;] [-visual &lt;id&gt;]</pre></blockquote>
 
271
 
 
272
<p>where <tt>&lt;dpy&gt;</tt> is the X11 display and <tt>&lt;id&gt;</tt> is
 
273
the visual id for which the capabilities are displayed.</p>
 
274
 
 
275
</td>
 
276
</tr>
 
277
 
 
278
</table>
 
279
 
 
280
</body>