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

« back to all changes in this revision

Viewing changes to doc/advanced.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"><a href="basic.html">Basic Usage</a></td></tr>
 
58
<tr><td align="center"><b>Advanced Usage</b></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>Automatic Code Generation</h2>
 
96
 
 
97
<p>
 
98
Starting from release 1.1.0, the source code and parts of the
 
99
documentation are automatically generated from the extension
 
100
specifications in a two-step process.  In the first step,
 
101
specification files from the OpenGL registry are downloaded and
 
102
parsed. Skeleton descriptors are created for each extension.  These
 
103
descriptors contain all necessary information for creating the source
 
104
code and documentation in a simple and compact format, including the
 
105
name of the extension, url link to the specification, tokens, function
 
106
declarations, typedefs and struct definitions.  In the second step,
 
107
the header files as well as the library and glewinfo source are
 
108
generated from the descriptor files.  The code generation scripts are
 
109
located in the <tt>auto</tt> subdirectory.
 
110
</p>
 
111
 
 
112
<p>
 
113
The code generation scripts require GNU make, wget, and perl. On
 
114
Windows, the simplest way to get access to these tools is to install
 
115
<a href="http://www.cygwin.com/">Cygwin</a>, but make sure that the
 
116
root directory is mounted in binary mode. The makefile in the
 
117
<tt>auto</tt> directory provides the following build targets:
 
118
</p>
 
119
 
 
120
<center>
 
121
<table border=0 cellpadding=0 cellspacing=0> <!-- bgcolor="#f0f0f0" -->
 
122
<tr><td align="right" valign="top" width="25%"><tt>make</tt></td>
 
123
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 
124
<td align=left>Create the source files from the descriptors. If the
 
125
descriptors do not exist, create them from the spec files. If the spec
 
126
files do not exist, download them from the OpenGL repository.</td></tr>
 
127
<tr><td align="right" valign="top"><tt>make clean</tt></td>
 
128
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 
129
<td align=left>Delete the source files.</td></tr>
 
130
<tr><td align="right" valign="top"><tt>make clobber</tt></td>
 
131
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 
132
<td align=left>Delete the source files and the descriptors.</td></tr>
 
133
<tr><td align="right" valign="top"><tt>make destroy</tt></td>
 
134
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 
135
<td align=left>Delete the source files, the descriptors, and the spec files.</td></tr>
 
136
<tr><td align="right" valign="top"><tt>make custom</tt></td>
 
137
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
 
138
<td align=left>Create the source files for the extensions
 
139
listed in <tt>auto/custom.txt</tt>. See "Custom Code
 
140
Generation" below for more details.</td></tr>
 
141
</table>
 
142
</center>
 
143
 
 
144
<h3>Adding a New Extension</h3>
 
145
 
 
146
<p>
 
147
To add a new extension, create a descriptor file for the extension in
 
148
<tt>auto/core</tt> and rerun the code generation scripts by typing
 
149
<tt>make clean; make</tt> in the <tt>auto</tt> directory.
 
150
</p>
 
151
 
 
152
<p>
 
153
The format of the descriptor file is given below. Items in
 
154
brackets are optional.
 
155
</p>
 
156
 
 
157
<p class="pre">
 
158
&lt;Extension Name&gt;<br>
 
159
[&lt;URL of Specification File&gt;]<br>
 
160
&nbsp;&nbsp;&nbsp;&nbsp;[&lt;Token Name&gt; &lt;Token Value&gt;]<br>
 
161
&nbsp;&nbsp;&nbsp;&nbsp;[&lt;Token Name&gt; &lt;Token Value&gt;]<br>
 
162
&nbsp;&nbsp;&nbsp;&nbsp;...<br>
 
163
&nbsp;&nbsp;&nbsp;&nbsp;[&lt;Typedef&gt;]<br>
 
164
&nbsp;&nbsp;&nbsp;&nbsp;[&lt;Typedef&gt;]<br>
 
165
&nbsp;&nbsp;&nbsp;&nbsp;...<br>
 
166
&nbsp;&nbsp;&nbsp;&nbsp;[&lt;Function Signature&gt;]<br>
 
167
&nbsp;&nbsp;&nbsp;&nbsp;[&lt;Function Signature&gt;]<br>
 
168
&nbsp;&nbsp;&nbsp;&nbsp;...<br>
 
169
<!-- &nbsp;&nbsp;&nbsp;&nbsp;[&lt;Function Definition&gt;]<br>
 
170
&nbsp;&nbsp;&nbsp;&nbsp;[&lt;Function Definition&gt;]<br>
 
171
&nbsp;&nbsp;&nbsp;&nbsp;...<br> -->
 
172
</p>
 
173
 
 
174
<!--
 
175
<p>
 
