basic.html 9.6 KB

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