glfw3.h 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281
  1. /*************************************************************************
  2. * GLFW 3.0 - www.glfw.org
  3. * A library for OpenGL, window and input
  4. *------------------------------------------------------------------------
  5. * Copyright (c) 2002-2006 Marcus Geelnard
  6. * Copyright (c) 2006-2010 Camilla Berglund <[email protected]>
  7. *
  8. * This software is provided 'as-is', without any express or implied
  9. * warranty. In no event will the authors be held liable for any damages
  10. * arising from the use of this software.
  11. *
  12. * Permission is granted to anyone to use this software for any purpose,
  13. * including commercial applications, and to alter it and redistribute it
  14. * freely, subject to the following restrictions:
  15. *
  16. * 1. The origin of this software must not be misrepresented; you must not
  17. * claim that you wrote the original software. If you use this software
  18. * in a product, an acknowledgment in the product documentation would
  19. * be appreciated but is not required.
  20. *
  21. * 2. Altered source versions must be plainly marked as such, and must not
  22. * be misrepresented as being the original software.
  23. *
  24. * 3. This notice may not be removed or altered from any source
  25. * distribution.
  26. *
  27. *************************************************************************/
  28. #ifndef _glfw3_h_
  29. #define _glfw3_h_
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /*************************************************************************
  34. * Doxygen documentation
  35. *************************************************************************/
  36. /*! @defgroup clipboard Clipboard support
  37. */
  38. /*! @defgroup context Context handling
  39. */
  40. /*! @defgroup error Error handling
  41. */
  42. /*! @defgroup init Initialization and version information
  43. */
  44. /*! @defgroup input Input handling
  45. */
  46. /*! @defgroup monitor Monitor handling
  47. *
  48. * This is the reference documentation for monitor related functions and types.
  49. * For more information, see the @ref monitor.
  50. */
  51. /*! @defgroup time Time input
  52. */
  53. /*! @defgroup window Window handling
  54. *
  55. * This is the reference documentation for window related functions and types,
  56. * including creation, deletion and event polling. For more information, see
  57. * the @ref window.
  58. */
  59. /*************************************************************************
  60. * Global definitions
  61. *************************************************************************/
  62. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  63. /* Please report any problems that you find with your compiler, which may
  64. * be solved in this section! There are several compilers that I have not
  65. * been able to test this file with yet.
  66. *
  67. * First: If we are we on Windows, we want a single define for it (_WIN32)
  68. * (Note: For Cygwin the compiler flag -mwin32 should be used, but to
  69. * make sure that things run smoothly for Cygwin users, we add __CYGWIN__
  70. * to the list of "valid Win32 identifiers", which removes the need for
  71. * -mwin32)
  72. */
  73. #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
  74. #define _WIN32
  75. #endif /* _WIN32 */
  76. /* In order for extension support to be portable, we need to define an
  77. * OpenGL function call method. We use the keyword APIENTRY, which is
  78. * defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
  79. */
  80. #ifndef APIENTRY
  81. #ifdef _WIN32
  82. #define APIENTRY __stdcall
  83. #else
  84. #define APIENTRY
  85. #endif
  86. #endif /* APIENTRY */
  87. /* The following three defines are here solely to make some Windows-based
  88. * <GL/gl.h> files happy. Theoretically we could include <windows.h>, but
  89. * it has the major drawback of severely polluting our namespace.
  90. */
  91. /* Under Windows, we need WINGDIAPI defined */
  92. #if !defined(WINGDIAPI) && defined(_WIN32)
  93. #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
  94. /* Microsoft Visual C++, Borland C++ Builder and Pelles C */
  95. #define WINGDIAPI __declspec(dllimport)
  96. #elif defined(__LCC__)
  97. /* LCC-Win32 */
  98. #define WINGDIAPI __stdcall
  99. #else
  100. /* Others (e.g. MinGW, Cygwin) */
  101. #define WINGDIAPI extern
  102. #endif
  103. #define GLFW_WINGDIAPI_DEFINED
  104. #endif /* WINGDIAPI */
  105. /* Some <GL/glu.h> files also need CALLBACK defined */
  106. #if !defined(CALLBACK) && defined(_WIN32)
  107. #if defined(_MSC_VER)
  108. /* Microsoft Visual C++ */
  109. #if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
  110. #define CALLBACK __stdcall
  111. #else
  112. #define CALLBACK
  113. #endif
  114. #else
  115. /* Other Windows compilers */
  116. #define CALLBACK __stdcall
  117. #endif
  118. #define GLFW_CALLBACK_DEFINED
  119. #endif /* CALLBACK */
  120. /* Most GL/glu.h variants on Windows need wchar_t
  121. * OpenGL/gl.h blocks the definition of ptrdiff_t by glext.h on OS X */
  122. #if !defined(GLFW_INCLUDE_NONE)
  123. #include <stddef.h>
  124. #endif
  125. /* Include the chosen client API headers.
  126. */
  127. #if defined(__APPLE_CC__)
  128. #if defined(GLFW_INCLUDE_GLCOREARB)
  129. #include <OpenGL/gl3.h>
  130. #elif !defined(GLFW_INCLUDE_NONE)
  131. #define GL_GLEXT_LEGACY
  132. #include <OpenGL/gl.h>
  133. #endif
  134. #if defined(GLFW_INCLUDE_GLU)
  135. #include <OpenGL/glu.h>
  136. #endif
  137. #else
  138. #if defined(GLFW_INCLUDE_GLCOREARB)
  139. #include <GL/glcorearb.h>
  140. #elif defined(GLFW_INCLUDE_ES1)
  141. #include <GLES/gl.h>
  142. #elif defined(GLFW_INCLUDE_ES2)
  143. #include <GLES2/gl2.h>
  144. #elif defined(GLFW_INCLUDE_ES3)
  145. #include <GLES3/gl3.h>
  146. #elif !defined(GLFW_INCLUDE_NONE)
  147. #include <GL/gl.h>
  148. #endif
  149. #if defined(GLFW_INCLUDE_GLU)
  150. #include <GL/glu.h>
  151. #endif
  152. #endif
  153. #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
  154. /* GLFW_DLL is defined by users of GLFW when compiling programs that will link
  155. * to the DLL version of the GLFW library. _GLFW_BUILD_DLL is defined by the
  156. * GLFW configuration header when compiling the DLL version of the library.
  157. */
  158. #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
  159. #endif
  160. #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
  161. /* We are building a Win32 DLL */
  162. #define GLFWAPI __declspec(dllexport)
  163. #elif defined(_WIN32) && defined(GLFW_DLL)
  164. /* We are calling a Win32 DLL */
  165. #if defined(__LCC__)
  166. #define GLFWAPI extern
  167. #else
  168. #define GLFWAPI __declspec(dllimport)
  169. #endif
  170. #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
  171. #define GLFWAPI __attribute__((visibility("default")))
  172. #else
  173. /* We are either building/calling a static lib or we are non-win32 */
  174. #define GLFWAPI
  175. #endif
  176. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  177. /*************************************************************************
  178. * GLFW API tokens
  179. *************************************************************************/
  180. /*! @name GLFW version macros
  181. * @{ */
  182. /*! @brief The major version number of the GLFW library.
  183. *
  184. * This is incremented when the API is changed in non-compatible ways.
  185. * @ingroup init
  186. */
  187. #define GLFW_VERSION_MAJOR 3
  188. /*! @brief The minor version number of the GLFW library.
  189. *
  190. * This is incremented when features are added to the API but it remains
  191. * backward-compatible.
  192. * @ingroup init
  193. */
  194. #define GLFW_VERSION_MINOR 0
  195. /*! @brief The revision number of the GLFW library.
  196. *
  197. * This is incremented when a bug fix release is made that does not contain any
  198. * API changes.
  199. * @ingroup init
  200. */
  201. #define GLFW_VERSION_REVISION 3
  202. /*! @} */
  203. /*! @name Key and button actions
  204. * @{ */
  205. /*! @brief The key or button was released.
  206. * @ingroup input
  207. */
  208. #define GLFW_RELEASE 0
  209. /*! @brief The key or button was pressed.
  210. * @ingroup input
  211. */
  212. #define GLFW_PRESS 1
  213. /*! @brief The key was held down until it repeated.
  214. * @ingroup input
  215. */
  216. #define GLFW_REPEAT 2
  217. /*! @} */
  218. /*! @defgroup keys Keyboard keys
  219. *
  220. * These key codes are inspired by the *USB HID Usage Tables v1.12* (p. 53-60),
  221. * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
  222. * put in the 256+ range).
  223. *
  224. * The naming of the key codes follow these rules:
  225. * - The US keyboard layout is used
  226. * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
  227. * "3", etc.)
  228. * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
  229. * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
  230. * correspond to the Unicode standard (usually for brevity)
  231. * - Keys that lack a clear US mapping are named "WORLD_x"
  232. * - For non-printable keys, custom names are used (e.g. "F4",
  233. * "BACKSPACE", etc.)
  234. *
  235. * @ingroup input
  236. * @{
  237. */
  238. /* The unknown key */
  239. #define GLFW_KEY_UNKNOWN -1
  240. /* Printable keys */
  241. #define GLFW_KEY_SPACE 32
  242. #define GLFW_KEY_APOSTROPHE 39 /* ' */
  243. #define GLFW_KEY_COMMA 44 /* , */
  244. #define GLFW_KEY_MINUS 45 /* - */
  245. #define GLFW_KEY_PERIOD 46 /* . */
  246. #define GLFW_KEY_SLASH 47 /* / */
  247. #define GLFW_KEY_0 48
  248. #define GLFW_KEY_1 49
  249. #define GLFW_KEY_2 50
  250. #define GLFW_KEY_3 51
  251. #define GLFW_KEY_4 52
  252. #define GLFW_KEY_5 53
  253. #define GLFW_KEY_6 54
  254. #define GLFW_KEY_7 55
  255. #define GLFW_KEY_8 56
  256. #define GLFW_KEY_9 57
  257. #define GLFW_KEY_SEMICOLON 59 /* ; */
  258. #define GLFW_KEY_EQUAL 61 /* = */
  259. #define GLFW_KEY_A 65
  260. #define GLFW_KEY_B 66
  261. #define GLFW_KEY_C 67
  262. #define GLFW_KEY_D 68
  263. #define GLFW_KEY_E 69
  264. #define GLFW_KEY_F 70
  265. #define GLFW_KEY_G 71
  266. #define GLFW_KEY_H 72
  267. #define GLFW_KEY_I 73
  268. #define GLFW_KEY_J 74
  269. #define GLFW_KEY_K 75
  270. #define GLFW_KEY_L 76
  271. #define GLFW_KEY_M 77
  272. #define GLFW_KEY_N 78
  273. #define GLFW_KEY_O 79
  274. #define GLFW_KEY_P 80
  275. #define GLFW_KEY_Q 81
  276. #define GLFW_KEY_R 82
  277. #define GLFW_KEY_S 83
  278. #define GLFW_KEY_T 84
  279. #define GLFW_KEY_U 85
  280. #define GLFW_KEY_V 86
  281. #define GLFW_KEY_W 87
  282. #define GLFW_KEY_X 88
  283. #define GLFW_KEY_Y 89
  284. #define GLFW_KEY_Z 90
  285. #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
  286. #define GLFW_KEY_BACKSLASH 92 /* \ */
  287. #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
  288. #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
  289. #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
  290. #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
  291. /* Function keys */
  292. #define GLFW_KEY_ESCAPE 256
  293. #define GLFW_KEY_ENTER 257
  294. #define GLFW_KEY_TAB 258
  295. #define GLFW_KEY_BACKSPACE 259
  296. #define GLFW_KEY_INSERT 260
  297. #define GLFW_KEY_DELETE 261
  298. #define GLFW_KEY_RIGHT 262
  299. #define GLFW_KEY_LEFT 263
  300. #define GLFW_KEY_DOWN 264
  301. #define GLFW_KEY_UP 265
  302. #define GLFW_KEY_PAGE_UP 266
  303. #define GLFW_KEY_PAGE_DOWN 267
  304. #define GLFW_KEY_HOME 268
  305. #define GLFW_KEY_END 269
  306. #define GLFW_KEY_CAPS_LOCK 280
  307. #define GLFW_KEY_SCROLL_LOCK 281
  308. #define GLFW_KEY_NUM_LOCK 282
  309. #define GLFW_KEY_PRINT_SCREEN 283
  310. #define GLFW_KEY_PAUSE 284
  311. #define GLFW_KEY_F1 290
  312. #define GLFW_KEY_F2 291
  313. #define GLFW_KEY_F3 292
  314. #define GLFW_KEY_F4 293
  315. #define GLFW_KEY_F5 294
  316. #define GLFW_KEY_F6 295
  317. #define GLFW_KEY_F7 296
  318. #define GLFW_KEY_F8 297
  319. #define GLFW_KEY_F9 298
  320. #define GLFW_KEY_F10 299
  321. #define GLFW_KEY_F11 300
  322. #define GLFW_KEY_F12 301
  323. #define GLFW_KEY_F13 302
  324. #define GLFW_KEY_F14 303
  325. #define GLFW_KEY_F15 304
  326. #define GLFW_KEY_F16 305
  327. #define GLFW_KEY_F17 306
  328. #define GLFW_KEY_F18 307
  329. #define GLFW_KEY_F19 308
  330. #define GLFW_KEY_F20 309
  331. #define GLFW_KEY_F21 310
  332. #define GLFW_KEY_F22 311
  333. #define GLFW_KEY_F23 312
  334. #define GLFW_KEY_F24 313
  335. #define GLFW_KEY_F25 314
  336. #define GLFW_KEY_KP_0 320
  337. #define GLFW_KEY_KP_1 321
  338. #define GLFW_KEY_KP_2 322
  339. #define GLFW_KEY_KP_3 323
  340. #define GLFW_KEY_KP_4 324
  341. #define GLFW_KEY_KP_5 325
  342. #define GLFW_KEY_KP_6 326
  343. #define GLFW_KEY_KP_7 327
  344. #define GLFW_KEY_KP_8 328
  345. #define GLFW_KEY_KP_9 329
  346. #define GLFW_KEY_KP_DECIMAL 330
  347. #define GLFW_KEY_KP_DIVIDE 331
  348. #define GLFW_KEY_KP_MULTIPLY 332
  349. #define GLFW_KEY_KP_SUBTRACT 333
  350. #define GLFW_KEY_KP_ADD 334
  351. #define GLFW_KEY_KP_ENTER 335
  352. #define GLFW_KEY_KP_EQUAL 336
  353. #define GLFW_KEY_LEFT_SHIFT 340
  354. #define GLFW_KEY_LEFT_CONTROL 341
  355. #define GLFW_KEY_LEFT_ALT 342
  356. #define GLFW_KEY_LEFT_SUPER 343
  357. #define GLFW_KEY_RIGHT_SHIFT 344
  358. #define GLFW_KEY_RIGHT_CONTROL 345
  359. #define GLFW_KEY_RIGHT_ALT 346
  360. #define GLFW_KEY_RIGHT_SUPER 347
  361. #define GLFW_KEY_MENU 348
  362. #define GLFW_KEY_LAST GLFW_KEY_MENU
  363. /*! @} */
  364. /*! @defgroup mods Modifier key flags
  365. * @ingroup input
  366. * @{ */
  367. /*! @brief If this bit is set one or more Shift keys were held down.
  368. */
  369. #define GLFW_MOD_SHIFT 0x0001
  370. /*! @brief If this bit is set one or more Control keys were held down.
  371. */
  372. #define GLFW_MOD_CONTROL 0x0002
  373. /*! @brief If this bit is set one or more Alt keys were held down.
  374. */
  375. #define GLFW_MOD_ALT 0x0004
  376. /*! @brief If this bit is set one or more Super keys were held down.
  377. */
  378. #define GLFW_MOD_SUPER 0x0008
  379. /*! @} */
  380. /*! @defgroup buttons Mouse buttons
  381. * @ingroup input
  382. * @{ */
  383. #define GLFW_MOUSE_BUTTON_1 0
  384. #define GLFW_MOUSE_BUTTON_2 1
  385. #define GLFW_MOUSE_BUTTON_3 2
  386. #define GLFW_MOUSE_BUTTON_4 3
  387. #define GLFW_MOUSE_BUTTON_5 4
  388. #define GLFW_MOUSE_BUTTON_6 5
  389. #define GLFW_MOUSE_BUTTON_7 6
  390. #define GLFW_MOUSE_BUTTON_8 7
  391. #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
  392. #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
  393. #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
  394. #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
  395. /*! @} */
  396. /*! @defgroup joysticks Joysticks
  397. * @ingroup input
  398. * @{ */
  399. #define GLFW_JOYSTICK_1 0
  400. #define GLFW_JOYSTICK_2 1
  401. #define GLFW_JOYSTICK_3 2
  402. #define GLFW_JOYSTICK_4 3
  403. #define GLFW_JOYSTICK_5 4
  404. #define GLFW_JOYSTICK_6 5
  405. #define GLFW_JOYSTICK_7 6
  406. #define GLFW_JOYSTICK_8 7
  407. #define GLFW_JOYSTICK_9 8
  408. #define GLFW_JOYSTICK_10 9
  409. #define GLFW_JOYSTICK_11 10
  410. #define GLFW_JOYSTICK_12 11
  411. #define GLFW_JOYSTICK_13 12
  412. #define GLFW_JOYSTICK_14 13
  413. #define GLFW_JOYSTICK_15 14
  414. #define GLFW_JOYSTICK_16 15
  415. #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
  416. /*! @} */
  417. /*! @defgroup errors Error codes
  418. * @ingroup error
  419. * @{ */
  420. /*! @brief GLFW has not been initialized.
  421. */
  422. #define GLFW_NOT_INITIALIZED 0x00010001
  423. /*! @brief No context is current for this thread.
  424. */
  425. #define GLFW_NO_CURRENT_CONTEXT 0x00010002
  426. /*! @brief One of the enum parameters for the function was given an invalid
  427. * enum.
  428. */
  429. #define GLFW_INVALID_ENUM 0x00010003
  430. /*! @brief One of the parameters for the function was given an invalid value.
  431. */
  432. #define GLFW_INVALID_VALUE 0x00010004
  433. /*! @brief A memory allocation failed.
  434. */
  435. #define GLFW_OUT_OF_MEMORY 0x00010005
  436. /*! @brief GLFW could not find support for the requested client API on the
  437. * system.
  438. */
  439. #define GLFW_API_UNAVAILABLE 0x00010006
  440. /*! @brief The requested client API version is not available.
  441. */
  442. #define GLFW_VERSION_UNAVAILABLE 0x00010007
  443. /*! @brief A platform-specific error occurred that does not match any of the
  444. * more specific categories.
  445. */
  446. #define GLFW_PLATFORM_ERROR 0x00010008
  447. /*! @brief The clipboard did not contain data in the requested format.
  448. */
  449. #define GLFW_FORMAT_UNAVAILABLE 0x00010009
  450. /*! @} */
  451. #define GLFW_FOCUSED 0x00020001
  452. #define GLFW_ICONIFIED 0x00020002
  453. #define GLFW_RESIZABLE 0x00020003
  454. #define GLFW_VISIBLE 0x00020004
  455. #define GLFW_DECORATED 0x00020005
  456. #define GLFW_RED_BITS 0x00021001
  457. #define GLFW_GREEN_BITS 0x00021002
  458. #define GLFW_BLUE_BITS 0x00021003
  459. #define GLFW_ALPHA_BITS 0x00021004
  460. #define GLFW_DEPTH_BITS 0x00021005
  461. #define GLFW_STENCIL_BITS 0x00021006
  462. #define GLFW_ACCUM_RED_BITS 0x00021007
  463. #define GLFW_ACCUM_GREEN_BITS 0x00021008
  464. #define GLFW_ACCUM_BLUE_BITS 0x00021009
  465. #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
  466. #define GLFW_AUX_BUFFERS 0x0002100B
  467. #define GLFW_STEREO 0x0002100C
  468. #define GLFW_SAMPLES 0x0002100D
  469. #define GLFW_SRGB_CAPABLE 0x0002100E
  470. #define GLFW_REFRESH_RATE 0x0002100F
  471. #define GLFW_CLIENT_API 0x00022001
  472. #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
  473. #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
  474. #define GLFW_CONTEXT_REVISION 0x00022004
  475. #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
  476. #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
  477. #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
  478. #define GLFW_OPENGL_PROFILE 0x00022008
  479. #define GLFW_OPENGL_API 0x00030001
  480. #define GLFW_OPENGL_ES_API 0x00030002
  481. #define GLFW_NO_ROBUSTNESS 0
  482. #define GLFW_NO_RESET_NOTIFICATION 0x00031001
  483. #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
  484. #define GLFW_OPENGL_ANY_PROFILE 0
  485. #define GLFW_OPENGL_CORE_PROFILE 0x00032001
  486. #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
  487. #define GLFW_CURSOR 0x00033001
  488. #define GLFW_STICKY_KEYS 0x00033002
  489. #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
  490. #define GLFW_CURSOR_NORMAL 0x00034001
  491. #define GLFW_CURSOR_HIDDEN 0x00034002
  492. #define GLFW_CURSOR_DISABLED 0x00034003
  493. #define GLFW_CONNECTED 0x00040001
  494. #define GLFW_DISCONNECTED 0x00040002
  495. /*************************************************************************
  496. * GLFW API types
  497. *************************************************************************/
  498. /*! @brief Client API function pointer type.
  499. *
  500. * Generic function pointer used for returning client API function pointers
  501. * without forcing a cast from a regular pointer.
  502. *
  503. * @ingroup context
  504. */
  505. typedef void (*GLFWglproc)(void);
  506. /*! @brief Opaque monitor object.
  507. *
  508. * Opaque monitor object.
  509. *
  510. * @ingroup monitor
  511. */
  512. typedef struct GLFWmonitor GLFWmonitor;
  513. /*! @brief Opaque window object.
  514. *
  515. * Opaque window object.
  516. *
  517. * @ingroup window
  518. */
  519. typedef struct GLFWwindow GLFWwindow;
  520. /*! @brief The function signature for error callbacks.
  521. *
  522. * This is the function signature for error callback functions.
  523. *
  524. * @param[in] error An [error code](@ref errors).
  525. * @param[in] description A UTF-8 encoded string describing the error.
  526. *
  527. * @sa glfwSetErrorCallback
  528. *
  529. * @ingroup error
  530. */
  531. typedef void (* GLFWerrorfun)(int,const char*);
  532. /*! @brief The function signature for window position callbacks.
  533. *
  534. * This is the function signature for window position callback functions.
  535. *
  536. * @param[in] window The window that the user moved.
  537. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  538. * upper-left corner of the client area of the window.
  539. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  540. * upper-left corner of the client area of the window.
  541. *
  542. * @sa glfwSetWindowPosCallback
  543. *
  544. * @ingroup window
  545. */
  546. typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
  547. /*! @brief The function signature for window resize callbacks.
  548. *
  549. * This is the function signature for window size callback functions.
  550. *
  551. * @param[in] window The window that the user resized.
  552. * @param[in] width The new width, in screen coordinates, of the window.
  553. * @param[in] height The new height, in screen coordinates, of the window.
  554. *
  555. * @sa glfwSetWindowSizeCallback
  556. *
  557. * @ingroup window
  558. */
  559. typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
  560. /*! @brief The function signature for window close callbacks.
  561. *
  562. * This is the function signature for window close callback functions.
  563. *
  564. * @param[in] window The window that the user attempted to close.
  565. *
  566. * @sa glfwSetWindowCloseCallback
  567. *
  568. * @ingroup window
  569. */
  570. typedef void (* GLFWwindowclosefun)(GLFWwindow*);
  571. /*! @brief The function signature for window content refresh callbacks.
  572. *
  573. * This is the function signature for window refresh callback functions.
  574. *
  575. * @param[in] window The window whose content needs to be refreshed.
  576. *
  577. * @sa glfwSetWindowRefreshCallback
  578. *
  579. * @ingroup window
  580. */
  581. typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
  582. /*! @brief The function signature for window focus/defocus callbacks.
  583. *
  584. * This is the function signature for window focus callback functions.
  585. *
  586. * @param[in] window The window that was focused or defocused.
  587. * @param[in] focused `GL_TRUE` if the window was focused, or `GL_FALSE` if
  588. * it was defocused.
  589. *
  590. * @sa glfwSetWindowFocusCallback
  591. *
  592. * @ingroup window
  593. */
  594. typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
  595. /*! @brief The function signature for window iconify/restore callbacks.
  596. *
  597. * This is the function signature for window iconify/restore callback
  598. * functions.
  599. *
  600. * @param[in] window The window that was iconified or restored.
  601. * @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`
  602. * if it was restored.
  603. *
  604. * @sa glfwSetWindowIconifyCallback
  605. *
  606. * @ingroup window
  607. */
  608. typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
  609. /*! @brief The function signature for framebuffer resize callbacks.
  610. *
  611. * This is the function signature for framebuffer resize callback
  612. * functions.
  613. *
  614. * @param[in] window The window whose framebuffer was resized.
  615. * @param[in] width The new width, in pixels, of the framebuffer.
  616. * @param[in] height The new height, in pixels, of the framebuffer.
  617. *
  618. * @sa glfwSetFramebufferSizeCallback
  619. *
  620. * @ingroup window
  621. */
  622. typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
  623. /*! @brief The function signature for mouse button callbacks.
  624. *
  625. * This is the function signature for mouse button callback functions.
  626. *
  627. * @param[in] window The window that received the event.
  628. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  629. * released.
  630. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
  631. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  632. * held down.
  633. *
  634. * @sa glfwSetMouseButtonCallback
  635. *
  636. * @ingroup input
  637. */
  638. typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
  639. /*! @brief The function signature for cursor position callbacks.
  640. *
  641. * This is the function signature for cursor position callback functions.
  642. *
  643. * @param[in] window The window that received the event.
  644. * @param[in] xpos The new x-coordinate of the cursor.
  645. * @param[in] ypos The new y-coordinate of the cursor.
  646. *
  647. * @sa glfwSetCursorPosCallback
  648. *
  649. * @ingroup input
  650. */
  651. typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
  652. /*! @brief The function signature for cursor enter/leave callbacks.
  653. *
  654. * This is the function signature for cursor enter/leave callback functions.
  655. *
  656. * @param[in] window The window that received the event.
  657. * @param[in] entered `GL_TRUE` if the cursor entered the window's client
  658. * area, or `GL_FALSE` if it left it.
  659. *
  660. * @sa glfwSetCursorEnterCallback
  661. *
  662. * @ingroup input
  663. */
  664. typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
  665. /*! @brief The function signature for scroll callbacks.
  666. *
  667. * This is the function signature for scroll callback functions.
  668. *
  669. * @param[in] window The window that received the event.
  670. * @param[in] xoffset The scroll offset along the x-axis.
  671. * @param[in] yoffset The scroll offset along the y-axis.
  672. *
  673. * @sa glfwSetScrollCallback
  674. *
  675. * @ingroup input
  676. */
  677. typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
  678. /*! @brief The function signature for keyboard key callbacks.
  679. *
  680. * This is the function signature for keyboard key callback functions.
  681. *
  682. * @param[in] window The window that received the event.
  683. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
  684. * @param[in] scancode The system-specific scancode of the key.
  685. * @param[in] action @ref GLFW_PRESS, @ref GLFW_RELEASE or @ref GLFW_REPEAT.
  686. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  687. * held down.
  688. *
  689. * @sa glfwSetKeyCallback
  690. *
  691. * @ingroup input
  692. */
  693. typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
  694. /*! @brief The function signature for Unicode character callbacks.
  695. *
  696. * This is the function signature for Unicode character callback functions.
  697. *
  698. * @param[in] window The window that received the event.
  699. * @param[in] character The Unicode code point of the character.
  700. *
  701. * @sa glfwSetCharCallback
  702. *
  703. * @ingroup input
  704. */
  705. typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
  706. /*! @brief The function signature for monitor configuration callbacks.
  707. *
  708. * This is the function signature for monitor configuration callback functions.
  709. *
  710. * @param[in] monitor The monitor that was connected or disconnected.
  711. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
  712. *
  713. * @sa glfwSetMonitorCallback
  714. *
  715. * @ingroup monitor
  716. */
  717. typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
  718. /*! @brief Video mode type.
  719. *
  720. * This describes a single video mode.
  721. *
  722. * @ingroup monitor
  723. */
  724. typedef struct GLFWvidmode
  725. {
  726. /*! The width, in screen coordinates, of the video mode.
  727. */
  728. int width;
  729. /*! The height, in screen coordinates, of the video mode.
  730. */
  731. int height;
  732. /*! The bit depth of the red channel of the video mode.
  733. */
  734. int redBits;
  735. /*! The bit depth of the green channel of the video mode.
  736. */
  737. int greenBits;
  738. /*! The bit depth of the blue channel of the video mode.
  739. */
  740. int blueBits;
  741. /*! The refresh rate, in Hz, of the video mode.
  742. */
  743. int refreshRate;
  744. } GLFWvidmode;
  745. /*! @brief Gamma ramp.
  746. *
  747. * This describes the gamma ramp for a monitor.
  748. *
  749. * @sa glfwGetGammaRamp glfwSetGammaRamp
  750. *
  751. * @ingroup monitor
  752. */
  753. typedef struct GLFWgammaramp
  754. {
  755. /*! An array of value describing the response of the red channel.
  756. */
  757. unsigned short* red;
  758. /*! An array of value describing the response of the green channel.
  759. */
  760. unsigned short* green;
  761. /*! An array of value describing the response of the blue channel.
  762. */
  763. unsigned short* blue;
  764. /*! The number of elements in each array.
  765. */
  766. unsigned int size;
  767. } GLFWgammaramp;
  768. /*************************************************************************
  769. * GLFW API functions
  770. *************************************************************************/
  771. /*! @brief Initializes the GLFW library.
  772. *
  773. * This function initializes the GLFW library. Before most GLFW functions can
  774. * be used, GLFW must be initialized, and before a program terminates GLFW
  775. * should be terminated in order to free any resources allocated during or
  776. * after initialization.
  777. *
  778. * If this function fails, it calls @ref glfwTerminate before returning. If it
  779. * succeeds, you should call @ref glfwTerminate before the program exits.
  780. *
  781. * Additional calls to this function after successful initialization but before
  782. * termination will succeed but will do nothing.
  783. *
  784. * @return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred.
  785. *
  786. * @par New in GLFW 3
  787. * This function no longer registers @ref glfwTerminate with `atexit`.
  788. *
  789. * @note This function may only be called from the main thread.
  790. *
  791. * @note This function may take several seconds to complete on some systems,
  792. * while on other systems it may take only a fraction of a second to complete.
  793. *
  794. * @note **Mac OS X:** This function will change the current directory of the
  795. * application to the `Contents/Resources` subdirectory of the application's
  796. * bundle, if present.
  797. *
  798. * @sa glfwTerminate
  799. *
  800. * @ingroup init
  801. */
  802. GLFWAPI int glfwInit(void);
  803. /*! @brief Terminates the GLFW library.
  804. *
  805. * This function destroys all remaining windows, frees any allocated resources
  806. * and sets the library to an uninitialized state. Once this is called, you
  807. * must again call @ref glfwInit successfully before you will be able to use
  808. * most GLFW functions.
  809. *
  810. * If GLFW has been successfully initialized, this function should be called
  811. * before the program exits. If initialization fails, there is no need to call
  812. * this function, as it is called by @ref glfwInit before it returns failure.
  813. *
  814. * @remarks This function may be called before @ref glfwInit.
  815. *
  816. * @note This function may only be called from the main thread.
  817. *
  818. * @warning No window's context may be current on another thread when this
  819. * function is called.
  820. *
  821. * @sa glfwInit
  822. *
  823. * @ingroup init
  824. */
  825. GLFWAPI void glfwTerminate(void);
  826. /*! @brief Retrieves the version of the GLFW library.
  827. *
  828. * This function retrieves the major, minor and revision numbers of the GLFW
  829. * library. It is intended for when you are using GLFW as a shared library and
  830. * want to ensure that you are using the minimum required version.
  831. *
  832. * @param[out] major Where to store the major version number, or `NULL`.
  833. * @param[out] minor Where to store the minor version number, or `NULL`.
  834. * @param[out] rev Where to store the revision number, or `NULL`.
  835. *
  836. * @remarks This function may be called before @ref glfwInit.
  837. *
  838. * @remarks This function may be called from any thread.
  839. *
  840. * @sa glfwGetVersionString
  841. *
  842. * @ingroup init
  843. */
  844. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  845. /*! @brief Returns a string describing the compile-time configuration.
  846. *
  847. * This function returns a static string generated at compile-time according to
  848. * which configuration macros were defined. This is intended for use when
  849. * submitting bug reports, to allow developers to see which code paths are
  850. * enabled in a binary.
  851. *
  852. * The format of the string is as follows:
  853. * - The version of GLFW
  854. * - The name of the window system API
  855. * - The name of the context creation API
  856. * - Any additional options or APIs
  857. *
  858. * For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL
  859. * back ends, the version string may look something like this:
  860. *
  861. * 3.0.0 Win32 WGL MinGW
  862. *
  863. * @return The GLFW version string.
  864. *
  865. * @remarks This function may be called before @ref glfwInit.
  866. *
  867. * @remarks This function may be called from any thread.
  868. *
  869. * @sa glfwGetVersion
  870. *
  871. * @ingroup init
  872. */
  873. GLFWAPI const char* glfwGetVersionString(void);
  874. /*! @brief Sets the error callback.
  875. *
  876. * This function sets the error callback, which is called with an error code
  877. * and a human-readable description each time a GLFW error occurs.
  878. *
  879. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  880. * callback.
  881. * @return The previously set callback, or `NULL` if no callback was set or an
  882. * error occurred.
  883. *
  884. * @remarks This function may be called before @ref glfwInit.
  885. *
  886. * @note The error callback is called by the thread where the error was
  887. * generated. If you are using GLFW from multiple threads, your error callback
  888. * needs to be written accordingly.
  889. *
  890. * @note Because the description string provided to the callback may have been
  891. * generated specifically for that error, it is not guaranteed to be valid
  892. * after the callback has returned. If you wish to use it after that, you need
  893. * to make your own copy of it before returning.
  894. *
  895. * @ingroup error
  896. */
  897. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
  898. /*! @brief Returns the currently connected monitors.
  899. *
  900. * This function returns an array of handles for all currently connected
  901. * monitors.
  902. *
  903. * @param[out] count Where to store the size of the returned array. This is
  904. * set to zero if an error occurred.
  905. * @return An array of monitor handles, or `NULL` if an error occurred.
  906. *
  907. * @note The returned array is allocated and freed by GLFW. You should not
  908. * free it yourself.
  909. *
  910. * @note The returned array is valid only until the monitor configuration
  911. * changes. See @ref glfwSetMonitorCallback to receive notifications of
  912. * configuration changes.
  913. *
  914. * @sa glfwGetPrimaryMonitor
  915. *
  916. * @ingroup monitor
  917. */
  918. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  919. /*! @brief Returns the primary monitor.
  920. *
  921. * This function returns the primary monitor. This is usually the monitor
  922. * where elements like the Windows task bar or the OS X menu bar is located.
  923. *
  924. * @return The primary monitor, or `NULL` if an error occurred.
  925. *
  926. * @sa glfwGetMonitors
  927. *
  928. * @ingroup monitor
  929. */
  930. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  931. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  932. *
  933. * This function returns the position, in screen coordinates, of the upper-left
  934. * corner of the specified monitor.
  935. *
  936. * @param[in] monitor The monitor to query.
  937. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  938. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  939. *
  940. * @ingroup monitor
  941. */
  942. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  943. /*! @brief Returns the physical size of the monitor.
  944. *
  945. * This function returns the size, in millimetres, of the display area of the
  946. * specified monitor.
  947. *
  948. * @param[in] monitor The monitor to query.
  949. * @param[out] width Where to store the width, in mm, of the monitor's display
  950. * area, or `NULL`.
  951. * @param[out] height Where to store the height, in mm, of the monitor's
  952. * display area, or `NULL`.
  953. *
  954. * @note Some operating systems do not provide accurate information, either
  955. * because the monitor's EDID data is incorrect, or because the driver does not
  956. * report it accurately.
  957. *
  958. * @ingroup monitor
  959. */
  960. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
  961. /*! @brief Returns the name of the specified monitor.
  962. *
  963. * This function returns a human-readable name, encoded as UTF-8, of the
  964. * specified monitor.
  965. *
  966. * @param[in] monitor The monitor to query.
  967. * @return The UTF-8 encoded name of the monitor, or `NULL` if an error
  968. * occurred.
  969. *
  970. * @note The returned string is allocated and freed by GLFW. You should not
  971. * free it yourself.
  972. *
  973. * @ingroup monitor
  974. */
  975. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  976. /*! @brief Sets the monitor configuration callback.
  977. *
  978. * This function sets the monitor configuration callback, or removes the
  979. * currently set callback. This is called when a monitor is connected to or
  980. * disconnected from the system.
  981. *
  982. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  983. * callback.
  984. * @return The previously set callback, or `NULL` if no callback was set or an
  985. * error occurred.
  986. *
  987. * @bug **X11:** This callback is not yet called on monitor configuration
  988. * changes.
  989. *
  990. * @ingroup monitor
  991. */
  992. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
  993. /*! @brief Returns the available video modes for the specified monitor.
  994. *
  995. * This function returns an array of all video modes supported by the specified
  996. * monitor. The returned array is sorted in ascending order, first by color
  997. * bit depth (the sum of all channel depths) and then by resolution area (the
  998. * product of width and height).
  999. *
  1000. * @param[in] monitor The monitor to query.
  1001. * @param[out] count Where to store the number of video modes in the returned
  1002. * array. This is set to zero if an error occurred.
  1003. * @return An array of video modes, or `NULL` if an error occurred.
  1004. *
  1005. * @note The returned array is allocated and freed by GLFW. You should not
  1006. * free it yourself.
  1007. *
  1008. * @note The returned array is valid only until this function is called again
  1009. * for the specified monitor.
  1010. *
  1011. * @sa glfwGetVideoMode
  1012. *
  1013. * @ingroup monitor
  1014. */
  1015. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  1016. /*! @brief Returns the current mode of the specified monitor.
  1017. *
  1018. * This function returns the current video mode of the specified monitor. If
  1019. * you are using a full screen window, the return value will therefore depend
  1020. * on whether it is focused.
  1021. *
  1022. * @param[in] monitor The monitor to query.
  1023. * @return The current mode of the monitor, or `NULL` if an error occurred.
  1024. *
  1025. * @note The returned struct is allocated and freed by GLFW. You should not
  1026. * free it yourself.
  1027. *
  1028. * @sa glfwGetVideoModes
  1029. *
  1030. * @ingroup monitor
  1031. */
  1032. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  1033. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  1034. *
  1035. * This function generates a 256-element gamma ramp from the specified exponent
  1036. * and then calls @ref glfwSetGammaRamp with it.
  1037. *
  1038. * @param[in] monitor The monitor whose gamma ramp to set.
  1039. * @param[in] gamma The desired exponent.
  1040. *
  1041. * @ingroup monitor
  1042. */
  1043. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  1044. /*! @brief Retrieves the current gamma ramp for the specified monitor.
  1045. *
  1046. * This function retrieves the current gamma ramp of the specified monitor.
  1047. *
  1048. * @param[in] monitor The monitor to query.
  1049. * @return The current gamma ramp, or `NULL` if an error occurred.
  1050. *
  1051. * @note The value arrays of the returned ramp are allocated and freed by GLFW.
  1052. * You should not free them yourself.
  1053. *
  1054. * @ingroup monitor
  1055. */
  1056. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  1057. /*! @brief Sets the current gamma ramp for the specified monitor.
  1058. *
  1059. * This function sets the current gamma ramp for the specified monitor.
  1060. *
  1061. * @param[in] monitor The monitor whose gamma ramp to set.
  1062. * @param[in] ramp The gamma ramp to use.
  1063. *
  1064. * @note Gamma ramp sizes other than 256 are not supported by all hardware.
  1065. *
  1066. * @ingroup monitor
  1067. */
  1068. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  1069. /*! @brief Resets all window hints to their default values.
  1070. *
  1071. * This function resets all window hints to their
  1072. * [default values](@ref window_hints_values).
  1073. *
  1074. * @note This function may only be called from the main thread.
  1075. *
  1076. * @sa glfwWindowHint
  1077. *
  1078. * @ingroup window
  1079. */
  1080. GLFWAPI void glfwDefaultWindowHints(void);
  1081. /*! @brief Sets the specified window hint to the desired value.
  1082. *
  1083. * This function sets hints for the next call to @ref glfwCreateWindow. The
  1084. * hints, once set, retain their values until changed by a call to @ref
  1085. * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
  1086. * terminated with @ref glfwTerminate.
  1087. *
  1088. * @param[in] target The [window hint](@ref window_hints) to set.
  1089. * @param[in] hint The new value of the window hint.
  1090. *
  1091. * @par New in GLFW 3
  1092. * Hints are no longer reset to their default values on window creation. To
  1093. * set default hint values, use @ref glfwDefaultWindowHints.
  1094. *
  1095. * @note This function may only be called from the main thread.
  1096. *
  1097. * @sa glfwDefaultWindowHints
  1098. *
  1099. * @ingroup window
  1100. */
  1101. GLFWAPI void glfwWindowHint(int target, int hint);
  1102. /*! @brief Creates a window and its associated context.
  1103. *
  1104. * This function creates a window and its associated context. Most of the
  1105. * options controlling how the window and its context should be created are
  1106. * specified through @ref glfwWindowHint.
  1107. *
  1108. * Successful creation does not change which context is current. Before you
  1109. * can use the newly created context, you need to make it current using @ref
  1110. * glfwMakeContextCurrent.
  1111. *
  1112. * Note that the created window and context may differ from what you requested,
  1113. * as not all parameters and hints are
  1114. * [hard constraints](@ref window_hints_hard). This includes the size of the
  1115. * window, especially for full screen windows. To retrieve the actual
  1116. * attributes of the created window and context, use queries like @ref
  1117. * glfwGetWindowAttrib and @ref glfwGetWindowSize.
  1118. *
  1119. * To create a full screen window, you need to specify the monitor to use. If
  1120. * no monitor is specified, windowed mode will be used. Unless you have a way
  1121. * for the user to choose a specific monitor, it is recommended that you pick
  1122. * the primary monitor. For more information on how to retrieve monitors, see
  1123. * @ref monitor_monitors.
  1124. *
  1125. * To create the window at a specific position, make it initially invisible
  1126. * using the `GLFW_VISIBLE` window hint, set its position and then show it.
  1127. *
  1128. * If a full screen window is active, the screensaver is prohibited from
  1129. * starting.
  1130. *
  1131. * @param[in] width The desired width, in screen coordinates, of the window.
  1132. * This must be greater than zero.
  1133. * @param[in] height The desired height, in screen coordinates, of the window.
  1134. * This must be greater than zero.
  1135. * @param[in] title The initial, UTF-8 encoded window title.
  1136. * @param[in] monitor The monitor to use for full screen mode, or `NULL` to use
  1137. * windowed mode.
  1138. * @param[in] share The window whose context to share resources with, or `NULL`
  1139. * to not share resources.
  1140. * @return The handle of the created window, or `NULL` if an error occurred.
  1141. *
  1142. * @remarks **Windows:** If the executable has an icon resource named
  1143. * `GLFW_ICON,` it will be set as the icon for the window. If no such icon is
  1144. * present, the `IDI_WINLOGO` icon will be used instead.
  1145. *
  1146. * @remarks **Mac OS X:** The GLFW window has no icon, as it is not a document
  1147. * window, but the dock icon will be the same as the application bundle's icon.
  1148. * Also, the first time a window is opened the menu bar is populated with
  1149. * common commands like Hide, Quit and About. The (minimal) about dialog uses
  1150. * information from the application's bundle. For more information on bundles,
  1151. * see the Bundle Programming Guide provided by Apple.
  1152. *
  1153. * @note This function may only be called from the main thread.
  1154. *
  1155. * @sa glfwDestroyWindow
  1156. *
  1157. * @ingroup window
  1158. */
  1159. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  1160. /*! @brief Destroys the specified window and its context.
  1161. *
  1162. * This function destroys the specified window and its context. On calling
  1163. * this function, no further callbacks will be called for that window.
  1164. *
  1165. * @param[in] window The window to destroy.
  1166. *
  1167. * @note This function may only be called from the main thread.
  1168. *
  1169. * @note This function may not be called from a callback.
  1170. *
  1171. * @note If the window's context is current on the main thread, it is
  1172. * detached before being destroyed.
  1173. *
  1174. * @warning The window's context must not be current on any other thread.
  1175. *
  1176. * @sa glfwCreateWindow
  1177. *
  1178. * @ingroup window
  1179. */
  1180. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  1181. /*! @brief Checks the close flag of the specified window.
  1182. *
  1183. * This function returns the value of the close flag of the specified window.
  1184. *
  1185. * @param[in] window The window to query.
  1186. * @return The value of the close flag.
  1187. *
  1188. * @remarks This function may be called from secondary threads.
  1189. *
  1190. * @ingroup window
  1191. */
  1192. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  1193. /*! @brief Sets the close flag of the specified window.
  1194. *
  1195. * This function sets the value of the close flag of the specified window.
  1196. * This can be used to override the user's attempt to close the window, or
  1197. * to signal that it should be closed.
  1198. *
  1199. * @param[in] window The window whose flag to change.
  1200. * @param[in] value The new value.
  1201. *
  1202. * @remarks This function may be called from secondary threads.
  1203. *
  1204. * @ingroup window
  1205. */
  1206. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  1207. /*! @brief Sets the title of the specified window.
  1208. *
  1209. * This function sets the window title, encoded as UTF-8, of the specified
  1210. * window.
  1211. *
  1212. * @param[in] window The window whose title to change.
  1213. * @param[in] title The UTF-8 encoded window title.
  1214. *
  1215. * @note This function may only be called from the main thread.
  1216. *
  1217. * @ingroup window
  1218. */
  1219. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  1220. /*! @brief Retrieves the position of the client area of the specified window.
  1221. *
  1222. * This function retrieves the position, in screen coordinates, of the
  1223. * upper-left corner of the client area of the specified window.
  1224. *
  1225. * @param[in] window The window to query.
  1226. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  1227. * the client area, or `NULL`.
  1228. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  1229. * the client area, or `NULL`.
  1230. *
  1231. * @sa glfwSetWindowPos
  1232. *
  1233. * @ingroup window
  1234. */
  1235. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  1236. /*! @brief Sets the position of the client area of the specified window.
  1237. *
  1238. * This function sets the position, in screen coordinates, of the upper-left
  1239. * corner of the client area of the window.
  1240. *
  1241. * If the specified window is a full screen window, this function does nothing.
  1242. *
  1243. * If you wish to set an initial window position you should create a hidden
  1244. * window (using @ref glfwWindowHint and `GLFW_VISIBLE`), set its position and
  1245. * then show it.
  1246. *
  1247. * @param[in] window The window to query.
  1248. * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
  1249. * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
  1250. *
  1251. * @note It is very rarely a good idea to move an already visible window, as it
  1252. * will confuse and annoy the user.
  1253. *
  1254. * @note This function may only be called from the main thread.
  1255. *
  1256. * @note The window manager may put limits on what positions are allowed.
  1257. *
  1258. * @bug **X11:** Some window managers ignore the set position of hidden (i.e.
  1259. * unmapped) windows, instead placing them where it thinks is appropriate once
  1260. * they are shown.
  1261. *
  1262. * @sa glfwGetWindowPos
  1263. *
  1264. * @ingroup window
  1265. */
  1266. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  1267. /*! @brief Retrieves the size of the client area of the specified window.
  1268. *
  1269. * This function retrieves the size, in screen coordinates, of the client area
  1270. * of the specified window.
  1271. *
  1272. * @param[in] window The window whose size to retrieve.
  1273. * @param[out] width Where to store the width, in screen coordinates, of the
  1274. * client area, or `NULL`.
  1275. * @param[out] height Where to store the height, in screen coordinates, of the
  1276. * client area, or `NULL`.
  1277. *
  1278. * @sa glfwSetWindowSize
  1279. *
  1280. * @ingroup window
  1281. */
  1282. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  1283. /*! @brief Sets the size of the client area of the specified window.
  1284. *
  1285. * This function sets the size, in screen coordinates, of the client area of
  1286. * the specified window.
  1287. *
  1288. * For full screen windows, this function selects and switches to the resolution
  1289. * closest to the specified size, without affecting the window's context. As
  1290. * the context is unaffected, the bit depths of the framebuffer remain
  1291. * unchanged.
  1292. *
  1293. * @param[in] window The window to resize.
  1294. * @param[in] width The desired width of the specified window.
  1295. * @param[in] height The desired height of the specified window.
  1296. *
  1297. * @note This function may only be called from the main thread.
  1298. *
  1299. * @note The window manager may put limits on what window sizes are allowed.
  1300. *
  1301. * @sa glfwGetWindowSize
  1302. *
  1303. * @ingroup window
  1304. */
  1305. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  1306. /*! @brief Retrieves the size of the framebuffer of the specified window.
  1307. *
  1308. * This function retrieves the size, in pixels, of the framebuffer of the
  1309. * specified window.
  1310. *
  1311. * @param[in] window The window whose framebuffer to query.
  1312. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  1313. * or `NULL`.
  1314. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  1315. * or `NULL`.
  1316. *
  1317. * @sa glfwSetFramebufferSizeCallback
  1318. *
  1319. * @ingroup window
  1320. */
  1321. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  1322. /*! @brief Iconifies the specified window.
  1323. *
  1324. * This function iconifies/minimizes the specified window, if it was previously
  1325. * restored. If it is a full screen window, the original monitor resolution is
  1326. * restored until the window is restored. If the window is already iconified,
  1327. * this function does nothing.
  1328. *
  1329. * @param[in] window The window to iconify.
  1330. *
  1331. * @note This function may only be called from the main thread.
  1332. *
  1333. * @sa glfwRestoreWindow
  1334. *
  1335. * @ingroup window
  1336. */
  1337. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  1338. /*! @brief Restores the specified window.
  1339. *
  1340. * This function restores the specified window, if it was previously
  1341. * iconified/minimized. If it is a full screen window, the resolution chosen
  1342. * for the window is restored on the selected monitor. If the window is
  1343. * already restored, this function does nothing.
  1344. *
  1345. * @param[in] window The window to restore.
  1346. *
  1347. * @note This function may only be called from the main thread.
  1348. *
  1349. * @sa glfwIconifyWindow
  1350. *
  1351. * @ingroup window
  1352. */
  1353. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  1354. /*! @brief Makes the specified window visible.
  1355. *
  1356. * This function makes the specified window visible, if it was previously
  1357. * hidden. If the window is already visible or is in full screen mode, this
  1358. * function does nothing.
  1359. *
  1360. * @param[in] window The window to make visible.
  1361. *
  1362. * @note This function may only be called from the main thread.
  1363. *
  1364. * @sa glfwHideWindow
  1365. *
  1366. * @ingroup window
  1367. */
  1368. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  1369. /*! @brief Hides the specified window.
  1370. *
  1371. * This function hides the specified window, if it was previously visible. If
  1372. * the window is already hidden or is in full screen mode, this function does
  1373. * nothing.
  1374. *
  1375. * @param[in] window The window to hide.
  1376. *
  1377. * @note This function may only be called from the main thread.
  1378. *
  1379. * @sa glfwShowWindow
  1380. *
  1381. * @ingroup window
  1382. */
  1383. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  1384. /*! @brief Returns the monitor that the window uses for full screen mode.
  1385. *
  1386. * This function returns the handle of the monitor that the specified window is
  1387. * in full screen on.
  1388. *
  1389. * @param[in] window The window to query.
  1390. * @return The monitor, or `NULL` if the window is in windowed mode.
  1391. *
  1392. * @ingroup window
  1393. */
  1394. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  1395. /*! @brief Returns an attribute of the specified window.
  1396. *
  1397. * This function returns an attribute of the specified window. There are many
  1398. * attributes, some related to the window and others to its context.
  1399. *
  1400. * @param[in] window The window to query.
  1401. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  1402. * return.
  1403. * @return The value of the attribute, or zero if an error occurred.
  1404. *
  1405. * @ingroup window
  1406. */
  1407. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  1408. /*! @brief Sets the user pointer of the specified window.
  1409. *
  1410. * This function sets the user-defined pointer of the specified window. The
  1411. * current value is retained until the window is destroyed. The initial value
  1412. * is `NULL`.
  1413. *
  1414. * @param[in] window The window whose pointer to set.
  1415. * @param[in] pointer The new value.
  1416. *
  1417. * @sa glfwGetWindowUserPointer
  1418. *
  1419. * @ingroup window
  1420. */
  1421. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  1422. /*! @brief Returns the user pointer of the specified window.
  1423. *
  1424. * This function returns the current value of the user-defined pointer of the
  1425. * specified window. The initial value is `NULL`.
  1426. *
  1427. * @param[in] window The window whose pointer to return.
  1428. *
  1429. * @sa glfwSetWindowUserPointer
  1430. *
  1431. * @ingroup window
  1432. */
  1433. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  1434. /*! @brief Sets the position callback for the specified window.
  1435. *
  1436. * This function sets the position callback of the specified window, which is
  1437. * called when the window is moved. The callback is provided with the screen
  1438. * position of the upper-left corner of the client area of the window.
  1439. *
  1440. * @param[in] window The window whose callback to set.
  1441. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1442. * callback.
  1443. * @return The previously set callback, or `NULL` if no callback was set or an
  1444. * error occurred.
  1445. *
  1446. * @ingroup window
  1447. */
  1448. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
  1449. /*! @brief Sets the size callback for the specified window.
  1450. *
  1451. * This function sets the size callback of the specified window, which is
  1452. * called when the window is resized. The callback is provided with the size,
  1453. * in screen coordinates, of the client area of the window.
  1454. *
  1455. * @param[in] window The window whose callback to set.
  1456. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1457. * callback.
  1458. * @return The previously set callback, or `NULL` if no callback was set or an
  1459. * error occurred.
  1460. *
  1461. * @ingroup window
  1462. */
  1463. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
  1464. /*! @brief Sets the close callback for the specified window.
  1465. *
  1466. * This function sets the close callback of the specified window, which is
  1467. * called when the user attempts to close the window, for example by clicking
  1468. * the close widget in the title bar.
  1469. *
  1470. * The close flag is set before this callback is called, but you can modify it
  1471. * at any time with @ref glfwSetWindowShouldClose.
  1472. *
  1473. * The close callback is not triggered by @ref glfwDestroyWindow.
  1474. *
  1475. * @param[in] window The window whose callback to set.
  1476. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1477. * callback.
  1478. * @return The previously set callback, or `NULL` if no callback was set or an
  1479. * error occurred.
  1480. *
  1481. * @remarks **Mac OS X:** Selecting Quit from the application menu will
  1482. * trigger the close callback for all windows.
  1483. *
  1484. * @ingroup window
  1485. */
  1486. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
  1487. /*! @brief Sets the refresh callback for the specified window.
  1488. *
  1489. * This function sets the refresh callback of the specified window, which is
  1490. * called when the client area of the window needs to be redrawn, for example
  1491. * if the window has been exposed after having been covered by another window.
  1492. *
  1493. * On compositing window systems such as Aero, Compiz or Aqua, where the window
  1494. * contents are saved off-screen, this callback may be called only very
  1495. * infrequently or never at all.
  1496. *
  1497. * @param[in] window The window whose callback to set.
  1498. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1499. * callback.
  1500. * @return The previously set callback, or `NULL` if no callback was set or an
  1501. * error occurred.
  1502. *
  1503. * @note On compositing window systems such as Aero, Compiz or Aqua, where the
  1504. * window contents are saved off-screen, this callback may be called only very
  1505. * infrequently or never at all.
  1506. *
  1507. * @ingroup window
  1508. */
  1509. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
  1510. /*! @brief Sets the focus callback for the specified window.
  1511. *
  1512. * This function sets the focus callback of the specified window, which is
  1513. * called when the window gains or loses focus.
  1514. *
  1515. * After the focus callback is called for a window that lost focus, synthetic
  1516. * key and mouse button release events will be generated for all such that had
  1517. * been pressed. For more information, see @ref glfwSetKeyCallback and @ref
  1518. * glfwSetMouseButtonCallback.
  1519. *
  1520. * @param[in] window The window whose callback to set.
  1521. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1522. * callback.
  1523. * @return The previously set callback, or `NULL` if no callback was set or an
  1524. * error occurred.
  1525. *
  1526. * @ingroup window
  1527. */
  1528. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
  1529. /*! @brief Sets the iconify callback for the specified window.
  1530. *
  1531. * This function sets the iconification callback of the specified window, which
  1532. * is called when the window is iconified or restored.
  1533. *
  1534. * @param[in] window The window whose callback to set.
  1535. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1536. * callback.
  1537. * @return The previously set callback, or `NULL` if no callback was set or an
  1538. * error occurred.
  1539. *
  1540. * @ingroup window
  1541. */
  1542. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
  1543. /*! @brief Sets the framebuffer resize callback for the specified window.
  1544. *
  1545. * This function sets the framebuffer resize callback of the specified window,
  1546. * which is called when the framebuffer of the specified window is resized.
  1547. *
  1548. * @param[in] window The window whose callback to set.
  1549. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1550. * callback.
  1551. * @return The previously set callback, or `NULL` if no callback was set or an
  1552. * error occurred.
  1553. *
  1554. * @ingroup window
  1555. */
  1556. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
  1557. /*! @brief Processes all pending events.
  1558. *
  1559. * This function processes only those events that have already been received
  1560. * and then returns immediately. Processing events will cause the window and
  1561. * input callbacks associated with those events to be called.
  1562. *
  1563. * This function is not required for joystick input to work.
  1564. *
  1565. * @par New in GLFW 3
  1566. * This function is no longer called by @ref glfwSwapBuffers. You need to call
  1567. * it or @ref glfwWaitEvents yourself.
  1568. *
  1569. * @note This function may only be called from the main thread.
  1570. *
  1571. * @note This function may not be called from a callback.
  1572. *
  1573. * @note On some platforms, certain callbacks may be called outside of a call
  1574. * to one of the event processing functions.
  1575. *
  1576. * @sa glfwWaitEvents
  1577. *
  1578. * @ingroup window
  1579. */
  1580. GLFWAPI void glfwPollEvents(void);
  1581. /*! @brief Waits until events are pending and processes them.
  1582. *
  1583. * This function puts the calling thread to sleep until at least one event has
  1584. * been received. Once one or more events have been received, it behaves as if
  1585. * @ref glfwPollEvents was called, i.e. the events are processed and the
  1586. * function then returns immediately. Processing events will cause the window
  1587. * and input callbacks associated with those events to be called.
  1588. *
  1589. * Since not all events are associated with callbacks, this function may return
  1590. * without a callback having been called even if you are monitoring all
  1591. * callbacks.
  1592. *
  1593. * This function is not required for joystick input to work.
  1594. *
  1595. * @note This function may only be called from the main thread.
  1596. *
  1597. * @note This function may not be called from a callback.
  1598. *
  1599. * @note On some platforms, certain callbacks may be called outside of a call
  1600. * to one of the event processing functions.
  1601. *
  1602. * @sa glfwPollEvents
  1603. *
  1604. * @ingroup window
  1605. */
  1606. GLFWAPI void glfwWaitEvents(void);
  1607. /*! @brief Returns the value of an input option for the specified window.
  1608. *
  1609. * @param[in] window The window to query.
  1610. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  1611. * `GLFW_STICKY_MOUSE_BUTTONS`.
  1612. *
  1613. * @sa glfwSetInputMode
  1614. *
  1615. * @ingroup input
  1616. */
  1617. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  1618. /*! @brief Sets an input option for the specified window.
  1619. * @param[in] window The window whose input mode to set.
  1620. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  1621. * `GLFW_STICKY_MOUSE_BUTTONS`.
  1622. * @param[in] value The new value of the specified input mode.
  1623. *
  1624. * If `mode` is `GLFW_CURSOR`, the value must be one of the supported input
  1625. * modes:
  1626. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  1627. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
  1628. * area of the window.
  1629. * - `GLFW_CURSOR_DISABLED` disables the cursor and removes any limitations on
  1630. * cursor movement.
  1631. *
  1632. * If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
  1633. * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are
  1634. * enabled, a key press will ensure that @ref glfwGetKey returns @ref
  1635. * GLFW_PRESS the next time it is called even if the key had been released
  1636. * before the call. This is useful when you are only interested in whether
  1637. * keys have been pressed but not when or in which order.
  1638. *
  1639. * If `mode` is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either `GL_TRUE`
  1640. * to enable sticky mouse buttons, or `GL_FALSE` to disable it. If sticky
  1641. * mouse buttons are enabled, a mouse button press will ensure that @ref
  1642. * glfwGetMouseButton returns @ref GLFW_PRESS the next time it is called even
  1643. * if the mouse button had been released before the call. This is useful when
  1644. * you are only interested in whether mouse buttons have been pressed but not
  1645. * when or in which order.
  1646. *
  1647. * @sa glfwGetInputMode
  1648. *
  1649. * @ingroup input
  1650. */
  1651. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  1652. /*! @brief Returns the last reported state of a keyboard key for the specified
  1653. * window.
  1654. *
  1655. * This function returns the last state reported for the specified key to the
  1656. * specified window. The returned state is one of `GLFW_PRESS` or
  1657. * `GLFW_RELEASE`. The higher-level state `GLFW_REPEAT` is only reported to
  1658. * the key callback.
  1659. *
  1660. * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
  1661. * `GLFW_PRESS` the first time you call this function after a key has been
  1662. * pressed, even if the key has already been released.
  1663. *
  1664. * The key functions deal with physical keys, with [key tokens](@ref keys)
  1665. * named after their use on the standard US keyboard layout. If you want to
  1666. * input text, use the Unicode character callback instead.
  1667. *
  1668. * @param[in] window The desired window.
  1669. * @param[in] key The desired [keyboard key](@ref keys).
  1670. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  1671. *
  1672. * @note `GLFW_KEY_UNKNOWN` is not a valid key for this function.
  1673. *
  1674. * @ingroup input
  1675. */
  1676. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  1677. /*! @brief Returns the last reported state of a mouse button for the specified
  1678. * window.
  1679. *
  1680. * This function returns the last state reported for the specified mouse button
  1681. * to the specified window.
  1682. *
  1683. * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
  1684. * returns `GLFW_PRESS` the first time you call this function after a mouse
  1685. * button has been pressed, even if the mouse button has already been released.
  1686. *
  1687. * @param[in] window The desired window.
  1688. * @param[in] button The desired [mouse button](@ref buttons).
  1689. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  1690. *
  1691. * @ingroup input
  1692. */
  1693. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  1694. /*! @brief Retrieves the last reported cursor position, relative to the client
  1695. * area of the window.
  1696. *
  1697. * This function returns the last reported position of the cursor to the
  1698. * specified window.
  1699. *
  1700. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  1701. * position is unbounded and limited only by the minimum and maximum values of
  1702. * a `double`.
  1703. *
  1704. * The coordinate can be converted to their integer equivalents with the
  1705. * `floor` function. Casting directly to an integer type works for positive
  1706. * coordinates, but fails for negative ones.
  1707. *
  1708. * @param[in] window The desired window.
  1709. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  1710. * left edge of the client area, or `NULL`.
  1711. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  1712. * top edge of the client area, or `NULL`.
  1713. *
  1714. * @sa glfwSetCursorPos
  1715. *
  1716. * @ingroup input
  1717. */
  1718. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  1719. /*! @brief Sets the position of the cursor, relative to the client area of the window.
  1720. *
  1721. * This function sets the position of the cursor. The specified window must be
  1722. * focused. If the window does not have focus when this function is called, it
  1723. * fails silently.
  1724. *
  1725. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  1726. * position is unbounded and limited only by the minimum and maximum values of
  1727. * a `double`.
  1728. *
  1729. * @param[in] window The desired window.
  1730. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  1731. * client area.
  1732. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  1733. * client area.
  1734. *
  1735. * @sa glfwGetCursorPos
  1736. *
  1737. * @ingroup input
  1738. */
  1739. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  1740. /*! @brief Sets the key callback.
  1741. *
  1742. * This function sets the key callback of the specific window, which is called
  1743. * when a key is pressed, repeated or released.
  1744. *
  1745. * The key functions deal with physical keys, with layout independent
  1746. * [key tokens](@ref keys) named after their values in the standard US keyboard
  1747. * layout. If you want to input text, use the
  1748. * [character callback](@ref glfwSetCharCallback) instead.
  1749. *
  1750. * When a window loses focus, it will generate synthetic key release events
  1751. * for all pressed keys. You can tell these events from user-generated events
  1752. * by the fact that the synthetic ones are generated after the window has lost
  1753. * focus, i.e. `GLFW_FOCUSED` will be false and the focus callback will have
  1754. * already been called.
  1755. *
  1756. * The scancode of a key is specific to that platform or sometimes even to that
  1757. * machine. Scancodes are intended to allow users to bind keys that don't have
  1758. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  1759. * state is not saved and so it cannot be retrieved with @ref glfwGetKey.
  1760. *
  1761. * Sometimes GLFW needs to generate synthetic key events, in which case the
  1762. * scancode may be zero.
  1763. *
  1764. * @param[in] window The window whose callback to set.
  1765. * @param[in] cbfun The new key callback, or `NULL` to remove the currently
  1766. * set callback.
  1767. * @return The previously set callback, or `NULL` if no callback was set or an
  1768. * error occurred.
  1769. *
  1770. * @ingroup input
  1771. */
  1772. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
  1773. /*! @brief Sets the Unicode character callback.
  1774. *
  1775. * This function sets the character callback of the specific window, which is
  1776. * called when a Unicode character is input.
  1777. *
  1778. * The character callback is intended for text input. If you want to know
  1779. * whether a specific key was pressed or released, use the
  1780. * [key callback](@ref glfwSetKeyCallback) instead.
  1781. *
  1782. * @param[in] window The window whose callback to set.
  1783. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1784. * callback.
  1785. * @return The previously set callback, or `NULL` if no callback was set or an
  1786. * error occurred.
  1787. *
  1788. * @ingroup input
  1789. */
  1790. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
  1791. /*! @brief Sets the mouse button callback.
  1792. *
  1793. * This function sets the mouse button callback of the specified window, which
  1794. * is called when a mouse button is pressed or released.
  1795. *
  1796. * When a window loses focus, it will generate synthetic mouse button release
  1797. * events for all pressed mouse buttons. You can tell these events from
  1798. * user-generated events by the fact that the synthetic ones are generated
  1799. * after the window has lost focus, i.e. `GLFW_FOCUSED` will be false and the
  1800. * focus callback will have already been called.
  1801. *
  1802. * @param[in] window The window whose callback to set.
  1803. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1804. * callback.
  1805. * @return The previously set callback, or `NULL` if no callback was set or an
  1806. * error occurred.
  1807. *
  1808. * @ingroup input
  1809. */
  1810. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
  1811. /*! @brief Sets the cursor position callback.
  1812. *
  1813. * This function sets the cursor position callback of the specified window,
  1814. * which is called when the cursor is moved. The callback is provided with the
  1815. * position relative to the upper-left corner of the client area of the window.
  1816. *
  1817. * @param[in] window The window whose callback to set.
  1818. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1819. * callback.
  1820. * @return The previously set callback, or `NULL` if no callback was set or an
  1821. * error occurred.
  1822. *
  1823. * @ingroup input
  1824. */
  1825. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
  1826. /*! @brief Sets the cursor enter/exit callback.
  1827. *
  1828. * This function sets the cursor boundary crossing callback of the specified
  1829. * window, which is called when the cursor enters or leaves the client area of
  1830. * the window.
  1831. *
  1832. * @param[in] window The window whose callback to set.
  1833. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1834. * callback.
  1835. * @return The previously set callback, or `NULL` if no callback was set or an
  1836. * error occurred.
  1837. *
  1838. * @ingroup input
  1839. */
  1840. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
  1841. /*! @brief Sets the scroll callback.
  1842. *
  1843. * This function sets the scroll callback of the specified window, which is
  1844. * called when a scrolling device is used, such as a mouse wheel or scrolling
  1845. * area of a touchpad.
  1846. *
  1847. * The scroll callback receives all scrolling input, like that from a mouse
  1848. * wheel or a touchpad scrolling area.
  1849. *
  1850. * @param[in] window The window whose callback to set.
  1851. * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
  1852. * set callback.
  1853. * @return The previously set callback, or `NULL` if no callback was set or an
  1854. * error occurred.
  1855. *
  1856. * @ingroup input
  1857. */
  1858. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
  1859. /*! @brief Returns whether the specified joystick is present.
  1860. *
  1861. * This function returns whether the specified joystick is present.
  1862. *
  1863. * @param[in] joy The joystick to query.
  1864. * @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise.
  1865. *
  1866. * @ingroup input
  1867. */
  1868. GLFWAPI int glfwJoystickPresent(int joy);
  1869. /*! @brief Returns the values of all axes of the specified joystick.
  1870. *
  1871. * This function returns the values of all axes of the specified joystick.
  1872. *
  1873. * @param[in] joy The joystick to query.
  1874. * @param[out] count Where to store the size of the returned array. This is
  1875. * set to zero if an error occurred.
  1876. * @return An array of axis values, or `NULL` if the joystick is not present.
  1877. *
  1878. * @note The returned array is allocated and freed by GLFW. You should not
  1879. * free it yourself.
  1880. *
  1881. * @note The returned array is valid only until the next call to @ref
  1882. * glfwGetJoystickAxes for that joystick.
  1883. *
  1884. * @ingroup input
  1885. */
  1886. GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count);
  1887. /*! @brief Returns the state of all buttons of the specified joystick.
  1888. *
  1889. * This function returns the state of all buttons of the specified joystick.
  1890. *
  1891. * @param[in] joy The joystick to query.
  1892. * @param[out] count Where to store the size of the returned array. This is
  1893. * set to zero if an error occurred.
  1894. * @return An array of button states, or `NULL` if the joystick is not present.
  1895. *
  1896. * @note The returned array is allocated and freed by GLFW. You should not
  1897. * free it yourself.
  1898. *
  1899. * @note The returned array is valid only until the next call to @ref
  1900. * glfwGetJoystickButtons for that joystick.
  1901. *
  1902. * @ingroup input
  1903. */
  1904. GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count);
  1905. /*! @brief Returns the name of the specified joystick.
  1906. *
  1907. * This function returns the name, encoded as UTF-8, of the specified joystick.
  1908. *
  1909. * @param[in] joy The joystick to query.
  1910. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  1911. * is not present.
  1912. *
  1913. * @note The returned string is allocated and freed by GLFW. You should not
  1914. * free it yourself.
  1915. *
  1916. * @note The returned string is valid only until the next call to @ref
  1917. * glfwGetJoystickName for that joystick.
  1918. *
  1919. * @ingroup input
  1920. */
  1921. GLFWAPI const char* glfwGetJoystickName(int joy);
  1922. /*! @brief Sets the clipboard to the specified string.
  1923. *
  1924. * This function sets the system clipboard to the specified, UTF-8 encoded
  1925. * string. The string is copied before returning, so you don't have to retain
  1926. * it afterwards.
  1927. *
  1928. * @param[in] window The window that will own the clipboard contents.
  1929. * @param[in] string A UTF-8 encoded string.
  1930. *
  1931. * @note This function may only be called from the main thread.
  1932. *
  1933. * @sa glfwGetClipboardString
  1934. *
  1935. * @ingroup clipboard
  1936. */
  1937. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  1938. /*! @brief Retrieves the contents of the clipboard as a string.
  1939. *
  1940. * This function returns the contents of the system clipboard, if it contains
  1941. * or is convertible to a UTF-8 encoded string.
  1942. *
  1943. * @param[in] window The window that will request the clipboard contents.
  1944. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  1945. * if an error occurred.
  1946. *
  1947. * @note This function may only be called from the main thread.
  1948. *
  1949. * @note The returned string is allocated and freed by GLFW. You should not
  1950. * free it yourself.
  1951. *
  1952. * @note The returned string is valid only until the next call to @ref
  1953. * glfwGetClipboardString or @ref glfwSetClipboardString.
  1954. *
  1955. * @sa glfwSetClipboardString
  1956. *
  1957. * @ingroup clipboard
  1958. */
  1959. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  1960. /*! @brief Returns the value of the GLFW timer.
  1961. *
  1962. * This function returns the value of the GLFW timer. Unless the timer has
  1963. * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
  1964. * was initialized.
  1965. *
  1966. * @return The current value, in seconds, or zero if an error occurred.
  1967. *
  1968. * @remarks This function may be called from secondary threads.
  1969. *
  1970. * @note The resolution of the timer is system dependent, but is usually on the
  1971. * order of a few micro- or nanoseconds. It uses the highest-resolution
  1972. * monotonic time source on each supported platform.
  1973. *
  1974. * @ingroup time
  1975. */
  1976. GLFWAPI double glfwGetTime(void);
  1977. /*! @brief Sets the GLFW timer.
  1978. *
  1979. * This function sets the value of the GLFW timer. It then continues to count
  1980. * up from that value.
  1981. *
  1982. * @param[in] time The new value, in seconds.
  1983. *
  1984. * @note The resolution of the timer is system dependent, but is usually on the
  1985. * order of a few micro- or nanoseconds. It uses the highest-resolution
  1986. * monotonic time source on each supported platform.
  1987. *
  1988. * @ingroup time
  1989. */
  1990. GLFWAPI void glfwSetTime(double time);
  1991. /*! @brief Makes the context of the specified window current for the calling
  1992. * thread.
  1993. *
  1994. * This function makes the context of the specified window current on the
  1995. * calling thread. A context can only be made current on a single thread at
  1996. * a time and each thread can have only a single current context at a time.
  1997. *
  1998. * @param[in] window The window whose context to make current, or `NULL` to
  1999. * detach the current context.
  2000. *
  2001. * @remarks This function may be called from secondary threads.
  2002. *
  2003. * @sa glfwGetCurrentContext
  2004. *
  2005. * @ingroup context
  2006. */
  2007. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  2008. /*! @brief Returns the window whose context is current on the calling thread.
  2009. *
  2010. * This function returns the window whose context is current on the calling
  2011. * thread.
  2012. *
  2013. * @return The window whose context is current, or `NULL` if no window's
  2014. * context is current.
  2015. *
  2016. * @remarks This function may be called from secondary threads.
  2017. *
  2018. * @sa glfwMakeContextCurrent
  2019. *
  2020. * @ingroup context
  2021. */
  2022. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  2023. /*! @brief Swaps the front and back buffers of the specified window.
  2024. *
  2025. * This function swaps the front and back buffers of the specified window. If
  2026. * the swap interval is greater than zero, the GPU driver waits the specified
  2027. * number of screen updates before swapping the buffers.
  2028. *
  2029. * @param[in] window The window whose buffers to swap.
  2030. *
  2031. * @remarks This function may be called from secondary threads.
  2032. *
  2033. * @par New in GLFW 3
  2034. * This function no longer calls @ref glfwPollEvents. You need to call it or
  2035. * @ref glfwWaitEvents yourself.
  2036. *
  2037. * @sa glfwSwapInterval
  2038. *
  2039. * @ingroup context
  2040. */
  2041. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  2042. /*! @brief Sets the swap interval for the current context.
  2043. *
  2044. * This function sets the swap interval for the current context, i.e. the
  2045. * number of screen updates to wait before swapping the buffers of a window and
  2046. * returning from @ref glfwSwapBuffers. This is sometimes called 'vertical
  2047. * synchronization', 'vertical retrace synchronization' or 'vsync'.
  2048. *
  2049. * Contexts that support either of the `WGL_EXT_swap_control_tear` and
  2050. * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,
  2051. * which allow the driver to swap even if a frame arrives a little bit late.
  2052. * You can check for the presence of these extensions using @ref
  2053. * glfwExtensionSupported. For more information about swap tearing, see the
  2054. * extension specifications.
  2055. *
  2056. * @param[in] interval The minimum number of screen updates to wait for
  2057. * until the buffers are swapped by @ref glfwSwapBuffers.
  2058. *
  2059. * @remarks This function may be called from secondary threads.
  2060. *
  2061. * @note Some GPU drivers do not honor the requested swap interval, either
  2062. * because of user settings that override the request or due to bugs in the
  2063. * driver.
  2064. *
  2065. * @sa glfwSwapBuffers
  2066. *
  2067. * @ingroup context
  2068. */
  2069. GLFWAPI void glfwSwapInterval(int interval);
  2070. /*! @brief Returns whether the specified extension is available.
  2071. *
  2072. * This function returns whether the specified
  2073. * [OpenGL or context creation API extension](@ref context_glext) is supported
  2074. * by the current context. For example, on Windows both the OpenGL and WGL
  2075. * extension strings are checked.
  2076. *
  2077. * @param[in] extension The ASCII encoded name of the extension.
  2078. * @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise.
  2079. *
  2080. * @remarks This function may be called from secondary threads.
  2081. *
  2082. * @note As this functions searches one or more extension strings on each call,
  2083. * it is recommended that you cache its results if it's going to be used
  2084. * frequently. The extension strings will not change during the lifetime of
  2085. * a context, so there is no danger in doing this.
  2086. *
  2087. * @ingroup context
  2088. */
  2089. GLFWAPI int glfwExtensionSupported(const char* extension);
  2090. /*! @brief Returns the address of the specified function for the current
  2091. * context.
  2092. *
  2093. * This function returns the address of the specified
  2094. * [client API or extension function](@ref context_glext), if it is supported
  2095. * by the current context.
  2096. *
  2097. * @param[in] procname The ASCII encoded name of the function.
  2098. * @return The address of the function, or `NULL` if the function is
  2099. * unavailable.
  2100. *
  2101. * @remarks This function may be called from secondary threads.
  2102. *
  2103. * @note The addresses of these functions are not guaranteed to be the same for
  2104. * all contexts, especially if they use different client APIs or even different
  2105. * context creation hints.
  2106. *
  2107. * @ingroup context
  2108. */
  2109. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  2110. /*************************************************************************
  2111. * Global definition cleanup
  2112. *************************************************************************/
  2113. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  2114. #ifdef GLFW_WINGDIAPI_DEFINED
  2115. #undef WINGDIAPI
  2116. #undef GLFW_WINGDIAPI_DEFINED
  2117. #endif
  2118. #ifdef GLFW_CALLBACK_DEFINED
  2119. #undef CALLBACK
  2120. #undef GLFW_CALLBACK_DEFINED
  2121. #endif
  2122. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  2123. #ifdef __cplusplus
  2124. }
  2125. #endif
  2126. #endif /* _glfw3_h_ */