ruby-glfw 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. data/README +1 -0
  2. data/README.API +73 -0
  3. data/Rakefile +120 -0
  4. data/examples/boing.rb +519 -0
  5. data/examples/gears.rb +327 -0
  6. data/examples/keytest.rb +117 -0
  7. data/examples/listmodes.rb +20 -0
  8. data/examples/mipmaps.rb +104 -0
  9. data/examples/mipmaps.tga +0 -0
  10. data/examples/particles.rb +837 -0
  11. data/examples/pong3d.rb +741 -0
  12. data/examples/pong3d_field.tga +0 -0
  13. data/examples/pong3d_instr.tga +0 -0
  14. data/examples/pong3d_menu.tga +0 -0
  15. data/examples/pong3d_title.tga +0 -0
  16. data/examples/pong3d_winner1.tga +0 -0
  17. data/examples/pong3d_winner2.tga +0 -0
  18. data/examples/splitview.rb +432 -0
  19. data/examples/triangle.rb +89 -0
  20. data/examples/wave.rb +294 -0
  21. data/ext/glfw/glfw.c +1094 -0
  22. data/ext/glfw/mkrf_conf.rb +70 -0
  23. data/glfw-src/Makefile +220 -0
  24. data/glfw-src/compile.ami +61 -0
  25. data/glfw-src/compile.bat +217 -0
  26. data/glfw-src/compile.sh +607 -0
  27. data/glfw-src/docs/Makefile +57 -0
  28. data/glfw-src/docs/Reference.pdf +0 -0
  29. data/glfw-src/docs/UsersGuide.pdf +0 -0
  30. data/glfw-src/docs/cleanup.bat +22 -0
  31. data/glfw-src/docs/glfwdoc.sty +80 -0
  32. data/glfw-src/docs/glfwrm.tex +3034 -0
  33. data/glfw-src/docs/glfwug.tex +2024 -0
  34. data/glfw-src/docs/readme.txt +80 -0
  35. data/glfw-src/examples/Makefile.amigaos.gcc +70 -0
  36. data/glfw-src/examples/Makefile.amigaos.vbcc +70 -0
  37. data/glfw-src/examples/Makefile.dos.djgpp +71 -0
  38. data/glfw-src/examples/Makefile.macosx.gcc +96 -0
  39. data/glfw-src/examples/Makefile.win32.bcc +75 -0
  40. data/glfw-src/examples/Makefile.win32.cross-mgw +79 -0
  41. data/glfw-src/examples/Makefile.win32.cygwin +79 -0
  42. data/glfw-src/examples/Makefile.win32.lcc +74 -0
  43. data/glfw-src/examples/Makefile.win32.mgw +75 -0
  44. data/glfw-src/examples/Makefile.win32.msvc +74 -0
  45. data/glfw-src/examples/Makefile.win32.ow +74 -0
  46. data/glfw-src/examples/Makefile.win32.pellesc +74 -0
  47. data/glfw-src/examples/Makefile.x11.in +54 -0
  48. data/glfw-src/examples/boing.c +606 -0
  49. data/glfw-src/examples/bundle.sh +46 -0
  50. data/glfw-src/examples/gears.c +382 -0
  51. data/glfw-src/examples/keytest.c +264 -0
  52. data/glfw-src/examples/listmodes.c +48 -0
  53. data/glfw-src/examples/mipmaps.c +126 -0
  54. data/glfw-src/examples/mipmaps.tga +0 -0
  55. data/glfw-src/examples/mtbench.c +301 -0
  56. data/glfw-src/examples/mthello.c +48 -0
  57. data/glfw-src/examples/particles.c +1148 -0
  58. data/glfw-src/examples/pong3d.c +839 -0
  59. data/glfw-src/examples/pong3d_field.tga +0 -0
  60. data/glfw-src/examples/pong3d_instr.tga +0 -0
  61. data/glfw-src/examples/pong3d_menu.tga +0 -0
  62. data/glfw-src/examples/pong3d_title.tga +0 -0
  63. data/glfw-src/examples/pong3d_winner1.tga +0 -0
  64. data/glfw-src/examples/pong3d_winner2.tga +0 -0
  65. data/glfw-src/examples/splitview.c +506 -0
  66. data/glfw-src/examples/triangle.c +108 -0
  67. data/glfw-src/examples/wave.c +397 -0
  68. data/glfw-src/images/opengl.gif +0 -0
  69. data/glfw-src/images/osicert.gif +0 -0
  70. data/glfw-src/include/GL/glfw.h +486 -0
  71. data/glfw-src/lib/amigaos/Makefile.amigaos.gcc +128 -0
  72. data/glfw-src/lib/amigaos/Makefile.amigaos.vbcc +128 -0
  73. data/glfw-src/lib/amigaos/SDI_compiler.h +94 -0
  74. data/glfw-src/lib/amigaos/amigaos_enable.c +51 -0
  75. data/glfw-src/lib/amigaos/amigaos_fullscreen.c +319 -0
  76. data/glfw-src/lib/amigaos/amigaos_glext.c +61 -0
  77. data/glfw-src/lib/amigaos/amigaos_init.c +284 -0
  78. data/glfw-src/lib/amigaos/amigaos_joystick.c +359 -0
  79. data/glfw-src/lib/amigaos/amigaos_thread.c +494 -0
  80. data/glfw-src/lib/amigaos/amigaos_time.c +206 -0
  81. data/glfw-src/lib/amigaos/amigaos_window.c +830 -0
  82. data/glfw-src/lib/amigaos/platform.h +337 -0
  83. data/glfw-src/lib/dos/Makefile.dos.djgpp +146 -0
  84. data/glfw-src/lib/dos/dos_enable.c +51 -0
  85. data/glfw-src/lib/dos/dos_events.c +173 -0
  86. data/glfw-src/lib/dos/dos_fullscreen.c +101 -0
  87. data/glfw-src/lib/dos/dos_glext.c +59 -0
  88. data/glfw-src/lib/dos/dos_init.c +105 -0
  89. data/glfw-src/lib/dos/dos_irq.s +246 -0
  90. data/glfw-src/lib/dos/dos_joystick.c +94 -0
  91. data/glfw-src/lib/dos/dos_keyboard.c +694 -0
  92. data/glfw-src/lib/dos/dos_mouse.c +337 -0
  93. data/glfw-src/lib/dos/dos_thread.c +267 -0
  94. data/glfw-src/lib/dos/dos_time.c +309 -0
  95. data/glfw-src/lib/dos/dos_window.c +563 -0
  96. data/glfw-src/lib/dos/platform.h +341 -0
  97. data/glfw-src/lib/enable.c +295 -0
  98. data/glfw-src/lib/fullscreen.c +95 -0
  99. data/glfw-src/lib/glext.c +201 -0
  100. data/glfw-src/lib/image.c +629 -0
  101. data/glfw-src/lib/init.c +108 -0
  102. data/glfw-src/lib/input.c +280 -0
  103. data/glfw-src/lib/internal.h +210 -0
  104. data/glfw-src/lib/joystick.c +101 -0
  105. data/glfw-src/lib/macosx/Makefile.macosx.gcc +172 -0
  106. data/glfw-src/lib/macosx/Makefile.macosx.gcc.universal +166 -0
  107. data/glfw-src/lib/macosx/libglfw.pc.in +11 -0
  108. data/glfw-src/lib/macosx/macosx_enable.c +42 -0
  109. data/glfw-src/lib/macosx/macosx_fullscreen.c +126 -0
  110. data/glfw-src/lib/macosx/macosx_glext.c +52 -0
  111. data/glfw-src/lib/macosx/macosx_init.c +194 -0
  112. data/glfw-src/lib/macosx/macosx_joystick.c +50 -0
  113. data/glfw-src/lib/macosx/macosx_thread.c +414 -0
  114. data/glfw-src/lib/macosx/macosx_time.c +112 -0
  115. data/glfw-src/lib/macosx/macosx_window.c +1279 -0
  116. data/glfw-src/lib/macosx/platform.h +349 -0
  117. data/glfw-src/lib/stream.c +194 -0
  118. data/glfw-src/lib/tga.c +405 -0
  119. data/glfw-src/lib/thread.c +340 -0
  120. data/glfw-src/lib/time.c +83 -0
  121. data/glfw-src/lib/win32/Makefile.win32.bcc +265 -0
  122. data/glfw-src/lib/win32/Makefile.win32.cross-mgw +274 -0
  123. data/glfw-src/lib/win32/Makefile.win32.cygwin +279 -0
  124. data/glfw-src/lib/win32/Makefile.win32.lcc +246 -0
  125. data/glfw-src/lib/win32/Makefile.win32.mgw +243 -0
  126. data/glfw-src/lib/win32/Makefile.win32.msvc +242 -0
  127. data/glfw-src/lib/win32/Makefile.win32.ow +242 -0
  128. data/glfw-src/lib/win32/Makefile.win32.pellesc +242 -0
  129. data/glfw-src/lib/win32/glfwdll.def +67 -0
  130. data/glfw-src/lib/win32/glfwdll_mgw1.def +67 -0
  131. data/glfw-src/lib/win32/glfwdll_mgw2.def +67 -0
  132. data/glfw-src/lib/win32/glfwdll_pellesc.def +65 -0
  133. data/glfw-src/lib/win32/libglfw.pc.in +11 -0
  134. data/glfw-src/lib/win32/platform.h +474 -0
  135. data/glfw-src/lib/win32/win32_dllmain.c +60 -0
  136. data/glfw-src/lib/win32/win32_enable.c +155 -0
  137. data/glfw-src/lib/win32/win32_fullscreen.c +317 -0
  138. data/glfw-src/lib/win32/win32_glext.c +85 -0
  139. data/glfw-src/lib/win32/win32_init.c +356 -0
  140. data/glfw-src/lib/win32/win32_joystick.c +234 -0
  141. data/glfw-src/lib/win32/win32_thread.c +511 -0
  142. data/glfw-src/lib/win32/win32_time.c +146 -0
  143. data/glfw-src/lib/win32/win32_window.c +1714 -0
  144. data/glfw-src/lib/window.c +727 -0
  145. data/glfw-src/lib/x11/Makefile.x11.in +243 -0
  146. data/glfw-src/lib/x11/platform.h +415 -0
  147. data/glfw-src/lib/x11/x11_enable.c +51 -0
  148. data/glfw-src/lib/x11/x11_fullscreen.c +524 -0
  149. data/glfw-src/lib/x11/x11_glext.c +69 -0
  150. data/glfw-src/lib/x11/x11_init.c +275 -0
  151. data/glfw-src/lib/x11/x11_joystick.c +371 -0
  152. data/glfw-src/lib/x11/x11_keysym2unicode.c +902 -0
  153. data/glfw-src/lib/x11/x11_thread.c +507 -0
  154. data/glfw-src/lib/x11/x11_time.c +154 -0
  155. data/glfw-src/lib/x11/x11_window.c +1746 -0
  156. data/glfw-src/license.txt +21 -0
  157. data/glfw-src/readme.html +927 -0
  158. data/glfw-src/support/d/examples/Makefile +59 -0
  159. data/glfw-src/support/d/examples/boing.d +610 -0
  160. data/glfw-src/support/d/examples/gears.d +379 -0
  161. data/glfw-src/support/d/examples/keytest.d +272 -0
  162. data/glfw-src/support/d/examples/listmodes.d +48 -0
  163. data/glfw-src/support/d/examples/mipmaps.d +126 -0
  164. data/glfw-src/support/d/examples/mtbench.d +304 -0
  165. data/glfw-src/support/d/examples/mthello.d +54 -0
  166. data/glfw-src/support/d/examples/particles.d +1150 -0
  167. data/glfw-src/support/d/examples/pong3d.d +840 -0
  168. data/glfw-src/support/d/examples/splitview.d +486 -0
  169. data/glfw-src/support/d/examples/triangle.d +108 -0
  170. data/glfw-src/support/d/examples/wave.d +400 -0
  171. data/glfw-src/support/d/imports/gl.d +4539 -0
  172. data/glfw-src/support/d/imports/glfw.d +349 -0
  173. data/glfw-src/support/d/imports/glu.d +328 -0
  174. data/glfw-src/support/d/lib/glfwdll.def +64 -0
  175. data/glfw-src/support/d/lib/glu32.def +56 -0
  176. data/glfw-src/support/d/lib/makefile +12 -0
  177. data/glfw-src/support/d/lib/opengl32.def +372 -0
  178. data/glfw-src/support/d/readme.html +83 -0
  179. data/glfw-src/support/delphi/examples/Triangle.dpr +105 -0
  180. data/glfw-src/support/delphi/lib/glfw.pas +437 -0
  181. data/glfw-src/support/delphi/readme.html +97 -0
  182. data/glfw-src/support/lua/examples/gears.lua +383 -0
  183. data/glfw-src/support/lua/examples/test1.lua +68 -0
  184. data/glfw-src/support/lua/readme.html +128 -0
  185. data/glfw-src/support/lua/src/luaglfw.c +1179 -0
  186. data/glfw-src/support/lua/src/luaglfw.h +48 -0
  187. data/glfw-src/support/lua/src/runlua.c +82 -0
  188. data/glfw-src/support/masm/examples/fpc.mac +47 -0
  189. data/glfw-src/support/masm/examples/makeit.bat +66 -0
  190. data/glfw-src/support/masm/examples/triangle.asm +232 -0
  191. data/glfw-src/support/masm/include/glfw.inc +326 -0
  192. data/glfw-src/support/masm/include/glu32.inc +55 -0
  193. data/glfw-src/support/masm/include/opengl32.inc +372 -0
  194. data/glfw-src/support/masm/lib/glfwdll.lib +0 -0
  195. data/glfw-src/support/masm/readme.html +170 -0
  196. data/glfw-src/support/msvc80/GLFW.sln +26 -0
  197. data/glfw-src/support/msvc80/GLFW.vcproj +257 -0
  198. data/glfw-src/support/msvc80/GLFWDLL.vcproj +287 -0
  199. data/glfw-src/support/visualbasic/bindings/glfw.bas +320 -0
  200. data/glfw-src/support/visualbasic/bindings/glu32.bas +284 -0
  201. data/glfw-src/support/visualbasic/bindings/opengl32.bas +999 -0
  202. data/glfw-src/support/visualbasic/examples/Triangle.bas +101 -0
  203. data/glfw-src/support/visualbasic/readme.html +164 -0
  204. data/website/index.html +84 -0
  205. data/website/style.css +110 -0
  206. metadata +301 -0
