source: GTP/trunk/Lib/Illum/GPUObscurancesGT/Libraries/glew/doc/basic.html @ 1648

Revision 1648, 7.9 KB checked in by igarcia, 18 years ago (diff)
Line 
1<!--
2 Copyright (C) 2002-2005, Milan Ikits <milan ikits[]ieee org>
3 Copyright (C) 2002-2005, Marcelo E. Magallon <mmagallo[]debian org>
4 This documentation may not be modified or redistributed in any
5 form, except by the copyright holder.
6-->
7<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html/4/loose.dtd">
8<!-- &nbsp;<img src="new.png" height="12" alt="NEW!"> -->
9<html>
10<head>
11<title>
12GLEW: The OpenGL Extension Wrangler Library
13</title>
14<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> 
15<link href="glew.css" type="text/css" rel="stylesheet">
16</head>
17<body bgcolor="#fff0d0">
18<table border="0" width="100%" cellpadding="12" cellspacing="8" style="height:100%">
19<tr>
20<td bgcolor="#ffffff" align="left" valign="top" width="200">
21<table border="0" width="100%" cellpadding="0" cellspacing="0" align="left">
22<tr>
23<td valign="top">
24<table border="0" width="100%" cellpadding="0" cellspacing="0" align="left">
25<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=327647">1.3.3</a></i></td></tr>
26<tr><td align="center"><br></td></tr>
27<tr><td align="center"><img src="./glew.png" alt="GLEW Logo" width="97" height="75"></td></tr>
28<tr><td align="center"><br></td></tr>
29<tr><td align="center">
30<table border="0" cellpadding="0" cellspacing="0" align="center">
31<tr><td align="center"><a href="index.html">Download</a></td></tr>
32<tr><td align="center"><a href="install.html">Installation</a></td></tr>
33<tr><td align="center"><b>Basic Usage</b></td></tr>
34<tr><td align="center"><a href="advanced.html">Advanced Usage</a></td></tr>
35<tr><td align="center"><a href="credits.html">Credits & Copyright</a></td></tr>
36<tr><td align="center"><a href="log.html">Change Log</a></td></tr>
37<tr><td align="center"><a href="http://sourceforge.net/projects/glew/">Project Page</a></td></tr>
38<tr><td align="center"><a href="https://sourceforge.net/mail/?group_id=67586">Mailing Lists</a></td></tr>
39<tr><td align="center"><a href="http://sourceforge.net/tracker/?group_id=67586">Bug Tracker</a></td></tr>
40</table>
41<tr><td align="center"><br></tr>
42</table>
43</td>
44</tr>
45<tr>
46<td valign="bottom">
47<table border="0" width="100%" cellpadding="5" cellspacing="0" align="left">
48<tr><td align="center"><i>Last Update: 05-16-05</i></td></tr>
49<tr><td align="center">
50<a href="http://www.opengl.org"> <img src="./ogl_sm.jpg" width="68"
51height="35" border="0" alt="OpenGL Logo"></a>
52<a href="http://sourceforge.net"> <img
53src="http://sourceforge.net/sflogo.php?group_id=67586&amp;type=1"
54width="88" height="31" border="0" alt="SourceForge Logo"></a>
55</td>
56</tr>
57</table>
58</td>
59</tr>
60</table>
61</td>
62
63<td bgcolor="#ffffff" align="left" valign="top">
64
65<h1>The OpenGL Extension Wrangler Library</h1>
66
67<h2>Initializing GLEW</h2>
68<p>
69First you need to create a valid OpenGL rendering context and call
70<tt>glewInit()</tt> to initialize the extension entry points.  If
71<tt>glewInit()</tt> returns <tt>GLEW_OK</tt>, the initialization
72succeeded and you can use the available extensions as well as core
73OpenGL functionality. For example:
74</p>
75
76<p class="pre">
77#include &lt;GL/glew.h&gt;<br>
78#include &lt;GL/glut.h&gt;<br>
79...<br>
80glutInit(&amp;argc, argv);<br>
81glutCreateWindow("GLEW Test");<br>
82GLenum err = glewInit();<br>
83if (GLEW_OK != err)<br>
84{<br>
85&nbsp;&nbsp;/* Problem: glewInit failed, something is seriously wrong. */<br>
86&nbsp;&nbsp;fprintf(stderr, "Error: %s\n", glewGetErrorString(err));<br>
87&nbsp;&nbsp;...<br>
88}<br>
89fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));<br>
90</p>
91
92<h2>Checking for Extensions</h2>
93
94<p>
95Starting from GLEW 1.1.0, you can find out if a particular extension
96is available on your platform by querying globally defined variables
97of the form <tt>GLEW_{extension_name}</tt>:
98</p>
99
100<p class="pre">
101if (GLEW_ARB_vertex_program)<br>
102{<br>
103&nbsp;&nbsp;/* It is safe to use the ARB_vertex_program extension here. */<br>
104&nbsp;&nbsp;glGenProgramsARB(...);<br>
105}<br>
106</p>
107
108<p>
109<b>In GLEW 1.0.x, a global structure was used for this task. To ensure
110binary compatibility between releases, the struct was replaced with a
111set of variables.</b>
112</p>
113
114<p>
115You can also check for core OpenGL functionality.  For example, to
116see if OpenGL 1.3 is supported, do the following:
117</p>
118
119<p class="pre">
120if (GLEW_VERSION_1_3)<br>
121{<br>
122&nbsp;&nbsp;/* Yay! OpenGL 1.3 is supported! */<br>
123}<br>
124</p>
125
126<p>
127In general, you can check if <tt>GLEW_{extension_name}</tt> or
128<tt>GLEW_VERSION_{version}</tt> is true or false.
129</p>
130
131<p>
132It is also possible to perform extension checks from string
133input. Starting from the 1.3.0 release, use <tt>glewIsSupported</tt>
134to check if the required core or extension functionality is
135available:
136</p>
137
138<p class="pre">
139if (glewIsSupported("GL_VERSION_1_4&nbsp;&nbsp;GL_ARB_point_sprite"))<br>
140{<br>
141&nbsp;&nbsp;/* Great, we have OpenGL 1.4 + point sprites. */<br>
142}<br>
143</p>
144
145<p>
146For extensions only, <tt>glewGetExtension</tt> provides a slower alternative
147(GLEW 1.0.x-1.2.x). <b>Note that in the 1.3.0 release </b>
148<tt>glewGetExtension</tt> <b>was replaced with </b>
149<tt>glewIsSupported</tt>.
150</p>
151
152<p class="pre">
153if (glewGetExtension("GL_ARB_fragment_program"))<br>
154{<br>
155&nbsp;&nbsp;/* Looks like ARB_fragment_program is supported. */<br>
156}<br>
157</p>
158
159<h2>Experimental Drivers</h2>
160
161<p>
162GLEW obtains information on the supported extensions from the graphics
163driver.  Experimental or pre-release drivers, however, might not
164report every available extension through the standard mechanism, in
165which case GLEW will report it unsupported.  To circumvent this
166situation, the <tt>glewExperimental</tt> global switch can be turned
167on by setting it to <tt>GL_TRUE</tt> before calling
168<tt>glewInit()</tt>, which ensures that all extensions with valid
169entry points will be exposed.
170</p>
171
172<h2>Platform Specific Extensions</h2>
173
174<p>
175Platform specific extensions are separated into two header files:
176<tt>wglew.h</tt> and <tt>glxew.h</tt>, which define the available
177<tt>WGL</tt> and <tt>GLX</tt> extensions.  To determine if a certain
178extension is supported, query <tt>WGLEW_{extension name}</tt> or
179<tt>GLXEW_{extension_name}</tt>.  For example:
180</p>
181
182<p class="pre">
183#include &lt;GL/wglew.h&gt;<br>
184<br>
185if (WGLEW_ARB_pbuffer)<br>
186{<br>
187&nbsp;&nbsp;/* OK, we can use pbuffers. */<br>
188}<br>
189else<br>
190{<br>
191&nbsp;&nbsp;/* Sorry, pbuffers will not work on this platform. */<br>
192}<br>
193</p>
194
195<p>
196Alternatively, use <tt>wglewIsSupported</tt> or
197<tt>glxewIsSupported</tt> to check for extensions from a string:
198</p>
199
200<p class="pre">
201if (wglewIsSupported("WGL_ARB_pbuffer"))<br>
202{<br>
203&nbsp;&nbsp;/* OK, we can use pbuffers. */<br>
204}<br>
205</p>
206
207<h2>Utilities</h2>
208
209<p>
210GLEW provides two command-line utilities: one for creating a list of
211available extensions and visuals; and another for verifying extension
212entry points.
213</p>
214
215<h3>visualinfo: extensions and visuals</h3>
216
217<p>
218<tt>visualinfo</tt> is an extended version of <tt>glxinfo</tt>. The
219Windows version creates a file called <tt>visualinfo.txt</tt>, which
220contains a list of available OpenGL, WGL, and GLU extensions as well
221as a table of visuals aka. pixel formats. Pbuffer and MRT capable
222visuals are also included. For additional usage information, type
223<tt>visualinfo -h</tt>.
224</p>
225
226<h3>glewinfo: extension verification utility</h3>
227
228<p>
229<tt>glewinfo</tt> allows you to verify the entry points for the
230extensions supported on your platform. The Windows version
231reports the results to a text file called <tt>glewinfo.txt</tt>. The
232Unix version prints the results to <tt>stdout</tt>.
233</p>
234
235<p>Windows usage:</p>
236 <blockquote><pre>glewinfo [-pf &lt;id&gt;]</pre></blockquote>
237
238<p>where <tt>&lt;id&gt;</tt> is the pixel format id for which the
239capabilities are displayed.</p>
240
241<p>Unix usage:</p>
242<blockquote><pre>glewinfo [-display &lt;dpy&gt;] [-visual &lt;id&gt;]</pre></blockquote>
243
244<p>where <tt>&lt;dpy&gt;</tt> is the X11 display and <tt>&lt;id&gt;</tt> is
245the visual id for which the capabilities are displayed.</p>
246
247</td>
248</tr>
249
250</table>
251
252</body>
Note: See TracBrowser for help on using the repository browser.