window.dox 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. /*!
  2. @page window_guide Window guide
  3. @tableofcontents
  4. This guide introduces the window related functions of GLFW. For details on
  5. a specific function in this category, see the @ref window. There are also
  6. guides for the other areas of GLFW.
  7. - @ref intro_guide
  8. - @ref context_guide
  9. - @ref vulkan_guide
  10. - @ref monitor_guide
  11. - @ref input_guide
  12. @section window_object Window objects
  13. The @ref GLFWwindow object encapsulates both a window and a context. They are
  14. created with @ref glfwCreateWindow and destroyed with @ref glfwDestroyWindow, or
  15. @ref glfwTerminate, if any remain. As the window and context are inseparably
  16. linked, the object pointer is used as both a context and window handle.
  17. To see the event stream provided to the various window related callbacks, run
  18. the `events` test program.
  19. @subsection window_creation Window creation
  20. A window and its OpenGL or OpenGL ES context are created with @ref
  21. glfwCreateWindow, which returns a handle to the created window object. For
  22. example, this creates a 640 by 480 windowed mode window:
  23. @code
  24. GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
  25. @endcode
  26. If window creation fails, `NULL` will be returned, so it is necessary to check
  27. the return value.
  28. The window handle is passed to all window related functions and is provided to
  29. along with all input events, so event handlers can tell which window received
  30. the event.
  31. @subsubsection window_full_screen Full screen windows
  32. To create a full screen window, you need to specify which monitor the window
  33. should use. In most cases, the user's primary monitor is a good choice.
  34. For more information about retrieving monitors, see @ref monitor_monitors.
  35. @code
  36. GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL);
  37. @endcode
  38. Full screen windows cover the entire display area of a monitor, have no border
  39. or decorations.
  40. Windowed mode windows can be made full screen by setting a monitor with @ref
  41. glfwSetWindowMonitor, and full screen ones can be made windowed by unsetting it
  42. with the same function.
  43. Each field of the @ref GLFWvidmode structure corresponds to a function parameter
  44. or window hint and combine to form the _desired video mode_ for that window.
  45. The supported video mode most closely matching the desired video mode will be
  46. set for the chosen monitor as long as the window has input focus. For more
  47. information about retrieving video modes, see @ref monitor_modes.
  48. Video mode field | Corresponds to
  49. ----------------------- | ------------------------
  50. GLFWvidmode.width | `width` parameter
  51. GLFWvidmode.height | `height` parameter
  52. GLFWvidmode.redBits | @ref GLFW_RED_BITS hint
  53. GLFWvidmode.greenBits | @ref GLFW_GREEN_BITS hint
  54. GLFWvidmode.blueBits | @ref GLFW_BLUE_BITS hint
  55. GLFWvidmode.refreshRate | @ref GLFW_REFRESH_RATE hint
  56. Once you have a full screen window, you can change its resolution, refresh rate
  57. and monitor with @ref glfwSetWindowMonitor. If you just need change its
  58. resolution you can also call @ref glfwSetWindowSize. In all cases, the new
  59. video mode will be selected the same way as the video mode chosen by @ref
  60. glfwCreateWindow. If the window has an OpenGL or OpenGL ES context, it will be
  61. unaffected.
  62. By default, the original video mode of the monitor will be restored and the
  63. window iconified if it loses input focus, to allow the user to switch back to
  64. the desktop. This behavior can be disabled with the
  65. [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_hint) window hint, for example if you
  66. wish to simultaneously cover multiple windows with full screen windows.
  67. @subsubsection window_windowed_full_screen "Windowed full screen" windows
  68. If the closest match for the desired video mode is the current one, the video
  69. mode will not be changed, making window creation faster and application
  70. switching much smoother. This is sometimes called _windowed full screen_ or
  71. _borderless full screen_ window and counts as a full screen window. To create
  72. such a window, simply request the current video mode.
  73. @code
  74. const GLFWvidmode* mode = glfwGetVideoMode(monitor);
  75. glfwWindowHint(GLFW_RED_BITS, mode->redBits);
  76. glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
  77. glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
  78. glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
  79. GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "My Title", monitor, NULL);
  80. @endcode
  81. This also works for windowed mode windows that are made full screen.
  82. @code
  83. const GLFWvidmode* mode = glfwGetVideoMode(monitor);
  84. glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
  85. @endcode
  86. Note that @ref glfwGetVideoMode returns the _current_ video mode of a monitor,
  87. so if you already have a full screen window on that monitor that you want to
  88. make windowed full screen, you need to have saved the desktop resolution before.
  89. @subsection window_destruction Window destruction
  90. When a window is no longer needed, destroy it with @ref glfwDestroyWindow.
  91. @code
  92. glfwDestroyWindow(window);
  93. @endcode
  94. Window destruction always succeeds. Before the actual destruction, all
  95. callbacks are removed so no further events will be delivered for the window.
  96. All windows remaining when @ref glfwTerminate is called are destroyed as well.
  97. When a full screen window is destroyed, the original video mode of its monitor
  98. is restored, but the gamma ramp is left untouched.
  99. @subsection window_hints Window creation hints
  100. There are a number of hints that can be set before the creation of a window and
  101. context. Some affect the window itself, others affect the framebuffer or
  102. context. These hints are set to their default values each time the library is
  103. initialized with @ref glfwInit, can be set individually with @ref glfwWindowHint
  104. and reset all at once to their defaults with @ref glfwDefaultWindowHints.
  105. Some hints are platform specific. These are always valid to set on any
  106. platform but they will only affect their specific platform. Other platforms
  107. will simply ignore them. Setting these hints requires no platform specific
  108. headers or calls.
  109. Note that hints need to be set _before_ the creation of the window and context
  110. you wish to have the specified attributes.
  111. @subsubsection window_hints_hard Hard and soft constraints
  112. Some window hints are hard constraints. These must match the available
  113. capabilities _exactly_ for window and context creation to succeed. Hints
  114. that are not hard constraints are matched as closely as possible, but the
  115. resulting context and framebuffer may differ from what these hints requested.
  116. The following hints are always hard constraints:
  117. - @ref GLFW_STEREO
  118. - @ref GLFW_DOUBLEBUFFER
  119. - [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint)
  120. - [GLFW_CONTEXT_CREATION_API](@ref GLFW_CONTEXT_CREATION_API_hint)
  121. The following additional hints are hard constraints when requesting an OpenGL
  122. context, but are ignored when requesting an OpenGL ES context:
  123. - [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
  124. - [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
  125. @subsubsection window_hints_wnd Window related hints
  126. @anchor GLFW_RESIZABLE_hint
  127. __GLFW_RESIZABLE__ specifies whether the windowed mode window will be resizable
  128. _by the user_. The window will still be resizable using the @ref
  129. glfwSetWindowSize function. This hint is ignored for full screen and
  130. undecorated windows.
  131. @anchor GLFW_VISIBLE_hint
  132. __GLFW_VISIBLE__ specifies whether the windowed mode window will be initially
  133. visible. This hint is ignored for full screen windows.
  134. @anchor GLFW_DECORATED_hint
  135. __GLFW_DECORATED__ specifies whether the windowed mode window will have window
  136. decorations such as a border, a close widget, etc. An undecorated window will
  137. not be resizable by the user but will still allow the user to generate close
  138. events on some platforms. This hint is ignored for full screen windows.
  139. @anchor GLFW_FOCUSED_hint
  140. __GLFW_FOCUSED__ specifies whether the windowed mode window will be given input
  141. focus when created. This hint is ignored for full screen and initially hidden
  142. windows.
  143. @anchor GLFW_AUTO_ICONIFY_hint
  144. __GLFW_AUTO_ICONIFY__ specifies whether the full screen window will
  145. automatically iconify and restore the previous video mode on input focus loss.
  146. This hint is ignored for windowed mode windows.
  147. @anchor GLFW_FLOATING_hint
  148. __GLFW_FLOATING__ specifies whether the windowed mode window will be floating
  149. above other regular windows, also called topmost or always-on-top. This is
  150. intended primarily for debugging purposes and cannot be used to implement proper
  151. full screen windows. This hint is ignored for full screen windows.
  152. @anchor GLFW_MAXIMIZED_hint
  153. __GLFW_MAXIMIZED__ specifies whether the windowed mode window will be maximized
  154. when created. This hint is ignored for full screen windows.
  155. @subsubsection window_hints_fb Framebuffer related hints
  156. @anchor GLFW_RED_BITS
  157. @anchor GLFW_GREEN_BITS
  158. @anchor GLFW_BLUE_BITS
  159. @anchor GLFW_ALPHA_BITS
  160. @anchor GLFW_DEPTH_BITS
  161. @anchor GLFW_STENCIL_BITS
  162. __GLFW_RED_BITS__, __GLFW_GREEN_BITS__, __GLFW_BLUE_BITS__, __GLFW_ALPHA_BITS__,
  163. __GLFW_DEPTH_BITS__ and __GLFW_STENCIL_BITS__ specify the desired bit depths of
  164. the various components of the default framebuffer. A value of `GLFW_DONT_CARE`
  165. means the application has no preference.
  166. @anchor GLFW_ACCUM_RED_BITS
  167. @anchor GLFW_ACCUM_GREEN_BITS
  168. @anchor GLFW_ACCUM_BLUE_BITS
  169. @anchor GLFW_ACCUM_ALPHA_BITS
  170. __GLFW_ACCUM_RED_BITS__, __GLFW_ACCUM_GREEN_BITS__, __GLFW_ACCUM_BLUE_BITS__ and
  171. __GLFW_ACCUM_ALPHA_BITS__ specify the desired bit depths of the various
  172. components of the accumulation buffer. A value of `GLFW_DONT_CARE` means the
  173. application has no preference.
  174. @par
  175. Accumulation buffers are a legacy OpenGL feature and should not be used in new
  176. code.
  177. @anchor GLFW_AUX_BUFFERS
  178. __GLFW_AUX_BUFFERS__ specifies the desired number of auxiliary buffers. A value
  179. of `GLFW_DONT_CARE` means the application has no preference.
  180. @par
  181. Auxiliary buffers are a legacy OpenGL feature and should not be used in new
  182. code.
  183. @anchor GLFW_STEREO
  184. __GLFW_STEREO__ specifies whether to use OpenGL stereoscopic rendering. This is
  185. a hard constraint.
  186. @anchor GLFW_SAMPLES
  187. __GLFW_SAMPLES__ specifies the desired number of samples to use for
  188. multisampling. Zero disables multisampling. A value of `GLFW_DONT_CARE` means
  189. the application has no preference.
  190. @anchor GLFW_SRGB_CAPABLE
  191. __GLFW_SRGB_CAPABLE__ specifies whether the framebuffer should be sRGB capable.
  192. If supported, a created OpenGL context will support the `GL_FRAMEBUFFER_SRGB`
  193. enable, also called `GL_FRAMEBUFFER_SRGB_EXT`) for controlling sRGB rendering
  194. and a created OpenGL ES context will always have sRGB rendering enabled.
  195. @anchor GLFW_DOUBLEBUFFER
  196. __GLFW_DOUBLEBUFFER__ specifies whether the framebuffer should be double
  197. buffered. You nearly always want to use double buffering. This is a hard
  198. constraint.
  199. @subsubsection window_hints_mtr Monitor related hints
  200. @anchor GLFW_REFRESH_RATE
  201. __GLFW_REFRESH_RATE__ specifies the desired refresh rate for full screen
  202. windows. A value of `GLFW_DONT_CARE` means the highest available refresh rate
  203. will be used. This hint is ignored for windowed mode windows.
  204. @subsubsection window_hints_ctx Context related hints
  205. @anchor GLFW_CLIENT_API_hint
  206. __GLFW_CLIENT_API__ specifies which client API to create the context for.
  207. Possible values are `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` and `GLFW_NO_API`.
  208. This is a hard constraint.
  209. @anchor GLFW_CONTEXT_CREATION_API_hint
  210. __GLFW_CONTEXT_CREATION_API__ specifies which context creation API to use to
  211. create the context. Possible values are `GLFW_NATIVE_CONTEXT_API` and
  212. `GLFW_EGL_CONTEXT_API`. This is a hard constraint. If no client API is
  213. requested, this hint is ignored.
  214. @par
  215. @macos The EGL API is not available on this platform and requests to use it
  216. will fail.
  217. @par
  218. __Wayland, Mir:__ The EGL API _is_ the native context creation API, so this hint
  219. will have no effect.
  220. @note An OpenGL extension loader library that assumes it knows which context
  221. creation API is used on a given platform may fail if you change this hint. This
  222. can be resolved by having it load via @ref glfwGetProcAddress, which always uses
  223. the selected API.
  224. @bug On some Linux systems, creating contexts via both the native and EGL APIs
  225. in a single process will cause the application to segfault. Stick to one API or
  226. the other on Linux for now.
  227. @anchor GLFW_CONTEXT_VERSION_MAJOR_hint
  228. @anchor GLFW_CONTEXT_VERSION_MINOR_hint
  229. __GLFW_CONTEXT_VERSION_MAJOR__ and __GLFW_CONTEXT_VERSION_MINOR__ specify the
  230. client API version that the created context must be compatible with. The exact
  231. behavior of these hints depend on the requested client API.
  232. @par
  233. __OpenGL:__ These hints are not hard constraints, but creation will fail if the
  234. OpenGL version of the created context is less than the one requested. It is
  235. therefore perfectly safe to use the default of version 1.0 for legacy code and
  236. you will still get backwards-compatible contexts of version 3.0 and above when
  237. available.
  238. @par
  239. While there is no way to ask the driver for a context of the highest supported
  240. version, GLFW will attempt to provide this when you ask for a version 1.0
  241. context, which is the default for these hints.
  242. @par
  243. __OpenGL ES:__ These hints are not hard constraints, but creation will fail if
  244. the OpenGL ES version of the created context is less than the one requested.
  245. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested,
  246. and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0,
  247. but OpenGL ES 2.0 is not backward compatible with 1.x.
  248. @note @macos The OS only supports forward-compatible core profile contexts for
  249. OpenGL versions 3.2 and later. Before creating an OpenGL context of version
  250. 3.2 or later you must set the
  251. [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and
  252. [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly. OpenGL
  253. 3.0 and 3.1 contexts are not supported at all on macOS.
  254. @anchor GLFW_OPENGL_FORWARD_COMPAT_hint
  255. __GLFW_OPENGL_FORWARD_COMPAT__ specifies whether the OpenGL context should be
  256. forward-compatible, i.e. one where all functionality deprecated in the requested
  257. version of OpenGL is removed. This must only be used if the requested OpenGL
  258. version is 3.0 or above. If OpenGL ES is requested, this hint is ignored.
  259. @par
  260. Forward-compatibility is described in detail in the
  261. [OpenGL Reference Manual](https://www.opengl.org/registry/).
  262. @anchor GLFW_OPENGL_DEBUG_CONTEXT_hint
  263. __GLFW_OPENGL_DEBUG_CONTEXT__ specifies whether to create a debug OpenGL
  264. context, which may have additional error and performance issue reporting
  265. functionality. If OpenGL ES is requested, this hint is ignored.
  266. @anchor GLFW_OPENGL_PROFILE_hint
  267. __GLFW_OPENGL_PROFILE__ specifies which OpenGL profile to create the context
  268. for. Possible values are one of `GLFW_OPENGL_CORE_PROFILE` or
  269. `GLFW_OPENGL_COMPAT_PROFILE`, or `GLFW_OPENGL_ANY_PROFILE` to not request
  270. a specific profile. If requesting an OpenGL version below 3.2,
  271. `GLFW_OPENGL_ANY_PROFILE` must be used. If OpenGL ES is requested, this hint
  272. is ignored.
  273. @par
  274. OpenGL profiles are described in detail in the
  275. [OpenGL Reference Manual](https://www.opengl.org/registry/).
  276. @anchor GLFW_CONTEXT_ROBUSTNESS_hint
  277. __GLFW_CONTEXT_ROBUSTNESS__ specifies the robustness strategy to be used by the
  278. context. This can be one of `GLFW_NO_RESET_NOTIFICATION` or
  279. `GLFW_LOSE_CONTEXT_ON_RESET`, or `GLFW_NO_ROBUSTNESS` to not request
  280. a robustness strategy.
  281. @anchor GLFW_CONTEXT_RELEASE_BEHAVIOR_hint
  282. __GLFW_CONTEXT_RELEASE_BEHAVIOR__ specifies the release behavior to be
  283. used by the context. Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`,
  284. `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the
  285. behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context
  286. creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`,
  287. the pipeline will be flushed whenever the context is released from being the
  288. current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
  289. not be flushed on release.
  290. @par
  291. Context release behaviors are described in detail by the
  292. [GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)
  293. extension.
  294. @anchor GLFW_CONTEXT_NO_ERROR_hint
  295. __GLFW_CONTEXT_NO_ERROR__ specifies whether errors should be generated by the
  296. context. If enabled, situations that would have generated errors instead cause
  297. undefined behavior.
  298. @par
  299. The no error mode for OpenGL and OpenGL ES is described in detail by the
  300. [GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt)
  301. extension.
  302. @note This hint is experimental in its current state. There are currently
  303. (October 2015) no corresponding WGL or GLX extensions. That makes this hint
  304. a [hard constraint](@ref window_hints_hard) for those backends, as creation will
  305. fail if unsupported context flags are requested. Once the extensions are
  306. available, they will be required and creation of `GL_KHR_no_error` contexts may
  307. fail on early drivers where this flag is supported without those extensions
  308. being listed.
  309. @subsubsection window_hints_osx macOS specific hints
  310. @anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint
  311. __GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution
  312. framebuffers on Retina displays. This is ignored on other platforms.
  313. @subsubsection window_hints_values Supported and default values
  314. Window hint | Default value | Supported values
  315. ----------------------------- | --------------------------- | ----------------
  316. GLFW_RESIZABLE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
  317. GLFW_VISIBLE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
  318. GLFW_DECORATED | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
  319. GLFW_FOCUSED | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
  320. GLFW_AUTO_ICONIFY | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
  321. GLFW_FLOATING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
  322. GLFW_MAXIMIZED | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
  323. GLFW_RED_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  324. GLFW_GREEN_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  325. GLFW_BLUE_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  326. GLFW_ALPHA_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  327. GLFW_DEPTH_BITS | 24 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  328. GLFW_STENCIL_BITS | 8 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  329. GLFW_ACCUM_RED_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  330. GLFW_ACCUM_GREEN_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  331. GLFW_ACCUM_BLUE_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  332. GLFW_ACCUM_ALPHA_BITS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  333. GLFW_AUX_BUFFERS | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  334. GLFW_SAMPLES | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  335. GLFW_REFRESH_RATE | `GLFW_DONT_CARE` | 0 to `INT_MAX` or `GLFW_DONT_CARE`
  336. GLFW_STEREO | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
  337. GLFW_SRGB_CAPABLE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
  338. GLFW_DOUBLEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
  339. GLFW_CLIENT_API | `GLFW_OPENGL_API` | `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` or `GLFW_NO_API`
  340. GLFW_CONTEXT_CREATION_API | `GLFW_NATIVE_CONTEXT_API` | `GLFW_NATIVE_CONTEXT_API` or `GLFW_EGL_CONTEXT_API`
  341. GLFW_CONTEXT_VERSION_MAJOR | 1 | Any valid major version number of the chosen client API
  342. GLFW_CONTEXT_VERSION_MINOR | 0 | Any valid minor version number of the chosen client API
  343. GLFW_CONTEXT_ROBUSTNESS | `GLFW_NO_ROBUSTNESS` | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET`
  344. GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`
  345. GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
  346. GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
  347. GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
  348. GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
  349. @section window_events Window event processing
  350. See @ref events.
  351. @section window_properties Window properties and events
  352. @subsection window_userptr User pointer
  353. Each window has a user pointer that can be set with @ref
  354. glfwSetWindowUserPointer and fetched with @ref glfwGetWindowUserPointer. This
  355. can be used for any purpose you need and will not be modified by GLFW throughout
  356. the life-time of the window.
  357. The initial value of the pointer is `NULL`.
  358. @subsection window_close Window closing and close flag
  359. When the user attempts to close the window, for example by clicking the close
  360. widget or using a key chord like Alt+F4, the _close flag_ of the window is set.
  361. The window is however not actually destroyed and, unless you watch for this
  362. state change, nothing further happens.
  363. The current state of the close flag is returned by @ref glfwWindowShouldClose
  364. and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common
  365. pattern is to use the close flag as a main loop condition.
  366. @code
  367. while (!glfwWindowShouldClose(window))
  368. {
  369. render(window);
  370. glfwSwapBuffers(window);
  371. glfwPollEvents();
  372. }
  373. @endcode
  374. If you wish to be notified when the user attempts to close a window, set a close
  375. callback.
  376. @code
  377. glfwSetWindowCloseCallback(window, window_close_callback);
  378. @endcode
  379. The callback function is called directly _after_ the close flag has been set.
  380. It can be used for example to filter close requests and clear the close flag
  381. again unless certain conditions are met.
  382. @code
  383. void window_close_callback(GLFWwindow* window)
  384. {
  385. if (!time_to_close)
  386. glfwSetWindowShouldClose(window, GLFW_FALSE);
  387. }
  388. @endcode
  389. @subsection window_size Window size
  390. The size of a window can be changed with @ref glfwSetWindowSize. For windowed
  391. mode windows, this sets the size, in
  392. [screen coordinates](@ref coordinate_systems) of the _client area_ or _content
  393. area_ of the window. The window system may impose limits on window size.
  394. @code
  395. glfwSetWindowSize(window, 640, 480);
  396. @endcode
  397. For full screen windows, the specified size becomes the new resolution of the
  398. window's desired video mode. The video mode most closely matching the new
  399. desired video mode is set immediately. The window is resized to fit the
  400. resolution of the set video mode.
  401. If you wish to be notified when a window is resized, whether by the user or
  402. the system, set a size callback.
  403. @code
  404. glfwSetWindowSizeCallback(window, window_size_callback);
  405. @endcode
  406. The callback function receives the new size, in screen coordinates, of the
  407. client area of the window when it is resized.
  408. @code
  409. void window_size_callback(GLFWwindow* window, int width, int height)
  410. {
  411. }
  412. @endcode
  413. There is also @ref glfwGetWindowSize for directly retrieving the current size of
  414. a window.
  415. @code
  416. int width, height;
  417. glfwGetWindowSize(window, &width, &height);
  418. @endcode
  419. @note Do not pass the window size to `glViewport` or other pixel-based OpenGL
  420. calls. The window size is in screen coordinates, not pixels. Use the
  421. [framebuffer size](@ref window_fbsize), which is in pixels, for pixel-based
  422. calls.
  423. The above functions work with the size of the client area, but decorated windows
  424. typically have title bars and window frames around this rectangle. You can
  425. retrieve the extents of these with @ref glfwGetWindowFrameSize.
  426. @code
  427. int left, top, right, bottom;
  428. glfwGetWindowFrameSize(window, &left, &top, &right, &bottom);
  429. @endcode
  430. The returned values are the distances, in screen coordinates, from the edges of
  431. the client area to the corresponding edges of the full window. As they are
  432. distances and not coordinates, they are always zero or positive.
  433. @subsection window_fbsize Framebuffer size
  434. While the size of a window is measured in screen coordinates, OpenGL works with
  435. pixels. The size you pass into `glViewport`, for example, should be in pixels.
  436. On some machines screen coordinates and pixels are the same, but on others they
  437. will not be. There is a second set of functions to retrieve the size, in
  438. pixels, of the framebuffer of a window.
  439. If you wish to be notified when the framebuffer of a window is resized, whether
  440. by the user or the system, set a size callback.
  441. @code
  442. glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
  443. @endcode
  444. The callback function receives the new size of the framebuffer when it is
  445. resized, which can for example be used to update the OpenGL viewport.
  446. @code
  447. void framebuffer_size_callback(GLFWwindow* window, int width, int height)
  448. {
  449. glViewport(0, 0, width, height);
  450. }
  451. @endcode
  452. There is also @ref glfwGetFramebufferSize for directly retrieving the current
  453. size of the framebuffer of a window.
  454. @code
  455. int width, height;
  456. glfwGetFramebufferSize(window, &width, &height);
  457. glViewport(0, 0, width, height);
  458. @endcode
  459. The size of a framebuffer may change independently of the size of a window, for
  460. example if the window is dragged between a regular monitor and a high-DPI one.
  461. @subsection window_sizelimits Window size limits
  462. The minimum and maximum size of the client area of a windowed mode window can be
  463. enforced with @ref glfwSetWindowSizeLimits. The user may resize the window to
  464. any size and aspect ratio within the specified limits, unless the aspect ratio
  465. is also set.
  466. @code
  467. glfwSetWindowSizeLimits(window, 200, 200, 400, 400);
  468. @endcode
  469. To specify only a minimum size or only a maximum one, set the other pair to
  470. `GLFW_DONT_CARE`.
  471. @code
  472. glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE);
  473. @endcode
  474. To disable size limits for a window, set them all to `GLFW_DONT_CARE`.
  475. The aspect ratio of the client area of a windowed mode window can be enforced
  476. with @ref glfwSetWindowAspectRatio. The user may resize the window freely
  477. unless size limits are also set, but the size will be constrained to maintain
  478. the aspect ratio.
  479. @code
  480. glfwSetWindowAspectRatio(window, 16, 9);
  481. @endcode
  482. The aspect ratio is specified as a numerator and denominator, corresponding to
  483. the width and height, respectively. If you want a window to maintain its
  484. current aspect ratio, simply use its current size as the ratio.
  485. @code
  486. int width, height;
  487. glfwGetWindowSize(window, &width, &height);
  488. glfwSetWindowAspectRatio(window, width, height);
  489. @endcode
  490. To disable the aspect ratio limit for a window, set both terms to
  491. `GLFW_DONT_CARE`.
  492. You can have both size limits and aspect ratio set for a window, but the results
  493. are undefined if they conflict.
  494. @subsection window_pos Window position
  495. The position of a windowed-mode window can be changed with @ref
  496. glfwSetWindowPos. This moves the window so that the upper-left corner of its
  497. client area has the specified [screen coordinates](@ref coordinate_systems).
  498. The window system may put limitations on window placement.
  499. @code
  500. glfwSetWindowPos(window, 100, 100);
  501. @endcode
  502. If you wish to be notified when a window is moved, whether by the user, system
  503. or your own code, set a position callback.
  504. @code
  505. glfwSetWindowPosCallback(window, window_pos_callback);
  506. @endcode
  507. The callback function receives the new position of the upper-left corner of the
  508. client area when the window is moved.
  509. @code
  510. void window_pos_callback(GLFWwindow* window, int xpos, int ypos)
  511. {
  512. }
  513. @endcode
  514. There is also @ref glfwGetWindowPos for directly retrieving the current position
  515. of the client area of the window.
  516. @code
  517. int xpos, ypos;
  518. glfwGetWindowPos(window, &xpos, &ypos);
  519. @endcode
  520. @subsection window_title Window title
  521. All GLFW windows have a title, although undecorated or full screen windows may
  522. not display it or only display it in a task bar or similar interface. You can
  523. set a UTF-8 encoded window title with @ref glfwSetWindowTitle.
  524. @code
  525. glfwSetWindowTitle(window, "My Window");
  526. @endcode
  527. The specified string is copied before the function returns, so there is no need
  528. to keep it around.
  529. As long as your source file is encoded as UTF-8, you can use any Unicode
  530. characters directly in the source.
  531. @code
  532. glfwSetWindowTitle(window, "ラストエグザイル");
  533. @endcode
  534. If you are using C++11 or C11, you can use a UTF-8 string literal.
  535. @code
  536. glfwSetWindowTitle(window, u8"This is always a UTF-8 string");
  537. @endcode
  538. @subsection window_icon Window icon
  539. Decorated windows have icons on some platforms. You can set this icon by
  540. specifying a list of candidate images with @ref glfwSetWindowIcon.
  541. @code
  542. GLFWimage images[2];
  543. images[0] = load_icon("my_icon.png");
  544. images[1] = load_icon("my_icon_small.png");
  545. glfwSetWindowIcon(window, 2, images);
  546. @endcode
  547. To revert to the default window icon, pass in an empty image array.
  548. @code
  549. glfwSetWindowIcon(window, 0, NULL);
  550. @endcode
  551. @subsection window_monitor Window monitor
  552. Full screen windows are associated with a specific monitor. You can get the
  553. handle for this monitor with @ref glfwGetWindowMonitor.
  554. @code
  555. GLFWmonitor* monitor = glfwGetWindowMonitor(window);
  556. @endcode
  557. This monitor handle is one of those returned by @ref glfwGetMonitors.
  558. For windowed mode windows, this function returns `NULL`. This is how to tell
  559. full screen windows from windowed mode windows.
  560. You can move windows between monitors or between full screen and windowed mode
  561. with @ref glfwSetWindowMonitor. When making a window full screen on the same or
  562. on a different monitor, specify the desired monitor, resolution and refresh
  563. rate. The position arguments are ignored.
  564. @code
  565. const GLFWvidmode* mode = glfwGetVideoMode(monitor);
  566. glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
  567. @endcode
  568. When making the window windowed, specify the desired position and size. The
  569. refresh rate argument is ignored.
  570. @code
  571. glfwSetWindowMonitor(window, NULL, xpos, ypos, width, height, 0);
  572. @endcode
  573. This restores any previous window settings such as whether it is decorated,
  574. floating, resizable, has size or aspect ratio limits, etc.. To restore a window
  575. that was originally windowed to its original size and position, save these
  576. before making it full screen and then pass them in as above.
  577. @subsection window_iconify Window iconification
  578. Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow.
  579. @code
  580. glfwIconifyWindow(window);
  581. @endcode
  582. When a full screen window is iconified, the original video mode of its monitor
  583. is restored until the user or application restores the window.
  584. Iconified windows can be restored with @ref glfwRestoreWindow. This function
  585. also restores windows from maximization.
  586. @code
  587. glfwRestoreWindow(window);
  588. @endcode
  589. When a full screen window is restored, the desired video mode is restored to its
  590. monitor as well.
  591. If you wish to be notified when a window is iconified or restored, whether by
  592. the user, system or your own code, set a iconify callback.
  593. @code
  594. glfwSetWindowIconifyCallback(window, window_iconify_callback);
  595. @endcode
  596. The callback function receives changes in the iconification state of the window.
  597. @code
  598. void window_iconify_callback(GLFWwindow* window, int iconified)
  599. {
  600. if (iconified)
  601. {
  602. // The window was iconified
  603. }
  604. else
  605. {
  606. // The window was restored
  607. }
  608. }
  609. @endcode
  610. You can also get the current iconification state with @ref glfwGetWindowAttrib.
  611. @code
  612. int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);
  613. @endcode
  614. @subsection window_maximize Window maximization
  615. Windows can be maximized (i.e. zoomed) with @ref glfwMaximizeWindow.
  616. @code
  617. glfwMaximizeWindow(window);
  618. @endcode
  619. Full screen windows cannot be maximized and passing a full screen window to this
  620. function does nothing.
  621. Maximized windows can be restored with @ref glfwRestoreWindow. This function
  622. also restores windows from iconification.
  623. @code
  624. glfwRestoreWindow(window);
  625. @endcode
  626. If you wish to be notified when a window is maximized or restored, whether by
  627. the user, system or your own code, set a maximize callback.
  628. @code
  629. glfwSetWindowMaximizeCallback(window, window_maximize_callback);
  630. @endcode
  631. The callback function receives changes in the maximization state of the window.
  632. @code
  633. void window_maximize_callback(GLFWwindow* window, int maximized)
  634. {
  635. if (maximized)
  636. {
  637. // The window was maximized
  638. }
  639. else
  640. {
  641. // The window was restored
  642. }
  643. }
  644. @endcode
  645. You can also get the current maximization state with @ref glfwGetWindowAttrib.
  646. @code
  647. int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED);
  648. @endcode
  649. By default, newly created windows are not maximized. You can change this
  650. behavior by setting the [GLFW_MAXIMIZED](@ref GLFW_MAXIMIZED_hint) window hint
  651. before creating the window.
  652. @code
  653. glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
  654. @endcode
  655. @subsection window_hide Window visibility
  656. Windowed mode windows can be hidden with @ref glfwHideWindow.
  657. @code
  658. glfwHideWindow(window);
  659. @endcode
  660. This makes the window completely invisible to the user, including removing it
  661. from the task bar, dock or window list. Full screen windows cannot be hidden
  662. and calling @ref glfwHideWindow on a full screen window does nothing.
  663. Hidden windows can be shown with @ref glfwShowWindow.
  664. @code
  665. glfwShowWindow(window);
  666. @endcode
  667. You can also get the current visibility state with @ref glfwGetWindowAttrib.
  668. @code
  669. int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE);
  670. @endcode
  671. By default, newly created windows are visible. You can change this behavior by
  672. setting the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint before creating
  673. the window.
  674. @code
  675. glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
  676. @endcode
  677. Windows created hidden are completely invisible to the user until shown. This
  678. can be useful if you need to set up your window further before showing it, for
  679. example moving it to a specific location.
  680. @subsection window_focus Window input focus
  681. Windows can be given input focus and brought to the front with @ref
  682. glfwFocusWindow.
  683. @code
  684. glfwFocusWindow(window);
  685. @endcode
  686. If you wish to be notified when a window gains or loses input focus, whether by
  687. the user, system or your own code, set a focus callback.
  688. @code
  689. glfwSetWindowFocusCallback(window, window_focus_callback);
  690. @endcode
  691. The callback function receives changes in the input focus state of the window.
  692. @code
  693. void window_focus_callback(GLFWwindow* window, int focused)
  694. {
  695. if (focused)
  696. {
  697. // The window gained input focus
  698. }
  699. else
  700. {
  701. // The window lost input focus
  702. }
  703. }
  704. @endcode
  705. You can also get the current input focus state with @ref glfwGetWindowAttrib.
  706. @code
  707. int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED);
  708. @endcode
  709. By default, newly created windows are given input focus. You can change this
  710. behavior by setting the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint
  711. before creating the window.
  712. @code
  713. glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
  714. @endcode
  715. @subsection window_refresh Window damage and refresh
  716. If you wish to be notified when the contents of a window is damaged and needs
  717. to be refreshed, set a window refresh callback.
  718. @code
  719. glfwSetWindowRefreshCallback(m_handle, window_refresh_callback);
  720. @endcode
  721. The callback function is called when the contents of the window needs to be
  722. refreshed.
  723. @code
  724. void window_refresh_callback(GLFWwindow* window)
  725. {
  726. draw_editor_ui(window);
  727. glfwSwapBuffers(window);
  728. }
  729. @endcode
  730. @note On compositing window systems such as Aero, Compiz or Aqua, where the
  731. window contents are saved off-screen, this callback might only be called when
  732. the window or framebuffer is resized.
  733. @subsection window_attribs Window attributes
  734. Windows have a number of attributes that can be returned using @ref
  735. glfwGetWindowAttrib. Some reflect state that may change as a result of user
  736. interaction, (e.g. whether it has input focus), while others reflect inherent
  737. properties of the window (e.g. what kind of border it has). Some are related to
  738. the window and others to its OpenGL or OpenGL ES context.
  739. @code
  740. if (glfwGetWindowAttrib(window, GLFW_FOCUSED))
  741. {
  742. // window has input focus
  743. }
  744. @endcode
  745. The [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
  746. [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
  747. [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) and
  748. [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) window attributes can be
  749. changed with @ref glfwSetWindowAttrib.
  750. @code
  751. glfwSetWindowAttrib(window, GLFW_RESIZABLE, GLFW_FALSE);
  752. @endcode
  753. @subsubsection window_attribs_wnd Window related attributes
  754. @anchor GLFW_FOCUSED_attrib
  755. __GLFW_FOCUSED__ indicates whether the specified window has input focus. See
  756. @ref window_focus for details.
  757. @anchor GLFW_ICONIFIED_attrib
  758. __GLFW_ICONIFIED__ indicates whether the specified window is iconified.
  759. See @ref window_iconify for details.
  760. @anchor GLFW_MAXIMIZED_attrib
  761. __GLFW_MAXIMIZED__ indicates whether the specified window is maximized. See
  762. @ref window_maximize for details.
  763. @anchor GLFW_VISIBLE_attrib
  764. __GLFW_VISIBLE__ indicates whether the specified window is visible. See @ref
  765. window_hide for details.
  766. @anchor GLFW_RESIZABLE_attrib
  767. __GLFW_RESIZABLE__ indicates whether the specified window is resizable _by the
  768. user_. This can be set before creation with the
  769. [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_hint) window hint or after with @ref
  770. glfwSetWindowAttrib.
  771. @anchor GLFW_DECORATED_attrib
  772. __GLFW_DECORATED__ indicates whether the specified window has decorations such
  773. as a border, a close widget, etc. This can be set before creation with the
  774. [GLFW_DECORATED](@ref GLFW_DECORATED_hint) window hint or after with @ref
  775. glfwSetWindowAttrib.
  776. @anchor GLFW_AUTO_ICONIFY_attrib
  777. __GLFW_AUTO_ICONIFY__ indicates whether the specified full screen window is
  778. iconified on focus loss, a close widget, etc. This can be set before creation
  779. with the [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_hint) window hint or after
  780. with @ref glfwSetWindowAttrib.
  781. @anchor GLFW_FLOATING_attrib
  782. __GLFW_FLOATING__ indicates whether the specified window is floating, also
  783. called topmost or always-on-top. This can be set before creation with the
  784. [GLFW_FLOATING](@ref GLFW_FLOATING_hint) window hint or after with @ref
  785. glfwSetWindowAttrib.
  786. @subsubsection window_attribs_ctx Context related attributes
  787. @anchor GLFW_CLIENT_API_attrib
  788. __GLFW_CLIENT_API__ indicates the client API provided by the window's context;
  789. either `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API` or `GLFW_NO_API`.
  790. @anchor GLFW_CONTEXT_CREATION_API_attrib
  791. __GLFW_CONTEXT_CREATION_API__ indicates the context creation API used to create
  792. the window's context; either `GLFW_NATIVE_CONTEXT_API` or
  793. `GLFW_EGL_CONTEXT_API`.
  794. @anchor GLFW_CONTEXT_VERSION_MAJOR_attrib
  795. @anchor GLFW_CONTEXT_VERSION_MINOR_attrib
  796. @anchor GLFW_CONTEXT_REVISION_attrib
  797. __GLFW_CONTEXT_VERSION_MAJOR__, __GLFW_CONTEXT_VERSION_MINOR__ and
  798. __GLFW_CONTEXT_REVISION__ indicate the client API version of the window's
  799. context.
  800. @anchor GLFW_OPENGL_FORWARD_COMPAT_attrib
  801. __GLFW_OPENGL_FORWARD_COMPAT__ is `GLFW_TRUE` if the window's context is an
  802. OpenGL forward-compatible one, or `GLFW_FALSE` otherwise.
  803. @anchor GLFW_OPENGL_DEBUG_CONTEXT_attrib
  804. __GLFW_OPENGL_DEBUG_CONTEXT__ is `GLFW_TRUE` if the window's context is an
  805. OpenGL debug context, or `GLFW_FALSE` otherwise.
  806. @anchor GLFW_OPENGL_PROFILE_attrib
  807. __GLFW_OPENGL_PROFILE__ indicates the OpenGL profile used by the context. This
  808. is `GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE` if the context
  809. uses a known profile, or `GLFW_OPENGL_ANY_PROFILE` if the OpenGL profile is
  810. unknown or the context is an OpenGL ES context. Note that the returned profile
  811. may not match the profile bits of the context flags, as GLFW will try other
  812. means of detecting the profile when no bits are set.
  813. @anchor GLFW_CONTEXT_ROBUSTNESS_attrib
  814. __GLFW_CONTEXT_ROBUSTNESS__ indicates the robustness strategy used by the
  815. context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION`
  816. if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.
  817. @subsubsection window_attribs_fb Framebuffer related attributes
  818. GLFW does not expose attributes of the default framebuffer (i.e. the framebuffer
  819. attached to the window) as these can be queried directly with either OpenGL,
  820. OpenGL ES or Vulkan.
  821. If you are using version 3.0 or later of OpenGL or OpenGL ES, the
  822. `glGetFramebufferAttachmentParameteriv` function can be used to retrieve the
  823. number of bits for the red, green, blue, alpha, depth and stencil buffer
  824. channels. Otherwise, the `glGetIntegerv` function can be used.
  825. The number of MSAA samples are always retrieved with `glGetIntegerv`. For
  826. contexts supporting framebuffer objects, the number of samples of the currently
  827. bound framebuffer is returned.
  828. Attribute | glGetIntegerv | glGetFramebufferAttachmentParameteriv
  829. ------------ | ----------------- | -------------------------------------
  830. Red bits | `GL_RED_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE`
  831. Green bits | `GL_GREEN_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE`
  832. Blue bits | `GL_BLUE_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE`
  833. Alpha bits | `GL_ALPHA_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE`
  834. Depth bits | `GL_DEPTH_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE`
  835. Stencil bits | `GL_STENCIL_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE`
  836. MSAA samples | `GL_SAMPLES` | _Not provided by this function_
  837. When calling `glGetFramebufferAttachmentParameteriv`, the red, green, blue and
  838. alpha sizes are queried from the `GL_BACK_LEFT`, while the depth and stencil
  839. sizes are queried from the `GL_DEPTH` and `GL_STENCIL` attachments,
  840. respectively.
  841. @section buffer_swap Buffer swapping
  842. GLFW windows are by default double buffered. That means that you have two
  843. rendering buffers; a front buffer and a back buffer. The front buffer is
  844. the one being displayed and the back buffer the one you render to.
  845. When the entire frame has been rendered, it is time to swap the back and the
  846. front buffers in order to display what has been rendered and begin rendering
  847. a new frame. This is done with @ref glfwSwapBuffers.
  848. @code
  849. glfwSwapBuffers(window);
  850. @endcode
  851. Sometimes it can be useful to select when the buffer swap will occur. With the
  852. function @ref glfwSwapInterval it is possible to select the minimum number of
  853. monitor refreshes the driver wait should from the time @ref glfwSwapBuffers was
  854. called before swapping the buffers:
  855. @code
  856. glfwSwapInterval(1);
  857. @endcode
  858. If the interval is zero, the swap will take place immediately when @ref
  859. glfwSwapBuffers is called without waiting for a refresh. Otherwise at least
  860. interval retraces will pass between each buffer swap. Using a swap interval of
  861. zero can be useful for benchmarking purposes, when it is not desirable to
  862. measure the time it takes to wait for the vertical retrace. However, a swap
  863. interval of one lets you avoid tearing.
  864. Note that this may not work on all machines, as some drivers have
  865. user-controlled settings that override any swap interval the application
  866. requests.
  867. */