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