176
Note that <tt>Function Definitions</tt> are copied to the header files
 
177
without changes and have to be terminated with a semicolon. In
 
178
contrast, <tt>Tokens</tt>, <tt>Function signatures</tt>, and
 
179
<tt>Typedefs</tt> should not be terminated with a semicolon.
 
180
</p>
 
181
-->
 
182
 
 
183
<p>
 
184
Take a look at one of the files in <tt>auto/core</tt> for an
 
185
example. Note that typedefs and function signatures should not be
 
186
terminated with a semicolon.
 
187
</p>
 
188
 
 
189
<h3>Custom Code Generation</h3>
 
190
<p>
 
191
Starting from GLEW 1.3.0, it is possible to control which extensions
 
192
to include in the libarary by specifying a list in
 
193
<tt>auto/custom.txt</tt>. This is useful when you do not need all the
 
194
extensions and would like to reduce the size of the source files.
 
195
Type <tt>make clean; make custom</tt> in the <tt>auto</tt> directory
 
196
to rerun the scripts with the custom list of extensions.
 
197
</p>
 
198
 
 
199
<p>
 
200
For example, the following is the list of extensions needed to get GLEW and the
 
201
utilities to compile.
 
202
</p>
 
203
 
 
204
<p class="pre">
 
205
WGL_ARB_extensions_string<br>
 
206
WGL_ARB_multisample<br>
 
207
WGL_ARB_pixel_format<br>
 
208
WGL_ARB_pbuffer<br>
 
209
WGL_EXT_extensions_string<br>
 
210
WGL_ATI_pixel_format_float<br>
 
211
WGL_NV_float_buffer<br>
 
212
</p>
 
213
 
 
214
<h2>Multiple Rendering Contexts (GLEW MX)</h2>
 
215
 
 
216
<p>Starting with release 1.2.0, thread-safe support for multiple
 
217
rendering contexts, possibly with different capabilities, is
 
218
available. Since this is not required by most users, it is not added
 
219
to the binary releases to maintain compatibility between different
 
220
versions. To include multi-context support, you have to do the
 
221
following:</p>
 
222
<ol>
 
223
<li>Compile and use GLEW with the <tt>GLEW_MX</tt> preprocessor token
 
224
defined.</li>
 
225
<li>For each rendering context, create a <tt>GLEWContext</tt> object
 
226
that will be available as long as the rendering context exists.</li>
 
227
<li>Define a macro or function called <tt>glewGetContext()</tt> that
 
228
returns a pointer to the <tt>GLEWContext</tt> object associated with
 
229
the rendering context from which OpenGL/WGL/GLX calls are issued. This
 
230
dispatch mechanism is primitive, but generic.
 
231
<li>Make sure that you call <tt>glewInit()</tt> after creating the
 
232
<tt>GLEWContext</tt> object in each rendering context.  Note, that the
 
233
<tt>GLEWContext</tt> pointer returned by <tt>glewGetContext()</tt> has
 
234
to reside in global or thread-local memory.
 
235
</ol>
 
236
 
 
237
<p>Note that according to the <a
 
238
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglr_6yer.asp">MSDN
 
239
WGL documentation</a>, you have to initialize the entry points for
 
240
every rendering context that use pixel formats with different
 
241
capabilities For example, the pixel formats provided by the generic
 
242
software OpenGL implementation by Microsoft vs. the hardware
 
243
accelerated pixel formats have different capabilities.  <b>GLEW by
 
244
default ignores this requirement, and does not define per-context
 
245
entry points (you can however do this using the steps described
 
246
above).</b> Assuming a global namespace for the entry points works in
 
247
most situations, because typically all hardware accelerated pixel
 
248
formats provide the same entry points and capabilities. This means
 
249
that unless you use the multi-context version of GLEW, you need to
 
250
call <tt>glewInit()</tt> only once in your program, or more precisely,
 
251
once per process.</p>
 
252
 
 
253
<h2>Separate Namespace</h2>
 
254
 
 
255
<p>
 
256
To avoid name clashes when linking with libraries that include the
 
257
same symbols, extension entry points are declared in a separate
 
258
namespace (release 1.1.0 and up). This is achieved by aliasing OpenGL
 
259
function names to their GLEW equivalents. For instance,
 
260
<tt>glFancyFunction</tt> is simply an alias to
 
261
<tt>glewFancyFunction</tt>.  The separate namespace does not effect
 
262
token and function pointer definitions.
 
263
</p>
 
264
 
 
265
<h2>Known Issues</h2>
 
266
 
 
267
<p>
 
268
GLEW requires GLX 1.2 for compatibility with GLUT.
 
269
</p>
 
270
 
 
271
</td>
 
272
</tr>
 
273
 
 
274
</table>
 
275
 
 
276
</body>