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