glfw3.h 148 KB

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