window.dox 46 KB

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