PageRenderTime 44ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/samples/thirdparty/glew/glew-1.11.0/doc/basic.html

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