glfw3.h 112 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340
  1. /*************************************************************************
  2. * GLFW 3.1 - 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 <elmindreda@elmindreda.org>
  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 context Context handling
  37. *
  38. * This is the reference documentation for context related functions. For more
  39. * information, see the @ref context.
  40. */
  41. /*! @defgroup init Initialization, version and errors
  42. *
  43. * This is the reference documentation for initialization and termination of
  44. * the library, version management and error handling. For more information,
  45. * see the @ref intro.
  46. */
  47. /*! @defgroup input Input handling
  48. *
  49. * This is the reference documentation for input related functions and types.
  50. * For more information, see the @ref input.
  51. */
  52. /*! @defgroup monitor Monitor handling
  53. *
  54. * This is the reference documentation for monitor related functions and types.
  55. * For more information, see the @ref monitor.
  56. */
  57. /*! @defgroup window Window handling
  58. *
  59. * This is the reference documentation for window related functions and types,
  60. * including creation, deletion and event polling. For more information, see
  61. * the @ref window.
  62. */
  63. /*************************************************************************
  64. * Compiler- and platform-specific preprocessor work
  65. *************************************************************************/
  66. /* If we are we on Windows, we want a single define for it.
  67. */
  68. #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
  69. #define _WIN32
  70. #endif /* _WIN32 */
  71. /* It is customary to use APIENTRY for OpenGL function pointer declarations on
  72. * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
  73. */
  74. #ifndef APIENTRY
  75. #ifdef _WIN32
  76. #define APIENTRY __stdcall
  77. #else
  78. #define APIENTRY
  79. #endif
  80. #endif /* APIENTRY */
  81. /* Some Windows OpenGL headers need this.
  82. */
  83. #if !defined(WINGDIAPI) && defined(_WIN32)
  84. #define WINGDIAPI __declspec(dllimport)
  85. #define GLFW_WINGDIAPI_DEFINED
  86. #endif /* WINGDIAPI */
  87. /* Some Windows GLU headers need this.
  88. */
  89. #if !defined(CALLBACK) && defined(_WIN32)
  90. #define CALLBACK __stdcall
  91. #define GLFW_CALLBACK_DEFINED
  92. #endif /* CALLBACK */
  93. /* Most Windows GLU headers need wchar_t.
  94. * The OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.
  95. */
  96. #if !defined(GLFW_INCLUDE_NONE)
  97. #include <stddef.h>
  98. #endif
  99. /* Include the chosen client API headers.
  100. */
  101. #if defined(__APPLE_CC__)
  102. #if defined(GLFW_INCLUDE_GLCOREARB)
  103. #include <OpenGL/gl3.h>
  104. #if defined(GLFW_INCLUDE_GLEXT)
  105. #include <OpenGL/gl3ext.h>
  106. #endif
  107. #elif !defined(GLFW_INCLUDE_NONE)
  108. #if !defined(GLFW_INCLUDE_GLEXT)
  109. #define GL_GLEXT_LEGACY
  110. #endif
  111. #include <OpenGL/gl.h>
  112. #endif
  113. #if defined(GLFW_INCLUDE_GLU)
  114. #include <OpenGL/glu.h>
  115. #endif
  116. #else
  117. #if defined(GLFW_INCLUDE_GLCOREARB)
  118. #include <GL/glcorearb.h>
  119. #elif defined(GLFW_INCLUDE_ES1)
  120. #include <GLES/gl.h>
  121. #if defined(GLFW_INCLUDE_GLEXT)
  122. #include <GLES/glext.h>
  123. #endif
  124. #elif defined(GLFW_INCLUDE_ES2)
  125. #include <GLES2/gl2.h>
  126. #if defined(GLFW_INCLUDE_GLEXT)
  127. #include <GLES2/gl2ext.h>
  128. #endif
  129. #elif defined(GLFW_INCLUDE_ES3)
  130. #include <GLES3/gl3.h>
  131. #if defined(GLFW_INCLUDE_GLEXT)
  132. #include <GLES3/gl2ext.h>
  133. #endif
  134. #elif defined(GLFW_INCLUDE_ES31)
  135. #include <GLES3/gl31.h>
  136. #if defined(GLFW_INCLUDE_GLEXT)
  137. #include <GLES3/gl2ext.h>
  138. #endif
  139. #elif !defined(GLFW_INCLUDE_NONE)
  140. #include <GL/gl.h>
  141. #if defined(GLFW_INCLUDE_GLEXT)
  142. #include <GL/glext.h>
  143. #endif
  144. #endif
  145. #if defined(GLFW_INCLUDE_GLU)
  146. #include <GL/glu.h>
  147. #endif
  148. #endif
  149. #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
  150. /* GLFW_DLL must be defined by applications that are linking against the DLL
  151. * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
  152. * configuration header when compiling the DLL version of the library.
  153. */
  154. #error "You may not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
  155. #endif
  156. /* GLFWAPI is used to declare public API functions for export
  157. * from the DLL / shared library / dynamic library.
  158. */
  159. #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
  160. /* We are building GLFW as a Win32 DLL */
  161. #define GLFWAPI __declspec(dllexport)
  162. #elif defined(_WIN32) && defined(GLFW_DLL)
  163. /* We are calling GLFW as a Win32 DLL */
  164. #define GLFWAPI __declspec(dllimport)
  165. #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
  166. /* We are building GLFW as a shared / dynamic library */
  167. #define GLFWAPI __attribute__((visibility("default")))
  168. #else
  169. /* We are building or calling GLFW as a static library */
  170. #define GLFWAPI
  171. #endif
  172. /*************************************************************************
  173. * GLFW API tokens
  174. *************************************************************************/
  175. /*! @name GLFW version macros
  176. * @{ */
  177. /*! @brief The major version number of the GLFW library.
  178. *
  179. * This is incremented when the API is changed in non-compatible ways.
  180. * @ingroup init
  181. */
  182. #define GLFW_VERSION_MAJOR 3
  183. /*! @brief The minor version number of the GLFW library.
  184. *
  185. * This is incremented when features are added to the API but it remains
  186. * backward-compatible.
  187. * @ingroup init
  188. */
  189. #define GLFW_VERSION_MINOR 1
  190. /*! @brief The revision number of the GLFW library.
  191. *
  192. * This is incremented when a bug fix release is made that does not contain any
  193. * API changes.
  194. * @ingroup init
  195. */
  196. #define GLFW_VERSION_REVISION 1
  197. /*! @} */
  198. /*! @name Key and button actions
  199. * @{ */
  200. /*! @brief The key or mouse button was released.
  201. *
  202. * The key or mouse button was released.
  203. *
  204. * @ingroup input
  205. */
  206. #define GLFW_RELEASE 0
  207. /*! @brief The key or mouse button was pressed.
  208. *
  209. * The key or mouse button was pressed.
  210. *
  211. * @ingroup input
  212. */
  213. #define GLFW_PRESS 1
  214. /*! @brief The key was held down until it repeated.
  215. *
  216. * The key was held down until it repeated.
  217. *
  218. * @ingroup input
  219. */
  220. #define GLFW_REPEAT 2
  221. /*! @} */
  222. /*! @defgroup keys Keyboard keys
  223. *
  224. * See [key input](@ref input_key) for how these are used.
  225. *
  226. * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
  227. * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
  228. * put in the 256+ range).
  229. *
  230. * The naming of the key codes follow these rules:
  231. * - The US keyboard layout is used
  232. * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
  233. * "3", etc.)
  234. * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
  235. * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
  236. * correspond to the Unicode standard (usually for brevity)
  237. * - Keys that lack a clear US mapping are named "WORLD_x"
  238. * - For non-printable keys, custom names are used (e.g. "F4",
  239. * "BACKSPACE", etc.)
  240. *
  241. * @ingroup input
  242. * @{
  243. */
  244. /* The unknown key */
  245. #define GLFW_KEY_UNKNOWN -1
  246. /* Printable keys */
  247. #define GLFW_KEY_SPACE 32
  248. #define GLFW_KEY_APOSTROPHE 39 /* ' */
  249. #define GLFW_KEY_COMMA 44 /* , */
  250. #define GLFW_KEY_MINUS 45 /* - */
  251. #define GLFW_KEY_PERIOD 46 /* . */
  252. #define GLFW_KEY_SLASH 47 /* / */
  253. #define GLFW_KEY_0 48
  254. #define GLFW_KEY_1 49
  255. #define GLFW_KEY_2 50
  256. #define GLFW_KEY_3 51
  257. #define GLFW_KEY_4 52
  258. #define GLFW_KEY_5 53
  259. #define GLFW_KEY_6 54
  260. #define GLFW_KEY_7 55
  261. #define GLFW_KEY_8 56
  262. #define GLFW_KEY_9 57
  263. #define GLFW_KEY_SEMICOLON 59 /* ; */
  264. #define GLFW_KEY_EQUAL 61 /* = */
  265. #define GLFW_KEY_A 65
  266. #define GLFW_KEY_B 66
  267. #define GLFW_KEY_C 67
  268. #define GLFW_KEY_D 68
  269. #define GLFW_KEY_E 69
  270. #define GLFW_KEY_F 70
  271. #define GLFW_KEY_G 71
  272. #define GLFW_KEY_H 72
  273. #define GLFW_KEY_I 73
  274. #define GLFW_KEY_J 74
  275. #define GLFW_KEY_K 75
  276. #define GLFW_KEY_L 76
  277. #define GLFW_KEY_M 77
  278. #define GLFW_KEY_N 78
  279. #define GLFW_KEY_O 79
  280. #define GLFW_KEY_P 80
  281. #define GLFW_KEY_Q 81
  282. #define GLFW_KEY_R 82
  283. #define GLFW_KEY_S 83
  284. #define GLFW_KEY_T 84
  285. #define GLFW_KEY_U 85
  286. #define GLFW_KEY_V 86
  287. #define GLFW_KEY_W 87
  288. #define GLFW_KEY_X 88
  289. #define GLFW_KEY_Y 89
  290. #define GLFW_KEY_Z 90
  291. #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
  292. #define GLFW_KEY_BACKSLASH 92 /* \ */
  293. #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
  294. #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
  295. #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
  296. #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
  297. /* Function keys */
  298. #define GLFW_KEY_ESCAPE 256
  299. #define GLFW_KEY_ENTER 257
  300. #define GLFW_KEY_TAB 258
  301. #define GLFW_KEY_BACKSPACE 259
  302. #define GLFW_KEY_INSERT 260
  303. #define GLFW_KEY_DELETE 261
  304. #define GLFW_KEY_RIGHT 262
  305. #define GLFW_KEY_LEFT 263
  306. #define GLFW_KEY_DOWN 264
  307. #define GLFW_KEY_UP 265
  308. #define GLFW_KEY_PAGE_UP 266
  309. #define GLFW_KEY_PAGE_DOWN 267
  310. #define GLFW_KEY_HOME 268
  311. #define GLFW_KEY_END 269
  312. #define GLFW_KEY_CAPS_LOCK 280
  313. #define GLFW_KEY_SCROLL_LOCK 281
  314. #define GLFW_KEY_NUM_LOCK 282
  315. #define GLFW_KEY_PRINT_SCREEN 283
  316. #define GLFW_KEY_PAUSE 284
  317. #define GLFW_KEY_F1 290
  318. #define GLFW_KEY_F2 291
  319. #define GLFW_KEY_F3 292
  320. #define GLFW_KEY_F4 293
  321. #define GLFW_KEY_F5 294
  322. #define GLFW_KEY_F6 295
  323. #define GLFW_KEY_F7 296
  324. #define GLFW_KEY_F8 297
  325. #define GLFW_KEY_F9 298
  326. #define GLFW_KEY_F10 299
  327. #define GLFW_KEY_F11 300
  328. #define GLFW_KEY_F12 301
  329. #define GLFW_KEY_F13 302
  330. #define GLFW_KEY_F14 303
  331. #define GLFW_KEY_F15 304
  332. #define GLFW_KEY_F16 305
  333. #define GLFW_KEY_F17 306
  334. #define GLFW_KEY_F18 307
  335. #define GLFW_KEY_F19 308
  336. #define GLFW_KEY_F20 309
  337. #define GLFW_KEY_F21 310
  338. #define GLFW_KEY_F22 311
  339. #define GLFW_KEY_F23 312
  340. #define GLFW_KEY_F24 313
  341. #define GLFW_KEY_F25 314
  342. #define GLFW_KEY_KP_0 320
  343. #define GLFW_KEY_KP_1 321
  344. #define GLFW_KEY_KP_2 322
  345. #define GLFW_KEY_KP_3 323
  346. #define GLFW_KEY_KP_4 324
  347. #define GLFW_KEY_KP_5 325
  348. #define GLFW_KEY_KP_6 326
  349. #define GLFW_KEY_KP_7 327
  350. #define GLFW_KEY_KP_8 328
  351. #define GLFW_KEY_KP_9 329
  352. #define GLFW_KEY_KP_DECIMAL 330
  353. #define GLFW_KEY_KP_DIVIDE 331
  354. #define GLFW_KEY_KP_MULTIPLY 332
  355. #define GLFW_KEY_KP_SUBTRACT 333
  356. #define GLFW_KEY_KP_ADD 334
  357. #define GLFW_KEY_KP_ENTER 335
  358. #define GLFW_KEY_KP_EQUAL 336
  359. #define GLFW_KEY_LEFT_SHIFT 340
  360. #define GLFW_KEY_LEFT_CONTROL 341
  361. #define GLFW_KEY_LEFT_ALT 342
  362. #define GLFW_KEY_LEFT_SUPER 343
  363. #define GLFW_KEY_RIGHT_SHIFT 344
  364. #define GLFW_KEY_RIGHT_CONTROL 345
  365. #define GLFW_KEY_RIGHT_ALT 346
  366. #define GLFW_KEY_RIGHT_SUPER 347
  367. #define GLFW_KEY_MENU 348
  368. #define GLFW_KEY_LAST GLFW_KEY_MENU
  369. /*! @} */
  370. /*! @defgroup mods Modifier key flags
  371. *
  372. * See [key input](@ref input_key) for how these are used.
  373. *
  374. * @ingroup input
  375. * @{ */
  376. /*! @brief If this bit is set one or more Shift keys were held down.
  377. */
  378. #define GLFW_MOD_SHIFT 0x0001
  379. /*! @brief If this bit is set one or more Control keys were held down.
  380. */
  381. #define GLFW_MOD_CONTROL 0x0002
  382. /*! @brief If this bit is set one or more Alt keys were held down.
  383. */
  384. #define GLFW_MOD_ALT 0x0004
  385. /*! @brief If this bit is set one or more Super keys were held down.
  386. */
  387. #define GLFW_MOD_SUPER 0x0008
  388. /*! @} */
  389. /*! @defgroup buttons Mouse buttons
  390. *
  391. * See [mouse button input](@ref input_mouse_button) for how these are used.
  392. *
  393. * @ingroup input
  394. * @{ */
  395. #define GLFW_MOUSE_BUTTON_1 0
  396. #define GLFW_MOUSE_BUTTON_2 1
  397. #define GLFW_MOUSE_BUTTON_3 2
  398. #define GLFW_MOUSE_BUTTON_4 3
  399. #define GLFW_MOUSE_BUTTON_5 4
  400. #define GLFW_MOUSE_BUTTON_6 5
  401. #define GLFW_MOUSE_BUTTON_7 6
  402. #define GLFW_MOUSE_BUTTON_8 7
  403. #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
  404. #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
  405. #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
  406. #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
  407. /*! @} */
  408. /*! @defgroup joysticks Joysticks
  409. *
  410. * See [joystick input](@ref joystick) for how these are used.
  411. *
  412. * @ingroup input
  413. * @{ */
  414. #define GLFW_JOYSTICK_1 0
  415. #define GLFW_JOYSTICK_2 1
  416. #define GLFW_JOYSTICK_3 2
  417. #define GLFW_JOYSTICK_4 3
  418. #define GLFW_JOYSTICK_5 4
  419. #define GLFW_JOYSTICK_6 5
  420. #define GLFW_JOYSTICK_7 6
  421. #define GLFW_JOYSTICK_8 7
  422. #define GLFW_JOYSTICK_9 8
  423. #define GLFW_JOYSTICK_10 9
  424. #define GLFW_JOYSTICK_11 10
  425. #define GLFW_JOYSTICK_12 11
  426. #define GLFW_JOYSTICK_13 12
  427. #define GLFW_JOYSTICK_14 13
  428. #define GLFW_JOYSTICK_15 14
  429. #define GLFW_JOYSTICK_16 15
  430. #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
  431. /*! @} */
  432. /*! @defgroup errors Error codes
  433. *
  434. * See [error handling](@ref error_handling) for how these are used.
  435. *
  436. * @ingroup init
  437. * @{ */
  438. /*! @brief GLFW has not been initialized.
  439. *
  440. * This occurs if a GLFW function was called that may not be called unless the
  441. * library is [initialized](@ref intro_init).
  442. *
  443. * @par Analysis
  444. * Application programmer error. Initialize GLFW before calling any function
  445. * that requires initialization.
  446. */
  447. #define GLFW_NOT_INITIALIZED 0x00010001
  448. /*! @brief No context is current for this thread.
  449. *
  450. * This occurs if a GLFW function was called that needs and operates on the
  451. * current OpenGL or OpenGL ES context but no context is current on the calling
  452. * thread. One such function is @ref glfwSwapInterval.
  453. *
  454. * @par Analysis
  455. * Application programmer error. Ensure a context is current before calling
  456. * functions that require a current context.
  457. */
  458. #define GLFW_NO_CURRENT_CONTEXT 0x00010002
  459. /*! @brief One of the arguments to the function was an invalid enum value.
  460. *
  461. * One of the arguments to the function was an invalid enum value, for example
  462. * requesting [GLFW_RED_BITS](@ref window_hints_fb) with @ref
  463. * glfwGetWindowAttrib.
  464. *
  465. * @par Analysis
  466. * Application programmer error. Fix the offending call.
  467. */
  468. #define GLFW_INVALID_ENUM 0x00010003
  469. /*! @brief One of the arguments to the function was an invalid value.
  470. *
  471. * One of the arguments to the function was an invalid value, for example
  472. * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
  473. *
  474. * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
  475. * result in a @ref GLFW_VERSION_UNAVAILABLE error.
  476. *
  477. * @par Analysis
  478. * Application programmer error. Fix the offending call.
  479. */
  480. #define GLFW_INVALID_VALUE 0x00010004
  481. /*! @brief A memory allocation failed.
  482. *
  483. * A memory allocation failed.
  484. *
  485. * @par Analysis
  486. * A bug in GLFW or the underlying operating system. Report the bug to our
  487. * [issue tracker](https://github.com/glfw/glfw/issues).
  488. */
  489. #define GLFW_OUT_OF_MEMORY 0x00010005
  490. /*! @brief GLFW could not find support for the requested client API on the
  491. * system.
  492. *
  493. * GLFW could not find support for the requested client API on the system. If
  494. * emitted by functions other than @ref glfwCreateWindow, no supported client
  495. * API was found.
  496. *
  497. * @par Analysis
  498. * The installed graphics driver does not support the requested client API, or
  499. * does not support it via the chosen context creation backend. Below are
  500. * a few examples.
  501. *
  502. * @par
  503. * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
  504. * supports OpenGL ES via EGL, while Nvidia and Intel only supports it via
  505. * a WGL or GLX extension. OS X does not provide OpenGL ES at all. The Mesa
  506. * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
  507. * driver.
  508. */
  509. #define GLFW_API_UNAVAILABLE 0x00010006
  510. /*! @brief The requested OpenGL or OpenGL ES version is not available.
  511. *
  512. * The requested OpenGL or OpenGL ES version (including any requested context
  513. * or framebuffer hints) is not available on this machine.
  514. *
  515. * @par Analysis
  516. * The machine does not support your requirements. If your application is
  517. * sufficiently flexible, downgrade your requirements and try again.
  518. * Otherwise, inform the user that their machine does not match your
  519. * requirements.
  520. *
  521. * @par
  522. * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
  523. * comes out before the 4.x series gets that far, also fail with this error and
  524. * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
  525. * will exist.
  526. */
  527. #define GLFW_VERSION_UNAVAILABLE 0x00010007
  528. /*! @brief A platform-specific error occurred that does not match any of the
  529. * more specific categories.
  530. *
  531. * A platform-specific error occurred that does not match any of the more
  532. * specific categories.
  533. *
  534. * @par Analysis
  535. * A bug or configuration error in GLFW, the underlying operating system or
  536. * its drivers, or a lack of required resources. Report the issue to our
  537. * [issue tracker](https://github.com/glfw/glfw/issues).
  538. */
  539. #define GLFW_PLATFORM_ERROR 0x00010008
  540. /*! @brief The requested format is not supported or available.
  541. *
  542. * If emitted during window creation, the requested pixel format is not
  543. * supported.
  544. *
  545. * If emitted when querying the clipboard, the contents of the clipboard could
  546. * not be converted to the requested format.
  547. *
  548. * @par Analysis
  549. * If emitted during window creation, one or more
  550. * [hard constraints](@ref window_hints_hard) did not match any of the
  551. * available pixel formats. If your application is sufficiently flexible,
  552. * downgrade your requirements and try again. Otherwise, inform the user that
  553. * their machine does not match your requirements.
  554. *
  555. * @par
  556. * If emitted when querying the clipboard, ignore the error or report it to
  557. * the user, as appropriate.
  558. */
  559. #define GLFW_FORMAT_UNAVAILABLE 0x00010009
  560. /*! @} */
  561. #define GLFW_FOCUSED 0x00020001
  562. #define GLFW_ICONIFIED 0x00020002
  563. #define GLFW_RESIZABLE 0x00020003
  564. #define GLFW_VISIBLE 0x00020004
  565. #define GLFW_DECORATED 0x00020005
  566. #define GLFW_AUTO_ICONIFY 0x00020006
  567. #define GLFW_FLOATING 0x00020007
  568. #define GLFW_RED_BITS 0x00021001
  569. #define GLFW_GREEN_BITS 0x00021002
  570. #define GLFW_BLUE_BITS 0x00021003
  571. #define GLFW_ALPHA_BITS 0x00021004
  572. #define GLFW_DEPTH_BITS 0x00021005
  573. #define GLFW_STENCIL_BITS 0x00021006
  574. #define GLFW_ACCUM_RED_BITS 0x00021007
  575. #define GLFW_ACCUM_GREEN_BITS 0x00021008
  576. #define GLFW_ACCUM_BLUE_BITS 0x00021009
  577. #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
  578. #define GLFW_AUX_BUFFERS 0x0002100B
  579. #define GLFW_STEREO 0x0002100C
  580. #define GLFW_SAMPLES 0x0002100D
  581. #define GLFW_SRGB_CAPABLE 0x0002100E
  582. #define GLFW_REFRESH_RATE 0x0002100F
  583. #define GLFW_DOUBLEBUFFER 0x00021010
  584. #define GLFW_CLIENT_API 0x00022001
  585. #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
  586. #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
  587. #define GLFW_CONTEXT_REVISION 0x00022004
  588. #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
  589. #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
  590. #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
  591. #define GLFW_OPENGL_PROFILE 0x00022008
  592. #define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
  593. #define GLFW_OPENGL_API 0x00030001
  594. #define GLFW_OPENGL_ES_API 0x00030002
  595. #define GLFW_NO_ROBUSTNESS 0
  596. #define GLFW_NO_RESET_NOTIFICATION 0x00031001
  597. #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
  598. #define GLFW_OPENGL_ANY_PROFILE 0
  599. #define GLFW_OPENGL_CORE_PROFILE 0x00032001
  600. #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
  601. #define GLFW_CURSOR 0x00033001
  602. #define GLFW_STICKY_KEYS 0x00033002
  603. #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
  604. #define GLFW_CURSOR_NORMAL 0x00034001
  605. #define GLFW_CURSOR_HIDDEN 0x00034002
  606. #define GLFW_CURSOR_DISABLED 0x00034003
  607. #define GLFW_ANY_RELEASE_BEHAVIOR 0
  608. #define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
  609. #define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
  610. /*! @defgroup shapes Standard cursor shapes
  611. *
  612. * See [standard cursor creation](@ref cursor_standard) for how these are used.
  613. *
  614. * @ingroup input
  615. * @{ */
  616. /*! @brief The regular arrow cursor shape.
  617. *
  618. * The regular arrow cursor.
  619. */
  620. #define GLFW_ARROW_CURSOR 0x00036001
  621. /*! @brief The text input I-beam cursor shape.
  622. *
  623. * The text input I-beam cursor shape.
  624. */
  625. #define GLFW_IBEAM_CURSOR 0x00036002
  626. /*! @brief The crosshair shape.
  627. *
  628. * The crosshair shape.
  629. */
  630. #define GLFW_CROSSHAIR_CURSOR 0x00036003
  631. /*! @brief The hand shape.
  632. *
  633. * The hand shape.
  634. */
  635. #define GLFW_HAND_CURSOR 0x00036004
  636. /*! @brief The horizontal resize arrow shape.
  637. *
  638. * The horizontal resize arrow shape.
  639. */
  640. #define GLFW_HRESIZE_CURSOR 0x00036005
  641. /*! @brief The vertical resize arrow shape.
  642. *
  643. * The vertical resize arrow shape.
  644. */
  645. #define GLFW_VRESIZE_CURSOR 0x00036006
  646. /*! @} */
  647. #define GLFW_CONNECTED 0x00040001
  648. #define GLFW_DISCONNECTED 0x00040002
  649. #define GLFW_DONT_CARE -1
  650. /*************************************************************************
  651. * GLFW API types
  652. *************************************************************************/
  653. /*! @brief Client API function pointer type.
  654. *
  655. * Generic function pointer used for returning client API function pointers
  656. * without forcing a cast from a regular pointer.
  657. *
  658. * @ingroup context
  659. */
  660. typedef void (*GLFWglproc)(void);
  661. /*! @brief Opaque monitor object.
  662. *
  663. * Opaque monitor object.
  664. *
  665. * @ingroup monitor
  666. */
  667. typedef struct GLFWmonitor GLFWmonitor;
  668. /*! @brief Opaque window object.
  669. *
  670. * Opaque window object.
  671. *
  672. * @ingroup window
  673. */
  674. typedef struct GLFWwindow GLFWwindow;
  675. /*! @brief Opaque cursor object.
  676. *
  677. * Opaque cursor object.
  678. *
  679. * @ingroup cursor
  680. */
  681. typedef struct GLFWcursor GLFWcursor;
  682. /*! @brief The function signature for error callbacks.
  683. *
  684. * This is the function signature for error callback functions.
  685. *
  686. * @param[in] error An [error code](@ref errors).
  687. * @param[in] description A UTF-8 encoded string describing the error.
  688. *
  689. * @sa glfwSetErrorCallback
  690. *
  691. * @ingroup init
  692. */
  693. typedef void (* GLFWerrorfun)(int,const char*);
  694. /*! @brief The function signature for window position callbacks.
  695. *
  696. * This is the function signature for window position callback functions.
  697. *
  698. * @param[in] window The window that was moved.
  699. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  700. * upper-left corner of the client area of the window.
  701. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  702. * upper-left corner of the client area of the window.
  703. *
  704. * @sa glfwSetWindowPosCallback
  705. *
  706. * @ingroup window
  707. */
  708. typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
  709. /*! @brief The function signature for window resize callbacks.
  710. *
  711. * This is the function signature for window size callback functions.
  712. *
  713. * @param[in] window The window that was resized.
  714. * @param[in] width The new width, in screen coordinates, of the window.
  715. * @param[in] height The new height, in screen coordinates, of the window.
  716. *
  717. * @sa glfwSetWindowSizeCallback
  718. *
  719. * @ingroup window
  720. */
  721. typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
  722. /*! @brief The function signature for window close callbacks.
  723. *
  724. * This is the function signature for window close callback functions.
  725. *
  726. * @param[in] window The window that the user attempted to close.
  727. *
  728. * @sa glfwSetWindowCloseCallback
  729. *
  730. * @ingroup window
  731. */
  732. typedef void (* GLFWwindowclosefun)(GLFWwindow*);
  733. /*! @brief The function signature for window content refresh callbacks.
  734. *
  735. * This is the function signature for window refresh callback functions.
  736. *
  737. * @param[in] window The window whose content needs to be refreshed.
  738. *
  739. * @sa glfwSetWindowRefreshCallback
  740. *
  741. * @ingroup window
  742. */
  743. typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
  744. /*! @brief The function signature for window focus/defocus callbacks.
  745. *
  746. * This is the function signature for window focus callback functions.
  747. *
  748. * @param[in] window The window that gained or lost input focus.
  749. * @param[in] focused `GL_TRUE` if the window was given input focus, or
  750. * `GL_FALSE` if it lost it.
  751. *
  752. * @sa glfwSetWindowFocusCallback
  753. *
  754. * @ingroup window
  755. */
  756. typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
  757. /*! @brief The function signature for window iconify/restore callbacks.
  758. *
  759. * This is the function signature for window iconify/restore callback
  760. * functions.
  761. *
  762. * @param[in] window The window that was iconified or restored.
  763. * @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`
  764. * if it was restored.
  765. *
  766. * @sa glfwSetWindowIconifyCallback
  767. *
  768. * @ingroup window
  769. */
  770. typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
  771. /*! @brief The function signature for framebuffer resize callbacks.
  772. *
  773. * This is the function signature for framebuffer resize callback
  774. * functions.
  775. *
  776. * @param[in] window The window whose framebuffer was resized.
  777. * @param[in] width The new width, in pixels, of the framebuffer.
  778. * @param[in] height The new height, in pixels, of the framebuffer.
  779. *
  780. * @sa glfwSetFramebufferSizeCallback
  781. *
  782. * @ingroup window
  783. */
  784. typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
  785. /*! @brief The function signature for mouse button callbacks.
  786. *
  787. * This is the function signature for mouse button callback functions.
  788. *
  789. * @param[in] window The window that received the event.
  790. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  791. * released.
  792. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
  793. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  794. * held down.
  795. *
  796. * @sa glfwSetMouseButtonCallback
  797. *
  798. * @ingroup input
  799. */
  800. typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
  801. /*! @brief The function signature for cursor position callbacks.
  802. *
  803. * This is the function signature for cursor position callback functions.
  804. *
  805. * @param[in] window The window that received the event.
  806. * @param[in] xpos The new x-coordinate, in screen coordinates, of the cursor.
  807. * @param[in] ypos The new y-coordinate, in screen coordinates, of the cursor.
  808. *
  809. * @sa glfwSetCursorPosCallback
  810. *
  811. * @ingroup input
  812. */
  813. typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
  814. /*! @brief The function signature for cursor enter/leave callbacks.
  815. *
  816. * This is the function signature for cursor enter/leave callback functions.
  817. *
  818. * @param[in] window The window that received the event.
  819. * @param[in] entered `GL_TRUE` if the cursor entered the window's client
  820. * area, or `GL_FALSE` if it left it.
  821. *
  822. * @sa glfwSetCursorEnterCallback
  823. *
  824. * @ingroup input
  825. */
  826. typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
  827. /*! @brief The function signature for scroll callbacks.
  828. *
  829. * This is the function signature for scroll callback functions.
  830. *
  831. * @param[in] window The window that received the event.
  832. * @param[in] xoffset The scroll offset along the x-axis.
  833. * @param[in] yoffset The scroll offset along the y-axis.
  834. *
  835. * @sa glfwSetScrollCallback
  836. *
  837. * @ingroup input
  838. */
  839. typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
  840. /*! @brief The function signature for keyboard key callbacks.
  841. *
  842. * This is the function signature for keyboard key callback functions.
  843. *
  844. * @param[in] window The window that received the event.
  845. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
  846. * @param[in] scancode The system-specific scancode of the key.
  847. * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.
  848. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  849. * held down.
  850. *
  851. * @sa glfwSetKeyCallback
  852. *
  853. * @ingroup input
  854. */
  855. typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
  856. /*! @brief The function signature for Unicode character callbacks.
  857. *
  858. * This is the function signature for Unicode character callback functions.
  859. *
  860. * @param[in] window The window that received the event.
  861. * @param[in] codepoint The Unicode code point of the character.
  862. *
  863. * @sa glfwSetCharCallback
  864. *
  865. * @ingroup input
  866. */
  867. typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
  868. /*! @brief The function signature for Unicode character with modifiers
  869. * callbacks.
  870. *
  871. * This is the function signature for Unicode character with modifiers callback
  872. * functions. It is called for each input character, regardless of what
  873. * modifier keys are held down.
  874. *
  875. * @param[in] window The window that received the event.
  876. * @param[in] codepoint The Unicode code point of the character.
  877. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  878. * held down.
  879. *
  880. * @sa glfwSetCharModsCallback
  881. *
  882. * @ingroup input
  883. */
  884. typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
  885. /*! @brief The function signature for file drop callbacks.
  886. *
  887. * This is the function signature for file drop callbacks.
  888. *
  889. * @param[in] window The window that received the event.
  890. * @param[in] count The number of dropped files.
  891. * @param[in] paths The UTF-8 encoded file and/or directory path names.
  892. *
  893. * @sa glfwSetDropCallback
  894. *
  895. * @ingroup input
  896. */
  897. typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);
  898. /*! @brief The function signature for monitor configuration callbacks.
  899. *
  900. * This is the function signature for monitor configuration callback functions.
  901. *
  902. * @param[in] monitor The monitor that was connected or disconnected.
  903. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
  904. *
  905. * @sa glfwSetMonitorCallback
  906. *
  907. * @ingroup monitor
  908. */
  909. typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
  910. /*! @brief Video mode type.
  911. *
  912. * This describes a single video mode.
  913. *
  914. * @ingroup monitor
  915. */
  916. typedef struct GLFWvidmode
  917. {
  918. /*! The width, in screen coordinates, of the video mode.
  919. */
  920. int width;
  921. /*! The height, in screen coordinates, of the video mode.
  922. */
  923. int height;
  924. /*! The bit depth of the red channel of the video mode.
  925. */
  926. int redBits;
  927. /*! The bit depth of the green channel of the video mode.
  928. */
  929. int greenBits;
  930. /*! The bit depth of the blue channel of the video mode.
  931. */
  932. int blueBits;
  933. /*! The refresh rate, in Hz, of the video mode.
  934. */
  935. int refreshRate;
  936. } GLFWvidmode;
  937. /*! @brief Gamma ramp.
  938. *
  939. * This describes the gamma ramp for a monitor.
  940. *
  941. * @sa glfwGetGammaRamp glfwSetGammaRamp
  942. *
  943. * @ingroup monitor
  944. */
  945. typedef struct GLFWgammaramp
  946. {
  947. /*! An array of value describing the response of the red channel.
  948. */
  949. unsigned short* red;
  950. /*! An array of value describing the response of the green channel.
  951. */
  952. unsigned short* green;
  953. /*! An array of value describing the response of the blue channel.
  954. */
  955. unsigned short* blue;
  956. /*! The number of elements in each array.
  957. */
  958. unsigned int size;
  959. } GLFWgammaramp;
  960. /*! @brief Image data.
  961. */
  962. typedef struct GLFWimage
  963. {
  964. /*! The width, in pixels, of this image.
  965. */
  966. int width;
  967. /*! The height, in pixels, of this image.
  968. */
  969. int height;
  970. /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
  971. */
  972. unsigned char* pixels;
  973. } GLFWimage;
  974. /*************************************************************************
  975. * GLFW API functions
  976. *************************************************************************/
  977. /*! @brief Initializes the GLFW library.
  978. *
  979. * This function initializes the GLFW library. Before most GLFW functions can
  980. * be used, GLFW must be initialized, and before an application terminates GLFW
  981. * should be terminated in order to free any resources allocated during or
  982. * after initialization.
  983. *
  984. * If this function fails, it calls @ref glfwTerminate before returning. If it
  985. * succeeds, you should call @ref glfwTerminate before the application exits.
  986. *
  987. * Additional calls to this function after successful initialization but before
  988. * termination will return `GL_TRUE` immediately.
  989. *
  990. * @return `GL_TRUE` if successful, or `GL_FALSE` if an
  991. * [error](@ref error_handling) occurred.
  992. *
  993. * @remarks __OS X:__ This function will change the current directory of the
  994. * application to the `Contents/Resources` subdirectory of the application's
  995. * bundle, if present. This can be disabled with a
  996. * [compile-time option](@ref compile_options_osx).
  997. *
  998. * @remarks __X11:__ If the `LC_CTYPE` category of the current locale is set to
  999. * `"C"` then the environment's locale will be applied to that category. This
  1000. * is done because character input will not function when `LC_CTYPE` is set to
  1001. * `"C"`. If another locale was set before this function was called, it will
  1002. * be left untouched.
  1003. *
  1004. * @par Thread Safety
  1005. * This function may only be called from the main thread.
  1006. *
  1007. * @sa @ref intro_init
  1008. * @sa glfwTerminate
  1009. *
  1010. * @since Added in GLFW 1.0.
  1011. *
  1012. * @ingroup init
  1013. */
  1014. GLFWAPI int glfwInit(void);
  1015. /*! @brief Terminates the GLFW library.
  1016. *
  1017. * This function destroys all remaining windows and cursors, restores any
  1018. * modified gamma ramps and frees any other allocated resources. Once this
  1019. * function is called, you must again call @ref glfwInit successfully before
  1020. * you will be able to use most GLFW functions.
  1021. *
  1022. * If GLFW has been successfully initialized, this function should be called
  1023. * before the application exits. If initialization fails, there is no need to
  1024. * call this function, as it is called by @ref glfwInit before it returns
  1025. * failure.
  1026. *
  1027. * @remarks This function may be called before @ref glfwInit.
  1028. *
  1029. * @warning No window's context may be current on another thread when this
  1030. * function is called.
  1031. *
  1032. * @par Reentrancy
  1033. * This function may not be called from a callback.
  1034. *
  1035. * @par Thread Safety
  1036. * This function may only be called from the main thread.
  1037. *
  1038. * @sa @ref intro_init
  1039. * @sa glfwInit
  1040. *
  1041. * @since Added in GLFW 1.0.
  1042. *
  1043. * @ingroup init
  1044. */
  1045. GLFWAPI void glfwTerminate(void);
  1046. /*! @brief Retrieves the version of the GLFW library.
  1047. *
  1048. * This function retrieves the major, minor and revision numbers of the GLFW
  1049. * library. It is intended for when you are using GLFW as a shared library and
  1050. * want to ensure that you are using the minimum required version.
  1051. *
  1052. * Any or all of the version arguments may be `NULL`. This function always
  1053. * succeeds.
  1054. *
  1055. * @param[out] major Where to store the major version number, or `NULL`.
  1056. * @param[out] minor Where to store the minor version number, or `NULL`.
  1057. * @param[out] rev Where to store the revision number, or `NULL`.
  1058. *
  1059. * @remarks This function may be called before @ref glfwInit.
  1060. *
  1061. * @par Thread Safety
  1062. * This function may be called from any thread.
  1063. *
  1064. * @sa @ref intro_version
  1065. * @sa glfwGetVersionString
  1066. *
  1067. * @since Added in GLFW 1.0.
  1068. *
  1069. * @ingroup init
  1070. */
  1071. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  1072. /*! @brief Returns a string describing the compile-time configuration.
  1073. *
  1074. * This function returns the compile-time generated
  1075. * [version string](@ref intro_version_string) of the GLFW library binary. It
  1076. * describes the version, platform, compiler and any platform-specific
  1077. * compile-time options.
  1078. *
  1079. * __Do not use the version string__ to parse the GLFW library version. The
  1080. * @ref glfwGetVersion function already provides the version of the running
  1081. * library binary.
  1082. *
  1083. * This function always succeeds.
  1084. *
  1085. * @return The GLFW version string.
  1086. *
  1087. * @remarks This function may be called before @ref glfwInit.
  1088. *
  1089. * @par Pointer Lifetime
  1090. * The returned string is static and compile-time generated.
  1091. *
  1092. * @par Thread Safety
  1093. * This function may be called from any thread.
  1094. *
  1095. * @sa @ref intro_version
  1096. * @sa glfwGetVersion
  1097. *
  1098. * @since Added in GLFW 3.0.
  1099. *
  1100. * @ingroup init
  1101. */
  1102. GLFWAPI const char* glfwGetVersionString(void);
  1103. /*! @brief Sets the error callback.
  1104. *
  1105. * This function sets the error callback, which is called with an error code
  1106. * and a human-readable description each time a GLFW error occurs.
  1107. *
  1108. * The error callback is called on the thread where the error occurred. If you
  1109. * are using GLFW from multiple threads, your error callback needs to be
  1110. * written accordingly.
  1111. *
  1112. * Because the description string may have been generated specifically for that
  1113. * error, it is not guaranteed to be valid after the callback has returned. If
  1114. * you wish to use it after the callback returns, you need to make a copy.
  1115. *
  1116. * Once set, the error callback remains set even after the library has been
  1117. * terminated.
  1118. *
  1119. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1120. * callback.
  1121. * @return The previously set callback, or `NULL` if no callback was set.
  1122. *
  1123. * @remarks This function may be called before @ref glfwInit.
  1124. *
  1125. * @par Thread Safety
  1126. * This function may only be called from the main thread.
  1127. *
  1128. * @sa @ref error_handling
  1129. *
  1130. * @since Added in GLFW 3.0.
  1131. *
  1132. * @ingroup init
  1133. */
  1134. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
  1135. /*! @brief Returns the currently connected monitors.
  1136. *
  1137. * This function returns an array of handles for all currently connected
  1138. * monitors.
  1139. *
  1140. * @param[out] count Where to store the number of monitors in the returned
  1141. * array. This is set to zero if an error occurred.
  1142. * @return An array of monitor handles, or `NULL` if an
  1143. * [error](@ref error_handling) occurred.
  1144. *
  1145. * @par Pointer Lifetime
  1146. * The returned array is allocated and freed by GLFW. You should not free it
  1147. * yourself. It is guaranteed to be valid only until the monitor configuration
  1148. * changes or the library is terminated.
  1149. *
  1150. * @par Thread Safety
  1151. * This function may only be called from the main thread.
  1152. *
  1153. * @sa @ref monitor_monitors
  1154. * @sa @ref monitor_event
  1155. * @sa glfwGetPrimaryMonitor
  1156. *
  1157. * @since Added in GLFW 3.0.
  1158. *
  1159. * @ingroup monitor
  1160. */
  1161. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  1162. /*! @brief Returns the primary monitor.
  1163. *
  1164. * This function returns the primary monitor. This is usually the monitor
  1165. * where elements like the Windows task bar or the OS X menu bar is located.
  1166. *
  1167. * @return The primary monitor, or `NULL` if an [error](@ref error_handling)
  1168. * occurred.
  1169. *
  1170. * @par Thread Safety
  1171. * This function may only be called from the main thread.
  1172. *
  1173. * @sa @ref monitor_monitors
  1174. * @sa glfwGetMonitors
  1175. *
  1176. * @since Added in GLFW 3.0.
  1177. *
  1178. * @ingroup monitor
  1179. */
  1180. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  1181. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  1182. *
  1183. * This function returns the position, in screen coordinates, of the upper-left
  1184. * corner of the specified monitor.
  1185. *
  1186. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1187. * non-`NULL` position arguments will be set to zero.
  1188. *
  1189. * @param[in] monitor The monitor to query.
  1190. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  1191. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  1192. *
  1193. * @par Thread Safety
  1194. * This function may only be called from the main thread.
  1195. *
  1196. * @sa @ref monitor_properties
  1197. *
  1198. * @since Added in GLFW 3.0.
  1199. *
  1200. * @ingroup monitor
  1201. */
  1202. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  1203. /*! @brief Returns the physical size of the monitor.
  1204. *
  1205. * This function returns the size, in millimetres, of the display area of the
  1206. * specified monitor.
  1207. *
  1208. * Some systems do not provide accurate monitor size information, either
  1209. * because the monitor
  1210. * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
  1211. * data is incorrect or because the driver does not report it accurately.
  1212. *
  1213. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1214. * non-`NULL` size arguments will be set to zero.
  1215. *
  1216. * @param[in] monitor The monitor to query.
  1217. * @param[out] widthMM Where to store the width, in millimetres, of the
  1218. * monitor's display area, or `NULL`.
  1219. * @param[out] heightMM Where to store the height, in millimetres, of the
  1220. * monitor's display area, or `NULL`.
  1221. *
  1222. * @remarks __Windows:__ The OS calculates the returned physical size from the
  1223. * current resolution and system DPI instead of querying the monitor EDID data.
  1224. *
  1225. * @par Thread Safety
  1226. * This function may only be called from the main thread.
  1227. *
  1228. * @sa @ref monitor_properties
  1229. *
  1230. * @since Added in GLFW 3.0.
  1231. *
  1232. * @ingroup monitor
  1233. */
  1234. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
  1235. /*! @brief Returns the name of the specified monitor.
  1236. *
  1237. * This function returns a human-readable name, encoded as UTF-8, of the
  1238. * specified monitor. The name typically reflects the make and model of the
  1239. * monitor and is not guaranteed to be unique among the connected monitors.
  1240. *
  1241. * @param[in] monitor The monitor to query.
  1242. * @return The UTF-8 encoded name of the monitor, or `NULL` if an
  1243. * [error](@ref error_handling) occurred.
  1244. *
  1245. * @par Pointer Lifetime
  1246. * The returned string is allocated and freed by GLFW. You should not free it
  1247. * yourself. It is valid until the specified monitor is disconnected or the
  1248. * library is terminated.
  1249. *
  1250. * @par Thread Safety
  1251. * This function may only be called from the main thread.
  1252. *
  1253. * @sa @ref monitor_properties
  1254. *
  1255. * @since Added in GLFW 3.0.
  1256. *
  1257. * @ingroup monitor
  1258. */
  1259. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  1260. /*! @brief Sets the monitor configuration callback.
  1261. *
  1262. * This function sets the monitor configuration callback, or removes the
  1263. * currently set callback. This is called when a monitor is connected to or
  1264. * disconnected from the system.
  1265. *
  1266. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1267. * callback.
  1268. * @return The previously set callback, or `NULL` if no callback was set or the
  1269. * library had not been [initialized](@ref intro_init).
  1270. *
  1271. * @bug __X11:__ This callback is not yet called on monitor configuration
  1272. * changes.
  1273. *
  1274. * @par Thread Safety
  1275. * This function may only be called from the main thread.
  1276. *
  1277. * @sa @ref monitor_event
  1278. *
  1279. * @since Added in GLFW 3.0.
  1280. *
  1281. * @ingroup monitor
  1282. */
  1283. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
  1284. /*! @brief Returns the available video modes for the specified monitor.
  1285. *
  1286. * This function returns an array of all video modes supported by the specified
  1287. * monitor. The returned array is sorted in ascending order, first by color
  1288. * bit depth (the sum of all channel depths) and then by resolution area (the
  1289. * product of width and height).
  1290. *
  1291. * @param[in] monitor The monitor to query.
  1292. * @param[out] count Where to store the number of video modes in the returned
  1293. * array. This is set to zero if an error occurred.
  1294. * @return An array of video modes, or `NULL` if an
  1295. * [error](@ref error_handling) occurred.
  1296. *
  1297. * @par Pointer Lifetime
  1298. * The returned array is allocated and freed by GLFW. You should not free it
  1299. * yourself. It is valid until the specified monitor is disconnected, this
  1300. * function is called again for that monitor or the library is terminated.
  1301. *
  1302. * @par Thread Safety
  1303. * This function may only be called from the main thread.
  1304. *
  1305. * @sa @ref monitor_modes
  1306. * @sa glfwGetVideoMode
  1307. *
  1308. * @since Added in GLFW 1.0.
  1309. *
  1310. * @par
  1311. * __GLFW 3:__ Changed to return an array of modes for a specific monitor.
  1312. *
  1313. * @ingroup monitor
  1314. */
  1315. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  1316. /*! @brief Returns the current mode of the specified monitor.
  1317. *
  1318. * This function returns the current video mode of the specified monitor. If
  1319. * you have created a full screen window for that monitor, the return value
  1320. * will depend on whether that window is iconified.
  1321. *
  1322. * @param[in] monitor The monitor to query.
  1323. * @return The current mode of the monitor, or `NULL` if an
  1324. * [error](@ref error_handling) occurred.
  1325. *
  1326. * @par Pointer Lifetime
  1327. * The returned array is allocated and freed by GLFW. You should not free it
  1328. * yourself. It is valid until the specified monitor is disconnected or the
  1329. * library is terminated.
  1330. *
  1331. * @par Thread Safety
  1332. * This function may only be called from the main thread.
  1333. *
  1334. * @sa @ref monitor_modes
  1335. * @sa glfwGetVideoModes
  1336. *
  1337. * @since Added in GLFW 3.0. Replaces `glfwGetDesktopMode`.
  1338. *
  1339. * @ingroup monitor
  1340. */
  1341. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  1342. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  1343. *
  1344. * This function generates a 256-element gamma ramp from the specified exponent
  1345. * and then calls @ref glfwSetGammaRamp with it. The value must be a finite
  1346. * number greater than zero.
  1347. *
  1348. * @param[in] monitor The monitor whose gamma ramp to set.
  1349. * @param[in] gamma The desired exponent.
  1350. *
  1351. * @par Thread Safety
  1352. * This function may only be called from the main thread.
  1353. *
  1354. * @sa @ref monitor_gamma
  1355. *
  1356. * @since Added in GLFW 3.0.
  1357. *
  1358. * @ingroup monitor
  1359. */
  1360. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  1361. /*! @brief Returns the current gamma ramp for the specified monitor.
  1362. *
  1363. * This function returns the current gamma ramp of the specified monitor.
  1364. *
  1365. * @param[in] monitor The monitor to query.
  1366. * @return The current gamma ramp, or `NULL` if an
  1367. * [error](@ref error_handling) occurred.
  1368. *
  1369. * @par Pointer Lifetime
  1370. * The returned structure and its arrays are allocated and freed by GLFW. You
  1371. * should not free them yourself. They are valid until the specified monitor
  1372. * is disconnected, this function is called again for that monitor or the
  1373. * library is terminated.
  1374. *
  1375. * @par Thread Safety
  1376. * This function may only be called from the main thread.
  1377. *
  1378. * @sa @ref monitor_gamma
  1379. *
  1380. * @since Added in GLFW 3.0.
  1381. *
  1382. * @ingroup monitor
  1383. */
  1384. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  1385. /*! @brief Sets the current gamma ramp for the specified monitor.
  1386. *
  1387. * This function sets the current gamma ramp for the specified monitor. The
  1388. * original gamma ramp for that monitor is saved by GLFW the first time this
  1389. * function is called and is restored by @ref glfwTerminate.
  1390. *
  1391. * @param[in] monitor The monitor whose gamma ramp to set.
  1392. * @param[in] ramp The gamma ramp to use.
  1393. *
  1394. * @remarks Gamma ramp sizes other than 256 are not supported by all platforms
  1395. * or graphics hardware.
  1396. *
  1397. * @remarks __Windows:__ The gamma ramp size must be 256.
  1398. *
  1399. * @par Pointer Lifetime
  1400. * The specified gamma ramp is copied before this function returns.
  1401. *
  1402. * @par Thread Safety
  1403. * This function may only be called from the main thread.
  1404. *
  1405. * @sa @ref monitor_gamma
  1406. *
  1407. * @since Added in GLFW 3.0.
  1408. *
  1409. * @ingroup monitor
  1410. */
  1411. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  1412. /*! @brief Resets all window hints to their default values.
  1413. *
  1414. * This function resets all window hints to their
  1415. * [default values](@ref window_hints_values).
  1416. *
  1417. * @par Thread Safety
  1418. * This function may only be called from the main thread.
  1419. *
  1420. * @sa @ref window_hints
  1421. * @sa glfwWindowHint
  1422. *
  1423. * @since Added in GLFW 3.0.
  1424. *
  1425. * @ingroup window
  1426. */
  1427. GLFWAPI void glfwDefaultWindowHints(void);
  1428. /*! @brief Sets the specified window hint to the desired value.
  1429. *
  1430. * This function sets hints for the next call to @ref glfwCreateWindow. The
  1431. * hints, once set, retain their values until changed by a call to @ref
  1432. * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
  1433. * terminated.
  1434. *
  1435. * @param[in] target The [window hint](@ref window_hints) to set.
  1436. * @param[in] hint The new value of the window hint.
  1437. *
  1438. * @par Thread Safety
  1439. * This function may only be called from the main thread.
  1440. *
  1441. * @sa @ref window_hints
  1442. * @sa glfwDefaultWindowHints
  1443. *
  1444. * @since Added in GLFW 3.0. Replaces `glfwOpenWindowHint`.
  1445. *
  1446. * @ingroup window
  1447. */
  1448. GLFWAPI void glfwWindowHint(int target, int hint);
  1449. /*! @brief Creates a window and its associated context.
  1450. *
  1451. * This function creates a window and its associated OpenGL or OpenGL ES
  1452. * context. Most of the options controlling how the window and its context
  1453. * should be created are specified with [window hints](@ref window_hints).
  1454. *
  1455. * Successful creation does not change which context is current. Before you
  1456. * can use the newly created context, you need to
  1457. * [make it current](@ref context_current). For information about the `share`
  1458. * parameter, see @ref context_sharing.
  1459. *
  1460. * The created window, framebuffer and context may differ from what you
  1461. * requested, as not all parameters and hints are
  1462. * [hard constraints](@ref window_hints_hard). This includes the size of the
  1463. * window, especially for full screen windows. To query the actual attributes
  1464. * of the created window, framebuffer and context, use queries like @ref
  1465. * glfwGetWindowAttrib and @ref glfwGetWindowSize.
  1466. *
  1467. * To create a full screen window, you need to specify the monitor the window
  1468. * will cover. If no monitor is specified, windowed mode will be used. Unless
  1469. * you have a way for the user to choose a specific monitor, it is recommended
  1470. * that you pick the primary monitor. For more information on how to query
  1471. * connected monitors, see @ref monitor_monitors.
  1472. *
  1473. * For full screen windows, the specified size becomes the resolution of the
  1474. * window's _desired video mode_. As long as a full screen window has input
  1475. * focus, the supported video mode most closely matching the desired video mode
  1476. * is set for the specified monitor. For more information about full screen
  1477. * windows, including the creation of so called _windowed full screen_ or
  1478. * _borderless full screen_ windows, see @ref window_windowed_full_screen.
  1479. *
  1480. * By default, newly created windows use the placement recommended by the
  1481. * window system. To create the window at a specific position, make it
  1482. * initially invisible using the [GLFW_VISIBLE](@ref window_hints_wnd) window
  1483. * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
  1484. * it.
  1485. *
  1486. * If a full screen window has input focus, the screensaver is prohibited from
  1487. * starting.
  1488. *
  1489. * Window systems put limits on window sizes. Very large or very small window
  1490. * dimensions may be overridden by the window system on creation. Check the
  1491. * actual [size](@ref window_size) after creation.
  1492. *
  1493. * The [swap interval](@ref buffer_swap) is not set during window creation and
  1494. * the initial value may vary depending on driver settings and defaults.
  1495. *
  1496. * @param[in] width The desired width, in screen coordinates, of the window.
  1497. * This must be greater than zero.
  1498. * @param[in] height The desired height, in screen coordinates, of the window.
  1499. * This must be greater than zero.
  1500. * @param[in] title The initial, UTF-8 encoded window title.
  1501. * @param[in] monitor The monitor to use for full screen mode, or `NULL` to use
  1502. * windowed mode.
  1503. * @param[in] share The window whose context to share resources with, or `NULL`
  1504. * to not share resources.
  1505. * @return The handle of the created window, or `NULL` if an
  1506. * [error](@ref error_handling) occurred.
  1507. *
  1508. * @remarks __Windows:__ Window creation will fail if the Microsoft GDI
  1509. * software OpenGL implementation is the only one available.
  1510. *
  1511. * @remarks __Windows:__ If the executable has an icon resource named
  1512. * `GLFW_ICON,` it will be set as the icon for the window. If no such icon is
  1513. * present, the `IDI_WINLOGO` icon will be used instead.
  1514. *
  1515. * @remarks __Windows:__ The context to share resources with may not be current
  1516. * on any other thread.
  1517. *
  1518. * @remarks __OS X:__ The GLFW window has no icon, as it is not a document
  1519. * window, but the dock icon will be the same as the application bundle's icon.
  1520. * For more information on bundles, see the
  1521. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  1522. * in the Mac Developer Library.
  1523. *
  1524. * @remarks __OS X:__ The first time a window is created the menu bar is
  1525. * populated with common commands like Hide, Quit and About. The About entry
  1526. * opens a minimal about dialog with information from the application's bundle.
  1527. * The menu bar can be disabled with a
  1528. * [compile-time option](@ref compile_options_osx).
  1529. *
  1530. * @remarks __OS X:__ On OS X 10.10 and later the window frame will not be
  1531. * rendered at full resolution on Retina displays unless the
  1532. * `NSHighResolutionCapable` key is enabled in the application bundle's
  1533. * `Info.plist`. For more information, see
  1534. * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
  1535. * in the Mac Developer Library.
  1536. *
  1537. * @remarks __X11:__ There is no mechanism for setting the window icon yet.
  1538. *
  1539. * @remarks __X11:__ Some window managers will not respect the placement of
  1540. * initially hidden windows.
  1541. *
  1542. * @par Reentrancy
  1543. * This function may not be called from a callback.
  1544. *
  1545. * @par Thread Safety
  1546. * This function may only be called from the main thread.
  1547. *
  1548. * @sa @ref window_creation
  1549. * @sa glfwDestroyWindow
  1550. *
  1551. * @since Added in GLFW 3.0. Replaces `glfwOpenWindow`.
  1552. *
  1553. * @ingroup window
  1554. */
  1555. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  1556. /*! @brief Destroys the specified window and its context.
  1557. *
  1558. * This function destroys the specified window and its context. On calling
  1559. * this function, no further callbacks will be called for that window.
  1560. *
  1561. * If the context of the specified window is current on the main thread, it is
  1562. * detached before being destroyed.
  1563. *
  1564. * @param[in] window The window to destroy.
  1565. *
  1566. * @note The context of the specified window must not be current on any other
  1567. * thread when this function is called.
  1568. *
  1569. * @par Reentrancy
  1570. * This function may not be called from a callback.
  1571. *
  1572. * @par Thread Safety
  1573. * This function may only be called from the main thread.
  1574. *
  1575. * @sa @ref window_creation
  1576. * @sa glfwCreateWindow
  1577. *
  1578. * @since Added in GLFW 3.0. Replaces `glfwCloseWindow`.
  1579. *
  1580. * @ingroup window
  1581. */
  1582. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  1583. /*! @brief Checks the close flag of the specified window.
  1584. *
  1585. * This function returns the value of the close flag of the specified window.
  1586. *
  1587. * @param[in] window The window to query.
  1588. * @return The value of the close flag.
  1589. *
  1590. * @par Thread Safety
  1591. * This function may be called from any thread. Access is not synchronized.
  1592. *
  1593. * @sa @ref window_close
  1594. *
  1595. * @since Added in GLFW 3.0.
  1596. *
  1597. * @ingroup window
  1598. */
  1599. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  1600. /*! @brief Sets the close flag of the specified window.
  1601. *
  1602. * This function sets the value of the close flag of the specified window.
  1603. * This can be used to override the user's attempt to close the window, or
  1604. * to signal that it should be closed.
  1605. *
  1606. * @param[in] window The window whose flag to change.
  1607. * @param[in] value The new value.
  1608. *
  1609. * @par Thread Safety
  1610. * This function may be called from any thread. Access is not synchronized.
  1611. *
  1612. * @sa @ref window_close
  1613. *
  1614. * @since Added in GLFW 3.0.
  1615. *
  1616. * @ingroup window
  1617. */
  1618. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  1619. /*! @brief Sets the title of the specified window.
  1620. *
  1621. * This function sets the window title, encoded as UTF-8, of the specified
  1622. * window.
  1623. *
  1624. * @param[in] window The window whose title to change.
  1625. * @param[in] title The UTF-8 encoded window title.
  1626. *
  1627. * @par Thread Safety
  1628. * This function may only be called from the main thread.
  1629. *
  1630. * @sa @ref window_title
  1631. *
  1632. * @since Added in GLFW 1.0.
  1633. *
  1634. * @par
  1635. * __GLFW 3:__ Added window handle parameter.
  1636. *
  1637. * @ingroup window
  1638. */
  1639. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  1640. /*! @brief Retrieves the position of the client area of the specified window.
  1641. *
  1642. * This function retrieves the position, in screen coordinates, of the
  1643. * upper-left corner of the client area of the specified window.
  1644. *
  1645. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1646. * non-`NULL` position arguments will be set to zero.
  1647. *
  1648. * @param[in] window The window to query.
  1649. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  1650. * the client area, or `NULL`.
  1651. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  1652. * the client area, or `NULL`.
  1653. *
  1654. * @par Thread Safety
  1655. * This function may only be called from the main thread.
  1656. *
  1657. * @sa @ref window_pos
  1658. * @sa glfwSetWindowPos
  1659. *
  1660. * @since Added in GLFW 3.0.
  1661. *
  1662. * @ingroup window
  1663. */
  1664. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  1665. /*! @brief Sets the position of the client area of the specified window.
  1666. *
  1667. * This function sets the position, in screen coordinates, of the upper-left
  1668. * corner of the client area of the specified windowed mode window. If the
  1669. * window is a full screen window, this function does nothing.
  1670. *
  1671. * __Do not use this function__ to move an already visible window unless you
  1672. * have very good reasons for doing so, as it will confuse and annoy the user.
  1673. *
  1674. * The window manager may put limits on what positions are allowed. GLFW
  1675. * cannot and should not override these limits.
  1676. *
  1677. * @param[in] window The window to query.
  1678. * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
  1679. * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
  1680. *
  1681. * @par Thread Safety
  1682. * This function may only be called from the main thread.
  1683. *
  1684. * @sa @ref window_pos
  1685. * @sa glfwGetWindowPos
  1686. *
  1687. * @since Added in GLFW 1.0.
  1688. *
  1689. * @par
  1690. * __GLFW 3:__ Added window handle parameter.
  1691. *
  1692. * @ingroup window
  1693. */
  1694. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  1695. /*! @brief Retrieves the size of the client area of the specified window.
  1696. *
  1697. * This function retrieves the size, in screen coordinates, of the client area
  1698. * of the specified window. If you wish to retrieve the size of the
  1699. * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
  1700. *
  1701. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1702. * non-`NULL` size arguments will be set to zero.
  1703. *
  1704. * @param[in] window The window whose size to retrieve.
  1705. * @param[out] width Where to store the width, in screen coordinates, of the
  1706. * client area, or `NULL`.
  1707. * @param[out] height Where to store the height, in screen coordinates, of the
  1708. * client area, or `NULL`.
  1709. *
  1710. * @par Thread Safety
  1711. * This function may only be called from the main thread.
  1712. *
  1713. * @sa @ref window_size
  1714. * @sa glfwSetWindowSize
  1715. *
  1716. * @since Added in GLFW 1.0.
  1717. *
  1718. * @par
  1719. * __GLFW 3:__ Added window handle parameter.
  1720. *
  1721. * @ingroup window
  1722. */
  1723. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  1724. /*! @brief Sets the size of the client area of the specified window.
  1725. *
  1726. * This function sets the size, in screen coordinates, of the client area of
  1727. * the specified window.
  1728. *
  1729. * For full screen windows, this function selects and switches to the resolution
  1730. * closest to the specified size, without affecting the window's context. As
  1731. * the context is unaffected, the bit depths of the framebuffer remain
  1732. * unchanged.
  1733. *
  1734. * The window manager may put limits on what sizes are allowed. GLFW cannot
  1735. * and should not override these limits.
  1736. *
  1737. * @param[in] window The window to resize.
  1738. * @param[in] width The desired width of the specified window.
  1739. * @param[in] height The desired height of the specified window.
  1740. *
  1741. * @par Thread Safety
  1742. * This function may only be called from the main thread.
  1743. *
  1744. * @sa @ref window_size
  1745. * @sa glfwGetWindowSize
  1746. *
  1747. * @since Added in GLFW 1.0.
  1748. *
  1749. * @par
  1750. * __GLFW 3:__ Added window handle parameter.
  1751. *
  1752. * @ingroup window
  1753. */
  1754. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  1755. /*! @brief Retrieves the size of the framebuffer of the specified window.
  1756. *
  1757. * This function retrieves the size, in pixels, of the framebuffer of the
  1758. * specified window. If you wish to retrieve the size of the window in screen
  1759. * coordinates, see @ref glfwGetWindowSize.
  1760. *
  1761. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1762. * non-`NULL` size arguments will be set to zero.
  1763. *
  1764. * @param[in] window The window whose framebuffer to query.
  1765. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  1766. * or `NULL`.
  1767. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  1768. * or `NULL`.
  1769. *
  1770. * @par Thread Safety
  1771. * This function may only be called from the main thread.
  1772. *
  1773. * @sa @ref window_fbsize
  1774. * @sa glfwSetFramebufferSizeCallback
  1775. *
  1776. * @since Added in GLFW 3.0.
  1777. *
  1778. * @ingroup window
  1779. */
  1780. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  1781. /*! @brief Retrieves the size of the frame of the window.
  1782. *
  1783. * This function retrieves the size, in screen coordinates, of each edge of the
  1784. * frame of the specified window. This size includes the title bar, if the
  1785. * window has one. The size of the frame may vary depending on the
  1786. * [window-related hints](@ref window_hints_wnd) used to create it.
  1787. *
  1788. * Because this function retrieves the size of each window frame edge and not
  1789. * the offset along a particular coordinate axis, the retrieved values will
  1790. * always be zero or positive.
  1791. *
  1792. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1793. * non-`NULL` size arguments will be set to zero.
  1794. *
  1795. * @param[in] window The window whose frame size to query.
  1796. * @param[out] left Where to store the size, in screen coordinates, of the left
  1797. * edge of the window frame, or `NULL`.
  1798. * @param[out] top Where to store the size, in screen coordinates, of the top
  1799. * edge of the window frame, or `NULL`.
  1800. * @param[out] right Where to store the size, in screen coordinates, of the
  1801. * right edge of the window frame, or `NULL`.
  1802. * @param[out] bottom Where to store the size, in screen coordinates, of the
  1803. * bottom edge of the window frame, or `NULL`.
  1804. *
  1805. * @par Thread Safety
  1806. * This function may only be called from the main thread.
  1807. *
  1808. * @sa @ref window_size
  1809. *
  1810. * @since Added in GLFW 3.1.
  1811. *
  1812. * @ingroup window
  1813. */
  1814. GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
  1815. /*! @brief Iconifies the specified window.
  1816. *
  1817. * This function iconifies (minimizes) the specified window if it was
  1818. * previously restored. If the window is already iconified, this function does
  1819. * nothing.
  1820. *
  1821. * If the specified window is a full screen window, the original monitor
  1822. * resolution is restored until the window is restored.
  1823. *
  1824. * @param[in] window The window to iconify.
  1825. *
  1826. * @par Thread Safety
  1827. * This function may only be called from the main thread.
  1828. *
  1829. * @sa @ref window_iconify
  1830. * @sa glfwRestoreWindow
  1831. *
  1832. * @since Added in GLFW 2.1.
  1833. *
  1834. * @par
  1835. * __GLFW 3:__ Added window handle parameter.
  1836. *
  1837. * @ingroup window
  1838. */
  1839. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  1840. /*! @brief Restores the specified window.
  1841. *
  1842. * This function restores the specified window if it was previously iconified
  1843. * (minimized). If the window is already restored, this function does nothing.
  1844. *
  1845. * If the specified window is a full screen window, the resolution chosen for
  1846. * the window is restored on the selected monitor.
  1847. *
  1848. * @param[in] window The window to restore.
  1849. *
  1850. * @par Thread Safety
  1851. * This function may only be called from the main thread.
  1852. *
  1853. * @sa @ref window_iconify
  1854. * @sa glfwIconifyWindow
  1855. *
  1856. * @since Added in GLFW 2.1.
  1857. *
  1858. * @par
  1859. * __GLFW 3:__ Added window handle parameter.
  1860. *
  1861. * @ingroup window
  1862. */
  1863. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  1864. /*! @brief Makes the specified window visible.
  1865. *
  1866. * This function makes the specified window visible if it was previously
  1867. * hidden. If the window is already visible or is in full screen mode, this
  1868. * function does nothing.
  1869. *
  1870. * @param[in] window The window to make visible.
  1871. *
  1872. * @par Thread Safety
  1873. * This function may only be called from the main thread.
  1874. *
  1875. * @sa @ref window_hide
  1876. * @sa glfwHideWindow
  1877. *
  1878. * @since Added in GLFW 3.0.
  1879. *
  1880. * @ingroup window
  1881. */
  1882. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  1883. /*! @brief Hides the specified window.
  1884. *
  1885. * This function hides the specified window if it was previously visible. If
  1886. * the window is already hidden or is in full screen mode, this function does
  1887. * nothing.
  1888. *
  1889. * @param[in] window The window to hide.
  1890. *
  1891. * @par Thread Safety
  1892. * This function may only be called from the main thread.
  1893. *
  1894. * @sa @ref window_hide
  1895. * @sa glfwShowWindow
  1896. *
  1897. * @since Added in GLFW 3.0.
  1898. *
  1899. * @ingroup window
  1900. */
  1901. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  1902. /*! @brief Returns the monitor that the window uses for full screen mode.
  1903. *
  1904. * This function returns the handle of the monitor that the specified window is
  1905. * in full screen on.
  1906. *
  1907. * @param[in] window The window to query.
  1908. * @return The monitor, or `NULL` if the window is in windowed mode or an error
  1909. * occurred.
  1910. *
  1911. * @par Thread Safety
  1912. * This function may only be called from the main thread.
  1913. *
  1914. * @sa @ref window_monitor
  1915. *
  1916. * @since Added in GLFW 3.0.
  1917. *
  1918. * @ingroup window
  1919. */
  1920. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  1921. /*! @brief Returns an attribute of the specified window.
  1922. *
  1923. * This function returns the value of an attribute of the specified window or
  1924. * its OpenGL or OpenGL ES context.
  1925. *
  1926. * @param[in] window The window to query.
  1927. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  1928. * return.
  1929. * @return The value of the attribute, or zero if an
  1930. * [error](@ref error_handling) occurred.
  1931. *
  1932. * @par Thread Safety
  1933. * This function may only be called from the main thread.
  1934. *
  1935. * @sa @ref window_attribs
  1936. *
  1937. * @since Added in GLFW 3.0. Replaces `glfwGetWindowParam` and
  1938. * `glfwGetGLVersion`.
  1939. *
  1940. * @ingroup window
  1941. */
  1942. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  1943. /*! @brief Sets the user pointer of the specified window.
  1944. *
  1945. * This function sets the user-defined pointer of the specified window. The
  1946. * current value is retained until the window is destroyed. The initial value
  1947. * is `NULL`.
  1948. *
  1949. * @param[in] window The window whose pointer to set.
  1950. * @param[in] pointer The new value.
  1951. *
  1952. * @par Thread Safety
  1953. * This function may be called from any thread. Access is not synchronized.
  1954. *
  1955. * @sa @ref window_userptr
  1956. * @sa glfwGetWindowUserPointer
  1957. *
  1958. * @since Added in GLFW 3.0.
  1959. *
  1960. * @ingroup window
  1961. */
  1962. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  1963. /*! @brief Returns the user pointer of the specified window.
  1964. *
  1965. * This function returns the current value of the user-defined pointer of the
  1966. * specified window. The initial value is `NULL`.
  1967. *
  1968. * @param[in] window The window whose pointer to return.
  1969. *
  1970. * @par Thread Safety
  1971. * This function may be called from any thread. Access is not synchronized.
  1972. *
  1973. * @sa @ref window_userptr
  1974. * @sa glfwSetWindowUserPointer
  1975. *
  1976. * @since Added in GLFW 3.0.
  1977. *
  1978. * @ingroup window
  1979. */
  1980. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  1981. /*! @brief Sets the position callback for the specified window.
  1982. *
  1983. * This function sets the position callback of the specified window, which is
  1984. * called when the window is moved. The callback is provided with the screen
  1985. * position of the upper-left corner of the client area of the window.
  1986. *
  1987. * @param[in] window The window whose callback to set.
  1988. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1989. * callback.
  1990. * @return The previously set callback, or `NULL` if no callback was set or the
  1991. * library had not been [initialized](@ref intro_init).
  1992. *
  1993. * @par Thread Safety
  1994. * This function may only be called from the main thread.
  1995. *
  1996. * @sa @ref window_pos
  1997. *
  1998. * @since Added in GLFW 3.0.
  1999. *
  2000. * @ingroup window
  2001. */
  2002. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
  2003. /*! @brief Sets the size callback for the specified window.
  2004. *
  2005. * This function sets the size callback of the specified window, which is
  2006. * called when the window is resized. The callback is provided with the size,
  2007. * in screen coordinates, of the client area of the window.
  2008. *
  2009. * @param[in] window The window whose callback to set.
  2010. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2011. * callback.
  2012. * @return The previously set callback, or `NULL` if no callback was set or the
  2013. * library had not been [initialized](@ref intro_init).
  2014. *
  2015. * @par Thread Safety
  2016. * This function may only be called from the main thread.
  2017. *
  2018. * @sa @ref window_size
  2019. *
  2020. * @since Added in GLFW 1.0.
  2021. *
  2022. * @par
  2023. * __GLFW 3:__ Added window handle parameter. Updated callback signature.
  2024. *
  2025. * @ingroup window
  2026. */
  2027. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
  2028. /*! @brief Sets the close callback for the specified window.
  2029. *
  2030. * This function sets the close callback of the specified window, which is
  2031. * called when the user attempts to close the window, for example by clicking
  2032. * the close widget in the title bar.
  2033. *
  2034. * The close flag is set before this callback is called, but you can modify it
  2035. * at any time with @ref glfwSetWindowShouldClose.
  2036. *
  2037. * The close callback is not triggered by @ref glfwDestroyWindow.
  2038. *
  2039. * @param[in] window The window whose callback to set.
  2040. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2041. * callback.
  2042. * @return The previously set callback, or `NULL` if no callback was set or the
  2043. * library had not been [initialized](@ref intro_init).
  2044. *
  2045. * @remarks __OS X:__ Selecting Quit from the application menu will
  2046. * trigger the close callback for all windows.
  2047. *
  2048. * @par Thread Safety
  2049. * This function may only be called from the main thread.
  2050. *
  2051. * @sa @ref window_close
  2052. *
  2053. * @since Added in GLFW 2.5.
  2054. *
  2055. * @par
  2056. * __GLFW 3:__ Added window handle parameter. Updated callback signature.
  2057. *
  2058. * @ingroup window
  2059. */
  2060. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
  2061. /*! @brief Sets the refresh callback for the specified window.
  2062. *
  2063. * This function sets the refresh callback of the specified window, which is
  2064. * called when the client area of the window needs to be redrawn, for example
  2065. * if the window has been exposed after having been covered by another window.
  2066. *
  2067. * On compositing window systems such as Aero, Compiz or Aqua, where the window
  2068. * contents are saved off-screen, this callback may be called only very
  2069. * infrequently or never at all.
  2070. *
  2071. * @param[in] window The window whose callback to set.
  2072. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2073. * callback.
  2074. * @return The previously set callback, or `NULL` if no callback was set or the
  2075. * library had not been [initialized](@ref intro_init).
  2076. *
  2077. * @par Thread Safety
  2078. * This function may only be called from the main thread.
  2079. *
  2080. * @sa @ref window_refresh
  2081. *
  2082. * @since Added in GLFW 2.5.
  2083. *
  2084. * @par
  2085. * __GLFW 3:__ Added window handle parameter. Updated callback signature.
  2086. *
  2087. * @ingroup window
  2088. */
  2089. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
  2090. /*! @brief Sets the focus callback for the specified window.
  2091. *
  2092. * This function sets the focus callback of the specified window, which is
  2093. * called when the window gains or loses input focus.
  2094. *
  2095. * After the focus callback is called for a window that lost input focus,
  2096. * synthetic key and mouse button release events will be generated for all such
  2097. * that had been pressed. For more information, see @ref glfwSetKeyCallback
  2098. * and @ref glfwSetMouseButtonCallback.
  2099. *
  2100. * @param[in] window The window whose callback to set.
  2101. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2102. * callback.
  2103. * @return The previously set callback, or `NULL` if no callback was set or the
  2104. * library had not been [initialized](@ref intro_init).
  2105. *
  2106. * @par Thread Safety
  2107. * This function may only be called from the main thread.
  2108. *
  2109. * @sa @ref window_focus
  2110. *
  2111. * @since Added in GLFW 3.0.
  2112. *
  2113. * @ingroup window
  2114. */
  2115. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
  2116. /*! @brief Sets the iconify callback for the specified window.
  2117. *
  2118. * This function sets the iconification callback of the specified window, which
  2119. * is called when the window is iconified or restored.
  2120. *
  2121. * @param[in] window The window whose callback to set.
  2122. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2123. * callback.
  2124. * @return The previously set callback, or `NULL` if no callback was set or the
  2125. * library had not been [initialized](@ref intro_init).
  2126. *
  2127. * @par Thread Safety
  2128. * This function may only be called from the main thread.
  2129. *
  2130. * @sa @ref window_iconify
  2131. *
  2132. * @since Added in GLFW 3.0.
  2133. *
  2134. * @ingroup window
  2135. */
  2136. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
  2137. /*! @brief Sets the framebuffer resize callback for the specified window.
  2138. *
  2139. * This function sets the framebuffer resize callback of the specified window,
  2140. * which is called when the framebuffer of the specified window is resized.
  2141. *
  2142. * @param[in] window The window whose callback to set.
  2143. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2144. * callback.
  2145. * @return The previously set callback, or `NULL` if no callback was set or the
  2146. * library had not been [initialized](@ref intro_init).
  2147. *
  2148. * @par Thread Safety
  2149. * This function may only be called from the main thread.
  2150. *
  2151. * @sa @ref window_fbsize
  2152. *
  2153. * @since Added in GLFW 3.0.
  2154. *
  2155. * @ingroup window
  2156. */
  2157. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
  2158. /*! @brief Processes all pending events.
  2159. *
  2160. * This function processes only those events that are already in the event
  2161. * queue and then returns immediately. Processing events will cause the window
  2162. * and input callbacks associated with those events to be called.
  2163. *
  2164. * On some platforms, a window move, resize or menu operation will cause event
  2165. * processing to block. This is due to how event processing is designed on
  2166. * those platforms. You can use the
  2167. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2168. * your window when necessary during such operations.
  2169. *
  2170. * On some platforms, certain events are sent directly to the application
  2171. * without going through the event queue, causing callbacks to be called
  2172. * outside of a call to one of the event processing functions.
  2173. *
  2174. * Event processing is not required for joystick input to work.
  2175. *
  2176. * @par Reentrancy
  2177. * This function may not be called from a callback.
  2178. *
  2179. * @par Thread Safety
  2180. * This function may only be called from the main thread.
  2181. *
  2182. * @sa @ref events
  2183. * @sa glfwWaitEvents
  2184. *
  2185. * @since Added in GLFW 1.0.
  2186. *
  2187. * @ingroup window
  2188. */
  2189. GLFWAPI void glfwPollEvents(void);
  2190. /*! @brief Waits until events are queued and processes them.
  2191. *
  2192. * This function puts the calling thread to sleep until at least one event is
  2193. * available in the event queue. Once one or more events are available,
  2194. * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
  2195. * are processed and the function then returns immediately. Processing events
  2196. * will cause the window and input callbacks associated with those events to be
  2197. * called.
  2198. *
  2199. * Since not all events are associated with callbacks, this function may return
  2200. * without a callback having been called even if you are monitoring all
  2201. * callbacks.
  2202. *
  2203. * On some platforms, a window move, resize or menu operation will cause event
  2204. * processing to block. This is due to how event processing is designed on
  2205. * those platforms. You can use the
  2206. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2207. * your window when necessary during such operations.
  2208. *
  2209. * On some platforms, certain callbacks may be called outside of a call to one
  2210. * of the event processing functions.
  2211. *
  2212. * If no windows exist, this function returns immediately. For synchronization
  2213. * of threads in applications that do not create windows, use your threading
  2214. * library of choice.
  2215. *
  2216. * Event processing is not required for joystick input to work.
  2217. *
  2218. * @par Reentrancy
  2219. * This function may not be called from a callback.
  2220. *
  2221. * @par Thread Safety
  2222. * This function may only be called from the main thread.
  2223. *
  2224. * @sa @ref events
  2225. * @sa glfwPollEvents
  2226. *
  2227. * @since Added in GLFW 2.5.
  2228. *
  2229. * @ingroup window
  2230. */
  2231. GLFWAPI void glfwWaitEvents(void);
  2232. /*! @brief Posts an empty event to the event queue.
  2233. *
  2234. * This function posts an empty event from the current thread to the event
  2235. * queue, causing @ref glfwWaitEvents to return.
  2236. *
  2237. * If no windows exist, this function returns immediately. For synchronization
  2238. * of threads in applications that do not create windows, use your threading
  2239. * library of choice.
  2240. *
  2241. * @par Thread Safety
  2242. * This function may be called from any thread.
  2243. *
  2244. * @sa @ref events
  2245. * @sa glfwWaitEvents
  2246. *
  2247. * @since Added in GLFW 3.1.
  2248. *
  2249. * @ingroup window
  2250. */
  2251. GLFWAPI void glfwPostEmptyEvent(void);
  2252. /*! @brief Returns the value of an input option for the specified window.
  2253. *
  2254. * This function returns the value of an input option for the specified window.
  2255. * The mode must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2256. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2257. *
  2258. * @param[in] window The window to query.
  2259. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2260. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2261. *
  2262. * @par Thread Safety
  2263. * This function may only be called from the main thread.
  2264. *
  2265. * @sa glfwSetInputMode
  2266. *
  2267. * @since Added in GLFW 3.0.
  2268. *
  2269. * @ingroup input
  2270. */
  2271. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  2272. /*! @brief Sets an input option for the specified window.
  2273. *
  2274. * This function sets an input mode option for the specified window. The mode
  2275. * must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2276. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2277. *
  2278. * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  2279. * modes:
  2280. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  2281. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
  2282. * area of the window but does not restrict the cursor from leaving.
  2283. * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  2284. * and unlimited cursor movement. This is useful for implementing for
  2285. * example 3D camera controls.
  2286. *
  2287. * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
  2288. * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are
  2289. * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  2290. * the next time it is called even if the key had been released before the
  2291. * call. This is useful when you are only interested in whether keys have been
  2292. * pressed but not when or in which order.
  2293. *
  2294. * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  2295. * `GL_TRUE` to enable sticky mouse buttons, or `GL_FALSE` to disable it. If
  2296. * sticky mouse buttons are enabled, a mouse button press will ensure that @ref
  2297. * glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even if
  2298. * the mouse button had been released before the call. This is useful when you
  2299. * are only interested in whether mouse buttons have been pressed but not when
  2300. * or in which order.
  2301. *
  2302. * @param[in] window The window whose input mode to set.
  2303. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2304. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2305. * @param[in] value The new value of the specified input mode.
  2306. *
  2307. * @par Thread Safety
  2308. * This function may only be called from the main thread.
  2309. *
  2310. * @sa glfwGetInputMode
  2311. *
  2312. * @since Added in GLFW 3.0. Replaces `glfwEnable` and `glfwDisable`.
  2313. *
  2314. * @ingroup input
  2315. */
  2316. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  2317. /*! @brief Returns the last reported state of a keyboard key for the specified
  2318. * window.
  2319. *
  2320. * This function returns the last state reported for the specified key to the
  2321. * specified window. The returned state is one of `GLFW_PRESS` or
  2322. * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
  2323. * the key callback.
  2324. *
  2325. * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
  2326. * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  2327. * that key has already been released.
  2328. *
  2329. * The key functions deal with physical keys, with [key tokens](@ref keys)
  2330. * named after their use on the standard US keyboard layout. If you want to
  2331. * input text, use the Unicode character callback instead.
  2332. *
  2333. * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  2334. * used with this function.
  2335. *
  2336. * @param[in] window The desired window.
  2337. * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
  2338. * not a valid key for this function.
  2339. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  2340. *
  2341. * @par Thread Safety
  2342. * This function may only be called from the main thread.
  2343. *
  2344. * @sa @ref input_key
  2345. *
  2346. * @since Added in GLFW 1.0.
  2347. *
  2348. * @par
  2349. * __GLFW 3:__ Added window handle parameter.
  2350. *
  2351. * @ingroup input
  2352. */
  2353. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  2354. /*! @brief Returns the last reported state of a mouse button for the specified
  2355. * window.
  2356. *
  2357. * This function returns the last state reported for the specified mouse button
  2358. * to the specified window. The returned state is one of `GLFW_PRESS` or
  2359. * `GLFW_RELEASE`.
  2360. *
  2361. * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
  2362. * `GLFW_PRESS` the first time you call it for a mouse button that was pressed,
  2363. * even if that mouse button has already been released.
  2364. *
  2365. * @param[in] window The desired window.
  2366. * @param[in] button The desired [mouse button](@ref buttons).
  2367. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  2368. *
  2369. * @par Thread Safety
  2370. * This function may only be called from the main thread.
  2371. *
  2372. * @sa @ref input_mouse_button
  2373. *
  2374. * @since Added in GLFW 1.0.
  2375. *
  2376. * @par
  2377. * __GLFW 3:__ Added window handle parameter.
  2378. *
  2379. * @ingroup input
  2380. */
  2381. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  2382. /*! @brief Retrieves the position of the cursor relative to the client area of
  2383. * the window.
  2384. *
  2385. * This function returns the position of the cursor, in screen coordinates,
  2386. * relative to the upper-left corner of the client area of the specified
  2387. * window.
  2388. *
  2389. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  2390. * position is unbounded and limited only by the minimum and maximum values of
  2391. * a `double`.
  2392. *
  2393. * The coordinate can be converted to their integer equivalents with the
  2394. * `floor` function. Casting directly to an integer type works for positive
  2395. * coordinates, but fails for negative ones.
  2396. *
  2397. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  2398. * non-`NULL` position arguments will be set to zero.
  2399. *
  2400. * @param[in] window The desired window.
  2401. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  2402. * left edge of the client area, or `NULL`.
  2403. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  2404. * top edge of the client area, or `NULL`.
  2405. *
  2406. * @par Thread Safety
  2407. * This function may only be called from the main thread.
  2408. *
  2409. * @sa @ref cursor_pos
  2410. * @sa glfwSetCursorPos
  2411. *
  2412. * @since Added in GLFW 3.0. Replaces `glfwGetMousePos`.
  2413. *
  2414. * @ingroup input
  2415. */
  2416. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  2417. /*! @brief Sets the position of the cursor, relative to the client area of the
  2418. * window.
  2419. *
  2420. * This function sets the position, in screen coordinates, of the cursor
  2421. * relative to the upper-left corner of the client area of the specified
  2422. * window. The window must have input focus. If the window does not have
  2423. * input focus when this function is called, it fails silently.
  2424. *
  2425. * __Do not use this function__ to implement things like camera controls. GLFW
  2426. * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  2427. * cursor, transparently re-centers it and provides unconstrained cursor
  2428. * motion. See @ref glfwSetInputMode for more information.
  2429. *
  2430. * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  2431. * unconstrained and limited only by the minimum and maximum values of
  2432. * a `double`.
  2433. *
  2434. * @param[in] window The desired window.
  2435. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  2436. * client area.
  2437. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  2438. * client area.
  2439. *
  2440. * @remarks __X11:__ Due to the asynchronous nature of a modern X desktop, it
  2441. * may take a moment for the window focus event to arrive. This means you will
  2442. * not be able to set the cursor position directly after window creation.
  2443. *
  2444. * @par Thread Safety
  2445. * This function may only be called from the main thread.
  2446. *
  2447. * @sa @ref cursor_pos
  2448. * @sa glfwGetCursorPos
  2449. *
  2450. * @since Added in GLFW 3.0. Replaces `glfwSetMousePos`.
  2451. *
  2452. * @ingroup input
  2453. */
  2454. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  2455. /*! @brief Creates a custom cursor.
  2456. *
  2457. * Creates a new custom cursor image that can be set for a window with @ref
  2458. * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
  2459. * Any remaining cursors are destroyed by @ref glfwTerminate.
  2460. *
  2461. * The pixels are 32-bit little-endian RGBA, i.e. eight bits per channel. They
  2462. * are arranged canonically as packed sequential rows, starting from the
  2463. * top-left corner.
  2464. *
  2465. * The cursor hotspot is specified in pixels, relative to the upper-left corner
  2466. * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
  2467. * points to the right and the Y-axis points down.
  2468. *
  2469. * @param[in] image The desired cursor image.
  2470. * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
  2471. * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
  2472. *
  2473. * @return The handle of the created cursor, or `NULL` if an
  2474. * [error](@ref error_handling) occurred.
  2475. *
  2476. * @par Pointer Lifetime
  2477. * The specified image data is copied before this function returns.
  2478. *
  2479. * @par Reentrancy
  2480. * This function may not be called from a callback.
  2481. *
  2482. * @par Thread Safety
  2483. * This function may only be called from the main thread.
  2484. *
  2485. * @sa @ref cursor_object
  2486. * @sa glfwDestroyCursor
  2487. * @sa glfwCreateStandardCursor
  2488. *
  2489. * @since Added in GLFW 3.1.
  2490. *
  2491. * @ingroup input
  2492. */
  2493. GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
  2494. /*! @brief Creates a cursor with a standard shape.
  2495. *
  2496. * Returns a cursor with a [standard shape](@ref shapes), that can be set for
  2497. * a window with @ref glfwSetCursor.
  2498. *
  2499. * @param[in] shape One of the [standard shapes](@ref shapes).
  2500. *
  2501. * @return A new cursor ready to use or `NULL` if an
  2502. * [error](@ref error_handling) occurred.
  2503. *
  2504. * @par Reentrancy
  2505. * This function may not be called from a callback.
  2506. *
  2507. * @par Thread Safety
  2508. * This function may only be called from the main thread.
  2509. *
  2510. * @sa @ref cursor_object
  2511. * @sa glfwCreateCursor
  2512. *
  2513. * @since Added in GLFW 3.1.
  2514. *
  2515. * @ingroup input
  2516. */
  2517. GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
  2518. /*! @brief Destroys a cursor.
  2519. *
  2520. * This function destroys a cursor previously created with @ref
  2521. * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
  2522. * glfwTerminate.
  2523. *
  2524. * @param[in] cursor The cursor object to destroy.
  2525. *
  2526. * @par Reentrancy
  2527. * This function may not be called from a callback.
  2528. *
  2529. * @par Thread Safety
  2530. * This function may only be called from the main thread.
  2531. *
  2532. * @sa @ref cursor_object
  2533. * @sa glfwCreateCursor
  2534. *
  2535. * @since Added in GLFW 3.1.
  2536. *
  2537. * @ingroup input
  2538. */
  2539. GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
  2540. /*! @brief Sets the cursor for the window.
  2541. *
  2542. * This function sets the cursor image to be used when the cursor is over the
  2543. * client area of the specified window. The set cursor will only be visible
  2544. * when the [cursor mode](@ref cursor_mode) of the window is
  2545. * `GLFW_CURSOR_NORMAL`.
  2546. *
  2547. * On some platforms, the set cursor may not be visible unless the window also
  2548. * has input focus.
  2549. *
  2550. * @param[in] window The window to set the cursor for.
  2551. * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  2552. * arrow cursor.
  2553. *
  2554. * @par Thread Safety
  2555. * This function may only be called from the main thread.
  2556. *
  2557. * @sa @ref cursor_object
  2558. *
  2559. * @since Added in GLFW 3.1.
  2560. *
  2561. * @ingroup input
  2562. */
  2563. GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
  2564. /*! @brief Sets the key callback.
  2565. *
  2566. * This function sets the key callback of the specified window, which is called
  2567. * when a key is pressed, repeated or released.
  2568. *
  2569. * The key functions deal with physical keys, with layout independent
  2570. * [key tokens](@ref keys) named after their values in the standard US keyboard
  2571. * layout. If you want to input text, use the
  2572. * [character callback](@ref glfwSetCharCallback) instead.
  2573. *
  2574. * When a window loses input focus, it will generate synthetic key release
  2575. * events for all pressed keys. You can tell these events from user-generated
  2576. * events by the fact that the synthetic ones are generated after the focus
  2577. * loss event has been processed, i.e. after the
  2578. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  2579. *
  2580. * The scancode of a key is specific to that platform or sometimes even to that
  2581. * machine. Scancodes are intended to allow users to bind keys that don't have
  2582. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  2583. * state is not saved and so it cannot be queried with @ref glfwGetKey.
  2584. *
  2585. * Sometimes GLFW needs to generate synthetic key events, in which case the
  2586. * scancode may be zero.
  2587. *
  2588. * @param[in] window The window whose callback to set.
  2589. * @param[in] cbfun The new key callback, or `NULL` to remove the currently
  2590. * set callback.
  2591. * @return The previously set callback, or `NULL` if no callback was set or the
  2592. * library had not been [initialized](@ref intro_init).
  2593. *
  2594. * @par Thread Safety
  2595. * This function may only be called from the main thread.
  2596. *
  2597. * @sa @ref input_key
  2598. *
  2599. * @since Added in GLFW 1.0.
  2600. *
  2601. * @par
  2602. * __GLFW 3:__ Added window handle parameter. Updated callback signature.
  2603. *
  2604. * @ingroup input
  2605. */
  2606. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
  2607. /*! @brief Sets the Unicode character callback.
  2608. *
  2609. * This function sets the character callback of the specified window, which is
  2610. * called when a Unicode character is input.
  2611. *
  2612. * The character callback is intended for Unicode text input. As it deals with
  2613. * characters, it is keyboard layout dependent, whereas the
  2614. * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
  2615. * to physical keys, as a key may produce zero, one or more characters. If you
  2616. * want to know whether a specific physical key was pressed or released, see
  2617. * the key callback instead.
  2618. *
  2619. * The character callback behaves as system text input normally does and will
  2620. * not be called if modifier keys are held down that would prevent normal text
  2621. * input on that platform, for example a Super (Command) key on OS X or Alt key
  2622. * on Windows. There is a
  2623. * [character with modifiers callback](@ref glfwSetCharModsCallback) that
  2624. * receives these events.
  2625. *
  2626. * @param[in] window The window whose callback to set.
  2627. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2628. * callback.
  2629. * @return The previously set callback, or `NULL` if no callback was set or the
  2630. * library had not been [initialized](@ref intro_init).
  2631. *
  2632. * @par Thread Safety
  2633. * This function may only be called from the main thread.
  2634. *
  2635. * @sa @ref input_char
  2636. *
  2637. * @since Added in GLFW 2.4.
  2638. *
  2639. * @par
  2640. * __GLFW 3:__ Added window handle parameter. Updated callback signature.
  2641. *
  2642. * @ingroup input
  2643. */
  2644. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
  2645. /*! @brief Sets the Unicode character with modifiers callback.
  2646. *
  2647. * This function sets the character with modifiers callback of the specified
  2648. * window, which is called when a Unicode character is input regardless of what
  2649. * modifier keys are used.
  2650. *
  2651. * The character with modifiers callback is intended for implementing custom
  2652. * Unicode character input. For regular Unicode text input, see the
  2653. * [character callback](@ref glfwSetCharCallback). Like the character
  2654. * callback, the character with modifiers callback deals with characters and is
  2655. * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
  2656. * a key may produce zero, one or more characters. If you want to know whether
  2657. * a specific physical key was pressed or released, see the
  2658. * [key callback](@ref glfwSetKeyCallback) instead.
  2659. *
  2660. * @param[in] window The window whose callback to set.
  2661. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2662. * callback.
  2663. * @return The previously set callback, or `NULL` if no callback was set or an
  2664. * error occurred.
  2665. *
  2666. * @par Thread Safety
  2667. * This function may only be called from the main thread.
  2668. *
  2669. * @sa @ref input_char
  2670. *
  2671. * @since Added in GLFW 3.1.
  2672. *
  2673. * @ingroup input
  2674. */
  2675. GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);
  2676. /*! @brief Sets the mouse button callback.
  2677. *
  2678. * This function sets the mouse button callback of the specified window, which
  2679. * is called when a mouse button is pressed or released.
  2680. *
  2681. * When a window loses input focus, it will generate synthetic mouse button
  2682. * release events for all pressed mouse buttons. You can tell these events
  2683. * from user-generated events by the fact that the synthetic ones are generated
  2684. * after the focus loss event has been processed, i.e. after the
  2685. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  2686. *
  2687. * @param[in] window The window whose callback to set.
  2688. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2689. * callback.
  2690. * @return The previously set callback, or `NULL` if no callback was set or the
  2691. * library had not been [initialized](@ref intro_init).
  2692. *
  2693. * @par Thread Safety
  2694. * This function may only be called from the main thread.
  2695. *
  2696. * @sa @ref input_mouse_button
  2697. *
  2698. * @since Added in GLFW 1.0.
  2699. *
  2700. * @par
  2701. * __GLFW 3:__ Added window handle parameter. Updated callback signature.
  2702. *
  2703. * @ingroup input
  2704. */
  2705. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
  2706. /*! @brief Sets the cursor position callback.
  2707. *
  2708. * This function sets the cursor position callback of the specified window,
  2709. * which is called when the cursor is moved. The callback is provided with the
  2710. * position, in screen coordinates, relative to the upper-left corner of the
  2711. * client area of the window.
  2712. *
  2713. * @param[in] window The window whose callback to set.
  2714. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2715. * callback.
  2716. * @return The previously set callback, or `NULL` if no callback was set or the
  2717. * library had not been [initialized](@ref intro_init).
  2718. *
  2719. * @par Thread Safety
  2720. * This function may only be called from the main thread.
  2721. *
  2722. * @sa @ref cursor_pos
  2723. *
  2724. * @since Added in GLFW 3.0. Replaces `glfwSetMousePosCallback`.
  2725. *
  2726. * @ingroup input
  2727. */
  2728. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
  2729. /*! @brief Sets the cursor enter/exit callback.
  2730. *
  2731. * This function sets the cursor boundary crossing callback of the specified
  2732. * window, which is called when the cursor enters or leaves the client area of
  2733. * the window.
  2734. *
  2735. * @param[in] window The window whose callback to set.
  2736. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2737. * callback.
  2738. * @return The previously set callback, or `NULL` if no callback was set or the
  2739. * library had not been [initialized](@ref intro_init).
  2740. *
  2741. * @par Thread Safety
  2742. * This function may only be called from the main thread.
  2743. *
  2744. * @sa @ref cursor_enter
  2745. *
  2746. * @since Added in GLFW 3.0.
  2747. *
  2748. * @ingroup input
  2749. */
  2750. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
  2751. /*! @brief Sets the scroll callback.
  2752. *
  2753. * This function sets the scroll callback of the specified window, which is
  2754. * called when a scrolling device is used, such as a mouse wheel or scrolling
  2755. * area of a touchpad.
  2756. *
  2757. * The scroll callback receives all scrolling input, like that from a mouse
  2758. * wheel or a touchpad scrolling area.
  2759. *
  2760. * @param[in] window The window whose callback to set.
  2761. * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
  2762. * set callback.
  2763. * @return The previously set callback, or `NULL` if no callback was set or the
  2764. * library had not been [initialized](@ref intro_init).
  2765. *
  2766. * @par Thread Safety
  2767. * This function may only be called from the main thread.
  2768. *
  2769. * @sa @ref scrolling
  2770. *
  2771. * @since Added in GLFW 3.0. Replaces `glfwSetMouseWheelCallback`.
  2772. *
  2773. * @ingroup input
  2774. */
  2775. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
  2776. /*! @brief Sets the file drop callback.
  2777. *
  2778. * This function sets the file drop callback of the specified window, which is
  2779. * called when one or more dragged files are dropped on the window.
  2780. *
  2781. * Because the path array and its strings may have been generated specifically
  2782. * for that event, they are not guaranteed to be valid after the callback has
  2783. * returned. If you wish to use them after the callback returns, you need to
  2784. * make a deep copy.
  2785. *
  2786. * @param[in] window The window whose callback to set.
  2787. * @param[in] cbfun The new file drop callback, or `NULL` to remove the
  2788. * currently set callback.
  2789. * @return The previously set callback, or `NULL` if no callback was set or the
  2790. * library had not been [initialized](@ref intro_init).
  2791. *
  2792. * @par Thread Safety
  2793. * This function may only be called from the main thread.
  2794. *
  2795. * @sa @ref path_drop
  2796. *
  2797. * @since Added in GLFW 3.1.
  2798. *
  2799. * @ingroup input
  2800. */
  2801. GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);
  2802. /*! @brief Returns whether the specified joystick is present.
  2803. *
  2804. * This function returns whether the specified joystick is present.
  2805. *
  2806. * @param[in] joy The [joystick](@ref joysticks) to query.
  2807. * @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise.
  2808. *
  2809. * @par Thread Safety
  2810. * This function may only be called from the main thread.
  2811. *
  2812. * @sa @ref joystick
  2813. *
  2814. * @since Added in GLFW 3.0. Replaces `glfwGetJoystickParam`.
  2815. *
  2816. * @ingroup input
  2817. */
  2818. GLFWAPI int glfwJoystickPresent(int joy);
  2819. /*! @brief Returns the values of all axes of the specified joystick.
  2820. *
  2821. * This function returns the values of all axes of the specified joystick.
  2822. * Each element in the array is a value between -1.0 and 1.0.
  2823. *
  2824. * @param[in] joy The [joystick](@ref joysticks) to query.
  2825. * @param[out] count Where to store the number of axis values in the returned
  2826. * array. This is set to zero if an error occurred.
  2827. * @return An array of axis values, or `NULL` if the joystick is not present.
  2828. *
  2829. * @par Pointer Lifetime
  2830. * The returned array is allocated and freed by GLFW. You should not free it
  2831. * yourself. It is valid until the specified joystick is disconnected, this
  2832. * function is called again for that joystick or the library is terminated.
  2833. *
  2834. * @par Thread Safety
  2835. * This function may only be called from the main thread.
  2836. *
  2837. * @sa @ref joystick_axis
  2838. *
  2839. * @since Added in GLFW 3.0. Replaces `glfwGetJoystickPos`.
  2840. *
  2841. * @ingroup input
  2842. */
  2843. GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count);
  2844. /*! @brief Returns the state of all buttons of the specified joystick.
  2845. *
  2846. * This function returns the state of all buttons of the specified joystick.
  2847. * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
  2848. *
  2849. * @param[in] joy The [joystick](@ref joysticks) to query.
  2850. * @param[out] count Where to store the number of button states in the returned
  2851. * array. This is set to zero if an error occurred.
  2852. * @return An array of button states, or `NULL` if the joystick is not present.
  2853. *
  2854. * @par Pointer Lifetime
  2855. * The returned array is allocated and freed by GLFW. You should not free it
  2856. * yourself. It is valid until the specified joystick is disconnected, this
  2857. * function is called again for that joystick or the library is terminated.
  2858. *
  2859. * @par Thread Safety
  2860. * This function may only be called from the main thread.
  2861. *
  2862. * @sa @ref joystick_button
  2863. *
  2864. * @since Added in GLFW 2.2.
  2865. *
  2866. * @par
  2867. * __GLFW 3:__ Changed to return a dynamic array.
  2868. *
  2869. * @ingroup input
  2870. */
  2871. GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count);
  2872. /*! @brief Returns the name of the specified joystick.
  2873. *
  2874. * This function returns the name, encoded as UTF-8, of the specified joystick.
  2875. * The returned string is allocated and freed by GLFW. You should not free it
  2876. * yourself.
  2877. *
  2878. * @param[in] joy The [joystick](@ref joysticks) to query.
  2879. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  2880. * is not present.
  2881. *
  2882. * @par Pointer Lifetime
  2883. * The returned string is allocated and freed by GLFW. You should not free it
  2884. * yourself. It is valid until the specified joystick is disconnected, this
  2885. * function is called again for that joystick or the library is terminated.
  2886. *
  2887. * @par Thread Safety
  2888. * This function may only be called from the main thread.
  2889. *
  2890. * @sa @ref joystick_name
  2891. *
  2892. * @since Added in GLFW 3.0.
  2893. *
  2894. * @ingroup input
  2895. */
  2896. GLFWAPI const char* glfwGetJoystickName(int joy);
  2897. /*! @brief Sets the clipboard to the specified string.
  2898. *
  2899. * This function sets the system clipboard to the specified, UTF-8 encoded
  2900. * string.
  2901. *
  2902. * @param[in] window The window that will own the clipboard contents.
  2903. * @param[in] string A UTF-8 encoded string.
  2904. *
  2905. * @par Pointer Lifetime
  2906. * The specified string is copied before this function returns.
  2907. *
  2908. * @par Thread Safety
  2909. * This function may only be called from the main thread.
  2910. *
  2911. * @sa @ref clipboard
  2912. * @sa glfwGetClipboardString
  2913. *
  2914. * @since Added in GLFW 3.0.
  2915. *
  2916. * @ingroup input
  2917. */
  2918. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  2919. /*! @brief Returns the contents of the clipboard as a string.
  2920. *
  2921. * This function returns the contents of the system clipboard, if it contains
  2922. * or is convertible to a UTF-8 encoded string.
  2923. *
  2924. * @param[in] window The window that will request the clipboard contents.
  2925. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  2926. * if an [error](@ref error_handling) occurred.
  2927. *
  2928. * @par Pointer Lifetime
  2929. * The returned string is allocated and freed by GLFW. You should not free it
  2930. * yourself. It is valid until the next call to @ref
  2931. * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
  2932. * is terminated.
  2933. *
  2934. * @par Thread Safety
  2935. * This function may only be called from the main thread.
  2936. *
  2937. * @sa @ref clipboard
  2938. * @sa glfwSetClipboardString
  2939. *
  2940. * @since Added in GLFW 3.0.
  2941. *
  2942. * @ingroup input
  2943. */
  2944. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  2945. /*! @brief Returns the value of the GLFW timer.
  2946. *
  2947. * This function returns the value of the GLFW timer. Unless the timer has
  2948. * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
  2949. * was initialized.
  2950. *
  2951. * The resolution of the timer is system dependent, but is usually on the order
  2952. * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
  2953. * time source on each supported platform.
  2954. *
  2955. * @return The current value, in seconds, or zero if an
  2956. * [error](@ref error_handling) occurred.
  2957. *
  2958. * @par Thread Safety
  2959. * This function may be called from any thread. Access is not synchronized.
  2960. *
  2961. * @sa @ref time
  2962. *
  2963. * @since Added in GLFW 1.0.
  2964. *
  2965. * @ingroup input
  2966. */
  2967. GLFWAPI double glfwGetTime(void);
  2968. /*! @brief Sets the GLFW timer.
  2969. *
  2970. * This function sets the value of the GLFW timer. It then continues to count
  2971. * up from that value. The value must be a positive finite number less than
  2972. * or equal to 18446744073.0, which is approximately 584.5 years.
  2973. *
  2974. * @param[in] time The new value, in seconds.
  2975. *
  2976. * @remarks The upper limit of the timer is calculated as
  2977. * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
  2978. * storing nanoseconds in 64 bits. The limit may be increased in the future.
  2979. *
  2980. * @par Thread Safety
  2981. * This function may only be called from the main thread.
  2982. *
  2983. * @sa @ref time
  2984. *
  2985. * @since Added in GLFW 2.2.
  2986. *
  2987. * @ingroup input
  2988. */
  2989. GLFWAPI void glfwSetTime(double time);
  2990. /*! @brief Makes the context of the specified window current for the calling
  2991. * thread.
  2992. *
  2993. * This function makes the OpenGL or OpenGL ES context of the specified window
  2994. * current on the calling thread. A context can only be made current on
  2995. * a single thread at a time and each thread can have only a single current
  2996. * context at a time.
  2997. *
  2998. * By default, making a context non-current implicitly forces a pipeline flush.
  2999. * On machines that support `GL_KHR_context_flush_control`, you can control
  3000. * whether a context performs this flush by setting the
  3001. * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint.
  3002. *
  3003. * @param[in] window The window whose context to make current, or `NULL` to
  3004. * detach the current context.
  3005. *
  3006. * @par Thread Safety
  3007. * This function may be called from any thread.
  3008. *
  3009. * @sa @ref context_current
  3010. * @sa glfwGetCurrentContext
  3011. *
  3012. * @since Added in GLFW 3.0.
  3013. *
  3014. * @ingroup context
  3015. */
  3016. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  3017. /*! @brief Returns the window whose context is current on the calling thread.
  3018. *
  3019. * This function returns the window whose OpenGL or OpenGL ES context is
  3020. * current on the calling thread.
  3021. *
  3022. * @return The window whose context is current, or `NULL` if no window's
  3023. * context is current.
  3024. *
  3025. * @par Thread Safety
  3026. * This function may be called from any thread.
  3027. *
  3028. * @sa @ref context_current
  3029. * @sa glfwMakeContextCurrent
  3030. *
  3031. * @since Added in GLFW 3.0.
  3032. *
  3033. * @ingroup context
  3034. */
  3035. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  3036. /*! @brief Swaps the front and back buffers of the specified window.
  3037. *
  3038. * This function swaps the front and back buffers of the specified window. If
  3039. * the swap interval is greater than zero, the GPU driver waits the specified
  3040. * number of screen updates before swapping the buffers.
  3041. *
  3042. * @param[in] window The window whose buffers to swap.
  3043. *
  3044. * @par Thread Safety
  3045. * This function may be called from any thread.
  3046. *
  3047. * @sa @ref buffer_swap
  3048. * @sa glfwSwapInterval
  3049. *
  3050. * @since Added in GLFW 1.0.
  3051. *
  3052. * @par
  3053. * __GLFW 3:__ Added window handle parameter.
  3054. *
  3055. * @ingroup window
  3056. */
  3057. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  3058. /*! @brief Sets the swap interval for the current context.
  3059. *
  3060. * This function sets the swap interval for the current context, i.e. the
  3061. * number of screen updates to wait from the time @ref glfwSwapBuffers was
  3062. * called before swapping the buffers and returning. This is sometimes called
  3063. * _vertical synchronization_, _vertical retrace synchronization_ or just
  3064. * _vsync_.
  3065. *
  3066. * Contexts that support either of the `WGL_EXT_swap_control_tear` and
  3067. * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,
  3068. * which allow the driver to swap even if a frame arrives a little bit late.
  3069. * You can check for the presence of these extensions using @ref
  3070. * glfwExtensionSupported. For more information about swap tearing, see the
  3071. * extension specifications.
  3072. *
  3073. * A context must be current on the calling thread. Calling this function
  3074. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3075. *
  3076. * @param[in] interval The minimum number of screen updates to wait for
  3077. * until the buffers are swapped by @ref glfwSwapBuffers.
  3078. *
  3079. * @remarks This function is not called during context creation, leaving the
  3080. * swap interval set to whatever is the default on that platform. This is done
  3081. * because some swap interval extensions used by GLFW do not allow the swap
  3082. * interval to be reset to zero once it has been set to a non-zero value.
  3083. *
  3084. * @remarks Some GPU drivers do not honor the requested swap interval, either
  3085. * because of a user setting that overrides the application's request or due to
  3086. * bugs in the driver.
  3087. *
  3088. * @par Thread Safety
  3089. * This function may be called from any thread.
  3090. *
  3091. * @sa @ref buffer_swap
  3092. * @sa glfwSwapBuffers
  3093. *
  3094. * @since Added in GLFW 1.0.
  3095. *
  3096. * @ingroup context
  3097. */
  3098. GLFWAPI void glfwSwapInterval(int interval);
  3099. /*! @brief Returns whether the specified extension is available.
  3100. *
  3101. * This function returns whether the specified
  3102. * [client API extension](@ref context_glext) is supported by the current
  3103. * OpenGL or OpenGL ES context. It searches both for OpenGL and OpenGL ES
  3104. * extension and platform-specific context creation API extensions.
  3105. *
  3106. * A context must be current on the calling thread. Calling this function
  3107. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3108. *
  3109. * As this functions retrieves and searches one or more extension strings each
  3110. * call, it is recommended that you cache its results if it is going to be used
  3111. * frequently. The extension strings will not change during the lifetime of
  3112. * a context, so there is no danger in doing this.
  3113. *
  3114. * @param[in] extension The ASCII encoded name of the extension.
  3115. * @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise.
  3116. *
  3117. * @par Thread Safety
  3118. * This function may be called from any thread.
  3119. *
  3120. * @sa @ref context_glext
  3121. * @sa glfwGetProcAddress
  3122. *
  3123. * @since Added in GLFW 1.0.
  3124. *
  3125. * @ingroup context
  3126. */
  3127. GLFWAPI int glfwExtensionSupported(const char* extension);
  3128. /*! @brief Returns the address of the specified function for the current
  3129. * context.
  3130. *
  3131. * This function returns the address of the specified
  3132. * [core or extension function](@ref context_glext), if it is supported
  3133. * by the current context.
  3134. *
  3135. * A context must be current on the calling thread. Calling this function
  3136. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3137. *
  3138. * @param[in] procname The ASCII encoded name of the function.
  3139. * @return The address of the function, or `NULL` if the function is
  3140. * unavailable or an [error](@ref error_handling) occurred.
  3141. *
  3142. * @remarks The addresses of a given function is not guaranteed to be the same
  3143. * between contexts.
  3144. *
  3145. * @remarks This function may return a non-`NULL` address despite the
  3146. * associated version or extension not being available. Always check the
  3147. * context version or extension string presence first.
  3148. *
  3149. * @par Pointer Lifetime
  3150. * The returned function pointer is valid until the context is destroyed or the
  3151. * library is terminated.
  3152. *
  3153. * @par Thread Safety
  3154. * This function may be called from any thread.
  3155. *
  3156. * @sa @ref context_glext
  3157. * @sa glfwExtensionSupported
  3158. *
  3159. * @since Added in GLFW 1.0.
  3160. *
  3161. * @ingroup context
  3162. */
  3163. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  3164. /*************************************************************************
  3165. * Global definition cleanup
  3166. *************************************************************************/
  3167. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  3168. #ifdef GLFW_WINGDIAPI_DEFINED
  3169. #undef WINGDIAPI
  3170. #undef GLFW_WINGDIAPI_DEFINED
  3171. #endif
  3172. #ifdef GLFW_CALLBACK_DEFINED
  3173. #undef CALLBACK
  3174. #undef GLFW_CALLBACK_DEFINED
  3175. #endif
  3176. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  3177. #ifdef __cplusplus
  3178. }
  3179. #endif
  3180. #endif /* _glfw3_h_ */