@@ -0,0 +1,57 @@
1
+ ##########################################################################
2
+ # Makefile for the GLFW documentation.
3
+ ##########################################################################
4
+
5
+ PDFDOCS = glfwrm.pdf glfwug.pdf
6
+ DVIDOCS = glfwrm.dvi glfwug.dvi
7
+
8
+
9
+ ##########################################################################
10
+ # Build macros
11
+ ##########################################################################
12
+ default: pdf
13
+ pdf: $(PDFDOCS)
14
+ dvi: $(DVIDOCS)
15
+
16
+
17
+ ##########################################################################
18
+ # Clean macros
19
+ ##########################################################################
20
+ clean:
21
+ rm -f glfwrm.dvi glfwrm.aux glfwrm.log glfwrm.out glfwrm.pdf glfwrm.toc glfwrm.lot
22
+ rm -f glfwug.dvi glfwug.aux glfwug.log glfwug.out glfwug.pdf glfwug.toc
23
+
24
+ clean-win:
25
+ @.\\cleanup.bat
26
+
27
+
28
+ ##########################################################################
29
+ # Rules for building the GLFW Reference Manual
30
+ ##########################################################################
31
+
32
+ glfwrm.pdf: glfwrm.tex glfwrm.toc glfwrm.lot glfwdoc.sty
33
+ pdflatex glfwrm.tex
34
+
35
+ glfwrm.dvi: glfwrm.tex glfwrm.toc glfwrm.lot glfwdoc.sty
36
+ latex glfwrm.tex
37
+
38
+ glfwrm.toc: glfwrm.tex glfwdoc.sty
39
+ latex glfwrm.tex
40
+
41
+ glfwrm.lot: glfwrm.tex glfwdoc.sty
42
+ latex glfwrm.tex
43
+
44
+
45
+ ##########################################################################
46
+ # Rules for building the GLFW Users Guide
47
+ ##########################################################################
48
+
49
+ glfwug.pdf: glfwug.tex glfwug.toc glfwdoc.sty
50
+ pdflatex glfwug.tex
51
+
52
+ glfwug.dvi: glfwug.tex glfwug.toc glfwdoc.sty
53
+ latex glfwug.tex
54
+
55
+ glfwug.toc: glfwug.tex glfwdoc.sty
56
+ latex glfwug.tex
57
+
@@ -0,0 +1,22 @@
1
+ @echo off
2
+
3
+ REM ----------------------------------------------------------------------
4
+ REM Windows cleanup batch file for the GLFW documentation.
5
+ REM ----------------------------------------------------------------------
6
+
7
+ REM GLFW Reference Manual
8
+ if exist glfwrm.dvi del glfwrm.dvi
9
+ if exist glfwrm.aux del glfwrm.aux
10
+ if exist glfwrm.log del glfwrm.log
11
+ if exist glfwrm.out del glfwrm.out
12
+ if exist glfwrm.pdf del glfwrm.pdf
13
+ if exist glfwrm.toc del glfwrm.toc
14
+ if exist glfwrm.lot del glfwrm.lot
15
+
16
+ REM GLFW Users Guide
17
+ if exist glfwug.dvi del glfwug.dvi
18
+ if exist glfwug.aux del glfwug.aux
19
+ if exist glfwug.log del glfwug.log
20
+ if exist glfwug.out del glfwug.out
21
+ if exist glfwug.pdf del glfwug.pdf
22
+ if exist glfwug.toc del glfwug.toc
@@ -0,0 +1,80 @@
1
+ %-------------------------------------------------------------------------
2
+ % Common document formatting and macros for GLFW manuals
3
+ %-------------------------------------------------------------------------
4
+
5
+ % Misc. document info
6
+ \date{\today}
7
+
8
+ % Packages
9
+ \usepackage{fancyhdr}
10
+ \usepackage{titling}
11
+ \usepackage{lastpage}
12
+ \usepackage{listings}
13
+ \usepackage{color}
14
+ \usepackage[overload]{textcase}
15
+ \usepackage{needspace}
16
+ \usepackage{times}
17
+
18
+ % Logo macros
19
+ \newcommand{\OpenGL}[1][0]{\textbf{OpenGL}\texttrademark}
20
+ \newcommand{\GLFW}[1][0]{\textbf{GLFW}}
21
+
22
+ % Encoding
23
+ \usepackage[latin1]{inputenc}
24
+ \usepackage[T1]{fontenc}
25
+
26
+ % Page formatting
27
+ \usepackage[hmargin=2.5cm]{geometry}
28
+ \raggedright
29
+ \raggedbottom
30
+ \sloppy
31
+ \usepackage{parskip}
32
+
33
+ % Header and footer
34
+ \pagestyle{fancy}
35
+ %\lhead{\textit{GLFW Reference Manual}}
36
+ \lhead{\textit{GLFW \glfwdoctype}}
37
+ \chead{API version \glfwapiver}
38
+ \rhead{Page \thepage/\pageref{LastPage}}
39
+ \lfoot{}
40
+ \cfoot{}
41
+ \rfoot{}
42
+ \renewcommand{\headrulewidth}{0.4pt}
43
+ \renewcommand{\footrulewidth}{0.0pt}
44
+
45
+ % Titlepage
46
+ \newcommand{\glfwmaketitle}{\begin{titlepage}\ \\%
47
+ \begin{center}%
48
+ \vspace{7.0cm}{\Huge\textbf{GLFW}}\\%
49
+ \rule{10.0cm}{0.5pt}\\%
50
+ \vspace{0.5cm}{\LARGE\textbf{\glfwdoctype}}\\%
51
+ \vspace{0.8cm}{\large\textbf{API version \glfwapiver}}\\%
52
+ \textit{\today}\\%
53
+ \vspace{1.5cm}\textbf{\textcopyright2002-2007 Camilla Berglund}\\%
54
+ \end{center}\end{titlepage}\newpage}
55
+
56
+ % Colors
57
+ \definecolor{code}{rgb}{0.9,0.9,1.0}
58
+ \definecolor{link}{rgb}{0.6,0.0,0.0}
59
+ \definecolor{codeA}{rgb}{0.9,1.0,0.9}
60
+ \definecolor{codeB}{rgb}{1.0,0.9,0.9}
61
+
62
+ % Code listings
63
+ \lstset{frame=single,frameround=tttt,backgroundcolor=\color{code},%
64
+ language=C,basicstyle={\ttfamily},%
65
+ breaklines,breakindent=0pt,postbreak=\space\space\space\space}
66
+
67
+
68
+ % A simple hack for keeping lines together
69
+ \newenvironment{mysamepage}[1][2]{\begin{samepage}\needspace{#1\baselineskip}}{\end{samepage}}
70
+
71
+ % Macros for automating function reference entries
72
+ \newenvironment{refparameters}[1][0]{\begin{mysamepage}\textbf{Parameters}\\}{\end{mysamepage}\bigskip}
73
+ \newenvironment{refreturn}[1][0]{\begin{mysamepage}\textbf{Return values}\\}{\end{mysamepage}\bigskip}
74
+ \newenvironment{refdescription}[1][0]{\begin{mysamepage}\textbf{Description}\\}{\end{mysamepage}\bigskip}
75
+ \newenvironment{refnotes}[1][0]{\begin{mysamepage}\textbf{Notes}\\}{\end{mysamepage}\bigskip}
76
+
77
+ % hyperref (bookmarks, links etc) - use this package last
78
+ \usepackage[colorlinks=true,linkcolor=link,bookmarks=true,bookmarksopen=true,%
79
+ pdfhighlight=/N,bookmarksnumbered=true,bookmarksopenlevel=1,%
80
+ pdfview=FitH,pdfstartview=FitH]{hyperref}
@@ -0,0 +1,3034 @@
1
+ %-------------------------------------------------------------------------
2
+ % GLFW Reference Manual
3
+ % API Version: 2.6
4
+ %-------------------------------------------------------------------------
5
+
6
+ % Document class
7
+ \documentclass[a4paper,11pt,oneside]{report}
8
+
9
+ % Document title and API version
10
+ \newcommand{\glfwdoctype}[1][0]{Reference Manual}
11
+ \newcommand{\glfwapiver}[1][0]{2.6}
12
+
13
+ % Common document settings and macros
14
+ \input{glfwdoc.sty}
15
+
16
+ % PDF specific document settings
17
+ \hypersetup{pdftitle={GLFW Reference Manual}}
18
+ \hypersetup{pdfauthor={Marcus Geelnard}}
19
+ \hypersetup{pdfkeywords={GLFW,OpenGL,reference,manual}}
20
+
21
+
22
+ %-------------------------------------------------------------------------
23
+ % Document body
24
+ %-------------------------------------------------------------------------
25
+
26
+ \begin{document}
27
+
28
+ \pagestyle{plain}
29
+
30
+ % Title page
31
+ \glfwmaketitle
32
+
33
+ % Summary, trademarks and table of contents
34
+ \pagenumbering{roman}
35
+ \setcounter{page}{1}
36
+
37
+ %-------------------------------------------------------------------------
38
+ % Summary and Trademarks
39
+ %-------------------------------------------------------------------------
40
+ \chapter*{Summary}
41
+
42
+ This document is primarily a function reference manual for the \GLFW\ API.
43
+ For a description of how to use \GLFW\ you should refer to the
44
+ \textit{GLFW Users Guide}.
45
+ \vspace{10cm}
46
+
47
+ \large
48
+ Trademarks
49
+
50
+ \small
51
+ OpenGL and IRIX are registered trademarks of Silicon Graphics, Inc.\linebreak
52
+ Microsoft and Windows are registered trademarks of Microsoft Corporation.\linebreak
53
+ Mac OS is a registered trademark of Apple Computer, Inc.\linebreak
54
+ Linux is a registered trademark of Linus Torvalds.\linebreak
55
+ FreeBSD is a registered trademark of Wind River Systems, Inc.\linebreak
56
+ Solaris is a trademark of Sun Microsystems, Inc.\linebreak
57
+ UNIX is a registered trademark of The Open Group.\linebreak
58
+ X Window System is a trademark of The Open Group.\linebreak
59
+ POSIX is a trademark of IEEE.\linebreak
60
+ Truevision, TARGA and TGA are registered trademarks of Truevision, Inc.\linebreak
61
+
62
+ All other trademarks mentioned in this document are the property of their respective owners.
63
+ \normalsize
64
+
65
+
66
+ %-------------------------------------------------------------------------
67
+ % Table of contents
68
+ %-------------------------------------------------------------------------
69
+ \tableofcontents
70
+
71
+ %-------------------------------------------------------------------------
72
+ % List of tables
73
+ %-------------------------------------------------------------------------
74
+ \listoftables
75
+ \pagebreak
76
+
77
+
78
+ % Document chapters starts here...
79
+ \pagenumbering{arabic}
80
+ \setcounter{page}{1}
81
+
82
+ \pagestyle{fancy}
83
+
84
+
85
+ %-------------------------------------------------------------------------
86
+ % Introduction
87
+ %-------------------------------------------------------------------------
88
+ \chapter{Introduction}
89
+ \thispagestyle{fancy}
90
+
91
+ \GLFW\ is a portable API (Application Program Interface) that handles
92
+ operating system specific tasks related to \OpenGL\ programming. While
93
+ \OpenGL\ in general is portable, easy to use and often results in tidy and
94
+ compact code, the operating system specific mechanisms that are required
95
+ to set up and manage an \OpenGL\ window are quite the opposite. \GLFW\ tries
96
+ to remedy this by providing the following functionality:
97
+
98
+ \begin{itemize}
99
+ \item Opening and managing an \OpenGL\ window.
100
+ \item Keyboard, mouse and joystick input.
101
+ \item A high precision timer.
102
+ \item Multi threading support.
103
+ \item Support for querying and using \OpenGL\ extensions.
104
+ \item Image file loading support.
105
+ \end{itemize}
106
+ \vspace{18pt}
107
+
108
+ All this functionality is implemented as a set of easy-to-use functions,
109
+ which makes it possible to write an \OpenGL\ application framework in just a
110
+ few lines of code. The \GLFW\ API is completely operating system and
111
+ platform independent, which makes it very simple to port \GLFW\ based \OpenGL\
112
+ applications to a variety of platforms.
113
+
114
+ Currently supported platforms are:
115
+ \begin{itemize}
116
+ \item Microsoft Windows\textsuperscript{\textregistered} 95/98/ME/NT/2000/XP/Vista.
117
+ \item Unix\textsuperscript{\textregistered} or Unix�-like systems running the
118
+ X Window System\texttrademark, e.g. Linux\textsuperscript{\textregistered},
119
+ IRIX\textsuperscript{\textregistered}, FreeBSD\textsuperscript{\textregistered},
120
+ Solaris\texttrademark, QNX\textsuperscript{\textregistered} and
121
+ Mac OS\textsuperscript{\textregistered} X.
122
+ \item Mac OS\textsuperscript{\textregistered} X (Carbon)\footnote{Support for joysticks missing at the time of writing.}
123
+ \end{itemize}
124
+
125
+
126
+
127
+ %-------------------------------------------------------------------------
128
+ % GLFW Operation
129
+ %-------------------------------------------------------------------------
130
+ \chapter{GLFW Operation Overview}
131
+ \thispagestyle{fancy}
132
+
133
+
134
+ %-------------------------------------------------------------------------
135
+ \section{The GLFW Window}
136
+ \GLFW\ only supports one opened window at a time. The window can be either
137
+ a normal desktop window or a fullscreen window. The latter is completely
138
+ undecorated, without window borders, and covers the entire monitor. With
139
+ a fullscreen window, it is also possible to select which video mode to use.
140
+
141
+ When a window is opened, an \OpenGL\ rendering context is created and
142
+ attached to the entire client area of the window. When the window is closed,
143
+ the \OpenGL\ rendering context is detached and destroyed.
144
+
145
+ Through a window it is possible to receive user input in the form of
146
+ keyboard and mouse input. User input is exposed through the \GLFW\ API via
147
+ callback functions. There are different callback functions for dealing with
148
+ different kinds of user input. Also, \GLFW\ stores most user input as
149
+ internal state that can be queried through different \GLFW\ API functions
150
+ (for instance it is possible to query the position of the mouse cursor
151
+ with the \textbf{glfwGetMousePos} function).
152
+
153
+ As for user input, it is possible to receive information about window
154
+ state changes, such as window resize or close events, through callback
155
+ functions. It is also possible to query different kinds of window
156
+ information through different \GLFW\ API functions.
157
+
158
+
159
+ %-------------------------------------------------------------------------
160
+ \section{The GLFW Event Loop}
161
+ The \GLFW\ event loop is an open loop, which means that it is up to the
162
+ programmer to design the loop. Events are processed by calling specific
163
+ \GLFW\ functions, which in turn query the system for new input and window
164
+ events, and reports these events back to the program through callback
165
+ functions.
166
+
167
+ The programmer decides when to call the event processing functions, and
168
+ when to abort the event loop.
169
+
170
+ In pseudo language, a typical event loop might look like this:
171
+
172
+ \begin{lstlisting}
173
+ repeat until window is closed
174
+ {
175
+ poll events
176
+ draw OpenGL graphics
177
+ }
178
+ \end{lstlisting}
179
+
180
+ There are two ways to handle events in \GLFW :
181
+
182
+ \begin{itemize}
183
+ \item Block the event loop while waiting for new events.
184
+ \item Poll for new events, and continue the loop regardless if there are
185
+ any new events or not.
186
+ \end{itemize}
187
+
188
+ The first method is useful for interactive applications that do not
189
+ need to refresh the \OpenGL\ display unless the user interacts with the
190
+ application through user input. Typical applications are CAD software
191
+ and other kinds of editors.
192
+
193
+ The second method is useful for applications that need to refresh the
194
+ \OpenGL\ display constantly, regardless of user input, such as games,
195
+ demos, 3D animations, screen savers and so on.
196
+
197
+
198
+ %-------------------------------------------------------------------------
199
+ \section{Callback Functions}
200
+ Using callback functions can be a good method for receiving up to date
201
+ information about window state and user input. When a window has been
202
+ opened, it is possible to register custom callback functions that will
203
+ be called when certain events occur.
204
+
205
+ Callback functions are called from any of the event polling functions
206
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
207
+ \textbf{glfwSwapBuffers}.
208
+
209
+ Callback functions should \emph{only} be used to gather information. Since
210
+ the callback functions are called from within the internal \GLFW\ event
211
+ polling loops, they should not call any \GLFW\ functions that might
212
+ result in considerable \GLFW\ state changes, nor stall the event polling
213
+ loop for a lengthy period of time.
214
+
215
+ In other words, most or all \OpenGL\ rendering should be called from the
216
+ main application event loop, not from any of the \GLFW\ callback
217
+ functions. Also, the only \GLFW\ functions that may be safely called from
218
+ callback functions are the different Get functions (e.g.
219
+ \textbf{glfwGetKey}, \textbf{glfwGetTime}, \textbf{glfwGetWindowParam}
220
+ etc).
221
+
222
+
223
+ %-------------------------------------------------------------------------
224
+ \section{Threads}
225
+ \GLFW\ has functions for creating threads, which means that it is possible
226
+ to make multi threaded applications with \GLFW . The thread that calls
227
+ glfwInit becomes the main thread, and it is recommended that all
228
+ \GLFW\ and \OpenGL\ functions are called from the main thread. Additional
229
+ threads should primarily be used for CPU heavy tasks or for managing
230
+ other resources, such as file or sound I/O.
231
+
232
+ It should be noted that the current implementation of \GLFW\ is not thread
233
+ safe, so you should never call \GLFW\ functions from different threads.
234
+ \footnote{Of course, all thread managing functions are thread safe.}
235
+
236
+
237
+ %-------------------------------------------------------------------------
238
+ % Function Reference
239
+ %-------------------------------------------------------------------------
240
+ \chapter{Function Reference}
241
+ \thispagestyle{fancy}
242
+
243
+ %-------------------------------------------------------------------------
244
+ \section{GLFW Initialization and Termination}
245
+ Before any \GLFW\ functions can be used, \GLFW\ must be initialized to
246
+ ensure proper functionality, and before a program terminates, \GLFW\ has to
247
+ be terminated in order to free up resources etc.
248
+
249
+
250
+ %-------------------------------------------------------------------------
251
+ \subsection{glfwInit}
252
+
253
+ \textbf{C language syntax}
254
+ \begin{lstlisting}
255
+ int glfwInit( void )
256
+ \end{lstlisting}
257
+
258
+ \begin{refparameters}
259
+ none
260
+ \end{refparameters}
261
+
262
+ \begin{refreturn}
263
+ If the function succeeds, GL\_TRUE is returned.\\
264
+ If the function fails, GL\_FALSE is returned.
265
+ \end{refreturn}
266
+
267
+ \begin{refdescription}
268
+ The glfwInit function initializes \GLFW. No other \GLFW\ functions may be
269
+ used before this function has been called.
270
+ \end{refdescription}
271
+
272
+ \begin{refnotes}
273
+ This function may take several seconds to complete on some systems, while
274
+ on other systems it may take only a fraction of a second to complete.
275
+ \end{refnotes}
276
+
277
+
278
+ %-------------------------------------------------------------------------
279
+ \subsection{glfwTerminate}
280
+
281
+ \textbf{C language syntax}
282
+ \begin{lstlisting}
283
+ void glfwTerminate( void )
284
+ \end{lstlisting}
285
+
286
+ \begin{refparameters}
287
+ none
288
+ \end{refparameters}
289
+
290
+ \begin{refreturn}
291
+ none
292
+ \end{refreturn}
293
+
294
+ \begin{refdescription}
295
+ The function terminates \GLFW. Among other things it closes the window,
296
+ if it is opened, and kills any running threads. This function must be
297
+ called before a program exits.
298
+ \end{refdescription}
299
+
300
+
301
+ %-------------------------------------------------------------------------
302
+ \subsection{glfwGetVersion}
303
+
304
+ \textbf{C language syntax}
305
+ \begin{lstlisting}
306
+ void glfwGetVersion( int *major, int *minor, int *rev )
307
+ \end{lstlisting}
308
+
309
+ \begin{refparameters}
310
+ \begin{description}
311
+ \item [\textit{major}]\ \\
312
+ Pointer to an integer that will hold the major version number.
313
+ \item [\textit{minor}]\ \\
314
+ Pointer to an integer that will hold the minor version number.
315
+ \item [\textit{rev}]\ \\
316
+ Pointer to an integer that will hold the revision.
317
+ \end{description}
318
+ \end{refparameters}
319
+
320
+ \begin{refreturn}
321
+ The function returns the major and minor version numbers and the revision
322
+ for the currently linked \GLFW\ library.
323
+ \end{refreturn}
324
+
325
+ \begin{refdescription}
326
+ The function returns the \GLFW\ library version.
327
+ \end{refdescription}
328
+
329
+
330
+ %-------------------------------------------------------------------------
331
+ \pagebreak
332
+ \section{Window Handling}
333
+ The main functionality of \GLFW\ is to provide a simple interface to
334
+ \OpenGL\ window management. \GLFW\ can open one window, which can be
335
+ either a normal desktop window or a fullscreen window.
336
+
337
+
338
+ %-------------------------------------------------------------------------
339
+ \subsection{glfwOpenWindow}
340
+
341
+ \textbf{C language syntax}
342
+ \begin{lstlisting}
343
+ int glfwOpenWindow( int width, int height, int redbits,
344
+ int greenbits, int bluebits, int alphabits, int depthbits,
345
+ int stencilbits, int mode )
346
+ \end{lstlisting}
347
+
348
+ \begin{refparameters}
349
+ \begin{description}
350
+ \item [\textit{width}]\ \\
351
+ The width of the window. If \textit{width} is zero, it will be
352
+ calculated as ${width=\frac{4}{3}height}$, if \textit{height} is not
353
+ zero. If both \textit{width} and \textit{height} are zero, then
354
+ \textit{width} will be set to 640.
355
+ \item [\textit{hieght}]\ \\
356
+ The height of the window. If \textit{height} is zero, it will be
357
+ calculated as ${height=\frac{3}{4}width}$, if \textit{width} is not
358
+ zero. If both \textit{width} and \textit{height} are zero, then
359
+ \textit{height} will be set to 480.
360
+ \item [\textit{redbits, greenbits, bluebits}]\ \\
361
+ The number of bits to use for each color component of the color buffer
362
+ (0 means default color depth). For instance, setting \textit{redbits=5,
363
+ greenbits=6, and bluebits=5} will generate a 16-�bit color buffer, if
364
+ possible.
365
+ \item [\textit{alphabits}]\ \\
366
+ The number of bits to use for the alpha buffer (0 means no alpha
367
+ buffer).
368
+ \item [\textit{depthbits}]\ \\
369
+ The number of bits to use for the depth buffer (0 means no depth
370
+ buffer).
371
+ \item [\textit{stencilbits}]\ \\
372
+ The number of bits to use for the stencil buffer (0 means no stencil
373
+ buffer).
374
+ \item [\textit{mode}]\ \\
375
+ Selects which type of \OpenGL\ window to use. \textit{mode} can be
376
+ either GLFW\_WINDOW, which will generate a normal desktop window, or
377
+ GLFW\_FULLSCREEN, which will generate a window which covers the entire
378
+ screen. When GLFW\_FULLSCREEN is selected, the video mode will be
379
+ changed to the resolution that closest matches the \textit{width} and
380
+ \textit{height} parameters.
381
+ \end{description}
382
+ \end{refparameters}
383
+
384
+ \begin{refreturn}
385
+ If the function succeeds, GL\_TRUE is returned.\\
386
+ If the function fails, GL\_FALSE is returned.
387
+ \end{refreturn}
388
+
389
+ \begin{refdescription}
390
+ The function opens a window that best matches the parameters given to the
391
+ function. How well the resulting window matches the desired window depends
392
+ mostly on the available hardware and \OpenGL\ drivers. In general,
393
+ selecting a fullscreen mode has better chances of generating a close match
394
+ than does a normal desktop window, since \GLFW\ can freely select from all
395
+ the available video modes. A desktop window is normally restricted to the
396
+ video mode of the desktop.
397
+ \end{refdescription}
398
+
399
+ \begin{refnotes}
400
+ For additional control of window properties, see
401
+ \textbf{glfwOpenWindowHint}.
402
+
403
+ In fullscreen mode the mouse cursor is hidden by default, and any system
404
+ screensavers are prohibited from starting. In windowed mode the mouse
405
+ cursor is visible, and screensavers are allowed to start. To change the
406
+ visibility of the mouse cursor, use \textbf{glfwEnable} or
407
+ \textbf{glfwDisable} with the argument GLFW\_MOUSE\_CURSOR.
408
+
409
+ In order to determine the actual properties of an opened window, use
410
+ \textbf{glfwGetWindowParam} and \textbf{glfwGetWindowSize} (or
411
+ \textbf{glfwSetWindowSizeCallback}).
412
+ \end{refnotes}
413
+
414
+
415
+ %-------------------------------------------------------------------------
416
+ \begin{table}[p]
417
+ \begin{center}
418
+ \begin{tabular}{|l|l|p{7.0cm}|} \hline \raggedright
419
+ \textbf{Name} & \textbf{Default} & \textbf{Description} \\ \hline
420
+ GLFW\_REFRESH\_RATE & 0 & Vertical monitor refresh rate in Hz (only used for fullscreen windows). Zero means system default.\\ \hline
421
+ GLFW\_ACCUM\_RED\_BITS & 0 & Number of bits for the red channel of the accumulator buffer.\\ \hline
422
+ GLFW\_ACCUM\_GREEN\_BITS & 0 & Number of bits for the green channel of the accumulator buffer.\\ \hline
423
+ GLFW\_ACCUM\_BLUE\_BITS & 0 & Number of bits for the blue channel of the accumulator buffer.\\ \hline
424
+ GLFW\_ACCUM\_ALPHA\_BITS & 0 & Number of bits for the alpha channel of the accumulator buffer.\\ \hline
425
+ GLFW\_AUX\_BUFFERS & 0 & Number of auxiliary buffers.\\ \hline
426
+ GLFW\_STEREO & GL\_FALSE & Specify if stereo rendering should be supported (can be GL\_TRUE or GL\_FALSE).\\ \hline
427
+ GLFW\_WINDOW\_NO\_RESIZE & GL\_FALSE & Specify whether the window can be resized (not used for fullscreen windows).\\ \hline
428
+ GLFW\_FSAA\_SAMPLES & 0 & Number of samples to use for the multisampling buffer. Zero disables multisampling.\\ \hline
429
+ \end{tabular}
430
+ \end{center}
431
+ \caption{Targets for \textbf{glfwOpenWindowHint}}
432
+ \label{tab:winhints}
433
+ \end{table}
434
+
435
+
436
+ %-------------------------------------------------------------------------
437
+ \subsection{glfwOpenWindowHint}
438
+
439
+ \textbf{C language syntax}
440
+ \begin{lstlisting}
441
+ void glfwOpenWindowHint( int target, int hint )
442
+ \end{lstlisting}
443
+
444
+ \begin{refparameters}
445
+ \begin{description}
446
+ \item [\textit{target}]\ \\
447
+ Can be any of the constants in the table \ref{tab:winhints}.
448
+ \item [\textit{hint}]\ \\
449
+ An integer giving the value of the corresponding target (see table
450
+ \ref{tab:winhints}).
451
+ \end{description}
452
+ \end{refparameters}
453
+
454
+ \begin{refreturn}
455
+ none
456
+ \end{refreturn}
457
+
458
+ \begin{refdescription}
459
+ The function sets additional properties for a window that is to be opened.
460
+ For a hint to be registered, the function must be called before calling
461
+ \textbf{glfwOpenWindow}. When the \textbf{glfwOpenWindow} function is
462
+ called, any hints that were registered with the \textbf{glfwOpenWindowHint}
463
+ function are used for setting the corresponding window properties, and
464
+ then all hints are reset to their default values.
465
+ \end{refdescription}
466
+
467
+ \begin{refnotes}
468
+ In order to determine the actual properties of an opened window, use
469
+ \textbf{glfwGetWindowParam} (after the window has been opened).
470
+
471
+ GLFW\_STEREO is a hard constraint. If stereo rendering is requested, but
472
+ no stereo rendering capable pixel formats / visuals are available,
473
+ \textbf{glfwOpenWindow} will fail.
474
+
475
+ The GLFW\_REFRESH\_RATE property should be used with caution. Most
476
+ systems have default values for monitor refresh rates that are optimal
477
+ for the specific system. Specifying the refresh rate can override these
478
+ settings, which can result in suboptimal operation. The monitor may be
479
+ unable to display the resulting video signal, or in the worst case it may
480
+ even be damaged!
481
+ \end{refnotes}
482
+
483
+
484
+ %-------------------------------------------------------------------------
485
+ \subsection{glfwCloseWindow}
486
+
487
+ \textbf{C language syntax}
488
+ \begin{lstlisting}
489
+ void glfwCloseWindow( void )
490
+ \end{lstlisting}
491
+
492
+ \begin{refparameters}
493
+ none
494
+ \end{refparameters}
495
+
496
+ \begin{refreturn}
497
+ none
498
+ \end{refreturn}
499
+
500
+ \begin{refdescription}
501
+ The function closes an opened window and destroys the associated \OpenGL\
502
+ context.
503
+ \end{refdescription}
504
+
505
+
506
+ %-------------------------------------------------------------------------
507
+ \subsection{glfwSetWindowCloseCallback}
508
+
509
+ \textbf{C language syntax}
510
+ \begin{lstlisting}
511
+ void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun )
512
+ \end{lstlisting}
513
+
514
+ \begin{refparameters}
515
+ \begin{description}
516
+ \item [\textit{cbfun}]\ \\
517
+ Pointer to a callback function that will be called when a user requests
518
+ that the window should be closed, typically by clicking the window close
519
+ icon (e.g. the cross in the upper right corner of a window under
520
+ Microsoft Windows). The function should have the following C language
521
+ prototype:
522
+
523
+ \texttt{int GLFWCALL functionname( void );}
524
+
525
+ Where \textit{functionname} is the name of the callback function. The
526
+ return value of the callback function indicates wether or not the window
527
+ close action should continue. If the function returns GL\_TRUE, the
528
+ window will be closed. If the function returns GL\_FALSE, the window
529
+ will not be closed.
530
+
531
+ If \textit{cbfun} is NULL, any previously selected callback function
532
+ will be deselected.
533
+ \end{description}
534
+ \end{refparameters}
535
+
536
+ \begin{refreturn}
537
+ none
538
+ \end{refreturn}
539
+
540
+ \begin{refdescription}
541
+ The function selects which function to be called upon a window close
542
+ event.
543
+
544
+ A window has to be opened for this function to have any effect.
545
+ \end{refdescription}
546
+
547
+ \begin{refnotes}
548
+ Window close events are recorded continuously, but only reported when
549
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
550
+ \textbf{glfwSwapBuffers} is called.
551
+
552
+ The \OpenGL\ context is still valid when this function is called.
553
+
554
+ Note that the window close callback function is not called when
555
+ \textbf{glfwCloseWindow} is called, but only when the close request
556
+ comes from the window manager.
557
+
558
+ Do \emph{not} call \textbf{glfwCloseWindow} from a window close
559
+ callback function. Close the window by returning GL\_TRUE from the
560
+ function.
561
+ \end{refnotes}
562
+
563
+
564
+ %-------------------------------------------------------------------------
565
+ \subsection{glfwSetWindowTitle}
566
+
567
+ \textbf{C language syntax}
568
+ \begin{lstlisting}
569
+ void glfwSetWindowTitle( const char *title )
570
+ \end{lstlisting}
571
+
572
+ \begin{refparameters}
573
+ \begin{description}
574
+ \item [\textit{title}]\ \\
575
+ Pointer to a null terminated ISO~8859-1 (8-bit Latin~1) string that
576
+ holds the title of the window.
577
+ \end{description}
578
+ \end{refparameters}
579
+
580
+ \begin{refreturn}
581
+ none
582
+ \end{refreturn}
583
+
584
+ \begin{refdescription}
585
+ The function changes the title of the opened window.
586
+ \end{refdescription}
587
+
588
+ \begin{refnotes}
589
+ The title property of a window is often used in situations other than for
590
+ the window title, such as the title of an application icon when it is in
591
+ iconified state.
592
+ \end{refnotes}
593
+
594
+
595
+ %-------------------------------------------------------------------------
596
+ \subsection{glfwSetWindowSize}
597
+
598
+ \textbf{C language syntax}
599
+ \begin{lstlisting}
600
+ void glfwSetWindowSize( int width, int height )
601
+ \end{lstlisting}
602
+
603
+ \begin{refparameters}
604
+ \begin{description}
605
+ \item [\textit{width}]\ \\
606
+ Width of the window.
607
+ \item [\textit{height}]\ \\
608
+ Height of the window.
609
+ \end{description}
610
+ \end{refparameters}
611
+
612
+ \begin{refreturn}
613
+ none
614
+ \end{refreturn}
615
+
616
+ \begin{refdescription}
617
+ The function changes the size of an opened window. The \textit{width} and
618
+ \textit{height} parameters denote the size of the client area of the
619
+ window (i.e. excluding any window borders and decorations).
620
+
621
+ If the window is in fullscreen mode, the video mode will be changed to a
622
+ resolution that closest matches the width and height parameters (the
623
+ number of color bits will not be changed).
624
+ \end{refdescription}
625
+
626
+ \begin{refnotes}
627
+ The \OpenGL\ context is guaranteed to be preserved after calling
628
+ \textbf{glfwSetWindowSize}, even if the video mode is changed.
629
+ \end{refnotes}
630
+
631
+
632
+ %-------------------------------------------------------------------------
633
+ \subsection{glfwSetWindowPos}
634
+
635
+ \textbf{C language syntax}
636
+ \begin{lstlisting}
637
+ void glfwSetWindowPos( int x, int y )
638
+ \end{lstlisting}
639
+
640
+ \begin{refparameters}
641
+ \begin{description}
642
+ \item [\textit{x}]\ \\
643
+ Horizontal position of the window, relative to the upper left corner
644
+ of the desktop.
645
+ \item [\textit{y}]\ \\
646
+ Vertical position of the window, relative to the upper left corner of
647
+ the desktop.
648
+ \end{description}
649
+ \end{refparameters}
650
+
651
+ \begin{refreturn}
652
+ none
653
+ \end{refreturn}
654
+
655
+ \begin{refdescription}
656
+ The function changes the position of an opened window. It does not have
657
+ any effect on a fullscreen window.
658
+ \end{refdescription}
659
+
660
+
661
+ %-------------------------------------------------------------------------
662
+ \subsection{glfwGetWindowSize}
663
+
664
+ \textbf{C language syntax}
665
+ \begin{lstlisting}
666
+ void glfwGetWindowSize( int *width, int *height )
667
+ \end{lstlisting}
668
+
669
+ \begin{refparameters}
670
+ \begin{description}
671
+ \item [\textit{width}]\ \\
672
+ Pointer to an integer that will hold the width of the window.
673
+ \item [\textit{height}]\ \\
674
+ Pointer to an integer that will hold the height of the window.
675
+ \end{description}
676
+ \end{refparameters}
677
+
678
+ \begin{refreturn}
679
+ The current width and height of the opened window is returned in the
680
+ \textit{width} and \textit{height} parameters, respectively.
681
+ \end{refreturn}
682
+
683
+ \begin{refdescription}
684
+ The function is used for determining the size of an opened window.
685
+ The returned values are dimensions of the client area of the window
686
+ (i.e. excluding any window borders and decorations).
687
+ \end{refdescription}
688
+
689
+ \begin{refnotes}
690
+ Even if the size of a fullscreen window does not change once the window
691
+ has been opened, it does not necessarily have to be the same as the size
692
+ that was requested using \textbf{glfwOpenWindow}. Therefor it is wise to
693
+ use this function to determine the true size of the window once it has
694
+ been opened.
695
+ \end{refnotes}
696
+
697
+
698
+ %-------------------------------------------------------------------------
699
+ \subsection{glfwSetWindowSizeCallback}
700
+
701
+ \textbf{C language syntax}
702
+ \begin{lstlisting}
703
+ void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
704
+ \end{lstlisting}
705
+
706
+ \begin{refparameters}
707
+ \begin{description}
708
+ \item [\textit{cbfun}]\ \\
709
+ Pointer to a callback function that will be called every time the
710
+ window size changes. The function should have the following C language
711
+ prototype:
712
+
713
+ \texttt{void GLFWCALL functionname( int width, int height );}
714
+
715
+ Where \textit{functionname} is the name of the callback function, and
716
+ \textit{width} and \textit{height} are the dimensions of the window
717
+ client area.
718
+
719
+ If \textit{cbfun} is NULL, any previously selected callback function
720
+ will be deselected.
721
+ \end{description}
722
+ \end{refparameters}
723
+
724
+ \begin{refreturn}
725
+ none
726
+ \end{refreturn}
727
+
728
+ \begin{refdescription}
729
+ The function selects which function to be called upon a window size
730
+ change event.
731
+
732
+ A window has to be opened for this function to have any effect.
733
+ \end{refdescription}
734
+
735
+ \begin{refnotes}
736
+ Window size changes are recorded continuously, but only reported when
737
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
738
+ \textbf{glfwSwapBuffers} is called.
739
+ \end{refnotes}
740
+
741
+
742
+ %-------------------------------------------------------------------------
743
+ \subsection{glfwIconifyWindow}
744
+
745
+ \textbf{C language syntax}
746
+ \begin{lstlisting}
747
+ void glfwIconifyWindow( void )
748
+ \end{lstlisting}
749
+
750
+ \begin{refparameters}
751
+ none
752
+ \end{refparameters}
753
+
754
+ \begin{refreturn}
755
+ none
756
+ \end{refreturn}
757
+
758
+ \begin{refdescription}
759
+ Iconify a window. If the window is in fullscreen mode, then the desktop
760
+ video mode will be restored.
761
+ \end{refdescription}
762
+
763
+
764
+ %-------------------------------------------------------------------------
765
+ \subsection{glfwRestoreWindow}
766
+
767
+ \textbf{C language syntax}
768
+ \begin{lstlisting}
769
+ void glfwRestoreWindow( void )
770
+ \end{lstlisting}
771
+
772
+ \begin{refparameters}
773
+ none
774
+ \end{refparameters}
775
+
776
+ \begin{refreturn}
777
+ none
778
+ \end{refreturn}
779
+
780
+ \begin{refdescription}
781
+ Restore an iconified window. If the window that is restored is in
782
+ fullscreen mode, then the fullscreen video mode will be restored.
783
+ \end{refdescription}
784
+
785
+
786
+ %-------------------------------------------------------------------------
787
+ \begin{table}[p]
788
+ \begin{center}
789
+ \begin{tabular}{|l|p{9.5cm}|} \hline \raggedright
790
+ \textbf{Name} & \textbf{Description} \\ \hline
791
+ GLFW\_OPENED & GL\_TRUE if window is opened, else GL\_FALSE.\\ \hline
792
+ GLFW\_ACTIVE & GL\_TRUE if window has focus, else GL\_FALSE.\\ \hline
793
+ GLFW\_ICONIFIED & GL\_TRUE if window is iconified, else GL\_FALSE.\\ \hline
794
+ GLFW\_ACCELERATED & GL\_TRUE if window is hardware accelerated, else GL\_FALSE.\\ \hline
795
+ GLFW\_RED\_BITS & Number of bits for the red color component.\\ \hline
796
+ GLFW\_GREEN\_BITS & Number of bits for the green color component.\\ \hline
797
+ GLFW\_BLUE\_BITS & Number of bits for the blue color component.\\ \hline
798
+ GLFW\_ALPHA\_BITS & Number of bits for the alpha buffer.\\ \hline
799
+ GLFW\_DEPTH\_BITS & Number of bits for the depth buffer.\\ \hline
800
+ GLFW\_STENCIL\_BITS & Number of bits for the stencil buffer.\\ \hline
801
+ GLFW\_REFRESH\_RATE & Vertical monitor refresh rate in Hz. Zero indicates an unknown or a default refresh rate.\\ \hline
802
+ GLFW\_ACCUM\_RED\_BITS & Number of bits for the red channel of the accumulator buffer.\\ \hline
803
+ GLFW\_ACCUM\_GREEN\_BITS & Number of bits for the green channel of the accumulator buffer.\\ \hline
804
+ GLFW\_ACCUM\_BLUE\_BITS & Number of bits for the blue channel of the accumulator buffer.\\ \hline
805
+ GLFW\_ACCUM\_ALPHA\_BITS & Number of bits for the alpha channel of the accumulator buffer.\\ \hline
806
+ GLFW\_AUX\_BUFFERS & Number of auxiliary buffers.\\ \hline
807
+ GLFW\_STEREO & GL\_TRUE if stereo rendering is supported, else GL\_FALSE.\\ \hline
808
+ GLFW\_FSAA\_SAMPLES & Number of multisampling buffer samples. Zero indicated multisampling is disabled.\\ \hline
809
+ GLFW\_WINDOW\_NO\_RESIZE & GL\_TRUE if the window cannot be resized, else GL\_FALSE.\\ \hline
810
+ \end{tabular}
811
+ \end{center}
812
+ \caption{Window parameters for \textbf{glfwGetWindowParam}}
813
+ \label{tab:winparams}
814
+ \end{table}
815
+
816
+
817
+ %-------------------------------------------------------------------------
818
+ \subsection{glfwGetWindowParam}
819
+
820
+ \textbf{C language syntax}
821
+ \begin{lstlisting}
822
+ int glfwGetWindowParam( int param )
823
+ \end{lstlisting}
824
+
825
+ \begin{refparameters}
826
+ \begin{description}
827
+ \item [\textit{param}]\ \\
828
+ A token selecting which parameter the function should return (see
829
+ table \ref{tab:winparams}).
830
+ \end{description}
831
+ \end{refparameters}
832
+
833
+ \begin{refreturn}
834
+ The function returns different parameters depending on the value of
835
+ \textit{param}. Table \ref{tab:winparams} lists valid \textit{param}
836
+ values, and their corresponding return values.
837
+ \end{refreturn}
838
+
839
+ \begin{refdescription}
840
+ The function is used for acquiring various properties of an opened window.
841
+ \end{refdescription}
842
+
843
+ \begin{refnotes}
844
+ GLFW\_ACCELERATED is only supported under Windows. Other systems will
845
+ always return GL\_TRUE. Under Windows, GLFW\_ACCELERATED means that the
846
+ \OpenGL\ renderer is a 3rd party renderer, rather than the fallback
847
+ Microsoft software \OpenGL\ renderer. In other words, it is not a real
848
+ guarantee that the \OpenGL\ renderer is actually hardware accelerated.
849
+ \end{refnotes}
850
+
851
+
852
+ %-------------------------------------------------------------------------
853
+ \subsection{glfwSwapBuffers}
854
+
855
+ \textbf{C language syntax}
856
+ \begin{lstlisting}
857
+ void glfwSwapBuffers( void )
858
+ \end{lstlisting}
859
+
860
+ \begin{refparameters}
861
+ none
862
+ \end{refparameters}
863
+
864
+ \begin{refreturn}
865
+ none
866
+ \end{refreturn}
867
+
868
+ \begin{refdescription}
869
+ The function swaps the back and front color buffers of the window. If
870
+ GLFW\_AUTO\_POLL\_EVENTS is enabled (which is the default),
871
+ \textbf{glfwPollEvents} is called before swapping the front and back
872
+ buffers.
873
+ \end{refdescription}
874
+
875
+
876
+ %-------------------------------------------------------------------------
877
+ \subsection{glfwSwapInterval}
878
+
879
+ \textbf{C language syntax}
880
+ \begin{lstlisting}
881
+ void glfwSwapInterval( int interval )
882
+ \end{lstlisting}
883
+
884
+ \begin{refparameters}
885
+ \begin{description}
886
+ \item [\textit{interval}]\ \\
887
+ Minimum number of monitor vertical retraces between each buffer swap
888
+ performed by \textbf{glfwSwapBuffers}. If \textit{interval} is zero,
889
+ buffer swaps will not be synchronized to the vertical refresh of the
890
+ monitor (also known as 'VSync off').
891
+ \end{description}
892
+ \end{refparameters}
893
+
894
+ \begin{refreturn}
895
+ none
896
+ \end{refreturn}
897
+
898
+ \begin{refdescription}
899
+ The function selects the minimum number of monitor vertical retraces that
900
+ should occur between two buffer swaps. If the selected swap interval is
901
+ one, the rate of buffer swaps will never be higher than the vertical
902
+ refresh rate of the monitor. If the selected swap interval is zero, the
903
+ rate of buffer swaps is only limited by the speed of the software and
904
+ the hardware.
905
+ \end{refdescription}
906
+
907
+ \begin{refnotes}
908
+ This function will only have an effect on hardware and drivers that
909
+ support user selection of the swap interval.
910
+ \end{refnotes}
911
+
912
+
913
+ %-------------------------------------------------------------------------
914
+ \subsection{glfwSetWindowRefreshCallback}
915
+
916
+ \textbf{C language syntax}
917
+ \begin{lstlisting}
918
+ void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun )
919
+ \end{lstlisting}
920
+
921
+ \begin{refparameters}
922
+ \begin{description}
923
+ \item [\textit{cbfun}]\ \\
924
+ Pointer to a callback function that will be called when the window client
925
+ area needs to be refreshed. The function should have the following C
926
+ language prototype:
927
+
928
+ \texttt{void GLFWCALL functionname( void );}
929
+
930
+ Where \textit{functionname} is the name of the callback function.
931
+
932
+ If \textit{cbfun} is NULL, any previously selected callback function
933
+ will be deselected.
934
+ \end{description}
935
+ \end{refparameters}
936
+
937
+ \begin{refreturn}
938
+ none
939
+ \end{refreturn}
940
+
941
+ \begin{refdescription}
942
+ The function selects which function to be called upon a window refresh
943
+ event, which occurs when any part of the window client area has been
944
+ damaged, and needs to be repainted (for instance, if a part of the window
945
+ that was previously occluded by another window has become visible).
946
+
947
+ A window has to be opened for this function to have any effect.
948
+ \end{refdescription}
949
+
950
+ \begin{refnotes}
951
+ Window refresh events are recorded continuously, but only reported when
952
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
953
+ \textbf{glfwSwapBuffers} is called.
954
+ \end{refnotes}
955
+
956
+
957
+ %-------------------------------------------------------------------------
958
+ \pagebreak
959
+ \section{Video Modes}
960
+ Since \GLFW\ supports video mode changes when using a fullscreen window,
961
+ it also provides functionality for querying which video modes are
962
+ supported on a system.
963
+
964
+
965
+ %-------------------------------------------------------------------------
966
+ \subsection{glfwGetVideoModes}
967
+
968
+ \textbf{C language syntax}
969
+ \begin{lstlisting}
970
+ int glfwGetVideoModes( GLFWvidmode *list, int maxcount )
971
+ \end{lstlisting}
972
+
973
+ \begin{refparameters}
974
+ \begin{description}
975
+ \item [\textit{list}]\ \\
976
+ A vector of \textit{GLFWvidmode} structures, which will be filled out
977
+ by the function.
978
+ \item [\textit{maxcount}]\ \\
979
+ Maximum number of video modes that \textit{list} vector can hold.
980
+ \end{description}
981
+ \end{refparameters}
982
+
983
+ \begin{refreturn}
984
+ The function returns the number of detected video modes (this number
985
+ will never exceed \textit{maxcount}). The \textit{list} vector is
986
+ filled out with the video modes that are supported by the system.
987
+ \end{refreturn}
988
+
989
+ \begin{refdescription}
990
+ The function returns a list of supported video modes. Each video mode is
991
+ represented by a \textit{GLFWvidmode} structure, which has the following
992
+ definition:
993
+
994
+ \begin{lstlisting}
995
+ typedef struct {
996
+ int Width, Height; // Video resolution
997
+ int RedBits; // Number of red bits
998
+ int GreenBits; // Number of green bits
999
+ int BlueBits; // Number of blue bits
1000
+ } GLFWvidmode;
1001
+ \end{lstlisting}
1002
+ \end{refdescription}
1003
+
1004
+ \begin{refnotes}
1005
+ The returned list is sorted, first by color depth ($RedBits + GreenBits +
1006
+ BlueBits$), and then by resolution ($Width \times Height$), with the
1007
+ lowest resolution, fewest bits per pixel mode first.
1008
+ \end{refnotes}
1009
+
1010
+
1011
+ %-------------------------------------------------------------------------
1012
+ \subsection{glfwGetDesktopMode}
1013
+
1014
+ \textbf{C language syntax}
1015
+ \begin{lstlisting}
1016
+ void glfwGetDesktopMode( GLFWvidmode *mode )
1017
+ \end{lstlisting}
1018
+
1019
+ \begin{refparameters}
1020
+ \begin{description}
1021
+ \item [\textit{mode}]\ \\
1022
+ Pointer to a \textit{GLFWvidmode} structure, which will be filled out
1023
+ by the function.
1024
+ \end{description}
1025
+ \end{refparameters}
1026
+
1027
+ \begin{refreturn}
1028
+ The \textit{GLFWvidmode} structure pointed to by \textit{mode} is filled
1029
+ out with the desktop video mode.
1030
+ \end{refreturn}
1031
+
1032
+ \begin{refdescription}
1033
+ The function returns the desktop video mode in a \textit{GLFWvidmode}
1034
+ structure. See \textbf{glfwGetVideoModes} for a definition of the
1035
+ \textit{GLFWvidmode} structure.
1036
+ \end{refdescription}
1037
+
1038
+ \begin{refnotes}
1039
+ The color depth of the desktop display is always reported as the number
1040
+ of bits for each individual color component (red, green and blue), even
1041
+ if the desktop is not using an RGB or RGBA color format. For instance, an
1042
+ indexed 256 color display may report \textit{RedBits} = 3,
1043
+ \textit{GreenBits} = 3 and \textit{BlueBits} = 2, which adds up to 8 bits
1044
+ in total.
1045
+
1046
+ The desktop video mode is the video mode used by the desktop, \textit{not}
1047
+ the current video mode (which may differ from the desktop video mode if
1048
+ the \GLFW\ window is a fullscreen window).
1049
+ \end{refnotes}
1050
+
1051
+
1052
+ %-------------------------------------------------------------------------
1053
+ \pagebreak
1054
+ \section{Input Handling}
1055
+ \GLFW\ supports three channels of user input: keyboard input, mouse input
1056
+ and joystick input.
1057
+
1058
+ Keyboard and mouse input can be treated either as events, using callback
1059
+ functions, or as state, using functions for polling specific keyboard and
1060
+ mouse states. Regardless of which method is used, all keyboard and mouse
1061
+ input is collected using window event polling.
1062
+
1063
+ Joystick input is asynchronous to the keyboard and mouse input, and does
1064
+ not require event polling for keeping up to date joystick information.
1065
+ Also, joystick input is independent of any window, so a window does not
1066
+ have to be opened for joystick input to be used.
1067
+
1068
+
1069
+ %-------------------------------------------------------------------------
1070
+ \subsection{glfwPollEvents}
1071
+
1072
+ \textbf{C language syntax}
1073
+ \begin{lstlisting}
1074
+ void glfwPollEvents( void )
1075
+ \end{lstlisting}
1076
+
1077
+ \begin{refparameters}
1078
+ none
1079
+ \end{refparameters}
1080
+
1081
+ \begin{refreturn}
1082
+ none
1083
+ \end{refreturn}
1084
+
1085
+ \begin{refdescription}
1086
+ The function is used for polling for events, such as user input and
1087
+ window resize events. Upon calling this function, all window states,
1088
+ keyboard states and mouse states are updated. If any related callback
1089
+ functions are registered, these are called during the call to
1090
+ \textbf{glfwPollEvents}.
1091
+ \end{refdescription}
1092
+
1093
+ \begin{refnotes}
1094
+ \textbf{glfwPollEvents} is called implicitly from \textbf{glfwSwapBuffers}
1095
+ if GLFW\_AUTO\_POLL\_EVENTS is enabled (default). Thus, if
1096
+ \textbf{glfwSwapBuffers} is called frequently, which is normally the case,
1097
+ there is no need to call \textbf{glfwPollEvents}.
1098
+ \end{refnotes}
1099
+
1100
+
1101
+ %-------------------------------------------------------------------------
1102
+ \subsection{glfwWaitEvents}
1103
+
1104
+ \textbf{C language syntax}
1105
+ \begin{lstlisting}
1106
+ void glfwWaitEvents( void )
1107
+ \end{lstlisting}
1108
+
1109
+ \begin{refparameters}
1110
+ none
1111
+ \end{refparameters}
1112
+
1113
+ \begin{refreturn}
1114
+ none
1115
+ \end{refreturn}
1116
+
1117
+ \begin{refdescription}
1118
+ The function is used for waiting for events, such as user input and
1119
+ window resize events. Upon calling this function, the calling thread will
1120
+ be put to sleep until any event appears in the event queue. When events
1121
+ are ready, the events will be processed just as they are processed by
1122
+ \textbf{glfwPollEvents}.
1123
+
1124
+ If there are any events in the queue when the function is called, the
1125
+ function will behave exactly like \textbf{glfwPollEvents} (i.e. process
1126
+ all messages and then return, without blocking the calling thread).
1127
+ \end{refdescription}
1128
+
1129
+ \begin{refnotes}
1130
+ It is guaranteed that \textbf{glfwWaitEvents} will wake up on any event
1131
+ that can be processed by \textbf{glfwPollEvents}. However,
1132
+ \textbf{glfwWaitEvents} may wake up on events that are \emph{not}
1133
+ processed or reported by \textbf{glfwPollEvents} too, and the function
1134
+ may behave differently on different systems. Do no make any assumptions
1135
+ about when or why \textbf{glfwWaitEvents} will return.
1136
+ \end{refnotes}
1137
+
1138
+
1139
+ %-------------------------------------------------------------------------
1140
+ \begin{table}[p]
1141
+ \begin{center}
1142
+ \begin{tabular}{|l|l|} \hline \raggedright
1143
+ \textbf{Name} & \textbf{Description} \\ \hline
1144
+ GLFW\_KEY\_SPACE & Space\\ \hline
1145
+ GLFW\_KEY\_ESC & Escape\\ \hline
1146
+ GLFW\_KEY\_F\textit{n} & Function key \textit{n} (\textit{n} can be in the range 1..25)\\ \hline
1147
+ GLFW\_KEY\_UP & Cursor up\\ \hline
1148
+ GLFW\_KEY\_DOWN & Cursor down\\ \hline
1149
+ GLFW\_KEY\_LEFT & Cursor left\\ \hline
1150
+ GLFW\_KEY\_RIGHT & Cursor right\\ \hline
1151
+ GLFW\_KEY\_LSHIFT & Left shift key\\ \hline
1152
+ GLFW\_KEY\_RSHIFT & Right shift key\\ \hline
1153
+ GLFW\_KEY\_LCTRL & Left control key\\ \hline
1154
+ GLFW\_KEY\_RCTRL & Right control key\\ \hline
1155
+ GLFW\_KEY\_LALT & Left alternate function key\\ \hline
1156
+ GLFW\_KEY\_RALT & Right alternate function key\\ \hline
1157
+ GLFW\_KEY\_TAB & Tabulator\\ \hline
1158
+ GLFW\_KEY\_ENTER & Enter\\ \hline
1159
+ GLFW\_KEY\_BACKSPACE & Backspace\\ \hline
1160
+ GLFW\_KEY\_INSERT & Insert\\ \hline
1161
+ GLFW\_KEY\_DEL & Delete\\ \hline
1162
+ GLFW\_KEY\_PAGEUP & Page up\\ \hline
1163
+ GLFW\_KEY\_PAGEDOWN & Page down\\ \hline
1164
+ GLFW\_KEY\_HOME & Home\\ \hline
1165
+ GLFW\_KEY\_END & End\\ \hline
1166
+ GLFW\_KEY\_KP\_\textit{n} & Keypad numeric key \textit{n} (\textit{n} can be in the range 0..9)\\ \hline
1167
+ GLFW\_KEY\_KP\_DIVIDE & Keypad divide ($\div$)\\ \hline
1168
+ GLFW\_KEY\_KP\_MULTIPLY & Keypad multiply ($\times$)\\ \hline
1169
+ GLFW\_KEY\_KP\_SUBTRACT & Keypad subtract ($-$)\\ \hline
1170
+ GLFW\_KEY\_KP\_ADD & Keypad add ($+$)\\ \hline
1171
+ GLFW\_KEY\_KP\_DECIMAL & Keypad decimal (. or ,)\\ \hline
1172
+ GLFW\_KEY\_KP\_EQUAL & Keypad equal (=)\\ \hline
1173
+ GLFW\_KEY\_KP\_ENTER & Keypad enter\\ \hline
1174
+ \end{tabular}
1175
+ \end{center}
1176
+ \caption{Special key identifiers}
1177
+ \label{tab:keys}
1178
+ \end{table}
1179
+
1180
+
1181
+ %-------------------------------------------------------------------------
1182
+ \begin{table}[p]
1183
+ \begin{center}
1184
+ \begin{tabular}{|l|l|} \hline \raggedright
1185
+ \textbf{Name} & \textbf{Description} \\ \hline
1186
+ GLFW\_MOUSE\_BUTTON\_LEFT & Left mouse button (button 1) \\ \hline
1187
+ GLFW\_MOUSE\_BUTTON\_RIGHT & Right mouse button (button 2) \\ \hline
1188
+ GLFW\_MOUSE\_BUTTON\_MIDDLE & Middle mouse button (button 3) \\ \hline
1189
+ GLFW\_MOUSE\_BUTTON\_\textit{n} & Mouse button \textit{n} (\textit{n} can be in the range 1..8)\\ \hline
1190
+ \end{tabular}
1191
+ \end{center}
1192
+ \caption{Valid mouse button identifiers}
1193
+ \label{tab:mousebuttons}
1194
+ \end{table}
1195
+
1196
+
1197
+ %-------------------------------------------------------------------------
1198
+ \subsection{glfwGetKey}
1199
+
1200
+ \textbf{C language syntax}
1201
+ \begin{lstlisting}
1202
+ int glfwGetKey( int key )
1203
+ \end{lstlisting}
1204
+
1205
+ \begin{refparameters}
1206
+ \begin{description}
1207
+ \item [\textit{key}]\ \\
1208
+ A keyboard key identifier, which can be either an uppercase printable
1209
+ ISO~8859-1 (Latin~1) character (e.g. 'A', '3' or '.'), or a special key
1210
+ identifier. Table \ref{tab:keys} lists valid special key identifiers.
1211
+ \end{description}
1212
+ \end{refparameters}
1213
+
1214
+ \begin{refreturn}
1215
+ The function returns GLFW\_PRESS if the key is held down, or GLFW\_RELEASE
1216
+ if the key is not held down.
1217
+ \end{refreturn}
1218
+
1219
+ \begin{refdescription}
1220
+ The function queries the current state of a specific keyboard key. The
1221
+ physical location of each key depends on the system keyboard layout
1222
+ setting.
1223
+ \end{refdescription}
1224
+
1225
+ \begin{refnotes}
1226
+ The constant GLFW\_KEY\_SPACE is equal to 32, which is the ISO~8859-1 code
1227
+ for space.
1228
+
1229
+ Not all key codes are supported on all systems. Also, while some keys are
1230
+ available on some keyboard layouts, they may not be available on other
1231
+ keyboard layouts.
1232
+
1233
+ For systems that do not distinguish between left and right versions of
1234
+ modifier keys (shift, alt and control), the left version is used (e.g.
1235
+ GLFW\_KEY\_LSHIFT).
1236
+
1237
+ A window must be opened for the function to have any effect, and
1238
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1239
+ \textbf{glfwSwapBuffers} must be called before any keyboard events are
1240
+ recorded and reported by \textbf{glfwGetKey}.
1241
+ \end{refnotes}
1242
+
1243
+
1244
+ %-------------------------------------------------------------------------
1245
+ \subsection{glfwGetMouseButton}
1246
+
1247
+ \textbf{C language syntax}
1248
+ \begin{lstlisting}
1249
+ int glfwGetMouseButton( int button )
1250
+ \end{lstlisting}
1251
+
1252
+ \begin{refparameters}
1253
+ \begin{description}
1254
+ \item [\textit{button}]\ \\
1255
+ A mouse button identifier, which can be one of the mouse button
1256
+ identifiers listed in table \ref{tab:mousebuttons}.
1257
+ \end{description}
1258
+ \end{refparameters}
1259
+
1260
+ \begin{refreturn}
1261
+ The function returns GLFW\_PRESS if the mouse button is held down, or
1262
+ GLFW\_RELEASE if the mouse button is not held down.
1263
+ \end{refreturn}
1264
+
1265
+ \begin{refdescription}
1266
+ The function queries the current state of a specific mouse button.
1267
+ \end{refdescription}
1268
+
1269
+ \begin{refnotes}
1270
+ A window must be opened for the function to have any effect, and
1271
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1272
+ \textbf{glfwSwapBuffers} must be called before any mouse button events
1273
+ are recorded and reported by \textbf{glfwGetMouseButton}.
1274
+
1275
+ GLFW\_MOUSE\_BUTTON\_LEFT is equal to GLFW\_MOUSE\_BUTTON\_1.
1276
+ GLFW\_MOUSE\_BUTTON\_RIGHT is equal to GLFW\_MOUSE\_BUTTON\_2.
1277
+ GLFW\_MOUSE\_BUTTON\_MIDDLE is equal to GLFW\_MOUSE\_BUTTON\_3.
1278
+ \end{refnotes}
1279
+
1280
+
1281
+ %-------------------------------------------------------------------------
1282
+ \subsection{glfwGetMousePos}
1283
+
1284
+ \textbf{C language syntax}
1285
+ \begin{lstlisting}
1286
+ void glfwGetMousePos( int *xpos, int *ypos )
1287
+ \end{lstlisting}
1288
+
1289
+ \begin{refparameters}
1290
+ \begin{description}
1291
+ \item [\textit{xpos}]\ \\
1292
+ Pointer to an integer that will be filled out with the horizontal
1293
+ position of the mouse.
1294
+ \item [\textit{ypos}]\ \\
1295
+ Pointer to an integer that will be filled out with the vertical
1296
+ position of the mouse.
1297
+ \end{description}
1298
+ \end{refparameters}
1299
+
1300
+ \begin{refreturn}
1301
+ The function returns the current mouse position in \textit{xpos} and
1302
+ \textit{ypos}.
1303
+ \end{refreturn}
1304
+
1305
+ \begin{refdescription}
1306
+ The function returns the current mouse position. If the cursor is not
1307
+ hidden, the mouse position is the cursor position, relative to the upper
1308
+ left corner of the window and limited to the client area of the window.
1309
+ If the cursor is hidden, the mouse position is a virtual absolute
1310
+ position, not limited to any boundaries except to those implied by the
1311
+ maximum number that can be represented by a signed integer (normally
1312
+ -2147483648 to +2147483647).
1313
+ \end{refdescription}
1314
+
1315
+ \begin{refnotes}
1316
+ A window must be opened for the function to have any effect, and
1317
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1318
+ \textbf{glfwSwapBuffers} must be called before any mouse movements are
1319
+ recorded and reported by \textbf{glfwGetMousePos}.
1320
+ \end{refnotes}
1321
+
1322
+
1323
+ %-------------------------------------------------------------------------
1324
+ \subsection{glfwSetMousePos}
1325
+
1326
+ \textbf{C language syntax}
1327
+ \begin{lstlisting}
1328
+ void glfwSetMousePos( int xpos, int ypos )
1329
+ \end{lstlisting}
1330
+
1331
+ \begin{refparameters}
1332
+ \begin{description}
1333
+ \item [\textit{xpos}]\ \\
1334
+ Horizontal position of the mouse.
1335
+ \item [\textit{ypos}]\ \\
1336
+ Vertical position of the mouse.
1337
+ \end{description}
1338
+ \end{refparameters}
1339
+
1340
+ \begin{refreturn}
1341
+ none
1342
+ \end{refreturn}
1343
+
1344
+ \begin{refdescription}
1345
+ The function changes the position of the mouse. If the cursor is
1346
+ visible (not disabled), the cursor will be moved to the specified
1347
+ position, relative to the upper left corner of the window client area.
1348
+ If the cursor is hidden (disabled), only the mouse position that is
1349
+ reported by \GLFW\ is changed.
1350
+ \end{refdescription}
1351
+
1352
+
1353
+ %-------------------------------------------------------------------------
1354
+ \subsection{glfwGetMouseWheel}
1355
+
1356
+ \textbf{C language syntax}
1357
+ \begin{lstlisting}
1358
+ int glfwGetMouseWheel( void )
1359
+ \end{lstlisting}
1360
+
1361
+ \begin{refparameters}
1362
+ none
1363
+ \end{refparameters}
1364
+
1365
+ \begin{refreturn}
1366
+ The function returns the current mouse wheel position.
1367
+ \end{refreturn}
1368
+
1369
+ \begin{refdescription}
1370
+ The function returns the current mouse wheel position. The mouse wheel can
1371
+ be thought of as a third mouse axis, which is available as a separate
1372
+ wheel or up/down stick on some mice.
1373
+ \end{refdescription}
1374
+
1375
+ \begin{refnotes}
1376
+ A window must be opened for the function to have any effect, and
1377
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1378
+ \textbf{glfwSwapBuffers} must be called before any mouse wheel movements
1379
+ are recorded and reported by \textbf{glfwGetMouseWheel}.
1380
+ \end{refnotes}
1381
+
1382
+
1383
+ %-------------------------------------------------------------------------
1384
+ \subsection{glfwSetMouseWheel}
1385
+
1386
+ \textbf{C language syntax}
1387
+ \begin{lstlisting}
1388
+ void glfwSetMouseWheel( int pos )
1389
+ \end{lstlisting}
1390
+
1391
+ \begin{refparameters}
1392
+ \begin{description}
1393
+ \item [\textit{pos}]\ \\
1394
+ Position of the mouse wheel.
1395
+ \end{description}
1396
+ \end{refparameters}
1397
+
1398
+ \begin{refreturn}
1399
+ none
1400
+ \end{refreturn}
1401
+
1402
+ \begin{refdescription}
1403
+ The function changes the position of the mouse wheel.
1404
+ \end{refdescription}
1405
+
1406
+
1407
+ %-------------------------------------------------------------------------
1408
+ \subsection{glfwSetKeyCallback}
1409
+
1410
+ \textbf{C language syntax}
1411
+ \begin{lstlisting}
1412
+ void glfwSetKeyCallback( GLFWkeyfun cbfun )
1413
+ \end{lstlisting}
1414
+
1415
+ \begin{refparameters}
1416
+ \begin{description}
1417
+ \item [\textit{cbfun}]\ \\
1418
+ Pointer to a callback function that will be called every time a key is
1419
+ pressed or released. The function should have the following C language
1420
+ prototype:
1421
+
1422
+ \texttt{void GLFWCALL functionname( int key, int action );}
1423
+
1424
+ Where \textit{functionname} is the name of the callback function,
1425
+ \textit{key} is a key identifier, which is an uppercase printable
1426
+ ISO~8859-1 character or a special key identifier (see table
1427
+ \ref{tab:keys}), and \textit{action} is either GLFW\_PRESS or
1428
+ GLFW\_RELEASE.
1429
+
1430
+ If \textit{cbfun} is NULL, any previously selected callback function
1431
+ will be deselected.
1432
+ \end{description}
1433
+ \end{refparameters}
1434
+
1435
+ \begin{refreturn}
1436
+ none
1437
+ \end{refreturn}
1438
+
1439
+ \begin{refdescription}
1440
+ The function selects which function to be called upon a keyboard key
1441
+ event. The callback function is called every time the state of a single
1442
+ key is changed (from released to pressed or vice versa). The reported keys
1443
+ are unaffected by any modifiers (such as shift or alt).
1444
+
1445
+ A window has to be opened for this function to have any effect.
1446
+ \end{refdescription}
1447
+
1448
+ \begin{refnotes}
1449
+ Keyboard events are recorded continuously, but only reported when
1450
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1451
+ \textbf{glfwSwapBuffers} is called.
1452
+ \end{refnotes}
1453
+
1454
+
1455
+ %-------------------------------------------------------------------------
1456
+ \subsection{glfwSetCharCallback}
1457
+
1458
+ \textbf{C language syntax}
1459
+ \begin{lstlisting}
1460
+ void glfwSetCharCallback( GLFWcharfun cbfun )
1461
+ \end{lstlisting}
1462
+
1463
+ \begin{refparameters}
1464
+ \begin{description}
1465
+ \item [\textit{cbfun}]\ \\
1466
+ Pointer to a callback function that will be called every time a
1467
+ printable character is generated by the keyboard. The function should
1468
+ have the following C language prototype:
1469
+
1470
+ \texttt{void GLFWCALL functionname( int character, int action );}
1471
+
1472
+ Where \textit{functionname} is the name of the callback function,
1473
+ \textit{character} is a Unicode (ISO~10646) character, and
1474
+ \textit{action} is either GLFW\_PRESS or GLFW\_RELEASE.
1475
+
1476
+ If \textit{cbfun} is NULL, any previously selected callback function
1477
+ will be deselected.
1478
+ \end{description}
1479
+ \end{refparameters}
1480
+
1481
+ \begin{refreturn}
1482
+ none
1483
+ \end{refreturn}
1484
+
1485
+ \begin{refdescription}
1486
+ The function selects which function to be called upon a keyboard character
1487
+ event. The callback function is called every time a key that results in a
1488
+ printable Unicode character is pressed or released. Characters are
1489
+ affected by modifiers (such as shift or alt).
1490
+
1491
+ A window has to be opened for this function to have any effect.
1492
+ \end{refdescription}
1493
+
1494
+ \begin{refnotes}
1495
+ Character events are recorded continuously, but only reported when
1496
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1497
+ \textbf{glfwSwapBuffers} is called.
1498
+
1499
+ Control characters, such as tab and carriage return, are not reported to
1500
+ the character callback function, since they are not part of the Unicode
1501
+ character set. Use the key callback function for such events (see
1502
+ \textbf{glfwSetKeyCallback}).
1503
+
1504
+ The Unicode character set supports character codes above 255, so never
1505
+ cast a Unicode character to an eight bit data type (e.g. the C language
1506
+ 'char' type) without first checking that the character code is less than
1507
+ 256. Also note that Unicode character codes 0 to 255 are equal to
1508
+ ISO~8859-1 (Latin~1).
1509
+ \end{refnotes}
1510
+
1511
+
1512
+ %-------------------------------------------------------------------------
1513
+ \subsection{glfwSetMouseButtonCallback}
1514
+
1515
+ \textbf{C language syntax}
1516
+ \begin{lstlisting}
1517
+ void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun )
1518
+ \end{lstlisting}
1519
+
1520
+ \begin{refparameters}
1521
+ \begin{description}
1522
+ \item [\textit{cbfun}]\ \\
1523
+ Pointer to a callback function that will be called every time a mouse
1524
+ button is pressed or released. The function should have the following C
1525
+ language prototype:
1526
+
1527
+ \texttt{void GLFWCALL functionname( int button, int action );}
1528
+
1529
+ Where \textit{functionname} is the name of the callback function,
1530
+ \textit{button} is a mouse button identifier (see table
1531
+ \ref{tab:mousebuttons} on page \pageref{tab:mousebuttons}), and
1532
+ \textit{action} is either GLFW\_PRESS or GLFW\_RELEASE.
1533
+
1534
+ If \textit{cbfun} is NULL, any previously selected callback function
1535
+ will be deselected.
1536
+ \end{description}
1537
+ \end{refparameters}
1538
+
1539
+ \begin{refreturn}
1540
+ none
1541
+ \end{refreturn}
1542
+
1543
+ \begin{refdescription}
1544
+ The function selects which function to be called upon a mouse button
1545
+ event.
1546
+
1547
+ A window has to be opened for this function to have any effect.
1548
+ \end{refdescription}
1549
+
1550
+ \begin{refnotes}
1551
+ Mouse button events are recorded continuously, but only reported when
1552
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1553
+ \textbf{glfwSwapBuffers} is called.
1554
+
1555
+ GLFW\_MOUSE\_BUTTON\_LEFT is equal to GLFW\_MOUSE\_BUTTON\_1.
1556
+ GLFW\_MOUSE\_BUTTON\_RIGHT is equal to GLFW\_MOUSE\_BUTTON\_2.
1557
+ GLFW\_MOUSE\_BUTTON\_MIDDLE is equal to GLFW\_MOUSE\_BUTTON\_3.
1558
+ \end{refnotes}
1559
+
1560
+
1561
+ %-------------------------------------------------------------------------
1562
+ \subsection{glfwSetMousePosCallback}
1563
+
1564
+ \textbf{C language syntax}
1565
+ \begin{lstlisting}
1566
+ void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
1567
+ \end{lstlisting}
1568
+
1569
+ \begin{refparameters}
1570
+ \begin{description}
1571
+ \item [\textit{cbfun}]\ \\
1572
+ Pointer to a callback function that will be called every time the mouse
1573
+ is moved. The function should have the following C language prototype:
1574
+
1575
+ \texttt{void GLFWCALL functionname( int x, int y );}
1576
+
1577
+ Where \textit{functionname} is the name of the callback function, and
1578
+ \textit{x} and \textit{y} are the mouse coordinates (see
1579
+ \textbf{glfwGetMousePos} for more information on mouse coordinates).
1580
+
1581
+ If \textit{cbfun} is NULL, any previously selected callback function
1582
+ will be deselected.
1583
+ \end{description}
1584
+ \end{refparameters}
1585
+
1586
+ \begin{refreturn}
1587
+ none
1588
+ \end{refreturn}
1589
+
1590
+ \begin{refdescription}
1591
+ The function selects which function to be called upon a mouse motion event.
1592
+
1593
+ A window has to be opened for this function to have any effect.
1594
+ \end{refdescription}
1595
+
1596
+ \begin{refnotes}
1597
+ Mouse motion events are recorded continuously, but only reported when
1598
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1599
+ \textbf{glfwSwapBuffers} is called.
1600
+ \end{refnotes}
1601
+
1602
+
1603
+ %-------------------------------------------------------------------------
1604
+ \subsection{glfwSetMouseWheelCallback}
1605
+
1606
+ \textbf{C language syntax}
1607
+ \begin{lstlisting}
1608
+ void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun )
1609
+ \end{lstlisting}
1610
+
1611
+ \begin{refparameters}
1612
+ \begin{description}
1613
+ \item [\textit{cbfun}]\ \\
1614
+ Pointer to a callback function that will be called every time the mouse
1615
+ wheel is moved. The function should have the following C language
1616
+ prototype:
1617
+
1618
+ \texttt{void GLFWCALL functionname( int pos );}
1619
+
1620
+ Where \textit{functionname} is the name of the callback function, and
1621
+ \textit{pos} is the mouse wheel position.
1622
+
1623
+ If \textit{cbfun} is NULL, any previously selected callback function
1624
+ will be deselected.
1625
+ \end{description}
1626
+ \end{refparameters}
1627
+
1628
+ \begin{refreturn}
1629
+ none
1630
+ \end{refreturn}
1631
+
1632
+ \begin{refdescription}
1633
+ The function selects which function to be called upon a mouse wheel event.
1634
+
1635
+ A window has to be opened for this function to have any effect.
1636
+ \end{refdescription}
1637
+
1638
+ \begin{refnotes}
1639
+ Mouse wheel events are recorded continuously, but only reported when
1640
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
1641
+ \textbf{glfwSwapBuffers} is called.
1642
+ \end{refnotes}
1643
+
1644
+
1645
+ %-------------------------------------------------------------------------
1646
+ \begin{table}[p]
1647
+ \begin{center}
1648
+ \begin{tabular}{|l|l|}\hline \raggedright
1649
+ \textbf{Name} & \textbf{Return value}\\ \hline
1650
+ GLFW\_PRESENT & GL\_TRUE if the joystick is connected, else GL\_FALSE.\\ \hline
1651
+ GLFW\_AXES & Number of axes supported by the joystick.\\ \hline
1652
+ GLFW\_BUTTONS & Number of buttons supported by the joystick.\\ \hline
1653
+ \end{tabular}
1654
+ \end{center}
1655
+ \caption{Joystick parameters for \textbf{glfwGetJoystickParam}}
1656
+ \label{tab:joyparams}
1657
+ \end{table}
1658
+
1659
+
1660
+ %-------------------------------------------------------------------------
1661
+ \subsection{glfwGetJoystickParam}
1662
+
1663
+ \textbf{C language syntax}
1664
+ \begin{lstlisting}
1665
+ int glfwGetJoystickParam( int joy, int param )
1666
+ \end{lstlisting}
1667
+
1668
+ \begin{refparameters}
1669
+ \begin{description}
1670
+ \item [\textit{joy}]\ \\
1671
+ A joystick identifier, which should be GLFW\_JOYSTICK\_\textit{n}, where
1672
+ \textit{n} is in the range 1 to 16.
1673
+ \item [\textit{param}]\ \\
1674
+ A token selecting which parameter the function should return (see table
1675
+ \ref{tab:joyparams}).
1676
+ \end{description}
1677
+ \end{refparameters}
1678
+
1679
+ \begin{refreturn}
1680
+ The function returns different parameters depending on the value of
1681
+ \textit{param}. Table \ref{tab:joyparams} lists valid \textit{param}
1682
+ values, and their corresponding return values.
1683
+ \end{refreturn}
1684
+
1685
+ \begin{refdescription}
1686
+ The function is used for acquiring various properties of a joystick.
1687
+ \end{refdescription}
1688
+
1689
+ \begin{refnotes}
1690
+ The joystick information is updated every time the function is called.
1691
+
1692
+ No window has to be opened for joystick information to be valid.
1693
+ \end{refnotes}
1694
+
1695
+
1696
+ %-------------------------------------------------------------------------
1697
+ \subsection{glfwGetJoystickPos}
1698
+
1699
+ \textbf{C language syntax}
1700
+ \begin{lstlisting}
1701
+ int glfwGetJoystickPos( int joy, float *pos, int numaxes )
1702
+ \end{lstlisting}
1703
+
1704
+ \begin{refparameters}
1705
+ \begin{description}
1706
+ \item [\textit{joy}]\ \\
1707
+ A joystick identifier, which should be GLFW\_JOYSTICK\_\textit{n}, where
1708
+ \textit{n} is in the range 1 to 16.
1709
+ \item [\textit{pos}]\ \\
1710
+ An array that will hold the positional values for all requested axes.
1711
+ \item [\textit{numaxes}]\ \\
1712
+ Specifies how many axes should be returned.
1713
+ \end{description}
1714
+ \end{refparameters}
1715
+
1716
+ \begin{refreturn}
1717
+ The function returns the number of actually returned axes. This is the
1718
+ minimum of \textit{numaxes} and the number of axes supported by the
1719
+ joystick. If the joystick is not supported or connected, the function will
1720
+ return 0 (zero).
1721
+ \end{refreturn}
1722
+
1723
+ \begin{refdescription}
1724
+ The function queries the current position of one or more axes of a
1725
+ joystick. The positional values are returned in an array, where the first
1726
+ element represents the first axis of the joystick (normally the X axis).
1727
+ Each position is in the range -1.0 to 1.0. Where applicable, the positive
1728
+ direction of an axis is right, forward or up, and the negative direction
1729
+ is left, back or down.
1730
+
1731
+ If \textit{numaxes} exceeds the number of axes supported by the joystick,
1732
+ or if the joystick is not available, the unused elements in the
1733
+ \textit{pos} array will be set to 0.0 (zero).
1734
+ \end{refdescription}
1735
+
1736
+ \begin{refnotes}
1737
+ The joystick state is updated every time the function is called, so there
1738
+ is no need to call \textbf{glfwPollEvents} or \textbf{glfwWaitEvents} for
1739
+ joystick state to be updated.
1740
+
1741
+ Use \textbf{glfwGetJoystickParam} to retrieve joystick capabilities, such
1742
+ as joystick availability and number of supported axes.
1743
+
1744
+ No window has to be opened for joystick input to be valid.
1745
+ \end{refnotes}
1746
+
1747
+
1748
+ %-------------------------------------------------------------------------
1749
+ \subsection{glfwGetJoystickButtons}
1750
+
1751
+ \textbf{C language syntax}
1752
+ \begin{lstlisting}
1753
+ int glfwGetJoystickButtons( int joy, unsigned char *buttons,
1754
+ int numbuttons )
1755
+ \end{lstlisting}
1756
+
1757
+ \begin{refparameters}
1758
+ \begin{description}
1759
+ \item [\textit{joy}]\ \\
1760
+ A joystick identifier, which should be GLFW\_JOYSTICK\_\textit{n}, where
1761
+ \textit{n} is in the range 1 to 16.
1762
+ \item [\textit{buttons}]\ \\
1763
+ An array that will hold the button states for all requested buttons.
1764
+ \item [\textit{numbuttons}]\ \\
1765
+ Specifies how many buttons should be returned.
1766
+ \end{description}
1767
+ \end{refparameters}
1768
+
1769
+ \begin{refreturn}
1770
+ The function returns the number of actually returned buttons. This is the
1771
+ minimum of \textit{numbuttons} and the number of buttons supported by the
1772
+ joystick. If the joystick is not supported or connected, the function will
1773
+ return 0 (zero).
1774
+ \end{refreturn}
1775
+
1776
+ \begin{refdescription}
1777
+ The function queries the current state of one or more buttons of a
1778
+ joystick. The button states are returned in an array, where the first
1779
+ element represents the first button of the joystick. Each state can be
1780
+ either GLFW\_PRESS or GLFW\_RELEASE.
1781
+
1782
+ If \textit{numbuttons} exceeds the number of buttons supported by the
1783
+ joystick, or if the joystick is not available, the unused elements in the
1784
+ \textit{buttons} array will be set to GLFW\_RELEASE.
1785
+ \end{refdescription}
1786
+
1787
+ \begin{refnotes}
1788
+ The joystick state is updated every time the function is called, so there
1789
+ is no need to call \textbf{glfwPollEvents} or \textbf{glfwWaitEvents} for
1790
+ joystick state to be updated.
1791
+
1792
+ Use \textbf{glfwGetJoystickParam} to retrieve joystick capabilities, such
1793
+ as joystick availability and number of supported buttons.
1794
+
1795
+ No window has to be opened for joystick input to be valid.
1796
+ \end{refnotes}
1797
+
1798
+
1799
+ %-------------------------------------------------------------------------
1800
+ \pagebreak
1801
+ \section{Timing}
1802
+
1803
+ %-------------------------------------------------------------------------
1804
+ \subsection{glfwGetTime}
1805
+
1806
+ \textbf{C language syntax}
1807
+ \begin{lstlisting}
1808
+ double glfwGetTime( void )
1809
+ \end{lstlisting}
1810
+
1811
+ \begin{refparameters}
1812
+ none
1813
+ \end{refparameters}
1814
+
1815
+ \begin{refreturn}
1816
+ The function returns the value of the high precision timer. The time is
1817
+ measured in seconds, and is returned as a double precision floating point
1818
+ value.
1819
+ \end{refreturn}
1820
+
1821
+ \begin{refdescription}
1822
+ The function returns the state of a high precision timer. Unless the timer
1823
+ has been set by the \textbf{glfwSetTime} function, the time is measured as
1824
+ the number of seconds that have passed since \textbf{glfwInit} was called.
1825
+ \end{refdescription}
1826
+
1827
+ \begin{refnotes}
1828
+ The resolution of the timer depends on which system the program is running
1829
+ on. The worst case resolution is somewhere in the order of $10~ms$, while
1830
+ for most systems the resolution should be better than $1~\mu s$.
1831
+ \end{refnotes}
1832
+
1833
+
1834
+ %-------------------------------------------------------------------------
1835
+ \subsection{glfwSetTime}
1836
+
1837
+ \textbf{C language syntax}
1838
+ \begin{lstlisting}
1839
+ void glfwSetTime( double time )
1840
+ \end{lstlisting}
1841
+
1842
+ \begin{refparameters}
1843
+ \begin{description}
1844
+ \item [\textit{time}]\ \\
1845
+ Time (in seconds) that the timer should be set to.
1846
+ \end{description}
1847
+ \end{refparameters}
1848
+
1849
+ \begin{refreturn}
1850
+ none
1851
+ \end{refreturn}
1852
+
1853
+ \begin{refdescription}
1854
+ The function sets the current time of the high precision timer to the
1855
+ specified time. Subsequent calls to \textbf{glfwGetTime} will be relative
1856
+ to this time. The time is given in seconds.
1857
+ \end{refdescription}
1858
+
1859
+
1860
+ %-------------------------------------------------------------------------
1861
+ \subsection{glfwSleep}
1862
+
1863
+ \textbf{C language syntax}
1864
+ \begin{lstlisting}
1865
+ void glfwSleep( double time )
1866
+ \end{lstlisting}
1867
+
1868
+ \begin{refparameters}
1869
+ \begin{description}
1870
+ \item [\textit{time}]\ \\
1871
+ Time, in seconds, to sleep.
1872
+ \end{description}
1873
+ \end{refparameters}
1874
+
1875
+ \begin{refreturn}
1876
+ none
1877
+ \end{refreturn}
1878
+
1879
+ \begin{refdescription}
1880
+ The function puts the calling thread to sleep for the requested period of
1881
+ time. Only the calling thread is put to sleep. Other threads within the
1882
+ same process can still execute.
1883
+ \end{refdescription}
1884
+
1885
+ \begin{refnotes}
1886
+ There is usually a system dependent minimum time for which it is possible
1887
+ to sleep. This time is generally in the range 1~$ms$ to 20~$ms$, depending
1888
+ on thread sheduling time slot intervals etc. Using a shorter time as a
1889
+ parameter to \textbf{glfwSleep} can give one of two results: either the
1890
+ thread will sleep for the minimum possible sleep time, or the thread will
1891
+ not sleep at all (\textbf{glfwSleep} returns immediately). The latter
1892
+ should only happen when very short sleep times are specified, if at all.
1893
+ \end{refnotes}
1894
+
1895
+
1896
+ %-------------------------------------------------------------------------
1897
+ \pagebreak
1898
+ \section{Image and Texture Loading}
1899
+ In order to aid loading of image data into textures, \GLFW\ has basic support
1900
+ for loading images from files and memory buffers.
1901
+
1902
+
1903
+ %-------------------------------------------------------------------------
1904
+ \begin{table}[p]
1905
+ \begin{center}
1906
+ \begin{tabular}{|l|p{9.0cm}|} \hline \raggedright
1907
+ \textbf{Name} & \textbf{Description}\\ \hline
1908
+ GLFW\_NO\_RESCALE\_BIT & Do not rescale image to closest $2^m\times2^n$ resolution\\ \hline
1909
+ GLFW\_ORIGIN\_UL\_BIT & Specifies that the origin of the \textit{loaded} image should be in the upper left corner (default is the lower left corner)\\ \hline
1910
+ GLFW\_ALPHA\_MAP\_BIT & Treat single component images as alpha maps rather than luminance maps\\ \hline
1911
+ \end{tabular}
1912
+ \end{center}
1913
+ \caption{Flags for functions loading image data into textures}
1914
+ \label{tab:rdimgflags}
1915
+ \end{table}
1916
+
1917
+
1918
+ %-------------------------------------------------------------------------
1919
+ \subsection{glfwReadImage}
1920
+
1921
+ \textbf{C language syntax}
1922
+ \begin{lstlisting}
1923
+ int glfwReadImage( const char *name, GLFWimage *img, int flags )
1924
+ \end{lstlisting}
1925
+
1926
+ \begin{refparameters}
1927
+ \begin{description}
1928
+ \item [\textit{name}]\ \\
1929
+ A null terminated ISO~8859-1 string holding the name of the file that
1930
+ should be read.
1931
+ \item [\textit{img}]\ \\
1932
+ Pointer to a GLFWimage struct, which will hold the information about
1933
+ the loaded image (if the read was successful).
1934
+ \item [\textit{flags}]\ \\
1935
+ Flags for controlling the image reading process. Valid flags are listed
1936
+ in table \ref{tab:rdimgflags}
1937
+ \end{description}
1938
+ \end{refparameters}
1939
+
1940
+ \begin{refreturn}
1941
+ The function returns GL\_TRUE if the image was loaded successfully.
1942
+ Otherwise GL\_FALSE is returned.
1943
+ \end{refreturn}
1944
+
1945
+ \begin{refdescription}
1946
+ The function reads an image from the file specified by the parameter
1947
+ \textit{name} and returns the image information and data in a GLFWimage
1948
+ structure, which has the following definition:
1949
+
1950
+ \begin{lstlisting}
1951
+ typedef struct {
1952
+ int Width, Height; // Image dimensions
1953
+ int Format; // OpenGL pixel format
1954
+ int BytesPerPixel; // Number of bytes per pixel
1955
+ unsigned char *Data; // Pointer to pixel data
1956
+ } GLFWimage;
1957
+ \end{lstlisting}
1958
+
1959
+ \textit{Width} and \textit{Height} give the dimensions of the image.
1960
+ \textit{Format} specifies an \OpenGL\ pixel format, which can be
1961
+ GL\_LUMINANCE or GL\_ALPHA (for gray scale images), GL\_RGB or GL\_RGBA.
1962
+ \textit{BytesPerPixel} specifies the number of bytes per pixel.
1963
+ \textit{Data} is a pointer to the actual pixel data.
1964
+
1965
+ By default the read image is rescaled to the nearest larger $2^m\times2^n$
1966
+ resolution using bilinear interpolation, if necessary, which is useful if
1967
+ the image is to be used as an \OpenGL\ texture. This behavior can be
1968
+ disabled by setting the GLFW\_NO\_RESCALE\_BIT flag.
1969
+
1970
+ Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the first pixel in
1971
+ \textit{img->Data} is the lower left corner of the image. If the flag
1972
+ GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
1973
+ corner.
1974
+
1975
+ For single component images (i.e. gray scale), \textit{Format} is set
1976
+ to GL\_ALPHA if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
1977
+ \textit{Format} is set to GL\_LUMINANCE.
1978
+ \end{refdescription}
1979
+
1980
+ \begin{refnotes}
1981
+ \textbf{glfwReadImage} supports the Truevision Targa version 1 file format
1982
+ (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted
1983
+ (24/32-bit color), 24-bit true color and 32-bit true color + alpha.
1984
+
1985
+ Paletted images are translated into true color or true color + alpha pixel
1986
+ formats.
1987
+
1988
+ Please note that \OpenGL~1.0 does not support single component alpha maps,
1989
+ so do not use images with Format = GL\_ALPHA directly as textures under
1990
+ \OpenGL~1.0.
1991
+ \end{refnotes}
1992
+
1993
+
1994
+ %-------------------------------------------------------------------------
1995
+ \subsection{glfwReadMemoryImage}
1996
+
1997
+ \textbf{C language syntax}
1998
+ \begin{lstlisting}
1999
+ int glfwReadMemoryImage( const void *data, long size, GLFWimage *img, int flags )
2000
+ \end{lstlisting}
2001
+
2002
+ \begin{refparameters}
2003
+ \begin{description}
2004
+ \item [\textit{data}]\ \\
2005
+ The memory buffer holding the contents of the file that should be read.
2006
+ \item [\textit{size}]\ \\
2007
+ The size, in bytes, of the memory buffer.
2008
+ \item [\textit{img}]\ \\
2009
+ Pointer to a GLFWimage struct, which will hold the information about
2010
+ the loaded image (if the read was successful).
2011
+ \item [\textit{flags}]\ \\
2012
+ Flags for controlling the image reading process. Valid flags are listed
2013
+ in table \ref{tab:rdimgflags}
2014
+ \end{description}
2015
+ \end{refparameters}
2016
+
2017
+ \begin{refreturn}
2018
+ The function returns GL\_TRUE if the image was loaded successfully.
2019
+ Otherwise GL\_FALSE is returned.
2020
+ \end{refreturn}
2021
+
2022
+ \begin{refdescription}
2023
+ The function reads an image from the memory buffer specified by the parameter
2024
+ \textit{data} and returns the image information and data in a GLFWimage
2025
+ structure, which has the following definition:
2026
+
2027
+ \begin{lstlisting}
2028
+ typedef struct {
2029
+ int Width, Height; // Image dimensions
2030
+ int Format; // OpenGL pixel format
2031
+ int BytesPerPixel; // Number of bytes per pixel
2032
+ unsigned char *Data; // Pointer to pixel data
2033
+ } GLFWimage;
2034
+ \end{lstlisting}
2035
+
2036
+ \textit{Width} and \textit{Height} give the dimensions of the image.
2037
+ \textit{Format} specifies an \OpenGL\ pixel format, which can be
2038
+ GL\_LUMINANCE or GL\_ALPHA (for gray scale images), GL\_RGB or GL\_RGBA.
2039
+ \textit{BytesPerPixel} specifies the number of bytes per pixel.
2040
+ \textit{Data} is a pointer to the actual pixel data.
2041
+
2042
+ By default the read image is rescaled to the nearest larger $2^m\times2^n$
2043
+ resolution using bilinear interpolation, if necessary, which is useful if
2044
+ the image is to be used as an \OpenGL\ texture. This behavior can be
2045
+ disabled by setting the GLFW\_NO\_RESCALE\_BIT flag.
2046
+
2047
+ Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the first pixel in
2048
+ \textit{img->Data} is the lower left corner of the image. If the flag
2049
+ GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
2050
+ corner.
2051
+
2052
+ For single component images (i.e. gray scale), \textit{Format} is set
2053
+ to GL\_ALPHA if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
2054
+ \textit{Format} is set to GL\_LUMINANCE.
2055
+ \end{refdescription}
2056
+
2057
+ \begin{refnotes}
2058
+ \textbf{glfwReadMemoryImage} supports the Truevision Targa version 1 file
2059
+ format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted
2060
+ (24/32-bit color), 24-bit true color and 32-bit true color + alpha.
2061
+
2062
+ Paletted images are translated into true color or true color + alpha pixel
2063
+ formats.
2064
+
2065
+ Please note that \OpenGL~1.0 does not support single component alpha maps,
2066
+ so do not use images with Format = GL\_ALPHA directly as textures under
2067
+ \OpenGL~1.0.
2068
+ \end{refnotes}
2069
+
2070
+
2071
+ %-------------------------------------------------------------------------
2072
+ \subsection{glfwFreeImage}
2073
+
2074
+ \textbf{C language syntax}
2075
+ \begin{lstlisting}
2076
+ void glfwFreeImage( GLFWimage *img )
2077
+ \end{lstlisting}
2078
+
2079
+ \begin{refparameters}
2080
+ \begin{description}
2081
+ \item [\textit{img}]\ \\
2082
+ Pointer to a GLFWimage struct.
2083
+ \end{description}
2084
+ \end{refparameters}
2085
+
2086
+ \begin{refreturn}
2087
+ none
2088
+ \end{refreturn}
2089
+
2090
+ \begin{refdescription}
2091
+ The function frees any memory occupied by a loaded image, and clears all
2092
+ the fields of the GLFWimage struct. Any image that has been loaded by the
2093
+ \textbf{glfwReadImage} function should be deallocated using this function,
2094
+ once the image is not needed anymore.
2095
+ \end{refdescription}
2096
+
2097
+
2098
+ %-------------------------------------------------------------------------
2099
+ \begin{table}[p]
2100
+ \begin{center}
2101
+ \begin{tabular}{|l|p{9.0cm}|} \hline \raggedright
2102
+ \textbf{Name} & \textbf{Description}\\ \hline
2103
+ GLFW\_BUILD\_MIPMAPS\_BIT & Automatically build and upload all mipmap levels\\ \hline
2104
+ GLFW\_ORIGIN\_UL\_BIT & Specifies that the origin of the \textit{loaded} image should be in the upper left corner (default is the lower left corner)\\ \hline
2105
+ GLFW\_ALPHA\_MAP\_BIT & Treat single component images as alpha maps rather than luminance maps\\ \hline
2106
+ \end{tabular}
2107
+ \end{center}
2108
+ \caption{Flags for \textbf{glfwLoadTexture2D}}
2109
+ \label{tab:ldtexflags}
2110
+ \end{table}
2111
+
2112
+
2113
+ %-------------------------------------------------------------------------
2114
+ \subsection{glfwLoadTexture2D}
2115
+
2116
+ \textbf{C language syntax}
2117
+ \begin{lstlisting}
2118
+ int glfwLoadTexture2D( const char *name, int flags )
2119
+ \end{lstlisting}
2120
+
2121
+ \begin{refparameters}
2122
+ \begin{description}
2123
+ \item [\textit{name}]\ \\
2124
+ An ISO~8859-1 string holding the name of the file that should be loaded.
2125
+ \item [\textit{flags}]\ \\
2126
+ Flags for controlling the texture loading process. Valid flags are
2127
+ listed in table \ref{tab:ldtexflags}.
2128
+ \end{description}
2129
+ \end{refparameters}
2130
+
2131
+ \begin{refreturn}
2132
+ The function returns GL\_TRUE if the texture was loaded successfully.
2133
+ Otherwise GL\_FALSE is returned.
2134
+ \end{refreturn}
2135
+
2136
+ \begin{refdescription}
2137
+ The function reads an image from the file specified by the parameter
2138
+ \textit{name} and uploads the image to \OpenGL\ texture memory (using the
2139
+ \textbf{glTexImage2D} function).
2140
+
2141
+ If the GLFW\_BUILD\_MIPMAPS\_BIT flag is set, all mipmap levels for the
2142
+ loaded texture are generated and uploaded to texture memory.
2143
+
2144
+ Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the origin of the texture
2145
+ is the lower left corner of the loaded image. If the flag
2146
+ GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
2147
+ corner.
2148
+
2149
+ For single component images (i.e. gray scale), the texture is uploaded as
2150
+ an alpha mask if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
2151
+ it is uploaded as a luminance texture.
2152
+ \end{refdescription}
2153
+
2154
+ \begin{refnotes}
2155
+ \textbf{glfwLoadTexture2D} supports the Truevision Targa version 1 file
2156
+ format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit
2157
+ paletted (24/32-bit color), 24-bit true color and 32-bit true color +
2158
+ alpha.
2159
+
2160
+ Paletted images are translated into true color or true color + alpha pixel
2161
+ formats.
2162
+
2163
+ The read texture is always rescaled to the nearest larger $2^m\times2^n$
2164
+ resolution using bilinear interpolation, if necessary, since \OpenGL\
2165
+ requires textures to have a $2^m\times2^n$ resolution.
2166
+
2167
+ If the GL\_SGIS\_generate\_mipmap extension, which is usually hardware
2168
+ accelerated, is supported by the \OpenGL\ implementation it will be used
2169
+ for mipmap generation. Otherwise the mipmaps will be generated by \GLFW\
2170
+ in software.
2171
+
2172
+ Since \OpenGL~1.0 does not support single component alpha maps, alpha map
2173
+ textures are converted to RGBA format under \OpenGL~1.0 when the
2174
+ GLFW\_ALPHA\_MAP\_BIT flag is set and the loaded texture is a single
2175
+ component texture. The red, green and blue components are set to 1.0.
2176
+ \end{refnotes}
2177
+
2178
+
2179
+ %-------------------------------------------------------------------------
2180
+ \subsection{glfwLoadMemoryTexture2D}
2181
+
2182
+ \textbf{C language syntax}
2183
+ \begin{lstlisting}
2184
+ int glfwLoadMemoryTexture2D( const void *data, long size, int flags )
2185
+ \end{lstlisting}
2186
+
2187
+ \begin{refparameters}
2188
+ \begin{description}
2189
+ \item [\textit{data}]\ \\
2190
+ The memory buffer holding the contents of the file that should be loaded.
2191
+ \item [\textit{size}]\ \\
2192
+ The size, in bytes, of the memory buffer.
2193
+ \item [\textit{flags}]\ \\
2194
+ Flags for controlling the texture loading process. Valid flags are
2195
+ listed in table \ref{tab:ldtexflags}.
2196
+ \end{description}
2197
+ \end{refparameters}
2198
+
2199
+ \begin{refreturn}
2200
+ The function returns GL\_TRUE if the texture was loaded successfully.
2201
+ Otherwise GL\_FALSE is returned.
2202
+ \end{refreturn}
2203
+
2204
+ \begin{refdescription}
2205
+ The function reads an image from the memory buffer specified by the parameter
2206
+ \textit{data} and uploads the image to \OpenGL\ texture memory (using the
2207
+ \textbf{glTexImage2D} function).
2208
+
2209
+ If the GLFW\_BUILD\_MIPMAPS\_BIT flag is set, all mipmap levels for the
2210
+ loaded texture are generated and uploaded to texture memory.
2211
+
2212
+ Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the origin of the texture
2213
+ is the lower left corner of the loaded image. If the flag
2214
+ GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
2215
+ corner.
2216
+
2217
+ For single component images (i.e. gray scale), the texture is uploaded as
2218
+ an alpha mask if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
2219
+ it is uploaded as a luminance texture.
2220
+ \end{refdescription}
2221
+
2222
+ \begin{refnotes}
2223
+ \textbf{glfwLoadMemoryTexture2D} supports the Truevision Targa version 1 file
2224
+ format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit
2225
+ paletted (24/32-bit color), 24-bit true color and 32-bit true color +
2226
+ alpha.
2227
+
2228
+ Paletted images are translated into true color or true color + alpha pixel
2229
+ formats.
2230
+
2231
+ The read texture is always rescaled to the nearest larger $2^m\times2^n$
2232
+ resolution using bilinear interpolation, if necessary, since \OpenGL\
2233
+ requires textures to have a $2^m\times2^n$ resolution.
2234
+
2235
+ If the GL\_SGIS\_generate\_mipmap extension, which is usually hardware
2236
+ accelerated, is supported by the \OpenGL\ implementation it will be used
2237
+ for mipmap generation. Otherwise the mipmaps will be generated by \GLFW\
2238
+ in software.
2239
+
2240
+ Since \OpenGL~1.0 does not support single component alpha maps, alpha map
2241
+ textures are converted to RGBA format under \OpenGL~1.0 when the
2242
+ GLFW\_ALPHA\_MAP\_BIT flag is set and the loaded texture is a single
2243
+ component texture. The red, green and blue components are set to 1.0.
2244
+ \end{refnotes}
2245
+
2246
+
2247
+ %-------------------------------------------------------------------------
2248
+ \subsection{glfwLoadTextureImage2D}
2249
+
2250
+ \textbf{C language syntax}
2251
+ \begin{lstlisting}
2252
+ int glfwLoadTextureImage2D( GLFWimage *img, int flags )
2253
+ \end{lstlisting}
2254
+
2255
+ \begin{refparameters}
2256
+ \begin{description}
2257
+ \item [\textit{img}]\ \\
2258
+ Pointer to a GLFWimage struct holding the information about
2259
+ the image to be loaded.
2260
+ \item [\textit{flags}]\ \\
2261
+ Flags for controlling the texture loading process. Valid flags are
2262
+ listed in table \ref{tab:ldtexflags}.
2263
+ \end{description}
2264
+ \end{refparameters}
2265
+
2266
+ \begin{refreturn}
2267
+ The function returns GL\_TRUE if the texture was loaded successfully.
2268
+ Otherwise GL\_FALSE is returned.
2269
+ \end{refreturn}
2270
+
2271
+ \begin{refdescription}
2272
+ The function uploads the image specified by the parameter \textit{img} to
2273
+ \OpenGL\ texture memory (using the \textbf{glTexImage2D} function).
2274
+
2275
+ If the GLFW\_BUILD\_MIPMAPS\_BIT flag is set, all mipmap levels for the
2276
+ loaded texture are generated and uploaded to texture memory.
2277
+
2278
+ Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the origin of the texture
2279
+ is the lower left corner of the loaded image. If the flag
2280
+ GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
2281
+ corner.
2282
+
2283
+ For single component images (i.e. gray scale), the texture is uploaded as
2284
+ an alpha mask if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
2285
+ it is uploaded as a luminance texture.
2286
+ \end{refdescription}
2287
+
2288
+ \begin{refnotes}
2289
+ \textbf{glfwLoadTextureImage2D} supports the Truevision Targa version 1 file
2290
+ format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit
2291
+ paletted (24/32-bit color), 24-bit true color and 32-bit true color +
2292
+ alpha.
2293
+
2294
+ Paletted images are translated into true color or true color + alpha pixel
2295
+ formats.
2296
+
2297
+ The read texture is always rescaled to the nearest larger $2^m\times2^n$
2298
+ resolution using bilinear interpolation, if necessary, since \OpenGL\
2299
+ requires textures to have a $2^m\times2^n$ resolution.
2300
+
2301
+ If the GL\_SGIS\_generate\_mipmap extension, which is usually hardware
2302
+ accelerated, is supported by the \OpenGL\ implementation it will be used
2303
+ for mipmap generation. Otherwise the mipmaps will be generated by \GLFW\
2304
+ in software.
2305
+
2306
+ Since \OpenGL~1.0 does not support single component alpha maps, alpha map
2307
+ textures are converted to RGBA format under \OpenGL~1.0 when the
2308
+ GLFW\_ALPHA\_MAP\_BIT flag is set and the loaded texture is a single
2309
+ component texture. The red, green and blue components are set to 1.0.
2310
+ \end{refnotes}
2311
+
2312
+
2313
+ %-------------------------------------------------------------------------
2314
+ \pagebreak
2315
+ \section{OpenGL Extension Support}
2316
+ One of the great features of \OpenGL\ is its support for extensions, which
2317
+ allow independent vendors to supply non-standard functionality in their
2318
+ \OpenGL\ implementations. Using extensions is different under different
2319
+ systems, which is why \GLFW\ has provided an operating system independent
2320
+ interface to querying and using \OpenGL\ extensions.
2321
+
2322
+
2323
+ %-------------------------------------------------------------------------
2324
+ \subsection{glfwExtensionSupported}
2325
+
2326
+ \textbf{C language syntax}
2327
+ \begin{lstlisting}
2328
+ int glfwExtensionSupported( const char *extension )
2329
+ \end{lstlisting}
2330
+
2331
+ \begin{refparameters}
2332
+ \begin{description}
2333
+ \item [\textit{extension}]\ \\
2334
+ A null terminated ISO~8859-1 string containing the name of an \OpenGL\
2335
+ extension.
2336
+ \end{description}
2337
+ \end{refparameters}
2338
+
2339
+ \begin{refreturn}
2340
+ The function returns GL\_TRUE if the extension is supported. Otherwise it
2341
+ returns GL\_FALSE.
2342
+ \end{refreturn}
2343
+
2344
+ \begin{refdescription}
2345
+ The function does a string search in the list of supported \OpenGL\
2346
+ extensions to find if the specified extension is listed.
2347
+ \end{refdescription}
2348
+
2349
+ \begin{refnotes}
2350
+ An \OpenGL\ context must be created before this function can be called
2351
+ (i.e. an \OpenGL\ window must have been opened with
2352
+ \textbf{glfwOpenWindow}).
2353
+
2354
+ In addition to checking for \OpenGL\ extensions, \GLFW\ also checks for
2355
+ extensions in the operating system ``glue API'', such as WGL extensions
2356
+ under Windows and glX extensions under the X Window System.
2357
+ \end{refnotes}
2358
+
2359
+
2360
+ %-------------------------------------------------------------------------
2361
+ \subsection{glfwGetProcAddress}
2362
+
2363
+ \textbf{C language syntax}
2364
+ \begin{lstlisting}
2365
+ void * glfwGetProcAddress( const char *procname )
2366
+ \end{lstlisting}
2367
+
2368
+ \begin{refparameters}
2369
+ \begin{description}
2370
+ \item [\textit{procname}]\ \\
2371
+ A null terminated ISO~8859-1 string containing the name of an \OpenGL\
2372
+ extension function.
2373
+ \end{description}
2374
+ \end{refparameters}
2375
+
2376
+ \begin{refreturn}
2377
+ The function returns the pointer to the specified \OpenGL\ function if it
2378
+ is supported, otherwise NULL is returned.
2379
+ \end{refreturn}
2380
+
2381
+ \begin{refdescription}
2382
+ The function acquires the pointer to an \OpenGL\ extension function. Some
2383
+ (but not all) \OpenGL\ extensions define new API functions, which are
2384
+ usually not available through normal linking. It is therefore necessary to
2385
+ get access to those API functions at runtime.
2386
+ \end{refdescription}
2387
+
2388
+ \begin{refnotes}
2389
+ An \OpenGL\ context must be created before this function can be called
2390
+ (i.e. an \OpenGL\ window must have been opened with
2391
+ \textbf{glfwOpenWindow}).
2392
+
2393
+ Some systems do not support dynamic function pointer retrieval, in which
2394
+ case \textbf{glfwGetProcAddress} will always return NULL.
2395
+ \end{refnotes}
2396
+
2397
+
2398
+ %-------------------------------------------------------------------------
2399
+ \subsection{glfwGetGLVersion}
2400
+
2401
+ \textbf{C language syntax}
2402
+ \begin{lstlisting}
2403
+ void glfwGetGLVersion( int *major, int *minor, int *rev )
2404
+ \end{lstlisting}
2405
+
2406
+ \begin{refparameters}
2407
+ \begin{description}
2408
+ \item [\textit{major}]\ \\
2409
+ Pointer to an integer that will hold the major version number.
2410
+ \item [\textit{minor}]\ \\
2411
+ Pointer to an integer that will hold the minor version number.
2412
+ \item [\textit{rev}]\ \\
2413
+ Pointer to an integer that will hold the revision.
2414
+ \end{description}
2415
+ \end{refparameters}
2416
+
2417
+ \begin{refreturn}
2418
+ The function returns the major and minor version numbers and the revision
2419
+ for the currently used \OpenGL\ implementation.
2420
+ \end{refreturn}
2421
+
2422
+ \begin{refdescription}
2423
+ The function returns the \OpenGL\ implementation version. This is a
2424
+ convenient function that parses the version number information from the
2425
+ string returned by calling \texttt{glGetString(~GL\_VERSION~)}. The
2426
+ \OpenGL\ version information can be used to determine what functionality
2427
+ is supported by the used \OpenGL\ implementation.
2428
+ \end{refdescription}
2429
+
2430
+ \begin{refnotes}
2431
+ An \OpenGL\ context must be created before this function can be called
2432
+ (i.e. an \OpenGL\ window must have been opened with
2433
+ \textbf{glfwOpenWindow}).
2434
+ \end{refnotes}
2435
+
2436
+
2437
+ %-------------------------------------------------------------------------
2438
+ \pagebreak
2439
+ \section{Threads}
2440
+ A thread is a separate execution path within a process. All threads within
2441
+ a process share the same address space and resources. Threads execute in
2442
+ parallel, either virtually by means of time-sharing on a single processor,
2443
+ or truly in parallel on several processors. Even on a multi-processor
2444
+ system, time-sharing is employed in order to maximize processor
2445
+ utilization and to ensure fair scheduling. \GLFW\ provides an operating
2446
+ system independent interface to thread management.
2447
+
2448
+
2449
+ %-------------------------------------------------------------------------
2450
+ \subsection{glfwCreateThread}
2451
+
2452
+ \textbf{C language syntax}
2453
+ \begin{lstlisting}
2454
+ GLFWthread glfwCreateThread( GLFWthreadfun fun, void *arg )
2455
+ \end{lstlisting}
2456
+
2457
+ \begin{refparameters}
2458
+ \begin{description}
2459
+ \item [\textit{fun}]\ \\
2460
+ A pointer to a function that acts as the entry point for the new thread.
2461
+ The function should have the following C language prototype:
2462
+
2463
+ \texttt{void GLFWCALL functionname( void *arg );}
2464
+
2465
+ Where \textit{functionname} is the name of the thread function, and
2466
+ \textit{arg} is the user supplied argument (see below).
2467
+ \item [\textit{arg}]\ \\
2468
+ An arbitrary argument for the thread. \textit{arg} will be passed as the
2469
+ argument to the thread function pointed to by \textit{fun}. For
2470
+ instance, \textit{arg} can point to data that is to be processed by the
2471
+ thread.
2472
+ \end{description}
2473
+ \end{refparameters}
2474
+
2475
+ \begin{refreturn}
2476
+ The function returns a thread identification number if the thread was
2477
+ created successfully. This number is always positive. If the function
2478
+ fails, a negative number is returned.
2479
+ \end{refreturn}
2480
+
2481
+ \begin{refdescription}
2482
+ The function creates a new thread, which executes within the same address
2483
+ space as the calling process. The thread entry point is specified with the
2484
+ \textit{fun} argument.
2485
+
2486
+ Once the thread function \textit{fun} returns, the thread dies.
2487
+ \end{refdescription}
2488
+
2489
+ \begin{refnotes}
2490
+ Even if the function returns a positive thread ID, indicating that the
2491
+ thread was created successfully, the thread may be unable to execute, for
2492
+ instance if the thread start address is not a valid thread entry point.
2493
+ \end{refnotes}
2494
+
2495
+
2496
+ %-------------------------------------------------------------------------
2497
+ \subsection{glfwDestroyThread}
2498
+
2499
+ \textbf{C language syntax}
2500
+ \begin{lstlisting}
2501
+ void glfwDestroyThread( GLFWthread ID )
2502
+ \end{lstlisting}
2503
+
2504
+ \begin{refparameters}
2505
+ \begin{description}
2506
+ \item [\textit{ID}]\ \\
2507
+ A thread identification handle, which is returned by
2508
+ \textbf{glfwCreateThread} or \textbf{glfwGetThreadID}.
2509
+ \end{description}
2510
+ \end{refparameters}
2511
+
2512
+ \begin{refreturn}
2513
+ none
2514
+ \end{refreturn}
2515
+
2516
+ \begin{refdescription}
2517
+ The function kills a running thread and removes it from the thread list.
2518
+ \end{refdescription}
2519
+
2520
+ \begin{refnotes}
2521
+ This function is a very dangerous operation, which may interrupt a thread
2522
+ in the middle of an important operation, and its use is discouraged. You
2523
+ should always try to end a thread in a graceful way using thread
2524
+ communication, and use \textbf{glfwWaitThread} in order to wait for the
2525
+ thread to die.
2526
+ \end{refnotes}
2527
+
2528
+
2529
+ %-------------------------------------------------------------------------
2530
+ \subsection{glfwWaitThread}
2531
+
2532
+ \textbf{C language syntax}
2533
+ \begin{lstlisting}
2534
+ int glfwWaitThread( GLFWthread ID, int waitmode )
2535
+ \end{lstlisting}
2536
+
2537
+ \begin{refparameters}
2538
+ \begin{description}
2539
+ \item [\textit{ID}]\ \\
2540
+ A thread identification handle, which is returned by
2541
+ \textbf{glfwCreateThread} or \textbf{glfwGetThreadID}.
2542
+ \item [\textit{waitmode}]\ \\
2543
+ Can be either GLFW\_WAIT or GLFW\_NOWAIT.
2544
+ \end{description}
2545
+ \end{refparameters}
2546
+
2547
+ \begin{refreturn}
2548
+ The function returns GL\_TRUE if the specified thread died after the
2549
+ function was called, or the thread did not exist, in which case
2550
+ \textbf{glfwWaitThread} will return immediately regardless of
2551
+ \textit{waitmode}. The function returns GL\_FALSE if \textit{waitmode}
2552
+ is GLFW\_NOWAIT, and the specified thread exists and is still running.
2553
+ \end{refreturn}
2554
+
2555
+ \begin{refdescription}
2556
+ If \textit{waitmode} is GLFW\_WAIT, the function waits for a thread to
2557
+ die. If \textit{waitmode} is GLFW\_NOWAIT, the function checks if a thread
2558
+ exists and returns immediately.
2559
+ \end{refdescription}
2560
+
2561
+
2562
+ %-------------------------------------------------------------------------
2563
+ \subsection{glfwGetThreadID}
2564
+
2565
+ \textbf{C language syntax}
2566
+ \begin{lstlisting}
2567
+ GLFWthread glfwGetThreadID( void )
2568
+ \end{lstlisting}
2569
+
2570
+ \begin{refparameters}
2571
+ none
2572
+ \end{refparameters}
2573
+
2574
+ \begin{refreturn}
2575
+ The function returns a thread identification handle for the calling
2576
+ thread.
2577
+ \end{refreturn}
2578
+
2579
+ \begin{refdescription}
2580
+ The function determines the thread ID for the calling thread. The ID is
2581
+ the same value as was returned by \textbf{glfwCreateThread} when the
2582
+ thread was created.
2583
+ \end{refdescription}
2584
+
2585
+
2586
+ %-------------------------------------------------------------------------
2587
+ \pagebreak
2588
+ \section{Mutexes}
2589
+ Mutexes are used to securely share data between threads. A mutex object
2590
+ can only be owned by one thread at a time. If more than one thread
2591
+ requires access to a mutex object, all but one thread will be put to sleep
2592
+ until they get access to it.
2593
+
2594
+
2595
+ %-------------------------------------------------------------------------
2596
+ \subsection{glfwCreateMutex}
2597
+
2598
+ \textbf{C language syntax}
2599
+ \begin{lstlisting}
2600
+ GLFWmutex glfwCreateMutex( void )
2601
+ \end{lstlisting}
2602
+
2603
+ \begin{refparameters}
2604
+ none
2605
+ \end{refparameters}
2606
+
2607
+ \begin{refreturn}
2608
+ The function returns a mutex handle, or NULL if the mutex could not be
2609
+ created.
2610
+ \end{refreturn}
2611
+
2612
+ \begin{refdescription}
2613
+ The function creates a mutex object, which can be used to control access
2614
+ to data that is shared between threads.
2615
+ \end{refdescription}
2616
+
2617
+
2618
+ %-------------------------------------------------------------------------
2619
+ \subsection{glfwDestroyMutex}
2620
+
2621
+ \textbf{C language syntax}
2622
+ \begin{lstlisting}
2623
+ void glfwDestroyMutex( GLFWmutex mutex )
2624
+ \end{lstlisting}
2625
+
2626
+ \begin{refparameters}
2627
+ \begin{description}
2628
+ \item [\textit{mutex}]\ \\
2629
+ A mutex object handle.
2630
+ \end{description}
2631
+ \end{refparameters}
2632
+
2633
+ \begin{refreturn}
2634
+ none
2635
+ \end{refreturn}
2636
+
2637
+ \begin{refdescription}
2638
+ The function destroys a mutex object. After a mutex object has been
2639
+ destroyed, it may no longer be used by any thread.
2640
+ \end{refdescription}
2641
+
2642
+
2643
+ %-------------------------------------------------------------------------
2644
+ \subsection{glfwLockMutex}
2645
+
2646
+ \textbf{C language syntax}
2647
+ \begin{lstlisting}
2648
+ void glfwLockMutex( GLFWmutex mutex )
2649
+ \end{lstlisting}
2650
+
2651
+ \begin{refparameters}
2652
+ \begin{description}
2653
+ \item [\textit{mutex}]\ \\
2654
+ A mutex object handle.
2655
+ \end{description}
2656
+ \end{refparameters}
2657
+
2658
+ \begin{refreturn}
2659
+ none
2660
+ \end{refreturn}
2661
+
2662
+ \begin{refdescription}
2663
+ The function will acquire a lock on the selected mutex object. If the
2664
+ mutex is already locked by another thread, the function will block the
2665
+ calling thread until it is released by the locking thread. Once the
2666
+ function returns, the calling thread has an exclusive lock on the mutex.
2667
+ To release the mutex, call \textbf{glfwUnlockMutex}.
2668
+ \end{refdescription}
2669
+
2670
+
2671
+ %-------------------------------------------------------------------------
2672
+ \subsection{glfwUnlockMutex}
2673
+
2674
+ \textbf{C language syntax}
2675
+ \begin{lstlisting}
2676
+ void glfwUnlockMutex( GLFWmutex mutex )
2677
+ \end{lstlisting}
2678
+
2679
+ \begin{refparameters}
2680
+ \begin{description}
2681
+ \item [\textit{mutex}]\ \\
2682
+ A mutex object handle.
2683
+ \end{description}
2684
+ \end{refparameters}
2685
+
2686
+ \begin{refreturn}
2687
+ none
2688
+ \end{refreturn}
2689
+
2690
+ \begin{refdescription}
2691
+ The function releases the lock of a locked mutex object.
2692
+ \end{refdescription}
2693
+
2694
+
2695
+ %-------------------------------------------------------------------------
2696
+ \pagebreak
2697
+ \section{Condition Variables}
2698
+ Condition variables are used to synchronize threads. A thread can wait for
2699
+ a condition variable to be signaled by another thread.
2700
+
2701
+
2702
+ %-------------------------------------------------------------------------
2703
+ \subsection{glfwCreateCond}
2704
+
2705
+ \textbf{C language syntax}
2706
+ \begin{lstlisting}
2707
+ GLFWcond glfwCreateCond( void )
2708
+ \end{lstlisting}
2709
+
2710
+ \begin{refparameters}
2711
+ none
2712
+ \end{refparameters}
2713
+
2714
+ \begin{refreturn}
2715
+ The function returns a condition variable handle, or NULL if the condition
2716
+ variable could not be created.
2717
+ \end{refreturn}
2718
+
2719
+ \begin{refdescription}
2720
+ The function creates a condition variable object, which can be used to
2721
+ synchronize threads.
2722
+ \end{refdescription}
2723
+
2724
+
2725
+ %-------------------------------------------------------------------------
2726
+ \subsection{glfwDestroyCond}
2727
+
2728
+ \textbf{C language syntax}
2729
+ \begin{lstlisting}
2730
+ void glfwDestroyCond( GLFWcond cond )
2731
+ \end{lstlisting}
2732
+
2733
+ \begin{refparameters}
2734
+ \begin{description}
2735
+ \item [\textit{cond}]\ \\
2736
+ A condition variable object handle.
2737
+ \end{description}
2738
+ \end{refparameters}
2739
+
2740
+ \begin{refreturn}
2741
+ none
2742
+ \end{refreturn}
2743
+
2744
+ \begin{refdescription}
2745
+ The function destroys a condition variable object. After a condition
2746
+ variable object has been destroyed, it may no longer be used by any
2747
+ thread.
2748
+ \end{refdescription}
2749
+
2750
+
2751
+ %-------------------------------------------------------------------------
2752
+ \subsection{glfwWaitCond}
2753
+
2754
+ \textbf{C language syntax}
2755
+ \begin{lstlisting}
2756
+ void glfwWaitCond( GLFWcond cond, GLFWmutex mutex, double timeout )
2757
+ \end{lstlisting}
2758
+
2759
+ \begin{refparameters}
2760
+ \begin{description}
2761
+ \item [\textit{cond}]\ \\
2762
+ A condition variable object handle.
2763
+ \item [\textit{mutex}]\ \\
2764
+ A mutex object handle.
2765
+ \item [\textit{timeout}]\ \\
2766
+ Maximum time to wait for the condition variable. The parameter can
2767
+ either be a positive time (in seconds), or GLFW\_INFINITY.
2768
+ \end{description}
2769
+ \end{refparameters}
2770
+
2771
+ \begin{refreturn}
2772
+ none
2773
+ \end{refreturn}
2774
+
2775
+ \begin{refdescription}
2776
+ The function atomically unlocks the mutex specified by \textit{mutex}, and
2777
+ waits for the condition variable \textit{cond} to be signaled. The thread
2778
+ execution is suspended and does not consume any CPU time until the
2779
+ condition variable is signaled or the amount of time specified by timeout
2780
+ has passed. If timeout is GLFW\_INFINITY, \textbf{glfwWaitCond} will wait
2781
+ forever for \textit{cond} to be signaled. Before returning to the calling
2782
+ thread, \textbf{glfwWaitCond} automatically re-acquires the mutex.
2783
+ \end{refdescription}
2784
+
2785
+ \begin{refnotes}
2786
+ The mutex specified by \textit{mutex} must be locked by the calling thread
2787
+ before entrance to \textbf{glfwWaitCond}.
2788
+
2789
+ A condition variable must always be associated with a mutex, to avoid the
2790
+ race condition where a thread prepares to wait on a condition variable and
2791
+ another thread signals the condition just before the first thread actually
2792
+ waits on it.
2793
+ \end{refnotes}
2794
+
2795
+
2796
+ %-------------------------------------------------------------------------
2797
+ \subsection{glfwSignalCond}
2798
+
2799
+ \textbf{C language syntax}
2800
+ \begin{lstlisting}
2801
+ void glfwSignalCond( GLFWcond cond )
2802
+ \end{lstlisting}
2803
+
2804
+ \begin{refparameters}
2805
+ \begin{description}
2806
+ \item [\textit{cond}]\ \\
2807
+ A condition variable object handle.
2808
+ \end{description}
2809
+ \end{refparameters}
2810
+
2811
+ \begin{refreturn}
2812
+ none
2813
+ \end{refreturn}
2814
+
2815
+ \begin{refdescription}
2816
+ The function restarts one of the threads that are waiting on the condition
2817
+ variable \textit{cond}. If no threads are waiting on \textit{cond},
2818
+ nothing happens. If several threads are waiting on \textit{cond}, exactly
2819
+ one is restarted, but it is not specified which.
2820
+ \end{refdescription}
2821
+
2822
+ \begin{refnotes}
2823
+ When several threads are waiting for the condition variable, which thread
2824
+ is started depends on operating system scheduling rules, and may vary from
2825
+ system to system and from time to time.
2826
+ \end{refnotes}
2827
+
2828
+
2829
+ %-------------------------------------------------------------------------
2830
+ \subsection{glfwBroadcastCond}
2831
+
2832
+ \textbf{C language syntax}
2833
+ \begin{lstlisting}
2834
+ void glfwBroadcastCond( GLFWcond cond )
2835
+ \end{lstlisting}
2836
+
2837
+ \begin{refparameters}
2838
+ \begin{description}
2839
+ \item [\textit{cond}]\ \\
2840
+ A condition variable object handle.
2841
+ \end{description}
2842
+ \end{refparameters}
2843
+
2844
+ \begin{refreturn}
2845
+ none
2846
+ \end{refreturn}
2847
+
2848
+ \begin{refdescription}
2849
+ The function restarts all the threads that are waiting on the condition
2850
+ variable \textit{cond}. If no threads are waiting on \textit{cond},
2851
+ nothing happens.
2852
+ \end{refdescription}
2853
+
2854
+ \begin{refnotes}
2855
+ When several threads are waiting for the condition variable, the order in
2856
+ which threads are started depends on operating system scheduling rules,
2857
+ and may vary from system to system and from time to time.
2858
+ \end{refnotes}
2859
+
2860
+
2861
+ %-------------------------------------------------------------------------
2862
+ \pagebreak
2863
+ \section{Miscellaneous}
2864
+
2865
+
2866
+ %-------------------------------------------------------------------------
2867
+ \subsection{glfwEnable/glfwDisable}
2868
+
2869
+ \textbf{C language syntax}
2870
+ \begin{lstlisting}
2871
+ void glfwEnable( int token )
2872
+ void glfwDisable( int token )
2873
+ \end{lstlisting}
2874
+
2875
+ \begin{refparameters}
2876
+ \begin{description}
2877
+ \item [\textit{token}]\ \\
2878
+ A value specifying a feature to enable or disable. Valid tokens are
2879
+ listed in table \ref{tab:enable}.
2880
+ \end{description}
2881
+ \end{refparameters}
2882
+
2883
+ \begin{refreturn}
2884
+ none
2885
+ \end{refreturn}
2886
+
2887
+ \begin{refdescription}
2888
+ \textbf{glfwEnable} is used to enable a certain feature, while
2889
+ \textbf{glfwDisable} is used to disable it. Below follows a description of
2890
+ each feature.
2891
+ \end{refdescription}
2892
+
2893
+
2894
+ \begin{table}[p]
2895
+ \begin{center}
2896
+ \begin{tabular}{|l|p{5.0cm}|p{3.0cm}|} \hline \raggedright
2897
+ \textbf{Name} & \textbf{Controls} & \textbf{Default}\\ \hline
2898
+ \hyperlink{lnk:autopollevents}{GLFW\_AUTO\_POLL\_EVENTS} & Automatic event polling when \textbf{glfwSwapBuffers} is called & Enabled\\ \hline
2899
+ \hyperlink{lnk:keyrepeat}{GLFW\_KEY\_REPEAT} & Keyboard key repeat & Disabled\\ \hline
2900
+ \hyperlink{lnk:mousecursor}{GLFW\_MOUSE\_CURSOR} & Mouse cursor visibility & Enabled in windowed mode. Disabled in fullscreen mode.\\ \hline
2901
+ \hyperlink{lnk:stickykeys}{GLFW\_STICKY\_KEYS} & Keyboard key ``stickiness'' & Disabled\\ \hline
2902
+ \hyperlink{lnk:stickymousebuttons}{GLFW\_STICKY\_MOUSE\_BUTTONS} & Mouse button ``stickiness'' & Disabled\\ \hline
2903
+ \hyperlink{lnk:systemkeys}{GLFW\_SYSTEM\_KEYS} & Special system key actions & Enabled\\ \hline
2904
+ \end{tabular}
2905
+ \end{center}
2906
+ \caption{Tokens for \textbf{glfwEnable}/\textbf{glfwDisable}}
2907
+ \label{tab:enable}
2908
+ \end{table}
2909
+
2910
+
2911
+ \bigskip\begin{mysamepage}\hypertarget{lnk:autopollevents}{}
2912
+ \textbf{GLFW\_AUTO\_POLL\_EVENTS}\\
2913
+ When GLFW\_AUTO\_POLL\_EVENTS is enabled, \textbf{glfwPollEvents} is
2914
+ automatically called each time that \textbf{glfwSwapBuffers} is called.
2915
+
2916
+ When GLFW\_AUTO\_POLL\_EVENTS is disabled, calling
2917
+ \textbf{glfwSwapBuffers} will not result in a call to
2918
+ \textbf{glfwPollEvents}. This can be useful if \textbf{glfwSwapBuffers}
2919
+ needs to be called from within a callback function, since calling
2920
+ \textbf{glfwPollEvents} from a callback function is not allowed.
2921
+ \end{mysamepage}
2922
+
2923
+
2924
+ \bigskip\begin{mysamepage}\hypertarget{lnk:keyrepeat}{}
2925
+ \textbf{GLFW\_KEY\_REPEAT}\\
2926
+ When GLFW\_KEY\_REPEAT is enabled, the key and character callback
2927
+ functions are called repeatedly when a key is held down long enough
2928
+ (according to the system key repeat configuration).
2929
+
2930
+ When GLFW\_KEY\_REPEAT is disabled, the key and character callback
2931
+ functions are only called once when a key is pressed (and once when it is
2932
+ released).
2933
+ \end{mysamepage}
2934
+
2935
+
2936
+ \bigskip\begin{mysamepage}\hypertarget{lnk:mousecursor}{}
2937
+ \textbf{GLFW\_MOUSE\_CURSOR}\\
2938
+ When GLFW\_MOUSE\_CURSOR is enabled, the mouse cursor is visible, and
2939
+ mouse coordinates are relative to the upper left corner of the client area
2940
+ of the \GLFW\ window. The coordinates are limited to the client area of
2941
+ the window.
2942
+
2943
+ When GLFW\_MOUSE\_CURSOR is disabled, the mouse cursor is invisible, and
2944
+ mouse coordinates are not limited to the drawing area of the window. It is
2945
+ as if the mouse coordinates are recieved directly from the mouse, without
2946
+ being restricted or manipulated by the windowing system.
2947
+ \end{mysamepage}
2948
+
2949
+
2950
+ \bigskip\begin{mysamepage}\hypertarget{lnk:stickykeys}{}
2951
+ \textbf{GLFW\_STICKY\_KEYS}\\
2952
+ When GLFW\_STICKY\_KEYS is enabled, keys which are pressed will not be
2953
+ released until they are physically released and checked with
2954
+ \textbf{glfwGetKey}. This behavior makes it possible to catch keys that
2955
+ were pressed and then released again between two calls to
2956
+ \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
2957
+ \textbf{glfwSwapBuffers}, which would otherwise have been reported as
2958
+ released. Care should be taken when using this mode, since keys that are
2959
+ not checked with \textbf{glfwGetKey} will never be released. Note also
2960
+ that enabling GLFW\_STICKY\_KEYS does not affect the behavior of the
2961
+ keyboard callback functionality.
2962
+
2963
+ When GLFW\_STICKY\_KEYS is disabled, the status of a key that is reported
2964
+ by \textbf{glfwGetKey} is always the physical state of the key. Disabling
2965
+ GLFW\_STICKY\_KEYS also clears the sticky information for all keys.
2966
+ \end{mysamepage}
2967
+
2968
+
2969
+ \bigskip\begin{mysamepage}\hypertarget{lnk:stickymousebuttons}{}
2970
+ \textbf{GLFW\_STICKY\_MOUSE\_BUTTONS}\\
2971
+ When GLFW\_STICKY\_MOUSE\_BUTTONS is enabled, mouse buttons that are
2972
+ pressed will not be released until they are physically released and
2973
+ checked with \textbf{glfwGetMouseButton}. This behavior makes it
2974
+ possible to catch mouse buttons which were pressed and then released again
2975
+ between two calls to \textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
2976
+ \textbf{glfwSwapBuffers}, which would otherwise have been reported as
2977
+ released. Care should be taken when using this mode, since mouse buttons
2978
+ that are not checked with \textbf{glfwGetMouseButton} will never be
2979
+ released. Note also that enabling GLFW\_STICKY\_MOUSE\_BUTTONS does not
2980
+ affect the behavior of the mouse button callback functionality.
2981
+
2982
+ When GLFW\_STICKY\_MOUSE\_BUTTONS is disabled, the status of a mouse
2983
+ button that is reported by \textbf{glfwGetMouseButton} is always the
2984
+ physical state of the mouse button. Disabling GLFW\_STICKY\_MOUSE\_BUTTONS
2985
+ also clears the sticky information for all mouse buttons.
2986
+ \end{mysamepage}
2987
+
2988
+
2989
+ \bigskip\begin{mysamepage}\hypertarget{lnk:systemkeys}{}
2990
+ \textbf{GLFW\_SYSTEM\_KEYS}\\
2991
+ When GLFW\_SYSTEM\_KEYS is enabled, pressing standard system key
2992
+ combinations, such as \texttt{ALT+TAB} under Windows, will give the normal
2993
+ behavior. Note that when \texttt{ALT+TAB} is issued under Windows in this
2994
+ mode so that the \GLFW\ application is deselected when \GLFW\ is operating
2995
+ in fullscreen mode, the \GLFW\ application window will be minimized and
2996
+ the video mode will be set to the original desktop mode. When the \GLFW\
2997
+ application is re-selected, the video mode will be set to the \GLFW\ video
2998
+ mode again.
2999
+
3000
+ When GLFW\_SYSTEM\_KEYS is disabled, pressing standard system key
3001
+ combinations will have no effect, since those key combinations are blocked
3002
+ by \GLFW . This mode can be useful in situations when the \GLFW\ program
3003
+ must not be interrupted (normally for games in fullscreen mode).
3004
+ \end{mysamepage}
3005
+
3006
+
3007
+ %-------------------------------------------------------------------------
3008
+ \subsection{glfwGetNumberOfProcessors}
3009
+
3010
+ \textbf{C language syntax}
3011
+ \begin{lstlisting}
3012
+ int glfwGetNumberOfProcessors( void )
3013
+ \end{lstlisting}
3014
+
3015
+ \begin{refparameters}
3016
+ none
3017
+ \end{refparameters}
3018
+
3019
+ \begin{refreturn}
3020
+ The function returns the number of active processors in the system.
3021
+ \end{refreturn}
3022
+
3023
+ \begin{refdescription}
3024
+ The function determines the number of active processors in the system.
3025
+ \end{refdescription}
3026
+
3027
+ \begin{refnotes}
3028
+ Systems with several logical processors per physical processor, also
3029
+ known as SMT (Symmetric Multi Threading) processors, will report the
3030
+ number of logical processors.
3031
+ \end{refnotes}
3032
+
3033
+
3034
+ \end{document}