glfw3.h 196 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538
  1. /*************************************************************************
  2. * GLFW 3.3 - www.glfw.org
  3. * A library for OpenGL, window and input
  4. *------------------------------------------------------------------------
  5. * Copyright (c) 2002-2006 Marcus Geelnard
  6. * Copyright (c) 2006-2016 Camilla Löwy <[email protected]>
  7. *
  8. * This software is provided 'as-is', without any express or implied
  9. * warranty. In no event will the authors be held liable for any damages
  10. * arising from the use of this software.
  11. *
  12. * Permission is granted to anyone to use this software for any purpose,
  13. * including commercial applications, and to alter it and redistribute it
  14. * freely, subject to the following restrictions:
  15. *
  16. * 1. The origin of this software must not be misrepresented; you must not
  17. * claim that you wrote the original software. If you use this software
  18. * in a product, an acknowledgment in the product documentation would
  19. * be appreciated but is not required.
  20. *
  21. * 2. Altered source versions must be plainly marked as such, and must not
  22. * be misrepresented as being the original software.
  23. *
  24. * 3. This notice may not be removed or altered from any source
  25. * distribution.
  26. *
  27. *************************************************************************/
  28. #ifndef _glfw3_h_
  29. #define _glfw3_h_
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /*************************************************************************
  34. * Doxygen documentation
  35. *************************************************************************/
  36. /*! @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. * @brief Functions and types related to OpenGL and OpenGL ES contexts.
  46. *
  47. * This is the reference documentation for OpenGL and OpenGL ES context related
  48. * functions. For more task-oriented information, see the @ref context_guide.
  49. */
  50. /*! @defgroup vulkan Vulkan reference
  51. * @brief Functions and types related to Vulkan.
  52. *
  53. * This is the reference documentation for Vulkan related functions and types.
  54. * For more task-oriented information, see the @ref vulkan_guide.
  55. */
  56. /*! @defgroup init Initialization, version and error reference
  57. * @brief Functions and types related to initialization and error handling.
  58. *
  59. * This is the reference documentation for initialization and termination of
  60. * the library, version management and error handling. For more task-oriented
  61. * information, see the @ref intro_guide.
  62. */
  63. /*! @defgroup input Input reference
  64. * @brief Functions and types related to input handling.
  65. *
  66. * This is the reference documentation for input related functions and types.
  67. * For more task-oriented information, see the @ref input_guide.
  68. */
  69. /*! @defgroup monitor Monitor reference
  70. * @brief Functions and types related to monitors.
  71. *
  72. * This is the reference documentation for monitor related functions and types.
  73. * For more task-oriented information, see the @ref monitor_guide.
  74. */
  75. /*! @defgroup window Window reference
  76. * @brief Functions and types related to windows.
  77. *
  78. * This is the reference documentation for window related functions and types,
  79. * including creation, deletion and event polling. For more task-oriented
  80. * information, see the @ref window_guide.
  81. */
  82. /*************************************************************************
  83. * Compiler- and platform-specific preprocessor work
  84. *************************************************************************/
  85. /* If we are we on Windows, we want a single define for it.
  86. */
  87. #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
  88. #define _WIN32
  89. #endif /* _WIN32 */
  90. /* It is customary to use APIENTRY for OpenGL function pointer declarations on
  91. * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
  92. */
  93. #ifndef APIENTRY
  94. #ifdef _WIN32
  95. #define APIENTRY __stdcall
  96. #else
  97. #define APIENTRY
  98. #endif
  99. #define GLFW_APIENTRY_DEFINED
  100. #endif /* APIENTRY */
  101. /* Some Windows OpenGL headers need this.
  102. */
  103. #if !defined(WINGDIAPI) && defined(_WIN32)
  104. #define WINGDIAPI __declspec(dllimport)
  105. #define GLFW_WINGDIAPI_DEFINED
  106. #endif /* WINGDIAPI */
  107. /* Some Windows GLU headers need this.
  108. */
  109. #if !defined(CALLBACK) && defined(_WIN32)
  110. #define CALLBACK __stdcall
  111. #define GLFW_CALLBACK_DEFINED
  112. #endif /* CALLBACK */
  113. /* Include because most Windows GLU headers need wchar_t and
  114. * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
  115. * Include it unconditionally to avoid surprising side-effects.
  116. */
  117. #include <stddef.h>
  118. /* Include because it is needed by Vulkan and related functions.
  119. * Include it unconditionally to avoid surprising side-effects.
  120. */
  121. #include <stdint.h>
  122. /* Include the chosen OpenGL or OpenGL ES headers.
  123. */
  124. #if defined(GLFW_INCLUDE_ES1)
  125. #include <GLES/gl.h>
  126. #if defined(GLFW_INCLUDE_GLEXT)
  127. #include <GLES/glext.h>
  128. #endif
  129. #elif defined(GLFW_INCLUDE_ES2)
  130. #include <GLES2/gl2.h>
  131. #if defined(GLFW_INCLUDE_GLEXT)
  132. #include <GLES2/gl2ext.h>
  133. #endif
  134. #elif defined(GLFW_INCLUDE_ES3)
  135. #include <GLES3/gl3.h>
  136. #if defined(GLFW_INCLUDE_GLEXT)
  137. #include <GLES2/gl2ext.h>
  138. #endif
  139. #elif defined(GLFW_INCLUDE_ES31)
  140. #include <GLES3/gl31.h>
  141. #if defined(GLFW_INCLUDE_GLEXT)
  142. #include <GLES2/gl2ext.h>
  143. #endif
  144. #elif defined(GLFW_INCLUDE_ES32)
  145. #include <GLES3/gl32.h>
  146. #if defined(GLFW_INCLUDE_GLEXT)
  147. #include <GLES2/gl2ext.h>
  148. #endif
  149. #elif defined(GLFW_INCLUDE_GLCOREARB)
  150. #if defined(__APPLE__)
  151. #include <OpenGL/gl3.h>
  152. #if defined(GLFW_INCLUDE_GLEXT)
  153. #include <OpenGL/gl3ext.h>
  154. #endif /*GLFW_INCLUDE_GLEXT*/
  155. #else /*__APPLE__*/
  156. #include <GL/glcorearb.h>
  157. #endif /*__APPLE__*/
  158. #elif !defined(GLFW_INCLUDE_NONE)
  159. #if defined(__APPLE__)
  160. #if !defined(GLFW_INCLUDE_GLEXT)
  161. #define GL_GLEXT_LEGACY
  162. #endif
  163. #include <OpenGL/gl.h>
  164. #if defined(GLFW_INCLUDE_GLU)
  165. #include <OpenGL/glu.h>
  166. #endif
  167. #else /*__APPLE__*/
  168. #include <GL/gl.h>
  169. #if defined(GLFW_INCLUDE_GLEXT)
  170. #include <GL/glext.h>
  171. #endif
  172. #if defined(GLFW_INCLUDE_GLU)
  173. #include <GL/glu.h>
  174. #endif
  175. #endif /*__APPLE__*/
  176. #endif /* OpenGL and OpenGL ES headers */
  177. #if defined(GLFW_INCLUDE_VULKAN)
  178. #include <vulkan/vulkan.h>
  179. #endif /* Vulkan header */
  180. #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
  181. /* GLFW_DLL must be defined by applications that are linking against the DLL
  182. * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
  183. * configuration header when compiling the DLL version of the library.
  184. */
  185. #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
  186. #endif
  187. /* GLFWAPI is used to declare public API functions for export
  188. * from the DLL / shared library / dynamic library.
  189. */
  190. #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
  191. /* We are building GLFW as a Win32 DLL */
  192. #define GLFWAPI __declspec(dllexport)
  193. #elif defined(_WIN32) && defined(GLFW_DLL)
  194. /* We are calling GLFW as a Win32 DLL */
  195. #define GLFWAPI __declspec(dllimport)
  196. #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
  197. /* We are building GLFW as a shared / dynamic library */
  198. #define GLFWAPI __attribute__((visibility("default")))
  199. #else
  200. /* We are building or calling GLFW as a static library */
  201. #define GLFWAPI
  202. #endif
  203. /*************************************************************************
  204. * GLFW API tokens
  205. *************************************************************************/
  206. /*! @name GLFW version macros
  207. * @{ */
  208. /*! @brief The major version number of the GLFW library.
  209. *
  210. * This is incremented when the API is changed in non-compatible ways.
  211. * @ingroup init
  212. */
  213. #define GLFW_VERSION_MAJOR 3
  214. /*! @brief The minor version number of the GLFW library.
  215. *
  216. * This is incremented when features are added to the API but it remains
  217. * backward-compatible.
  218. * @ingroup init
  219. */
  220. #define GLFW_VERSION_MINOR 3
  221. /*! @brief The revision number of the GLFW library.
  222. *
  223. * This is incremented when a bug fix release is made that does not contain any
  224. * API changes.
  225. * @ingroup init
  226. */
  227. #define GLFW_VERSION_REVISION 0
  228. /*! @} */
  229. /*! @name Boolean values
  230. * @{ */
  231. /*! @brief One.
  232. *
  233. * One. Seriously. You don't _need_ to use this symbol in your code. It's
  234. * semantic sugar for the number 1. You can also use `1` or `true` or `_True`
  235. * or `GL_TRUE` or whatever you want.
  236. */
  237. #define GLFW_TRUE 1
  238. /*! @brief Zero.
  239. *
  240. * Zero. Seriously. You don't _need_ to use this symbol in your code. It's
  241. * semantic sugar for the number 0. You can also use `0` or `false` or
  242. * `_False` or `GL_FALSE` or whatever you want.
  243. */
  244. #define GLFW_FALSE 0
  245. /*! @} */
  246. /*! @name Key and button actions
  247. * @{ */
  248. /*! @brief The key or mouse button was released.
  249. *
  250. * The key or mouse button was released.
  251. *
  252. * @ingroup input
  253. */
  254. #define GLFW_RELEASE 0
  255. /*! @brief The key or mouse button was pressed.
  256. *
  257. * The key or mouse button was pressed.
  258. *
  259. * @ingroup input
  260. */
  261. #define GLFW_PRESS 1
  262. /*! @brief The key was held down until it repeated.
  263. *
  264. * The key was held down until it repeated.
  265. *
  266. * @ingroup input
  267. */
  268. #define GLFW_REPEAT 2
  269. /*! @} */
  270. /*! @defgroup hat_state Joystick hat states
  271. *
  272. * See [joystick hat input](@ref joystick_hat) for how these are used.
  273. *
  274. * @ingroup input
  275. * @{ */
  276. #define GLFW_HAT_CENTERED 0
  277. #define GLFW_HAT_UP 1
  278. #define GLFW_HAT_RIGHT 2
  279. #define GLFW_HAT_DOWN 4
  280. #define GLFW_HAT_LEFT 8
  281. #define GLFW_HAT_RIGHT_UP (GLFW_HAT_RIGHT | GLFW_HAT_UP)
  282. #define GLFW_HAT_RIGHT_DOWN (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
  283. #define GLFW_HAT_LEFT_UP (GLFW_HAT_LEFT | GLFW_HAT_UP)
  284. #define GLFW_HAT_LEFT_DOWN (GLFW_HAT_LEFT | GLFW_HAT_DOWN)
  285. /*! @} */
  286. /*! @defgroup keys Keyboard keys
  287. * @brief Keyboard key IDs.
  288. *
  289. * See [key input](@ref input_key) for how these are used.
  290. *
  291. * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
  292. * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
  293. * put in the 256+ range).
  294. *
  295. * The naming of the key codes follow these rules:
  296. * - The US keyboard layout is used
  297. * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
  298. * "3", etc.)
  299. * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
  300. * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
  301. * correspond to the Unicode standard (usually for brevity)
  302. * - Keys that lack a clear US mapping are named "WORLD_x"
  303. * - For non-printable keys, custom names are used (e.g. "F4",
  304. * "BACKSPACE", etc.)
  305. *
  306. * @ingroup input
  307. * @{
  308. */
  309. /* The unknown key */
  310. #define GLFW_KEY_UNKNOWN -1
  311. /* Printable keys */
  312. #define GLFW_KEY_SPACE 32
  313. #define GLFW_KEY_APOSTROPHE 39 /* ' */
  314. #define GLFW_KEY_COMMA 44 /* , */
  315. #define GLFW_KEY_MINUS 45 /* - */
  316. #define GLFW_KEY_PERIOD 46 /* . */
  317. #define GLFW_KEY_SLASH 47 /* / */
  318. #define GLFW_KEY_0 48
  319. #define GLFW_KEY_1 49
  320. #define GLFW_KEY_2 50
  321. #define GLFW_KEY_3 51
  322. #define GLFW_KEY_4 52
  323. #define GLFW_KEY_5 53
  324. #define GLFW_KEY_6 54
  325. #define GLFW_KEY_7 55
  326. #define GLFW_KEY_8 56
  327. #define GLFW_KEY_9 57
  328. #define GLFW_KEY_SEMICOLON 59 /* ; */
  329. #define GLFW_KEY_EQUAL 61 /* = */
  330. #define GLFW_KEY_A 65
  331. #define GLFW_KEY_B 66
  332. #define GLFW_KEY_C 67
  333. #define GLFW_KEY_D 68
  334. #define GLFW_KEY_E 69
  335. #define GLFW_KEY_F 70
  336. #define GLFW_KEY_G 71
  337. #define GLFW_KEY_H 72
  338. #define GLFW_KEY_I 73
  339. #define GLFW_KEY_J 74
  340. #define GLFW_KEY_K 75
  341. #define GLFW_KEY_L 76
  342. #define GLFW_KEY_M 77
  343. #define GLFW_KEY_N 78
  344. #define GLFW_KEY_O 79
  345. #define GLFW_KEY_P 80
  346. #define GLFW_KEY_Q 81
  347. #define GLFW_KEY_R 82
  348. #define GLFW_KEY_S 83
  349. #define GLFW_KEY_T 84
  350. #define GLFW_KEY_U 85
  351. #define GLFW_KEY_V 86
  352. #define GLFW_KEY_W 87
  353. #define GLFW_KEY_X 88
  354. #define GLFW_KEY_Y 89
  355. #define GLFW_KEY_Z 90
  356. #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
  357. #define GLFW_KEY_BACKSLASH 92 /* \ */
  358. #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
  359. #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
  360. #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
  361. #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
  362. /* Function keys */
  363. #define GLFW_KEY_ESCAPE 256
  364. #define GLFW_KEY_ENTER 257
  365. #define GLFW_KEY_TAB 258
  366. #define GLFW_KEY_BACKSPACE 259
  367. #define GLFW_KEY_INSERT 260
  368. #define GLFW_KEY_DELETE 261
  369. #define GLFW_KEY_RIGHT 262
  370. #define GLFW_KEY_LEFT 263
  371. #define GLFW_KEY_DOWN 264
  372. #define GLFW_KEY_UP 265
  373. #define GLFW_KEY_PAGE_UP 266
  374. #define GLFW_KEY_PAGE_DOWN 267
  375. #define GLFW_KEY_HOME 268
  376. #define GLFW_KEY_END 269
  377. #define GLFW_KEY_CAPS_LOCK 280
  378. #define GLFW_KEY_SCROLL_LOCK 281
  379. #define GLFW_KEY_NUM_LOCK 282
  380. #define GLFW_KEY_PRINT_SCREEN 283
  381. #define GLFW_KEY_PAUSE 284
  382. #define GLFW_KEY_F1 290
  383. #define GLFW_KEY_F2 291
  384. #define GLFW_KEY_F3 292
  385. #define GLFW_KEY_F4 293
  386. #define GLFW_KEY_F5 294
  387. #define GLFW_KEY_F6 295
  388. #define GLFW_KEY_F7 296
  389. #define GLFW_KEY_F8 297
  390. #define GLFW_KEY_F9 298
  391. #define GLFW_KEY_F10 299
  392. #define GLFW_KEY_F11 300
  393. #define GLFW_KEY_F12 301
  394. #define GLFW_KEY_F13 302
  395. #define GLFW_KEY_F14 303
  396. #define GLFW_KEY_F15 304
  397. #define GLFW_KEY_F16 305
  398. #define GLFW_KEY_F17 306
  399. #define GLFW_KEY_F18 307
  400. #define GLFW_KEY_F19 308
  401. #define GLFW_KEY_F20 309
  402. #define GLFW_KEY_F21 310
  403. #define GLFW_KEY_F22 311
  404. #define GLFW_KEY_F23 312
  405. #define GLFW_KEY_F24 313
  406. #define GLFW_KEY_F25 314
  407. #define GLFW_KEY_KP_0 320
  408. #define GLFW_KEY_KP_1 321
  409. #define GLFW_KEY_KP_2 322
  410. #define GLFW_KEY_KP_3 323
  411. #define GLFW_KEY_KP_4 324
  412. #define GLFW_KEY_KP_5 325
  413. #define GLFW_KEY_KP_6 326
  414. #define GLFW_KEY_KP_7 327
  415. #define GLFW_KEY_KP_8 328
  416. #define GLFW_KEY_KP_9 329
  417. #define GLFW_KEY_KP_DECIMAL 330
  418. #define GLFW_KEY_KP_DIVIDE 331
  419. #define GLFW_KEY_KP_MULTIPLY 332
  420. #define GLFW_KEY_KP_SUBTRACT 333
  421. #define GLFW_KEY_KP_ADD 334
  422. #define GLFW_KEY_KP_ENTER 335
  423. #define GLFW_KEY_KP_EQUAL 336
  424. #define GLFW_KEY_LEFT_SHIFT 340
  425. #define GLFW_KEY_LEFT_CONTROL 341
  426. #define GLFW_KEY_LEFT_ALT 342
  427. #define GLFW_KEY_LEFT_SUPER 343
  428. #define GLFW_KEY_RIGHT_SHIFT 344
  429. #define GLFW_KEY_RIGHT_CONTROL 345
  430. #define GLFW_KEY_RIGHT_ALT 346
  431. #define GLFW_KEY_RIGHT_SUPER 347
  432. #define GLFW_KEY_MENU 348
  433. #define GLFW_KEY_LAST GLFW_KEY_MENU
  434. /*! @} */
  435. /*! @defgroup mods Modifier key flags
  436. * @brief Modifier key flags.
  437. *
  438. * See [key input](@ref input_key) for how these are used.
  439. *
  440. * @ingroup input
  441. * @{ */
  442. /*! @brief If this bit is set one or more Shift keys were held down.
  443. *
  444. * If this bit is set one or more Shift keys were held down.
  445. */
  446. #define GLFW_MOD_SHIFT 0x0001
  447. /*! @brief If this bit is set one or more Control keys were held down.
  448. *
  449. * If this bit is set one or more Control keys were held down.
  450. */
  451. #define GLFW_MOD_CONTROL 0x0002
  452. /*! @brief If this bit is set one or more Alt keys were held down.
  453. *
  454. * If this bit is set one or more Alt keys were held down.
  455. */
  456. #define GLFW_MOD_ALT 0x0004
  457. /*! @brief If this bit is set one or more Super keys were held down.
  458. *
  459. * If this bit is set one or more Super keys were held down.
  460. */
  461. #define GLFW_MOD_SUPER 0x0008
  462. /*! @brief If this bit is set the Caps Lock key is enabled.
  463. *
  464. * If this bit is set the Caps Lock key is enabled and the @ref
  465. * GLFW_LOCK_KEY_MODS input mode is set.
  466. */
  467. #define GLFW_MOD_CAPS_LOCK 0x0010
  468. /*! @brief If this bit is set the Num Lock key is enabled.
  469. *
  470. * If this bit is set the Num Lock key is enabled and the @ref
  471. * GLFW_LOCK_KEY_MODS input mode is set.
  472. */
  473. #define GLFW_MOD_NUM_LOCK 0x0020
  474. /*! @} */
  475. /*! @defgroup buttons Mouse buttons
  476. * @brief Mouse button IDs.
  477. *
  478. * See [mouse button input](@ref input_mouse_button) for how these are used.
  479. *
  480. * @ingroup input
  481. * @{ */
  482. #define GLFW_MOUSE_BUTTON_1 0
  483. #define GLFW_MOUSE_BUTTON_2 1
  484. #define GLFW_MOUSE_BUTTON_3 2
  485. #define GLFW_MOUSE_BUTTON_4 3
  486. #define GLFW_MOUSE_BUTTON_5 4
  487. #define GLFW_MOUSE_BUTTON_6 5
  488. #define GLFW_MOUSE_BUTTON_7 6
  489. #define GLFW_MOUSE_BUTTON_8 7
  490. #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
  491. #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
  492. #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
  493. #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
  494. /*! @} */
  495. /*! @defgroup joysticks Joysticks
  496. * @brief Joystick IDs.
  497. *
  498. * See [joystick input](@ref joystick) for how these are used.
  499. *
  500. * @ingroup input
  501. * @{ */
  502. #define GLFW_JOYSTICK_1 0
  503. #define GLFW_JOYSTICK_2 1
  504. #define GLFW_JOYSTICK_3 2
  505. #define GLFW_JOYSTICK_4 3
  506. #define GLFW_JOYSTICK_5 4
  507. #define GLFW_JOYSTICK_6 5
  508. #define GLFW_JOYSTICK_7 6
  509. #define GLFW_JOYSTICK_8 7
  510. #define GLFW_JOYSTICK_9 8
  511. #define GLFW_JOYSTICK_10 9
  512. #define GLFW_JOYSTICK_11 10
  513. #define GLFW_JOYSTICK_12 11
  514. #define GLFW_JOYSTICK_13 12
  515. #define GLFW_JOYSTICK_14 13
  516. #define GLFW_JOYSTICK_15 14
  517. #define GLFW_JOYSTICK_16 15
  518. #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
  519. /*! @} */
  520. /*! @defgroup gamepad_buttons Gamepad buttons
  521. * @brief Gamepad buttons.
  522. *
  523. * See @ref gamepad for how these are used.
  524. *
  525. * @ingroup input
  526. * @{ */
  527. #define GLFW_GAMEPAD_BUTTON_A 0
  528. #define GLFW_GAMEPAD_BUTTON_B 1
  529. #define GLFW_GAMEPAD_BUTTON_X 2
  530. #define GLFW_GAMEPAD_BUTTON_Y 3
  531. #define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER 4
  532. #define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER 5
  533. #define GLFW_GAMEPAD_BUTTON_BACK 6
  534. #define GLFW_GAMEPAD_BUTTON_START 7
  535. #define GLFW_GAMEPAD_BUTTON_GUIDE 8
  536. #define GLFW_GAMEPAD_BUTTON_LEFT_THUMB 9
  537. #define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB 10
  538. #define GLFW_GAMEPAD_BUTTON_DPAD_UP 11
  539. #define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT 12
  540. #define GLFW_GAMEPAD_BUTTON_DPAD_DOWN 13
  541. #define GLFW_GAMEPAD_BUTTON_DPAD_LEFT 14
  542. #define GLFW_GAMEPAD_BUTTON_LAST GLFW_GAMEPAD_BUTTON_DPAD_LEFT
  543. #define GLFW_GAMEPAD_BUTTON_CROSS GLFW_GAMEPAD_BUTTON_A
  544. #define GLFW_GAMEPAD_BUTTON_CIRCLE GLFW_GAMEPAD_BUTTON_B
  545. #define GLFW_GAMEPAD_BUTTON_SQUARE GLFW_GAMEPAD_BUTTON_X
  546. #define GLFW_GAMEPAD_BUTTON_TRIANGLE GLFW_GAMEPAD_BUTTON_Y
  547. /*! @} */
  548. /*! @defgroup gamepad_axes Gamepad axes
  549. * @brief Gamepad axes.
  550. *
  551. * See @ref gamepad for how these are used.
  552. *
  553. * @ingroup input
  554. * @{ */
  555. #define GLFW_GAMEPAD_AXIS_LEFT_X 0
  556. #define GLFW_GAMEPAD_AXIS_LEFT_Y 1
  557. #define GLFW_GAMEPAD_AXIS_RIGHT_X 2
  558. #define GLFW_GAMEPAD_AXIS_RIGHT_Y 3
  559. #define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER 4
  560. #define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
  561. #define GLFW_GAMEPAD_AXIS_LAST GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
  562. /*! @} */
  563. /*! @defgroup errors Error codes
  564. * @brief Error codes.
  565. *
  566. * See [error handling](@ref error_handling) for how these are used.
  567. *
  568. * @ingroup init
  569. * @{ */
  570. /*! @brief No error has occurred.
  571. *
  572. * No error has occurred.
  573. *
  574. * @analysis Yay.
  575. */
  576. #define GLFW_NO_ERROR 0
  577. /*! @brief GLFW has not been initialized.
  578. *
  579. * This occurs if a GLFW function was called that must not be called unless the
  580. * library is [initialized](@ref intro_init).
  581. *
  582. * @analysis Application programmer error. Initialize GLFW before calling any
  583. * function that requires initialization.
  584. */
  585. #define GLFW_NOT_INITIALIZED 0x00010001
  586. /*! @brief No context is current for this thread.
  587. *
  588. * This occurs if a GLFW function was called that needs and operates on the
  589. * current OpenGL or OpenGL ES context but no context is current on the calling
  590. * thread. One such function is @ref glfwSwapInterval.
  591. *
  592. * @analysis Application programmer error. Ensure a context is current before
  593. * calling functions that require a current context.
  594. */
  595. #define GLFW_NO_CURRENT_CONTEXT 0x00010002
  596. /*! @brief One of the arguments to the function was an invalid enum value.
  597. *
  598. * One of the arguments to the function was an invalid enum value, for example
  599. * requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
  600. *
  601. * @analysis Application programmer error. Fix the offending call.
  602. */
  603. #define GLFW_INVALID_ENUM 0x00010003
  604. /*! @brief One of the arguments to the function was an invalid value.
  605. *
  606. * One of the arguments to the function was an invalid value, for example
  607. * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
  608. *
  609. * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
  610. * result in a @ref GLFW_VERSION_UNAVAILABLE error.
  611. *
  612. * @analysis Application programmer error. Fix the offending call.
  613. */
  614. #define GLFW_INVALID_VALUE 0x00010004
  615. /*! @brief A memory allocation failed.
  616. *
  617. * A memory allocation failed.
  618. *
  619. * @analysis A bug in GLFW or the underlying operating system. Report the bug
  620. * to our [issue tracker](https://github.com/glfw/glfw/issues).
  621. */
  622. #define GLFW_OUT_OF_MEMORY 0x00010005
  623. /*! @brief GLFW could not find support for the requested API on the system.
  624. *
  625. * GLFW could not find support for the requested API on the system.
  626. *
  627. * @analysis The installed graphics driver does not support the requested
  628. * API, or does not support it via the chosen context creation backend.
  629. * Below are a few examples.
  630. *
  631. * @par
  632. * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
  633. * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
  634. * a WGL or GLX extension. macOS does not provide OpenGL ES at all. The Mesa
  635. * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
  636. * driver. Older graphics drivers do not support Vulkan.
  637. */
  638. #define GLFW_API_UNAVAILABLE 0x00010006
  639. /*! @brief The requested OpenGL or OpenGL ES version is not available.
  640. *
  641. * The requested OpenGL or OpenGL ES version (including any requested context
  642. * or framebuffer hints) is not available on this machine.
  643. *
  644. * @analysis The machine does not support your requirements. If your
  645. * application is sufficiently flexible, downgrade your requirements and try
  646. * again. Otherwise, inform the user that their machine does not match your
  647. * requirements.
  648. *
  649. * @par
  650. * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
  651. * comes out before the 4.x series gets that far, also fail with this error and
  652. * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
  653. * will exist.
  654. */
  655. #define GLFW_VERSION_UNAVAILABLE 0x00010007
  656. /*! @brief A platform-specific error occurred that does not match any of the
  657. * more specific categories.
  658. *
  659. * A platform-specific error occurred that does not match any of the more
  660. * specific categories.
  661. *
  662. * @analysis A bug or configuration error in GLFW, the underlying operating
  663. * system or its drivers, or a lack of required resources. Report the issue to
  664. * our [issue tracker](https://github.com/glfw/glfw/issues).
  665. */
  666. #define GLFW_PLATFORM_ERROR 0x00010008
  667. /*! @brief The requested format is not supported or available.
  668. *
  669. * If emitted during window creation, the requested pixel format is not
  670. * supported.
  671. *
  672. * If emitted when querying the clipboard, the contents of the clipboard could
  673. * not be converted to the requested format.
  674. *
  675. * @analysis If emitted during window creation, one or more
  676. * [hard constraints](@ref window_hints_hard) did not match any of the
  677. * available pixel formats. If your application is sufficiently flexible,
  678. * downgrade your requirements and try again. Otherwise, inform the user that
  679. * their machine does not match your requirements.
  680. *
  681. * @par
  682. * If emitted when querying the clipboard, ignore the error or report it to
  683. * the user, as appropriate.
  684. */
  685. #define GLFW_FORMAT_UNAVAILABLE 0x00010009
  686. /*! @brief The specified window does not have an OpenGL or OpenGL ES context.
  687. *
  688. * A window that does not have an OpenGL or OpenGL ES context was passed to
  689. * a function that requires it to have one.
  690. *
  691. * @analysis Application programmer error. Fix the offending call.
  692. */
  693. #define GLFW_NO_WINDOW_CONTEXT 0x0001000A
  694. /*! @} */
  695. /*! @addtogroup window
  696. * @{ */
  697. /*! @brief Input focus window hint and attribute
  698. *
  699. * Input focus [window hint](@ref GLFW_FOCUSED_hint) or
  700. * [window attribute](@ref GLFW_FOCUSED_attrib).
  701. */
  702. #define GLFW_FOCUSED 0x00020001
  703. /*! @brief Window iconification window attribute
  704. *
  705. * Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
  706. */
  707. #define GLFW_ICONIFIED 0x00020002
  708. /*! @brief Window resize-ability window hint and attribute
  709. *
  710. * Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
  711. * [window attribute](@ref GLFW_RESIZABLE_attrib).
  712. */
  713. #define GLFW_RESIZABLE 0x00020003
  714. /*! @brief Window visibility window hint and attribute
  715. *
  716. * Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
  717. * [window attribute](@ref GLFW_VISIBLE_attrib).
  718. */
  719. #define GLFW_VISIBLE 0x00020004
  720. /*! @brief Window decoration window hint and attribute
  721. *
  722. * Window decoration [window hint](@ref GLFW_DECORATED_hint) and
  723. * [window attribute](@ref GLFW_DECORATED_attrib).
  724. */
  725. #define GLFW_DECORATED 0x00020005
  726. /*! @brief Window auto-iconification window hint and attribute
  727. *
  728. * Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
  729. * [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
  730. */
  731. #define GLFW_AUTO_ICONIFY 0x00020006
  732. /*! @brief Window decoration window hint and attribute
  733. *
  734. * Window decoration [window hint](@ref GLFW_FLOATING_hint) and
  735. * [window attribute](@ref GLFW_FLOATING_attrib).
  736. */
  737. #define GLFW_FLOATING 0x00020007
  738. /*! @brief Window maximization window hint and attribute
  739. *
  740. * Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
  741. * [window attribute](@ref GLFW_MAXIMIZED_attrib).
  742. */
  743. #define GLFW_MAXIMIZED 0x00020008
  744. /*! @brief Cursor centering window hint
  745. *
  746. * Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
  747. */
  748. #define GLFW_CENTER_CURSOR 0x00020009
  749. /*! @brief Window framebuffer transparency hint and attribute
  750. *
  751. * Window framebuffer transparency
  752. * [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
  753. * [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
  754. */
  755. #define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
  756. /*! @brief Mouse cursor hover window attribute.
  757. *
  758. * Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
  759. */
  760. #define GLFW_HOVERED 0x0002000B
  761. /*! @brief Input focus on calling show window hint and attribute
  762. *
  763. * Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
  764. * [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
  765. */
  766. #define GLFW_FOCUS_ON_SHOW 0x0002000C
  767. /*! @brief Framebuffer bit depth hint.
  768. *
  769. * Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
  770. */
  771. #define GLFW_RED_BITS 0x00021001
  772. /*! @brief Framebuffer bit depth hint.
  773. *
  774. * Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
  775. */
  776. #define GLFW_GREEN_BITS 0x00021002
  777. /*! @brief Framebuffer bit depth hint.
  778. *
  779. * Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
  780. */
  781. #define GLFW_BLUE_BITS 0x00021003
  782. /*! @brief Framebuffer bit depth hint.
  783. *
  784. * Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
  785. */
  786. #define GLFW_ALPHA_BITS 0x00021004
  787. /*! @brief Framebuffer bit depth hint.
  788. *
  789. * Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
  790. */
  791. #define GLFW_DEPTH_BITS 0x00021005
  792. /*! @brief Framebuffer bit depth hint.
  793. *
  794. * Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
  795. */
  796. #define GLFW_STENCIL_BITS 0x00021006
  797. /*! @brief Framebuffer bit depth hint.
  798. *
  799. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
  800. */
  801. #define GLFW_ACCUM_RED_BITS 0x00021007
  802. /*! @brief Framebuffer bit depth hint.
  803. *
  804. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
  805. */
  806. #define GLFW_ACCUM_GREEN_BITS 0x00021008
  807. /*! @brief Framebuffer bit depth hint.
  808. *
  809. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
  810. */
  811. #define GLFW_ACCUM_BLUE_BITS 0x00021009
  812. /*! @brief Framebuffer bit depth hint.
  813. *
  814. * Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
  815. */
  816. #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
  817. /*! @brief Framebuffer auxiliary buffer hint.
  818. *
  819. * Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
  820. */
  821. #define GLFW_AUX_BUFFERS 0x0002100B
  822. /*! @brief OpenGL stereoscopic rendering hint.
  823. *
  824. * OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
  825. */
  826. #define GLFW_STEREO 0x0002100C
  827. /*! @brief Framebuffer MSAA samples hint.
  828. *
  829. * Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
  830. */
  831. #define GLFW_SAMPLES 0x0002100D
  832. /*! @brief Framebuffer sRGB hint.
  833. *
  834. * Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
  835. */
  836. #define GLFW_SRGB_CAPABLE 0x0002100E
  837. /*! @brief Monitor refresh rate hint.
  838. *
  839. * Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
  840. */
  841. #define GLFW_REFRESH_RATE 0x0002100F
  842. /*! @brief Framebuffer double buffering hint.
  843. *
  844. * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
  845. */
  846. #define GLFW_DOUBLEBUFFER 0x00021010
  847. /*! @brief Context client API hint and attribute.
  848. *
  849. * Context client API [hint](@ref GLFW_CLIENT_API_hint) and
  850. * [attribute](@ref GLFW_CLIENT_API_attrib).
  851. */
  852. #define GLFW_CLIENT_API 0x00022001
  853. /*! @brief Context client API major version hint and attribute.
  854. *
  855. * Context client API major version [hint](@ref GLFW_CLIENT_API_hint) and
  856. * [attribute](@ref GLFW_CLIENT_API_attrib).
  857. */
  858. #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
  859. /*! @brief Context client API minor version hint and attribute.
  860. *
  861. * Context client API minor version [hint](@ref GLFW_CLIENT_API_hint) and
  862. * [attribute](@ref GLFW_CLIENT_API_attrib).
  863. */
  864. #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
  865. /*! @brief Context client API revision number hint and attribute.
  866. *
  867. * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and
  868. * [attribute](@ref GLFW_CLIENT_API_attrib).
  869. */
  870. #define GLFW_CONTEXT_REVISION 0x00022004
  871. /*! @brief Context robustness hint and attribute.
  872. *
  873. * Context client API revision number [hint](@ref GLFW_CLIENT_API_hint) and
  874. * [attribute](@ref GLFW_CLIENT_API_attrib).
  875. */
  876. #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
  877. /*! @brief OpenGL forward-compatibility hint and attribute.
  878. *
  879. * OpenGL forward-compatibility [hint](@ref GLFW_CLIENT_API_hint) and
  880. * [attribute](@ref GLFW_CLIENT_API_attrib).
  881. */
  882. #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
  883. /*! @brief OpenGL debug context hint and attribute.
  884. *
  885. * OpenGL debug context [hint](@ref GLFW_CLIENT_API_hint) and
  886. * [attribute](@ref GLFW_CLIENT_API_attrib).
  887. */
  888. #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
  889. /*! @brief OpenGL profile hint and attribute.
  890. *
  891. * OpenGL profile [hint](@ref GLFW_CLIENT_API_hint) and
  892. * [attribute](@ref GLFW_CLIENT_API_attrib).
  893. */
  894. #define GLFW_OPENGL_PROFILE 0x00022008
  895. /*! @brief Context flush-on-release hint and attribute.
  896. *
  897. * Context flush-on-release [hint](@ref GLFW_CLIENT_API_hint) and
  898. * [attribute](@ref GLFW_CLIENT_API_attrib).
  899. */
  900. #define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
  901. /*! @brief Context error suppression hint and attribute.
  902. *
  903. * Context error suppression [hint](@ref GLFW_CLIENT_API_hint) and
  904. * [attribute](@ref GLFW_CLIENT_API_attrib).
  905. */
  906. #define GLFW_CONTEXT_NO_ERROR 0x0002200A
  907. /*! @brief Context creation API hint and attribute.
  908. *
  909. * Context creation API [hint](@ref GLFW_CLIENT_API_hint) and
  910. * [attribute](@ref GLFW_CLIENT_API_attrib).
  911. */
  912. #define GLFW_CONTEXT_CREATION_API 0x0002200B
  913. #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
  914. #define GLFW_COCOA_FRAME_NAME 0x00023002
  915. #define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
  916. #define GLFW_X11_CLASS_NAME 0x00024001
  917. #define GLFW_X11_INSTANCE_NAME 0x00024002
  918. /*! @} */
  919. #define GLFW_NO_API 0
  920. #define GLFW_OPENGL_API 0x00030001
  921. #define GLFW_OPENGL_ES_API 0x00030002
  922. #define GLFW_NO_ROBUSTNESS 0
  923. #define GLFW_NO_RESET_NOTIFICATION 0x00031001
  924. #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
  925. #define GLFW_OPENGL_ANY_PROFILE 0
  926. #define GLFW_OPENGL_CORE_PROFILE 0x00032001
  927. #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
  928. #define GLFW_CURSOR 0x00033001
  929. #define GLFW_STICKY_KEYS 0x00033002
  930. #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
  931. #define GLFW_LOCK_KEY_MODS 0x00033004
  932. #define GLFW_CURSOR_NORMAL 0x00034001
  933. #define GLFW_CURSOR_HIDDEN 0x00034002
  934. #define GLFW_CURSOR_DISABLED 0x00034003
  935. #define GLFW_ANY_RELEASE_BEHAVIOR 0
  936. #define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
  937. #define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
  938. #define GLFW_NATIVE_CONTEXT_API 0x00036001
  939. #define GLFW_EGL_CONTEXT_API 0x00036002
  940. #define GLFW_OSMESA_CONTEXT_API 0x00036003
  941. /*! @defgroup shapes Standard cursor shapes
  942. * @brief Standard system cursor shapes.
  943. *
  944. * See [standard cursor creation](@ref cursor_standard) for how these are used.
  945. *
  946. * @ingroup input
  947. * @{ */
  948. /*! @brief The regular arrow cursor shape.
  949. *
  950. * The regular arrow cursor.
  951. */
  952. #define GLFW_ARROW_CURSOR 0x00036001
  953. /*! @brief The text input I-beam cursor shape.
  954. *
  955. * The text input I-beam cursor shape.
  956. */
  957. #define GLFW_IBEAM_CURSOR 0x00036002
  958. /*! @brief The crosshair shape.
  959. *
  960. * The crosshair shape.
  961. */
  962. #define GLFW_CROSSHAIR_CURSOR 0x00036003
  963. /*! @brief The hand shape.
  964. *
  965. * The hand shape.
  966. */
  967. #define GLFW_HAND_CURSOR 0x00036004
  968. /*! @brief The horizontal resize arrow shape.
  969. *
  970. * The horizontal resize arrow shape.
  971. */
  972. #define GLFW_HRESIZE_CURSOR 0x00036005
  973. /*! @brief The vertical resize arrow shape.
  974. *
  975. * The vertical resize arrow shape.
  976. */
  977. #define GLFW_VRESIZE_CURSOR 0x00036006
  978. /*! @} */
  979. #define GLFW_CONNECTED 0x00040001
  980. #define GLFW_DISCONNECTED 0x00040002
  981. /*! @addtogroup init
  982. * @{ */
  983. #define GLFW_JOYSTICK_HAT_BUTTONS 0x00050001
  984. #define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
  985. #define GLFW_COCOA_MENUBAR 0x00051002
  986. /*! @} */
  987. #define GLFW_DONT_CARE -1
  988. /*************************************************************************
  989. * GLFW API types
  990. *************************************************************************/
  991. /*! @brief Client API function pointer type.
  992. *
  993. * Generic function pointer used for returning client API function pointers
  994. * without forcing a cast from a regular pointer.
  995. *
  996. * @sa @ref context_glext
  997. * @sa @ref glfwGetProcAddress
  998. *
  999. * @since Added in version 3.0.
  1000. *
  1001. * @ingroup context
  1002. */
  1003. typedef void (*GLFWglproc)(void);
  1004. /*! @brief Vulkan API function pointer type.
  1005. *
  1006. * Generic function pointer used for returning Vulkan API function pointers
  1007. * without forcing a cast from a regular pointer.
  1008. *
  1009. * @sa @ref vulkan_proc
  1010. * @sa @ref glfwGetInstanceProcAddress
  1011. *
  1012. * @since Added in version 3.2.
  1013. *
  1014. * @ingroup vulkan
  1015. */
  1016. typedef void (*GLFWvkproc)(void);
  1017. /*! @brief Opaque monitor object.
  1018. *
  1019. * Opaque monitor object.
  1020. *
  1021. * @see @ref monitor_object
  1022. *
  1023. * @since Added in version 3.0.
  1024. *
  1025. * @ingroup monitor
  1026. */
  1027. typedef struct GLFWmonitor GLFWmonitor;
  1028. /*! @brief Opaque window object.
  1029. *
  1030. * Opaque window object.
  1031. *
  1032. * @see @ref window_object
  1033. *
  1034. * @since Added in version 3.0.
  1035. *
  1036. * @ingroup window
  1037. */
  1038. typedef struct GLFWwindow GLFWwindow;
  1039. /*! @brief Opaque cursor object.
  1040. *
  1041. * Opaque cursor object.
  1042. *
  1043. * @see @ref cursor_object
  1044. *
  1045. * @since Added in version 3.1.
  1046. *
  1047. * @ingroup cursor
  1048. */
  1049. typedef struct GLFWcursor GLFWcursor;
  1050. /*! @brief The function signature for error callbacks.
  1051. *
  1052. * This is the function signature for error callback functions.
  1053. *
  1054. * @param[in] error An [error code](@ref errors).
  1055. * @param[in] description A UTF-8 encoded string describing the error.
  1056. *
  1057. * @sa @ref error_handling
  1058. * @sa @ref glfwSetErrorCallback
  1059. *
  1060. * @since Added in version 3.0.
  1061. *
  1062. * @ingroup init
  1063. */
  1064. typedef void (* GLFWerrorfun)(int,const char*);
  1065. /*! @brief The function signature for window position callbacks.
  1066. *
  1067. * This is the function signature for window position callback functions.
  1068. *
  1069. * @param[in] window The window that was moved.
  1070. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  1071. * upper-left corner of the client area of the window.
  1072. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  1073. * upper-left corner of the client area of the window.
  1074. *
  1075. * @sa @ref window_pos
  1076. * @sa @ref glfwSetWindowPosCallback
  1077. *
  1078. * @since Added in version 3.0.
  1079. *
  1080. * @ingroup window
  1081. */
  1082. typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
  1083. /*! @brief The function signature for window resize callbacks.
  1084. *
  1085. * This is the function signature for window size callback functions.
  1086. *
  1087. * @param[in] window The window that was resized.
  1088. * @param[in] width The new width, in screen coordinates, of the window.
  1089. * @param[in] height The new height, in screen coordinates, of the window.
  1090. *
  1091. * @sa @ref window_size
  1092. * @sa @ref glfwSetWindowSizeCallback
  1093. *
  1094. * @since Added in version 1.0.
  1095. * @glfw3 Added window handle parameter.
  1096. *
  1097. * @ingroup window
  1098. */
  1099. typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
  1100. /*! @brief The function signature for window close callbacks.
  1101. *
  1102. * This is the function signature for window close callback functions.
  1103. *
  1104. * @param[in] window The window that the user attempted to close.
  1105. *
  1106. * @sa @ref window_close
  1107. * @sa @ref glfwSetWindowCloseCallback
  1108. *
  1109. * @since Added in version 2.5.
  1110. * @glfw3 Added window handle parameter.
  1111. *
  1112. * @ingroup window
  1113. */
  1114. typedef void (* GLFWwindowclosefun)(GLFWwindow*);
  1115. /*! @brief The function signature for window content refresh callbacks.
  1116. *
  1117. * This is the function signature for window refresh callback functions.
  1118. *
  1119. * @param[in] window The window whose content needs to be refreshed.
  1120. *
  1121. * @sa @ref window_refresh
  1122. * @sa @ref glfwSetWindowRefreshCallback
  1123. *
  1124. * @since Added in version 2.5.
  1125. * @glfw3 Added window handle parameter.
  1126. *
  1127. * @ingroup window
  1128. */
  1129. typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
  1130. /*! @brief The function signature for window focus/defocus callbacks.
  1131. *
  1132. * This is the function signature for window focus callback functions.
  1133. *
  1134. * @param[in] window The window that gained or lost input focus.
  1135. * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
  1136. * `GLFW_FALSE` if it lost it.
  1137. *
  1138. * @sa @ref window_focus
  1139. * @sa @ref glfwSetWindowFocusCallback
  1140. *
  1141. * @since Added in version 3.0.
  1142. *
  1143. * @ingroup window
  1144. */
  1145. typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
  1146. /*! @brief The function signature for window iconify/restore callbacks.
  1147. *
  1148. * This is the function signature for window iconify/restore callback
  1149. * functions.
  1150. *
  1151. * @param[in] window The window that was iconified or restored.
  1152. * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
  1153. * `GLFW_FALSE` if it was restored.
  1154. *
  1155. * @sa @ref window_iconify
  1156. * @sa @ref glfwSetWindowIconifyCallback
  1157. *
  1158. * @since Added in version 3.0.
  1159. *
  1160. * @ingroup window
  1161. */
  1162. typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
  1163. /*! @brief The function signature for window maximize/restore callbacks.
  1164. *
  1165. * This is the function signature for window maximize/restore callback
  1166. * functions.
  1167. *
  1168. * @param[in] window The window that was maximized or restored.
  1169. * @param[in] iconified `GLFW_TRUE` if the window was maximized, or
  1170. * `GLFW_FALSE` if it was restored.
  1171. *
  1172. * @sa @ref window_maximize
  1173. * @sa glfwSetWindowMaximizeCallback
  1174. *
  1175. * @since Added in version 3.3.
  1176. *
  1177. * @ingroup window
  1178. */
  1179. typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
  1180. /*! @brief The function signature for framebuffer resize callbacks.
  1181. *
  1182. * This is the function signature for framebuffer resize callback
  1183. * functions.
  1184. *
  1185. * @param[in] window The window whose framebuffer was resized.
  1186. * @param[in] width The new width, in pixels, of the framebuffer.
  1187. * @param[in] height The new height, in pixels, of the framebuffer.
  1188. *
  1189. * @sa @ref window_fbsize
  1190. * @sa @ref glfwSetFramebufferSizeCallback
  1191. *
  1192. * @since Added in version 3.0.
  1193. *
  1194. * @ingroup window
  1195. */
  1196. typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
  1197. /*! @brief The function signature for window content scale callbacks.
  1198. *
  1199. * This is the function signature for window content scale callback
  1200. * functions.
  1201. *
  1202. * @param[in] window The window whose content scale changed.
  1203. * @param[in] xscale The new x-axis content scale of the window.
  1204. * @param[in] yscale The new y-axis content scale of the window.
  1205. *
  1206. * @sa @ref window_scale
  1207. * @sa @ref glfwSetWindowContentScaleCallback
  1208. *
  1209. * @since Added in version 3.3.
  1210. *
  1211. * @ingroup window
  1212. */
  1213. typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
  1214. /*! @brief The function signature for mouse button callbacks.
  1215. *
  1216. * This is the function signature for mouse button callback functions.
  1217. *
  1218. * @param[in] window The window that received the event.
  1219. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  1220. * released.
  1221. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
  1222. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  1223. * held down.
  1224. *
  1225. * @sa @ref input_mouse_button
  1226. * @sa @ref glfwSetMouseButtonCallback
  1227. *
  1228. * @since Added in version 1.0.
  1229. * @glfw3 Added window handle and modifier mask parameters.
  1230. *
  1231. * @ingroup input
  1232. */
  1233. typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
  1234. /*! @brief The function signature for cursor position callbacks.
  1235. *
  1236. * This is the function signature for cursor position callback functions.
  1237. *
  1238. * @param[in] window The window that received the event.
  1239. * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
  1240. * the client area.
  1241. * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
  1242. * client area.
  1243. *
  1244. * @sa @ref cursor_pos
  1245. * @sa @ref glfwSetCursorPosCallback
  1246. *
  1247. * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
  1248. *
  1249. * @ingroup input
  1250. */
  1251. typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
  1252. /*! @brief The function signature for cursor enter/leave callbacks.
  1253. *
  1254. * This is the function signature for cursor enter/leave callback functions.
  1255. *
  1256. * @param[in] window The window that received the event.
  1257. * @param[in] entered `GLFW_TRUE` if the cursor entered the window's client
  1258. * area, or `GLFW_FALSE` if it left it.
  1259. *
  1260. * @sa @ref cursor_enter
  1261. * @sa @ref glfwSetCursorEnterCallback
  1262. *
  1263. * @since Added in version 3.0.
  1264. *
  1265. * @ingroup input
  1266. */
  1267. typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
  1268. /*! @brief The function signature for scroll callbacks.
  1269. *
  1270. * This is the function signature for scroll callback functions.
  1271. *
  1272. * @param[in] window The window that received the event.
  1273. * @param[in] xoffset The scroll offset along the x-axis.
  1274. * @param[in] yoffset The scroll offset along the y-axis.
  1275. *
  1276. * @sa @ref scrolling
  1277. * @sa @ref glfwSetScrollCallback
  1278. *
  1279. * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
  1280. *
  1281. * @ingroup input
  1282. */
  1283. typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
  1284. /*! @brief The function signature for keyboard key callbacks.
  1285. *
  1286. * This is the function signature for keyboard key callback functions.
  1287. *
  1288. * @param[in] window The window that received the event.
  1289. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
  1290. * @param[in] scancode The system-specific scancode of the key.
  1291. * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.
  1292. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  1293. * held down.
  1294. *
  1295. * @sa @ref input_key
  1296. * @sa @ref glfwSetKeyCallback
  1297. *
  1298. * @since Added in version 1.0.
  1299. * @glfw3 Added window handle, scancode and modifier mask parameters.
  1300. *
  1301. * @ingroup input
  1302. */
  1303. typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
  1304. /*! @brief The function signature for Unicode character callbacks.
  1305. *
  1306. * This is the function signature for Unicode character callback functions.
  1307. *
  1308. * @param[in] window The window that received the event.
  1309. * @param[in] codepoint The Unicode code point of the character.
  1310. *
  1311. * @sa @ref input_char
  1312. * @sa @ref glfwSetCharCallback
  1313. *
  1314. * @since Added in version 2.4.
  1315. * @glfw3 Added window handle parameter.
  1316. *
  1317. * @ingroup input
  1318. */
  1319. typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
  1320. /*! @brief The function signature for Unicode character with modifiers
  1321. * callbacks.
  1322. *
  1323. * This is the function signature for Unicode character with modifiers callback
  1324. * functions. It is called for each input character, regardless of what
  1325. * modifier keys are held down.
  1326. *
  1327. * @param[in] window The window that received the event.
  1328. * @param[in] codepoint The Unicode code point of the character.
  1329. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  1330. * held down.
  1331. *
  1332. * @sa @ref input_char
  1333. * @sa @ref glfwSetCharModsCallback
  1334. *
  1335. * @deprecated Scheduled for removal in version 4.0.
  1336. *
  1337. * @since Added in version 3.1.
  1338. *
  1339. * @ingroup input
  1340. */
  1341. typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
  1342. /*! @brief The function signature for file drop callbacks.
  1343. *
  1344. * This is the function signature for file drop callbacks.
  1345. *
  1346. * @param[in] window The window that received the event.
  1347. * @param[in] count The number of dropped files.
  1348. * @param[in] paths The UTF-8 encoded file and/or directory path names.
  1349. *
  1350. * @sa @ref path_drop
  1351. * @sa @ref glfwSetDropCallback
  1352. *
  1353. * @since Added in version 3.1.
  1354. *
  1355. * @ingroup input
  1356. */
  1357. typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);
  1358. /*! @brief The function signature for monitor configuration callbacks.
  1359. *
  1360. * This is the function signature for monitor configuration callback functions.
  1361. *
  1362. * @param[in] monitor The monitor that was connected or disconnected.
  1363. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
  1364. * values reserved for future use.
  1365. *
  1366. * @sa @ref monitor_event
  1367. * @sa @ref glfwSetMonitorCallback
  1368. *
  1369. * @since Added in version 3.0.
  1370. *
  1371. * @ingroup monitor
  1372. */
  1373. typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
  1374. /*! @brief The function signature for joystick configuration callbacks.
  1375. *
  1376. * This is the function signature for joystick configuration callback
  1377. * functions.
  1378. *
  1379. * @param[in] jid The joystick that was connected or disconnected.
  1380. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Remaining
  1381. * values reserved for future use.
  1382. *
  1383. * @sa @ref joystick_event
  1384. * @sa @ref glfwSetJoystickCallback
  1385. *
  1386. * @since Added in version 3.2.
  1387. *
  1388. * @ingroup input
  1389. */
  1390. typedef void (* GLFWjoystickfun)(int,int);
  1391. /*! @brief Video mode type.
  1392. *
  1393. * This describes a single video mode.
  1394. *
  1395. * @sa @ref monitor_modes
  1396. * @sa @ref glfwGetVideoMode
  1397. * @sa @ref glfwGetVideoModes
  1398. *
  1399. * @since Added in version 1.0.
  1400. * @glfw3 Added refresh rate member.
  1401. *
  1402. * @ingroup monitor
  1403. */
  1404. typedef struct GLFWvidmode
  1405. {
  1406. /*! The width, in screen coordinates, of the video mode.
  1407. */
  1408. int width;
  1409. /*! The height, in screen coordinates, of the video mode.
  1410. */
  1411. int height;
  1412. /*! The bit depth of the red channel of the video mode.
  1413. */
  1414. int redBits;
  1415. /*! The bit depth of the green channel of the video mode.
  1416. */
  1417. int greenBits;
  1418. /*! The bit depth of the blue channel of the video mode.
  1419. */
  1420. int blueBits;
  1421. /*! The refresh rate, in Hz, of the video mode.
  1422. */
  1423. int refreshRate;
  1424. } GLFWvidmode;
  1425. /*! @brief Gamma ramp.
  1426. *
  1427. * This describes the gamma ramp for a monitor.
  1428. *
  1429. * @sa @ref monitor_gamma
  1430. * @sa @ref glfwGetGammaRamp
  1431. * @sa @ref glfwSetGammaRamp
  1432. *
  1433. * @since Added in version 3.0.
  1434. *
  1435. * @ingroup monitor
  1436. */
  1437. typedef struct GLFWgammaramp
  1438. {
  1439. /*! An array of value describing the response of the red channel.
  1440. */
  1441. unsigned short* red;
  1442. /*! An array of value describing the response of the green channel.
  1443. */
  1444. unsigned short* green;
  1445. /*! An array of value describing the response of the blue channel.
  1446. */
  1447. unsigned short* blue;
  1448. /*! The number of elements in each array.
  1449. */
  1450. unsigned int size;
  1451. } GLFWgammaramp;
  1452. /*! @brief Image data.
  1453. *
  1454. * This describes a single 2D image. See the documentation for each related
  1455. * function what the expected pixel format is.
  1456. *
  1457. * @sa @ref cursor_custom
  1458. * @sa @ref window_icon
  1459. *
  1460. * @since Added in version 2.1.
  1461. * @glfw3 Removed format and bytes-per-pixel members.
  1462. */
  1463. typedef struct GLFWimage
  1464. {
  1465. /*! The width, in pixels, of this image.
  1466. */
  1467. int width;
  1468. /*! The height, in pixels, of this image.
  1469. */
  1470. int height;
  1471. /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
  1472. */
  1473. unsigned char* pixels;
  1474. } GLFWimage;
  1475. /*! @brief Gamepad input state
  1476. *
  1477. * This describes the input state of a gamepad.
  1478. *
  1479. * @sa @ref gamepad
  1480. * @sa @ref glfwGetGamepadState
  1481. *
  1482. * @since Added in version 3.3.
  1483. */
  1484. typedef struct GLFWgamepadstate
  1485. {
  1486. /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
  1487. * or `GLFW_RELEASE`.
  1488. */
  1489. unsigned char buttons[15];
  1490. /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
  1491. * to 1.0 inclusive.
  1492. */
  1493. float axes[6];
  1494. } GLFWgamepadstate;
  1495. /*************************************************************************
  1496. * GLFW API functions
  1497. *************************************************************************/
  1498. /*! @brief Initializes the GLFW library.
  1499. *
  1500. * This function initializes the GLFW library. Before most GLFW functions can
  1501. * be used, GLFW must be initialized, and before an application terminates GLFW
  1502. * should be terminated in order to free any resources allocated during or
  1503. * after initialization.
  1504. *
  1505. * If this function fails, it calls @ref glfwTerminate before returning. If it
  1506. * succeeds, you should call @ref glfwTerminate before the application exits.
  1507. *
  1508. * Additional calls to this function after successful initialization but before
  1509. * termination will return `GLFW_TRUE` immediately.
  1510. *
  1511. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  1512. * [error](@ref error_handling) occurred.
  1513. *
  1514. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1515. *
  1516. * @remark @macos This function will change the current directory of the
  1517. * application to the `Contents/Resources` subdirectory of the application's
  1518. * bundle, if present. This can be disabled with the @ref
  1519. * GLFW_COCOA_CHDIR_RESOURCES init hint.
  1520. *
  1521. * @thread_safety This function must only be called from the main thread.
  1522. *
  1523. * @sa @ref intro_init
  1524. * @sa @ref glfwTerminate
  1525. *
  1526. * @since Added in version 1.0.
  1527. *
  1528. * @ingroup init
  1529. */
  1530. GLFWAPI int glfwInit(void);
  1531. /*! @brief Terminates the GLFW library.
  1532. *
  1533. * This function destroys all remaining windows and cursors, restores any
  1534. * modified gamma ramps and frees any other allocated resources. Once this
  1535. * function is called, you must again call @ref glfwInit successfully before
  1536. * you will be able to use most GLFW functions.
  1537. *
  1538. * If GLFW has been successfully initialized, this function should be called
  1539. * before the application exits. If initialization fails, there is no need to
  1540. * call this function, as it is called by @ref glfwInit before it returns
  1541. * failure.
  1542. *
  1543. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1544. *
  1545. * @remark This function may be called before @ref glfwInit.
  1546. *
  1547. * @warning The contexts of any remaining windows must not be current on any
  1548. * other thread when this function is called.
  1549. *
  1550. * @reentrancy This function must not be called from a callback.
  1551. *
  1552. * @thread_safety This function must only be called from the main thread.
  1553. *
  1554. * @sa @ref intro_init
  1555. * @sa @ref glfwInit
  1556. *
  1557. * @since Added in version 1.0.
  1558. *
  1559. * @ingroup init
  1560. */
  1561. GLFWAPI void glfwTerminate(void);
  1562. /*! @brief Sets the specified init hint to the desired value.
  1563. *
  1564. * This function sets hints for the next initialization of GLFW.
  1565. *
  1566. * The values you set hints to are never reset by GLFW, but they only take
  1567. * effect during initialization. Once GLFW has been initialized, any values
  1568. * you set will be ignored until the library is terminated and initialized
  1569. * again.
  1570. *
  1571. * Some hints are platform specific. These may be set on any platform but they
  1572. * will only affect their specific platform. Other platforms will ignore them.
  1573. * Setting these hints requires no platform specific headers or functions.
  1574. *
  1575. * @param[in] hint The [init hint](@ref init_hints) to set.
  1576. * @param[in] value The new value of the init hint.
  1577. *
  1578. * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
  1579. * GLFW_INVALID_VALUE.
  1580. *
  1581. * @remarks This function may be called before @ref glfwInit.
  1582. *
  1583. * @thread_safety This function must only be called from the main thread.
  1584. *
  1585. * @sa init_hints
  1586. * @sa glfwInit
  1587. *
  1588. * @since Added in version 3.3.
  1589. *
  1590. * @ingroup init
  1591. */
  1592. GLFWAPI void glfwInitHint(int hint, int value);
  1593. /*! @brief Retrieves the version of the GLFW library.
  1594. *
  1595. * This function retrieves the major, minor and revision numbers of the GLFW
  1596. * library. It is intended for when you are using GLFW as a shared library and
  1597. * want to ensure that you are using the minimum required version.
  1598. *
  1599. * Any or all of the version arguments may be `NULL`.
  1600. *
  1601. * @param[out] major Where to store the major version number, or `NULL`.
  1602. * @param[out] minor Where to store the minor version number, or `NULL`.
  1603. * @param[out] rev Where to store the revision number, or `NULL`.
  1604. *
  1605. * @errors None.
  1606. *
  1607. * @remark This function may be called before @ref glfwInit.
  1608. *
  1609. * @thread_safety This function may be called from any thread.
  1610. *
  1611. * @sa @ref intro_version
  1612. * @sa @ref glfwGetVersionString
  1613. *
  1614. * @since Added in version 1.0.
  1615. *
  1616. * @ingroup init
  1617. */
  1618. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  1619. /*! @brief Returns a string describing the compile-time configuration.
  1620. *
  1621. * This function returns the compile-time generated
  1622. * [version string](@ref intro_version_string) of the GLFW library binary. It
  1623. * describes the version, platform, compiler and any platform-specific
  1624. * compile-time options. It should not be confused with the OpenGL or OpenGL
  1625. * ES version string, queried with `glGetString`.
  1626. *
  1627. * __Do not use the version string__ to parse the GLFW library version. The
  1628. * @ref glfwGetVersion function provides the version of the running library
  1629. * binary in numerical format.
  1630. *
  1631. * @return The ASCII encoded GLFW version string.
  1632. *
  1633. * @errors None.
  1634. *
  1635. * @remark This function may be called before @ref glfwInit.
  1636. *
  1637. * @pointer_lifetime The returned string is static and compile-time generated.
  1638. *
  1639. * @thread_safety This function may be called from any thread.
  1640. *
  1641. * @sa @ref intro_version
  1642. * @sa @ref glfwGetVersion
  1643. *
  1644. * @since Added in version 3.0.
  1645. *
  1646. * @ingroup init
  1647. */
  1648. GLFWAPI const char* glfwGetVersionString(void);
  1649. /*! @brief Returns and clears the last error for the calling thread.
  1650. *
  1651. * This function returns and clears the [error code](@ref errors) of the last
  1652. * error that occurred on the calling thread, and optionally a UTF-8 encoded
  1653. * human-readable description of it. If no error has occurred since the last
  1654. * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
  1655. * set to `NULL`.
  1656. *
  1657. * @param[in] description Where to store the error description pointer, or `NULL`.
  1658. * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
  1659. * (zero).
  1660. *
  1661. * @errors None.
  1662. *
  1663. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  1664. * should not free it yourself. It is guaranteed to be valid only until the
  1665. * next error occurs or the library is terminated.
  1666. *
  1667. * @remark This function may be called before @ref glfwInit.
  1668. *
  1669. * @thread_safety This function may be called from any thread.
  1670. *
  1671. * @sa @ref error_handling
  1672. * @sa @ref glfwSetErrorCallback
  1673. *
  1674. * @since Added in version 3.3.
  1675. *
  1676. * @ingroup init
  1677. */
  1678. GLFWAPI int glfwGetError(const char** description);
  1679. /*! @brief Sets the error callback.
  1680. *
  1681. * This function sets the error callback, which is called with an error code
  1682. * and a human-readable description each time a GLFW error occurs.
  1683. *
  1684. * The error code is set before the callback is called. Calling @ref
  1685. * glfwGetError from the error callback will return the same value as the error
  1686. * code argument.
  1687. *
  1688. * The error callback is called on the thread where the error occurred. If you
  1689. * are using GLFW from multiple threads, your error callback needs to be
  1690. * written accordingly.
  1691. *
  1692. * Because the description string may have been generated specifically for that
  1693. * error, it is not guaranteed to be valid after the callback has returned. If
  1694. * you wish to use it after the callback returns, you need to make a copy.
  1695. *
  1696. * Once set, the error callback remains set even after the library has been
  1697. * terminated.
  1698. *
  1699. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1700. * callback.
  1701. * @return The previously set callback, or `NULL` if no callback was set.
  1702. *
  1703. * @errors None.
  1704. *
  1705. * @remark This function may be called before @ref glfwInit.
  1706. *
  1707. * @thread_safety This function must only be called from the main thread.
  1708. *
  1709. * @sa @ref error_handling
  1710. * @sa @ref glfwGetError
  1711. *
  1712. * @since Added in version 3.0.
  1713. *
  1714. * @ingroup init
  1715. */
  1716. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
  1717. /*! @brief Returns the currently connected monitors.
  1718. *
  1719. * This function returns an array of handles for all currently connected
  1720. * monitors. The primary monitor is always first in the returned array. If no
  1721. * monitors were found, this function returns `NULL`.
  1722. *
  1723. * @param[out] count Where to store the number of monitors in the returned
  1724. * array. This is set to zero if an error occurred.
  1725. * @return An array of monitor handles, or `NULL` if no monitors were found or
  1726. * if an [error](@ref error_handling) occurred.
  1727. *
  1728. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1729. *
  1730. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1731. * should not free it yourself. It is guaranteed to be valid only until the
  1732. * monitor configuration changes or the library is terminated.
  1733. *
  1734. * @thread_safety This function must only be called from the main thread.
  1735. *
  1736. * @sa @ref monitor_monitors
  1737. * @sa @ref monitor_event
  1738. * @sa @ref glfwGetPrimaryMonitor
  1739. *
  1740. * @since Added in version 3.0.
  1741. *
  1742. * @ingroup monitor
  1743. */
  1744. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  1745. /*! @brief Returns the primary monitor.
  1746. *
  1747. * This function returns the primary monitor. This is usually the monitor
  1748. * where elements like the task bar or global menu bar are located.
  1749. *
  1750. * @return The primary monitor, or `NULL` if no monitors were found or if an
  1751. * [error](@ref error_handling) occurred.
  1752. *
  1753. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1754. *
  1755. * @thread_safety This function must only be called from the main thread.
  1756. *
  1757. * @remark The primary monitor is always first in the array returned by @ref
  1758. * glfwGetMonitors.
  1759. *
  1760. * @sa @ref monitor_monitors
  1761. * @sa @ref glfwGetMonitors
  1762. *
  1763. * @since Added in version 3.0.
  1764. *
  1765. * @ingroup monitor
  1766. */
  1767. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  1768. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  1769. *
  1770. * This function returns the position, in screen coordinates, of the upper-left
  1771. * corner of the specified monitor.
  1772. *
  1773. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1774. * non-`NULL` position arguments will be set to zero.
  1775. *
  1776. * @param[in] monitor The monitor to query.
  1777. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  1778. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  1779. *
  1780. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1781. * GLFW_PLATFORM_ERROR.
  1782. *
  1783. * @thread_safety This function must only be called from the main thread.
  1784. *
  1785. * @sa @ref monitor_properties
  1786. *
  1787. * @since Added in version 3.0.
  1788. *
  1789. * @ingroup monitor
  1790. */
  1791. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  1792. /*! @brief Returns the physical size of the monitor.
  1793. *
  1794. * This function returns the size, in millimetres, of the display area of the
  1795. * specified monitor.
  1796. *
  1797. * Some systems do not provide accurate monitor size information, either
  1798. * because the monitor
  1799. * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
  1800. * data is incorrect or because the driver does not report it accurately.
  1801. *
  1802. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1803. * non-`NULL` size arguments will be set to zero.
  1804. *
  1805. * @param[in] monitor The monitor to query.
  1806. * @param[out] widthMM Where to store the width, in millimetres, of the
  1807. * monitor's display area, or `NULL`.
  1808. * @param[out] heightMM Where to store the height, in millimetres, of the
  1809. * monitor's display area, or `NULL`.
  1810. *
  1811. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1812. *
  1813. * @remark @win32 calculates the returned physical size from the
  1814. * current resolution and system DPI instead of querying the monitor EDID data.
  1815. *
  1816. * @thread_safety This function must only be called from the main thread.
  1817. *
  1818. * @sa @ref monitor_properties
  1819. *
  1820. * @since Added in version 3.0.
  1821. *
  1822. * @ingroup monitor
  1823. */
  1824. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
  1825. /*! @brief Retrieves the content scale for the specified monitor.
  1826. *
  1827. * This function retrieves the content scale for the specified monitor. The
  1828. * content scale is the ratio between the current DPI and the platform's
  1829. * default DPI. If you scale all pixel dimensions by this scale then your
  1830. * content should appear at an appropriate size. This is especially important
  1831. * for text and any UI elements.
  1832. *
  1833. * The content scale may depend on both the monitor resolution and pixel
  1834. * density and on user settings. It may be very different from the raw DPI
  1835. * calculated from the physical size and current resolution.
  1836. *
  1837. * @param[in] monitor The monitor to query.
  1838. * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
  1839. * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
  1840. *
  1841. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1842. * GLFW_PLATFORM_ERROR.
  1843. *
  1844. * @thread_safety This function must only be called from the main thread.
  1845. *
  1846. * @sa @ref monitor_scale
  1847. * @sa @ref glfwGetWindowContentScale
  1848. *
  1849. * @since Added in version 3.3.
  1850. *
  1851. * @ingroup monitor
  1852. */
  1853. GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
  1854. /*! @brief Returns the name of the specified monitor.
  1855. *
  1856. * This function returns a human-readable name, encoded as UTF-8, of the
  1857. * specified monitor. The name typically reflects the make and model of the
  1858. * monitor and is not guaranteed to be unique among the connected monitors.
  1859. *
  1860. * @param[in] monitor The monitor to query.
  1861. * @return The UTF-8 encoded name of the monitor, or `NULL` if an
  1862. * [error](@ref error_handling) occurred.
  1863. *
  1864. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1865. *
  1866. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  1867. * should not free it yourself. It is valid until the specified monitor is
  1868. * disconnected or the library is terminated.
  1869. *
  1870. * @thread_safety This function must only be called from the main thread.
  1871. *
  1872. * @sa @ref monitor_properties
  1873. *
  1874. * @since Added in version 3.0.
  1875. *
  1876. * @ingroup monitor
  1877. */
  1878. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  1879. /*! @brief Sets the user pointer of the specified monitor.
  1880. *
  1881. * This function sets the user-defined pointer of the specified monitor. The
  1882. * current value is retained until the monitor is disconnected. The initial
  1883. * value is `NULL`.
  1884. *
  1885. * This function may be called from the monitor callback, even for a monitor
  1886. * that is being disconnected.
  1887. *
  1888. * @param[in] monitor The monitor whose pointer to set.
  1889. * @param[in] pointer The new value.
  1890. *
  1891. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1892. *
  1893. * @thread_safety This function may be called from any thread. Access is not
  1894. * synchronized.
  1895. *
  1896. * @sa @ref monitor_userptr
  1897. * @sa @ref glfwGetMonitorUserPointer
  1898. *
  1899. * @since Added in version 3.3.
  1900. *
  1901. * @ingroup monitor
  1902. */
  1903. GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
  1904. /*! @brief Returns the user pointer of the specified monitor.
  1905. *
  1906. * This function returns the current value of the user-defined pointer of the
  1907. * specified monitor. The initial value is `NULL`.
  1908. *
  1909. * This function may be called from the monitor callback, even for a monitor
  1910. * that is being disconnected.
  1911. *
  1912. * @param[in] monitor The monitor whose pointer to return.
  1913. *
  1914. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1915. *
  1916. * @thread_safety This function may be called from any thread. Access is not
  1917. * synchronized.
  1918. *
  1919. * @sa @ref monitor_userptr
  1920. * @sa @ref glfwSetMonitorUserPointer
  1921. *
  1922. * @since Added in version 3.3.
  1923. *
  1924. * @ingroup monitor
  1925. */
  1926. GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
  1927. /*! @brief Sets the monitor configuration callback.
  1928. *
  1929. * This function sets the monitor configuration callback, or removes the
  1930. * currently set callback. This is called when a monitor is connected to or
  1931. * disconnected from the system.
  1932. *
  1933. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1934. * callback.
  1935. * @return The previously set callback, or `NULL` if no callback was set or the
  1936. * library had not been [initialized](@ref intro_init).
  1937. *
  1938. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1939. *
  1940. * @thread_safety This function must only be called from the main thread.
  1941. *
  1942. * @sa @ref monitor_event
  1943. *
  1944. * @since Added in version 3.0.
  1945. *
  1946. * @ingroup monitor
  1947. */
  1948. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
  1949. /*! @brief Returns the available video modes for the specified monitor.
  1950. *
  1951. * This function returns an array of all video modes supported by the specified
  1952. * monitor. The returned array is sorted in ascending order, first by color
  1953. * bit depth (the sum of all channel depths) and then by resolution area (the
  1954. * product of width and height).
  1955. *
  1956. * @param[in] monitor The monitor to query.
  1957. * @param[out] count Where to store the number of video modes in the returned
  1958. * array. This is set to zero if an error occurred.
  1959. * @return An array of video modes, or `NULL` if an
  1960. * [error](@ref error_handling) occurred.
  1961. *
  1962. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1963. * GLFW_PLATFORM_ERROR.
  1964. *
  1965. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1966. * should not free it yourself. It is valid until the specified monitor is
  1967. * disconnected, this function is called again for that monitor or the library
  1968. * is terminated.
  1969. *
  1970. * @thread_safety This function must only be called from the main thread.
  1971. *
  1972. * @sa @ref monitor_modes
  1973. * @sa @ref glfwGetVideoMode
  1974. *
  1975. * @since Added in version 1.0.
  1976. * @glfw3 Changed to return an array of modes for a specific monitor.
  1977. *
  1978. * @ingroup monitor
  1979. */
  1980. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  1981. /*! @brief Returns the current mode of the specified monitor.
  1982. *
  1983. * This function returns the current video mode of the specified monitor. If
  1984. * you have created a full screen window for that monitor, the return value
  1985. * will depend on whether that window is iconified.
  1986. *
  1987. * @param[in] monitor The monitor to query.
  1988. * @return The current mode of the monitor, or `NULL` if an
  1989. * [error](@ref error_handling) occurred.
  1990. *
  1991. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1992. * GLFW_PLATFORM_ERROR.
  1993. *
  1994. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1995. * should not free it yourself. It is valid until the specified monitor is
  1996. * disconnected or the library is terminated.
  1997. *
  1998. * @thread_safety This function must only be called from the main thread.
  1999. *
  2000. * @sa @ref monitor_modes
  2001. * @sa @ref glfwGetVideoModes
  2002. *
  2003. * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
  2004. *
  2005. * @ingroup monitor
  2006. */
  2007. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  2008. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  2009. *
  2010. * This function generates a 256-element gamma ramp from the specified exponent
  2011. * and then calls @ref glfwSetGammaRamp with it. The value must be a finite
  2012. * number greater than zero.
  2013. *
  2014. * The software controlled gamma ramp is applied _in addition_ to the hardware
  2015. * gamma correction, which today is usually an approximation of sRGB gamma.
  2016. * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
  2017. * the default (usually sRGB-like) behavior.
  2018. *
  2019. * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
  2020. * GLFW_SRGB_CAPABLE hint.
  2021. *
  2022. * @param[in] monitor The monitor whose gamma ramp to set.
  2023. * @param[in] gamma The desired exponent.
  2024. *
  2025. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2026. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2027. *
  2028. * @remark @wayland Gamma handling is a priviledged protocol, this function
  2029. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
  2030. *
  2031. * @thread_safety This function must only be called from the main thread.
  2032. *
  2033. * @sa @ref monitor_gamma
  2034. *
  2035. * @since Added in version 3.0.
  2036. *
  2037. * @ingroup monitor
  2038. */
  2039. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  2040. /*! @brief Returns the current gamma ramp for the specified monitor.
  2041. *
  2042. * This function returns the current gamma ramp of the specified monitor.
  2043. *
  2044. * @param[in] monitor The monitor to query.
  2045. * @return The current gamma ramp, or `NULL` if an
  2046. * [error](@ref error_handling) occurred.
  2047. *
  2048. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2049. * GLFW_PLATFORM_ERROR.
  2050. *
  2051. * @remark @wayland Gamma handling is a priviledged protocol, this function
  2052. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
  2053. * returning `NULL`.
  2054. *
  2055. * @pointer_lifetime The returned structure and its arrays are allocated and
  2056. * freed by GLFW. You should not free them yourself. They are valid until the
  2057. * specified monitor is disconnected, this function is called again for that
  2058. * monitor or the library is terminated.
  2059. *
  2060. * @thread_safety This function must only be called from the main thread.
  2061. *
  2062. * @sa @ref monitor_gamma
  2063. *
  2064. * @since Added in version 3.0.
  2065. *
  2066. * @ingroup monitor
  2067. */
  2068. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  2069. /*! @brief Sets the current gamma ramp for the specified monitor.
  2070. *
  2071. * This function sets the current gamma ramp for the specified monitor. The
  2072. * original gamma ramp for that monitor is saved by GLFW the first time this
  2073. * function is called and is restored by @ref glfwTerminate.
  2074. *
  2075. * The software controlled gamma ramp is applied _in addition_ to the hardware
  2076. * gamma correction, which today is usually an approximation of sRGB gamma.
  2077. * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
  2078. * the default (usually sRGB-like) behavior.
  2079. *
  2080. * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
  2081. * GLFW_SRGB_CAPABLE hint.
  2082. *
  2083. * @param[in] monitor The monitor whose gamma ramp to set.
  2084. * @param[in] ramp The gamma ramp to use.
  2085. *
  2086. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2087. * GLFW_PLATFORM_ERROR.
  2088. *
  2089. * @remark Gamma ramp sizes other than 256 are not supported by all platforms
  2090. * or graphics hardware.
  2091. *
  2092. * @remark @win32 The gamma ramp size must be 256.
  2093. *
  2094. * @remark @wayland Gamma handling is a priviledged protocol, this function
  2095. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
  2096. *
  2097. * @pointer_lifetime The specified gamma ramp is copied before this function
  2098. * returns.
  2099. *
  2100. * @thread_safety This function must only be called from the main thread.
  2101. *
  2102. * @sa @ref monitor_gamma
  2103. *
  2104. * @since Added in version 3.0.
  2105. *
  2106. * @ingroup monitor
  2107. */
  2108. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  2109. /*! @brief Resets all window hints to their default values.
  2110. *
  2111. * This function resets all window hints to their
  2112. * [default values](@ref window_hints_values).
  2113. *
  2114. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2115. *
  2116. * @thread_safety This function must only be called from the main thread.
  2117. *
  2118. * @sa @ref window_hints
  2119. * @sa @ref glfwWindowHint
  2120. * @sa @ref glfwWindowHintString
  2121. *
  2122. * @since Added in version 3.0.
  2123. *
  2124. * @ingroup window
  2125. */
  2126. GLFWAPI void glfwDefaultWindowHints(void);
  2127. /*! @brief Sets the specified window hint to the desired value.
  2128. *
  2129. * This function sets hints for the next call to @ref glfwCreateWindow. The
  2130. * hints, once set, retain their values until changed by a call to this
  2131. * function or @ref glfwDefaultWindowHints, or until the library is terminated.
  2132. *
  2133. * Only integer value hints can be set with this function. String value hints
  2134. * are set with @ref glfwWindowHintString.
  2135. *
  2136. * This function does not check whether the specified hint values are valid.
  2137. * If you set hints to invalid values this will instead be reported by the next
  2138. * call to @ref glfwCreateWindow.
  2139. *
  2140. * Some hints are platform specific. These may be set on any platform but they
  2141. * will only affect their specific platform. Other platforms will ignore them.
  2142. * Setting these hints requires no platform specific headers or functions.
  2143. *
  2144. * @param[in] hint The [window hint](@ref window_hints) to set.
  2145. * @param[in] value The new value of the window hint.
  2146. *
  2147. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2148. * GLFW_INVALID_ENUM.
  2149. *
  2150. * @thread_safety This function must only be called from the main thread.
  2151. *
  2152. * @sa @ref window_hints
  2153. * @sa @ref glfwWindowHintString
  2154. * @sa @ref glfwDefaultWindowHints
  2155. *
  2156. * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
  2157. *
  2158. * @ingroup window
  2159. */
  2160. GLFWAPI void glfwWindowHint(int hint, int value);
  2161. /*! @brief Sets the specified window hint to the desired value.
  2162. *
  2163. * This function sets hints for the next call to @ref glfwCreateWindow. The
  2164. * hints, once set, retain their values until changed by a call to this
  2165. * function or @ref glfwDefaultWindowHints, or until the library is terminated.
  2166. *
  2167. * Only string type hints can be set with this function. Integer value hints
  2168. * are set with @ref glfwWindowHint.
  2169. *
  2170. * This function does not check whether the specified hint values are valid.
  2171. * If you set hints to invalid values this will instead be reported by the next
  2172. * call to @ref glfwCreateWindow.
  2173. *
  2174. * Some hints are platform specific. These may be set on any platform but they
  2175. * will only affect their specific platform. Other platforms will ignore them.
  2176. * Setting these hints requires no platform specific headers or functions.
  2177. *
  2178. * @param[in] hint The [window hint](@ref window_hints) to set.
  2179. * @param[in] value The new value of the window hint.
  2180. *
  2181. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2182. * GLFW_INVALID_ENUM.
  2183. *
  2184. * @pointer_lifetime The specified string is copied before this function
  2185. * returns.
  2186. *
  2187. * @thread_safety This function must only be called from the main thread.
  2188. *
  2189. * @sa @ref window_hints
  2190. * @sa @ref glfwWindowHint
  2191. * @sa @ref glfwDefaultWindowHints
  2192. *
  2193. * @since Added in version 3.3.
  2194. *
  2195. * @ingroup window
  2196. */
  2197. GLFWAPI void glfwWindowHintString(int hint, const char* value);
  2198. /*! @brief Creates a window and its associated context.
  2199. *
  2200. * This function creates a window and its associated OpenGL or OpenGL ES
  2201. * context. Most of the options controlling how the window and its context
  2202. * should be created are specified with [window hints](@ref window_hints).
  2203. *
  2204. * Successful creation does not change which context is current. Before you
  2205. * can use the newly created context, you need to
  2206. * [make it current](@ref context_current). For information about the `share`
  2207. * parameter, see @ref context_sharing.
  2208. *
  2209. * The created window, framebuffer and context may differ from what you
  2210. * requested, as not all parameters and hints are
  2211. * [hard constraints](@ref window_hints_hard). This includes the size of the
  2212. * window, especially for full screen windows. To query the actual attributes
  2213. * of the created window, framebuffer and context, see @ref
  2214. * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
  2215. *
  2216. * To create a full screen window, you need to specify the monitor the window
  2217. * will cover. If no monitor is specified, the window will be windowed mode.
  2218. * Unless you have a way for the user to choose a specific monitor, it is
  2219. * recommended that you pick the primary monitor. For more information on how
  2220. * to query connected monitors, see @ref monitor_monitors.
  2221. *
  2222. * For full screen windows, the specified size becomes the resolution of the
  2223. * window's _desired video mode_. As long as a full screen window is not
  2224. * iconified, the supported video mode most closely matching the desired video
  2225. * mode is set for the specified monitor. For more information about full
  2226. * screen windows, including the creation of so called _windowed full screen_
  2227. * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
  2228. *
  2229. * Once you have created the window, you can switch it between windowed and
  2230. * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
  2231. * OpenGL or OpenGL ES context.
  2232. *
  2233. * By default, newly created windows use the placement recommended by the
  2234. * window system. To create the window at a specific position, make it
  2235. * initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
  2236. * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
  2237. * it.
  2238. *
  2239. * As long as at least one full screen window is not iconified, the screensaver
  2240. * is prohibited from starting.
  2241. *
  2242. * Window systems put limits on window sizes. Very large or very small window
  2243. * dimensions may be overridden by the window system on creation. Check the
  2244. * actual [size](@ref window_size) after creation.
  2245. *
  2246. * The [swap interval](@ref buffer_swap) is not set during window creation and
  2247. * the initial value may vary depending on driver settings and defaults.
  2248. *
  2249. * @param[in] width The desired width, in screen coordinates, of the window.
  2250. * This must be greater than zero.
  2251. * @param[in] height The desired height, in screen coordinates, of the window.
  2252. * This must be greater than zero.
  2253. * @param[in] title The initial, UTF-8 encoded window title.
  2254. * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
  2255. * windowed mode.
  2256. * @param[in] share The window whose context to share resources with, or `NULL`
  2257. * to not share resources.
  2258. * @return The handle of the created window, or `NULL` if an
  2259. * [error](@ref error_handling) occurred.
  2260. *
  2261. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2262. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
  2263. * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
  2264. * GLFW_PLATFORM_ERROR.
  2265. *
  2266. * @remark @win32 Window creation will fail if the Microsoft GDI software
  2267. * OpenGL implementation is the only one available.
  2268. *
  2269. * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
  2270. * will be set as the initial icon for the window. If no such icon is present,
  2271. * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
  2272. * see @ref glfwSetWindowIcon.
  2273. *
  2274. * @remark @win32 The context to share resources with must not be current on
  2275. * any other thread.
  2276. *
  2277. * @remark @macos The OS only supports forward-compatible core profile contexts
  2278. * for OpenGL versions 3.2 and later. Before creating an OpenGL context of
  2279. * version 3.2 or later you must set the
  2280. * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and
  2281. * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly.
  2282. * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
  2283. *
  2284. * @remark @macos The GLFW window has no icon, as it is not a document
  2285. * window, but the dock icon will be the same as the application bundle's icon.
  2286. * For more information on bundles, see the
  2287. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  2288. * in the Mac Developer Library.
  2289. *
  2290. * @remark @macos The first time a window is created the menu bar is created.
  2291. * If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu
  2292. * bar. Otherwise a minimal menu bar is created manually with common commands
  2293. * like Hide, Quit and About. The About entry opens a minimal about dialog
  2294. * with information from the application's bundle. Menu bar creation can be
  2295. * disabled entirely with the @ref GLFW_COCOA_MENUBAR init hint.
  2296. *
  2297. * @remark @macos On OS X 10.10 and later the window frame will not be rendered
  2298. * at full resolution on Retina displays unless the
  2299. * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
  2300. * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
  2301. * application bundle's `Info.plist`. For more information, see
  2302. * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
  2303. * in the Mac Developer Library. The GLFW test and example programs use
  2304. * a custom `Info.plist` template for this, which can be found as
  2305. * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
  2306. *
  2307. * @remark @macos When activating frame autosaving with
  2308. * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
  2309. * window size and position may be overriden by previously saved values.
  2310. *
  2311. * @remark @x11 Some window managers will not respect the placement of
  2312. * initially hidden windows.
  2313. *
  2314. * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
  2315. * a window to reach its requested state. This means you may not be able to
  2316. * query the final size, position or other attributes directly after window
  2317. * creation.
  2318. *
  2319. * @remark @x11 The class part of the `WM_CLASS` window property will by
  2320. * default be set to the window title passed to this function. The instance
  2321. * part will use the contents of the `RESOURCE_NAME` environment variable, if
  2322. * present and not empty, or fall back to the window title. Set the @ref
  2323. * GLFW_X11_CLASS_NAME and @ref GLFW_X11_INSTANCE_NAME window hints to override
  2324. * this.
  2325. *
  2326. * @remark @wayland The window frame is currently very simple, only allowing
  2327. * window resize or move. A compositor can still emit close, maximize or
  2328. * fullscreen events, using for example a keybind mechanism. Additionally,
  2329. * the wp_viewporter protocol is required for this feature, otherwise the
  2330. * window will not be decorated.
  2331. *
  2332. * @remark @wayland A full screen window will not attempt to change the mode,
  2333. * no matter what the requested size or refresh rate.
  2334. *
  2335. * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
  2336. * to be implemented in the user's compositor.
  2337. *
  2338. * @thread_safety This function must only be called from the main thread.
  2339. *
  2340. * @sa @ref window_creation
  2341. * @sa @ref glfwDestroyWindow
  2342. *
  2343. * @since Added in version 3.0. Replaces `glfwOpenWindow`.
  2344. *
  2345. * @ingroup window
  2346. */
  2347. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  2348. /*! @brief Destroys the specified window and its context.
  2349. *
  2350. * This function destroys the specified window and its context. On calling
  2351. * this function, no further callbacks will be called for that window.
  2352. *
  2353. * If the context of the specified window is current on the main thread, it is
  2354. * detached before being destroyed.
  2355. *
  2356. * @param[in] window The window to destroy.
  2357. *
  2358. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2359. * GLFW_PLATFORM_ERROR.
  2360. *
  2361. * @note The context of the specified window must not be current on any other
  2362. * thread when this function is called.
  2363. *
  2364. * @reentrancy This function must not be called from a callback.
  2365. *
  2366. * @thread_safety This function must only be called from the main thread.
  2367. *
  2368. * @sa @ref window_creation
  2369. * @sa @ref glfwCreateWindow
  2370. *
  2371. * @since Added in version 3.0. Replaces `glfwCloseWindow`.
  2372. *
  2373. * @ingroup window
  2374. */
  2375. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  2376. /*! @brief Checks the close flag of the specified window.
  2377. *
  2378. * This function returns the value of the close flag of the specified window.
  2379. *
  2380. * @param[in] window The window to query.
  2381. * @return The value of the close flag.
  2382. *
  2383. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2384. *
  2385. * @thread_safety This function may be called from any thread. Access is not
  2386. * synchronized.
  2387. *
  2388. * @sa @ref window_close
  2389. *
  2390. * @since Added in version 3.0.
  2391. *
  2392. * @ingroup window
  2393. */
  2394. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  2395. /*! @brief Sets the close flag of the specified window.
  2396. *
  2397. * This function sets the value of the close flag of the specified window.
  2398. * This can be used to override the user's attempt to close the window, or
  2399. * to signal that it should be closed.
  2400. *
  2401. * @param[in] window The window whose flag to change.
  2402. * @param[in] value The new value.
  2403. *
  2404. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2405. *
  2406. * @thread_safety This function may be called from any thread. Access is not
  2407. * synchronized.
  2408. *
  2409. * @sa @ref window_close
  2410. *
  2411. * @since Added in version 3.0.
  2412. *
  2413. * @ingroup window
  2414. */
  2415. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  2416. /*! @brief Sets the title of the specified window.
  2417. *
  2418. * This function sets the window title, encoded as UTF-8, of the specified
  2419. * window.
  2420. *
  2421. * @param[in] window The window whose title to change.
  2422. * @param[in] title The UTF-8 encoded window title.
  2423. *
  2424. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2425. * GLFW_PLATFORM_ERROR.
  2426. *
  2427. * @remark @macos The window title will not be updated until the next time you
  2428. * process events.
  2429. *
  2430. * @thread_safety This function must only be called from the main thread.
  2431. *
  2432. * @sa @ref window_title
  2433. *
  2434. * @since Added in version 1.0.
  2435. * @glfw3 Added window handle parameter.
  2436. *
  2437. * @ingroup window
  2438. */
  2439. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  2440. /*! @brief Sets the icon for the specified window.
  2441. *
  2442. * This function sets the icon of the specified window. If passed an array of
  2443. * candidate images, those of or closest to the sizes desired by the system are
  2444. * selected. If no images are specified, the window reverts to its default
  2445. * icon.
  2446. *
  2447. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  2448. * bits per channel with the red channel first. They are arranged canonically
  2449. * as packed sequential rows, starting from the top-left corner.
  2450. *
  2451. * The desired image sizes varies depending on platform and system settings.
  2452. * The selected images will be rescaled as needed. Good sizes include 16x16,
  2453. * 32x32 and 48x48.
  2454. *
  2455. * @param[in] window The window whose icon to set.
  2456. * @param[in] count The number of images in the specified array, or zero to
  2457. * revert to the default window icon.
  2458. * @param[in] images The images to create the icon from. This is ignored if
  2459. * count is zero.
  2460. *
  2461. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2462. * GLFW_PLATFORM_ERROR.
  2463. *
  2464. * @pointer_lifetime The specified image data is copied before this function
  2465. * returns.
  2466. *
  2467. * @remark @macos The GLFW window has no icon, as it is not a document
  2468. * window, so this function does nothing. The dock icon will be the same as
  2469. * the application bundle's icon. For more information on bundles, see the
  2470. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  2471. * in the Mac Developer Library.
  2472. *
  2473. * @remark @wayland There is no existing protocol to change an icon, the
  2474. * window will thus inherit the one defined in the application's desktop file.
  2475. * This function always emits @ref GLFW_PLATFORM_ERROR.
  2476. *
  2477. * @thread_safety This function must only be called from the main thread.
  2478. *
  2479. * @sa @ref window_icon
  2480. *
  2481. * @since Added in version 3.2.
  2482. *
  2483. * @ingroup window
  2484. */
  2485. GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
  2486. /*! @brief Retrieves the position of the client area of the specified window.
  2487. *
  2488. * This function retrieves the position, in screen coordinates, of the
  2489. * upper-left corner of the client area of the specified window.
  2490. *
  2491. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  2492. * non-`NULL` position arguments will be set to zero.
  2493. *
  2494. * @param[in] window The window to query.
  2495. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  2496. * the client area, or `NULL`.
  2497. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  2498. * the client area, or `NULL`.
  2499. *
  2500. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2501. * GLFW_PLATFORM_ERROR.
  2502. *
  2503. * @remark @wayland There is no way for an application to retrieve the global
  2504. * position of its windows, this function will always emit @ref
  2505. * GLFW_PLATFORM_ERROR.
  2506. *
  2507. * @thread_safety This function must only be called from the main thread.
  2508. *
  2509. * @sa @ref window_pos
  2510. * @sa @ref glfwSetWindowPos
  2511. *
  2512. * @since Added in version 3.0.
  2513. *
  2514. * @ingroup window
  2515. */
  2516. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  2517. /*! @brief Sets the position of the client area of the specified window.
  2518. *
  2519. * This function sets the position, in screen coordinates, of the upper-left
  2520. * corner of the client area of the specified windowed mode window. If the
  2521. * window is a full screen window, this function does nothing.
  2522. *
  2523. * __Do not use this function__ to move an already visible window unless you
  2524. * have very good reasons for doing so, as it will confuse and annoy the user.
  2525. *
  2526. * The window manager may put limits on what positions are allowed. GLFW
  2527. * cannot and should not override these limits.
  2528. *
  2529. * @param[in] window The window to query.
  2530. * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
  2531. * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
  2532. *
  2533. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2534. * GLFW_PLATFORM_ERROR.
  2535. *
  2536. * @remark @wayland There is no way for an application to set the global
  2537. * position of its windows, this function will always emit @ref
  2538. * GLFW_PLATFORM_ERROR.
  2539. *
  2540. * @thread_safety This function must only be called from the main thread.
  2541. *
  2542. * @sa @ref window_pos
  2543. * @sa @ref glfwGetWindowPos
  2544. *
  2545. * @since Added in version 1.0.
  2546. * @glfw3 Added window handle parameter.
  2547. *
  2548. * @ingroup window
  2549. */
  2550. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  2551. /*! @brief Retrieves the size of the client area of the specified window.
  2552. *
  2553. * This function retrieves the size, in screen coordinates, of the client area
  2554. * of the specified window. If you wish to retrieve the size of the
  2555. * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
  2556. *
  2557. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2558. * non-`NULL` size arguments will be set to zero.
  2559. *
  2560. * @param[in] window The window whose size to retrieve.
  2561. * @param[out] width Where to store the width, in screen coordinates, of the
  2562. * client area, or `NULL`.
  2563. * @param[out] height Where to store the height, in screen coordinates, of the
  2564. * client area, or `NULL`.
  2565. *
  2566. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2567. * GLFW_PLATFORM_ERROR.
  2568. *
  2569. * @thread_safety This function must only be called from the main thread.
  2570. *
  2571. * @sa @ref window_size
  2572. * @sa @ref glfwSetWindowSize
  2573. *
  2574. * @since Added in version 1.0.
  2575. * @glfw3 Added window handle parameter.
  2576. *
  2577. * @ingroup window
  2578. */
  2579. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  2580. /*! @brief Sets the size limits of the specified window.
  2581. *
  2582. * This function sets the size limits of the client area of the specified
  2583. * window. If the window is full screen, the size limits only take effect
  2584. * once it is made windowed. If the window is not resizable, this function
  2585. * does nothing.
  2586. *
  2587. * The size limits are applied immediately to a windowed mode window and may
  2588. * cause it to be resized.
  2589. *
  2590. * The maximum dimensions must be greater than or equal to the minimum
  2591. * dimensions and all must be greater than or equal to zero.
  2592. *
  2593. * @param[in] window The window to set limits for.
  2594. * @param[in] minwidth The minimum width, in screen coordinates, of the client
  2595. * area, or `GLFW_DONT_CARE`.
  2596. * @param[in] minheight The minimum height, in screen coordinates, of the
  2597. * client area, or `GLFW_DONT_CARE`.
  2598. * @param[in] maxwidth The maximum width, in screen coordinates, of the client
  2599. * area, or `GLFW_DONT_CARE`.
  2600. * @param[in] maxheight The maximum height, in screen coordinates, of the
  2601. * client area, or `GLFW_DONT_CARE`.
  2602. *
  2603. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2604. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2605. *
  2606. * @remark If you set size limits and an aspect ratio that conflict, the
  2607. * results are undefined.
  2608. *
  2609. * @remark @wayland The size limits will not be applied until the window is
  2610. * actually resized, either by the user or by the compositor.
  2611. *
  2612. * @thread_safety This function must only be called from the main thread.
  2613. *
  2614. * @sa @ref window_sizelimits
  2615. * @sa @ref glfwSetWindowAspectRatio
  2616. *
  2617. * @since Added in version 3.2.
  2618. *
  2619. * @ingroup window
  2620. */
  2621. GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
  2622. /*! @brief Sets the aspect ratio of the specified window.
  2623. *
  2624. * This function sets the required aspect ratio of the client area of the
  2625. * specified window. If the window is full screen, the aspect ratio only takes
  2626. * effect once it is made windowed. If the window is not resizable, this
  2627. * function does nothing.
  2628. *
  2629. * The aspect ratio is specified as a numerator and a denominator and both
  2630. * values must be greater than zero. For example, the common 16:9 aspect ratio
  2631. * is specified as 16 and 9, respectively.
  2632. *
  2633. * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
  2634. * ratio limit is disabled.
  2635. *
  2636. * The aspect ratio is applied immediately to a windowed mode window and may
  2637. * cause it to be resized.
  2638. *
  2639. * @param[in] window The window to set limits for.
  2640. * @param[in] numer The numerator of the desired aspect ratio, or
  2641. * `GLFW_DONT_CARE`.
  2642. * @param[in] denom The denominator of the desired aspect ratio, or
  2643. * `GLFW_DONT_CARE`.
  2644. *
  2645. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2646. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2647. *
  2648. * @remark If you set size limits and an aspect ratio that conflict, the
  2649. * results are undefined.
  2650. *
  2651. * @remark @wayland The aspect ratio will not be applied until the window is
  2652. * actually resized, either by the user or by the compositor.
  2653. *
  2654. * @thread_safety This function must only be called from the main thread.
  2655. *
  2656. * @sa @ref window_sizelimits
  2657. * @sa @ref glfwSetWindowSizeLimits
  2658. *
  2659. * @since Added in version 3.2.
  2660. *
  2661. * @ingroup window
  2662. */
  2663. GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
  2664. /*! @brief Sets the size of the client area of the specified window.
  2665. *
  2666. * This function sets the size, in screen coordinates, of the client area of
  2667. * the specified window.
  2668. *
  2669. * For full screen windows, this function updates the resolution of its desired
  2670. * video mode and switches to the video mode closest to it, without affecting
  2671. * the window's context. As the context is unaffected, the bit depths of the
  2672. * framebuffer remain unchanged.
  2673. *
  2674. * If you wish to update the refresh rate of the desired video mode in addition
  2675. * to its resolution, see @ref glfwSetWindowMonitor.
  2676. *
  2677. * The window manager may put limits on what sizes are allowed. GLFW cannot
  2678. * and should not override these limits.
  2679. *
  2680. * @param[in] window The window to resize.
  2681. * @param[in] width The desired width, in screen coordinates, of the window
  2682. * client area.
  2683. * @param[in] height The desired height, in screen coordinates, of the window
  2684. * client area.
  2685. *
  2686. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2687. * GLFW_PLATFORM_ERROR.
  2688. *
  2689. * @remark @wayland A full screen window will not attempt to change the mode,
  2690. * no matter what the requested size.
  2691. *
  2692. * @thread_safety This function must only be called from the main thread.
  2693. *
  2694. * @sa @ref window_size
  2695. * @sa @ref glfwGetWindowSize
  2696. * @sa @ref glfwSetWindowMonitor
  2697. *
  2698. * @since Added in version 1.0.
  2699. * @glfw3 Added window handle parameter.
  2700. *
  2701. * @ingroup window
  2702. */
  2703. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  2704. /*! @brief Retrieves the size of the framebuffer of the specified window.
  2705. *
  2706. * This function retrieves the size, in pixels, of the framebuffer of the
  2707. * specified window. If you wish to retrieve the size of the window in screen
  2708. * coordinates, see @ref glfwGetWindowSize.
  2709. *
  2710. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2711. * non-`NULL` size arguments will be set to zero.
  2712. *
  2713. * @param[in] window The window whose framebuffer to query.
  2714. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  2715. * or `NULL`.
  2716. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  2717. * or `NULL`.
  2718. *
  2719. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2720. * GLFW_PLATFORM_ERROR.
  2721. *
  2722. * @thread_safety This function must only be called from the main thread.
  2723. *
  2724. * @sa @ref window_fbsize
  2725. * @sa @ref glfwSetFramebufferSizeCallback
  2726. *
  2727. * @since Added in version 3.0.
  2728. *
  2729. * @ingroup window
  2730. */
  2731. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  2732. /*! @brief Retrieves the size of the frame of the window.
  2733. *
  2734. * This function retrieves the size, in screen coordinates, of each edge of the
  2735. * frame of the specified window. This size includes the title bar, if the
  2736. * window has one. The size of the frame may vary depending on the
  2737. * [window-related hints](@ref window_hints_wnd) used to create it.
  2738. *
  2739. * Because this function retrieves the size of each window frame edge and not
  2740. * the offset along a particular coordinate axis, the retrieved values will
  2741. * always be zero or positive.
  2742. *
  2743. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2744. * non-`NULL` size arguments will be set to zero.
  2745. *
  2746. * @param[in] window The window whose frame size to query.
  2747. * @param[out] left Where to store the size, in screen coordinates, of the left
  2748. * edge of the window frame, or `NULL`.
  2749. * @param[out] top Where to store the size, in screen coordinates, of the top
  2750. * edge of the window frame, or `NULL`.
  2751. * @param[out] right Where to store the size, in screen coordinates, of the
  2752. * right edge of the window frame, or `NULL`.
  2753. * @param[out] bottom Where to store the size, in screen coordinates, of the
  2754. * bottom edge of the window frame, or `NULL`.
  2755. *
  2756. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2757. * GLFW_PLATFORM_ERROR.
  2758. *
  2759. * @thread_safety This function must only be called from the main thread.
  2760. *
  2761. * @sa @ref window_size
  2762. *
  2763. * @since Added in version 3.1.
  2764. *
  2765. * @ingroup window
  2766. */
  2767. GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
  2768. /*! @brief Retrieves the content scale for the specified window.
  2769. *
  2770. * This function retrieves the content scale for the specified window. The
  2771. * content scale is the ratio between the current DPI and the platform's
  2772. * default DPI. If you scale all pixel dimensions by this scale then your
  2773. * content should appear at an appropriate size. This is especially important
  2774. * for text and any UI elements.
  2775. *
  2776. * On systems where each monitors can have its own content scale, the window
  2777. * content scale will depend on which monitor the system considers the window
  2778. * to be on.
  2779. *
  2780. * @param[in] window The window to query.
  2781. * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
  2782. * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
  2783. *
  2784. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2785. * GLFW_PLATFORM_ERROR.
  2786. *
  2787. * @thread_safety This function must only be called from the main thread.
  2788. *
  2789. * @sa @ref window_scale
  2790. * @sa @ref glfwSetWindowContentScaleCallback
  2791. * @sa @ref glfwGetMonitorContentScale
  2792. *
  2793. * @since Added in version 3.3.
  2794. *
  2795. * @ingroup window
  2796. */
  2797. GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
  2798. /*! @brief Returns the opacity of the whole window.
  2799. *
  2800. * This function returns the opacity of the window, including any decorations.
  2801. *
  2802. * The opacity (or alpha) value is a positive finite number between zero and
  2803. * one, where zero is fully transparent and one is fully opaque. If the system
  2804. * does not support whole window transparency, this function always returns one.
  2805. *
  2806. * The initial opacity value for newly created windows is one.
  2807. *
  2808. * @param[in] window The window to query.
  2809. * @return The opacity value of the specified window.
  2810. *
  2811. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2812. * GLFW_PLATFORM_ERROR.
  2813. *
  2814. * @thread_safety This function must only be called from the main thread.
  2815. *
  2816. * @sa @ref window_transparency
  2817. * @sa @ref glfwSetWindowOpacity
  2818. *
  2819. * @since Added in version 3.3.
  2820. *
  2821. * @ingroup window
  2822. */
  2823. GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
  2824. /*! @brief Sets the opacity of the whole window.
  2825. *
  2826. * This function sets the opacity of the window, including any decorations.
  2827. *
  2828. * The opacity (or alpha) value is a positive finite number between zero and
  2829. * one, where zero is fully transparent and one is fully opaque.
  2830. *
  2831. * The initial opacity value for newly created windows is one.
  2832. *
  2833. * A window created with framebuffer transparency may not use whole window
  2834. * transparency. The results of doing this are undefined.
  2835. *
  2836. * @param[in] window The window to set the opacity for.
  2837. * @param[in] opacity The desired opacity of the specified window.
  2838. *
  2839. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2840. * GLFW_PLATFORM_ERROR.
  2841. *
  2842. * @thread_safety This function must only be called from the main thread.
  2843. *
  2844. * @sa @ref window_transparency
  2845. * @sa @ref glfwGetWindowOpacity
  2846. *
  2847. * @since Added in version 3.3.
  2848. *
  2849. * @ingroup window
  2850. */
  2851. GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
  2852. /*! @brief Iconifies the specified window.
  2853. *
  2854. * This function iconifies (minimizes) the specified window if it was
  2855. * previously restored. If the window is already iconified, this function does
  2856. * nothing.
  2857. *
  2858. * If the specified window is a full screen window, the original monitor
  2859. * resolution is restored until the window is restored.
  2860. *
  2861. * @param[in] window The window to iconify.
  2862. *
  2863. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2864. * GLFW_PLATFORM_ERROR.
  2865. *
  2866. * @remark @wayland There is no concept of iconification in wl_shell, this
  2867. * function will emit @ref GLFW_PLATFORM_ERROR when using this deprecated
  2868. * protocol.
  2869. *
  2870. * @thread_safety This function must only be called from the main thread.
  2871. *
  2872. * @sa @ref window_iconify
  2873. * @sa @ref glfwRestoreWindow
  2874. * @sa @ref glfwMaximizeWindow
  2875. *
  2876. * @since Added in version 2.1.
  2877. * @glfw3 Added window handle parameter.
  2878. *
  2879. * @ingroup window
  2880. */
  2881. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  2882. /*! @brief Restores the specified window.
  2883. *
  2884. * This function restores the specified window if it was previously iconified
  2885. * (minimized) or maximized. If the window is already restored, this function
  2886. * does nothing.
  2887. *
  2888. * If the specified window is a full screen window, the resolution chosen for
  2889. * the window is restored on the selected monitor.
  2890. *
  2891. * @param[in] window The window to restore.
  2892. *
  2893. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2894. * GLFW_PLATFORM_ERROR.
  2895. *
  2896. * @thread_safety This function must only be called from the main thread.
  2897. *
  2898. * @sa @ref window_iconify
  2899. * @sa @ref glfwIconifyWindow
  2900. * @sa @ref glfwMaximizeWindow
  2901. *
  2902. * @since Added in version 2.1.
  2903. * @glfw3 Added window handle parameter.
  2904. *
  2905. * @ingroup window
  2906. */
  2907. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  2908. /*! @brief Maximizes the specified window.
  2909. *
  2910. * This function maximizes the specified window if it was previously not
  2911. * maximized. If the window is already maximized, this function does nothing.
  2912. *
  2913. * If the specified window is a full screen window, this function does nothing.
  2914. *
  2915. * @param[in] window The window to maximize.
  2916. *
  2917. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2918. * GLFW_PLATFORM_ERROR.
  2919. *
  2920. * @par Thread Safety
  2921. * This function may only be called from the main thread.
  2922. *
  2923. * @sa @ref window_iconify
  2924. * @sa @ref glfwIconifyWindow
  2925. * @sa @ref glfwRestoreWindow
  2926. *
  2927. * @since Added in GLFW 3.2.
  2928. *
  2929. * @ingroup window
  2930. */
  2931. GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
  2932. /*! @brief Makes the specified window visible.
  2933. *
  2934. * This function makes the specified window visible if it was previously
  2935. * hidden. If the window is already visible or is in full screen mode, this
  2936. * function does nothing.
  2937. *
  2938. * By default, windowed mode windows are focused when shown
  2939. * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
  2940. * to change this behavior for all newly created windows, or change the
  2941. * behavior for an existing window with @ref glfwSetWindowAttrib.
  2942. *
  2943. * @param[in] window The window to make visible.
  2944. *
  2945. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2946. * GLFW_PLATFORM_ERROR.
  2947. *
  2948. * @thread_safety This function must only be called from the main thread.
  2949. *
  2950. * @sa @ref window_hide
  2951. * @sa @ref glfwHideWindow
  2952. *
  2953. * @since Added in version 3.0.
  2954. *
  2955. * @ingroup window
  2956. */
  2957. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  2958. /*! @brief Hides the specified window.
  2959. *
  2960. * This function hides the specified window if it was previously visible. If
  2961. * the window is already hidden or is in full screen mode, this function does
  2962. * nothing.
  2963. *
  2964. * @param[in] window The window to hide.
  2965. *
  2966. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2967. * GLFW_PLATFORM_ERROR.
  2968. *
  2969. * @thread_safety This function must only be called from the main thread.
  2970. *
  2971. * @sa @ref window_hide
  2972. * @sa @ref glfwShowWindow
  2973. *
  2974. * @since Added in version 3.0.
  2975. *
  2976. * @ingroup window
  2977. */
  2978. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  2979. /*! @brief Brings the specified window to front and sets input focus.
  2980. *
  2981. * This function brings the specified window to front and sets input focus.
  2982. * The window should already be visible and not iconified.
  2983. *
  2984. * By default, both windowed and full screen mode windows are focused when
  2985. * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
  2986. * disable this behavior.
  2987. *
  2988. * Also by default, windowed mode windows are focused when shown
  2989. * with @ref glfwShowWindow. Set the
  2990. * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
  2991. *
  2992. * __Do not use this function__ to steal focus from other applications unless
  2993. * you are certain that is what the user wants. Focus stealing can be
  2994. * extremely disruptive.
  2995. *
  2996. * For a less disruptive way of getting the user's attention, see
  2997. * [attention requests](@ref window_attention).
  2998. *
  2999. * @param[in] window The window to give input focus.
  3000. *
  3001. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3002. * GLFW_PLATFORM_ERROR.
  3003. *
  3004. * @remark @wayland It is not possible for an application to bring its windows
  3005. * to front, this function will always emit @ref GLFW_PLATFORM_ERROR.
  3006. *
  3007. * @thread_safety This function must only be called from the main thread.
  3008. *
  3009. * @sa @ref window_focus
  3010. * @sa @ref window_attention
  3011. *
  3012. * @since Added in version 3.2.
  3013. *
  3014. * @ingroup window
  3015. */
  3016. GLFWAPI void glfwFocusWindow(GLFWwindow* window);
  3017. /*! @brief Requests user attention to the specified window.
  3018. *
  3019. * This function requests user attention to the specified window. On
  3020. * platforms where this is not supported, attention is requested to the
  3021. * application as a whole.
  3022. *
  3023. * Once the user has given attention, usually by focusing the window or
  3024. * application, the system will end the request automatically.
  3025. *
  3026. * @param[in] window The window to request attention to.
  3027. *
  3028. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3029. * GLFW_PLATFORM_ERROR.
  3030. *
  3031. * @remark @macos Attention is requested to the application as a whole, not the
  3032. * specific window.
  3033. *
  3034. * @thread_safety This function must only be called from the main thread.
  3035. *
  3036. * @sa @ref window_attention
  3037. *
  3038. * @since Added in version 3.3.
  3039. *
  3040. * @ingroup window
  3041. */
  3042. GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
  3043. /*! @brief Returns the monitor that the window uses for full screen mode.
  3044. *
  3045. * This function returns the handle of the monitor that the specified window is
  3046. * in full screen on.
  3047. *
  3048. * @param[in] window The window to query.
  3049. * @return The monitor, or `NULL` if the window is in windowed mode or an
  3050. * [error](@ref error_handling) occurred.
  3051. *
  3052. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3053. *
  3054. * @thread_safety This function must only be called from the main thread.
  3055. *
  3056. * @sa @ref window_monitor
  3057. * @sa @ref glfwSetWindowMonitor
  3058. *
  3059. * @since Added in version 3.0.
  3060. *
  3061. * @ingroup window
  3062. */
  3063. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  3064. /*! @brief Sets the mode, monitor, video mode and placement of a window.
  3065. *
  3066. * This function sets the monitor that the window uses for full screen mode or,
  3067. * if the monitor is `NULL`, makes it windowed mode.
  3068. *
  3069. * When setting a monitor, this function updates the width, height and refresh
  3070. * rate of the desired video mode and switches to the video mode closest to it.
  3071. * The window position is ignored when setting a monitor.
  3072. *
  3073. * When the monitor is `NULL`, the position, width and height are used to
  3074. * place the window client area. The refresh rate is ignored when no monitor
  3075. * is specified.
  3076. *
  3077. * If you only wish to update the resolution of a full screen window or the
  3078. * size of a windowed mode window, see @ref glfwSetWindowSize.
  3079. *
  3080. * When a window transitions from full screen to windowed mode, this function
  3081. * restores any previous window settings such as whether it is decorated,
  3082. * floating, resizable, has size or aspect ratio limits, etc.
  3083. *
  3084. * @param[in] window The window whose monitor, size or video mode to set.
  3085. * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
  3086. * @param[in] xpos The desired x-coordinate of the upper-left corner of the
  3087. * client area.
  3088. * @param[in] ypos The desired y-coordinate of the upper-left corner of the
  3089. * client area.
  3090. * @param[in] width The desired with, in screen coordinates, of the client area
  3091. * or video mode.
  3092. * @param[in] height The desired height, in screen coordinates, of the client
  3093. * area or video mode.
  3094. * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
  3095. * or `GLFW_DONT_CARE`.
  3096. *
  3097. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3098. * GLFW_PLATFORM_ERROR.
  3099. *
  3100. * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
  3101. * affected by any resizing or mode switching, although you may need to update
  3102. * your viewport if the framebuffer size has changed.
  3103. *
  3104. * @remark @wayland The desired window position is ignored, as there is no way
  3105. * for an application to set this property.
  3106. *
  3107. * @remark @wayland Setting the window to full screen will not attempt to
  3108. * change the mode, no matter what the requested size or refresh rate.
  3109. *
  3110. * @thread_safety This function must only be called from the main thread.
  3111. *
  3112. * @sa @ref window_monitor
  3113. * @sa @ref window_full_screen
  3114. * @sa @ref glfwGetWindowMonitor
  3115. * @sa @ref glfwSetWindowSize
  3116. *
  3117. * @since Added in version 3.2.
  3118. *
  3119. * @ingroup window
  3120. */
  3121. GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
  3122. /*! @brief Returns an attribute of the specified window.
  3123. *
  3124. * This function returns the value of an attribute of the specified window or
  3125. * its OpenGL or OpenGL ES context.
  3126. *
  3127. * @param[in] window The window to query.
  3128. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  3129. * return.
  3130. * @return The value of the attribute, or zero if an
  3131. * [error](@ref error_handling) occurred.
  3132. *
  3133. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3134. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3135. *
  3136. * @remark Framebuffer related hints are not window attributes. See @ref
  3137. * window_attribs_fb for more information.
  3138. *
  3139. * @remark Zero is a valid value for many window and context related
  3140. * attributes so you cannot use a return value of zero as an indication of
  3141. * errors. However, this function should not fail as long as it is passed
  3142. * valid arguments and the library has been [initialized](@ref intro_init).
  3143. *
  3144. * @thread_safety This function must only be called from the main thread.
  3145. *
  3146. * @sa @ref window_attribs
  3147. * @sa @ref glfwSetWindowAttrib
  3148. *
  3149. * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
  3150. * `glfwGetGLVersion`.
  3151. *
  3152. * @ingroup window
  3153. */
  3154. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  3155. /*! @brief Sets an attribute of the specified window.
  3156. *
  3157. * This function sets the value of an attribute of the specified window.
  3158. *
  3159. * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
  3160. * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
  3161. * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
  3162. * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
  3163. * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
  3164. *
  3165. * Some of these attributes are ignored for full screen windows. The new
  3166. * value will take effect if the window is later made windowed.
  3167. *
  3168. * Some of these attributes are ignored for windowed mode windows. The new
  3169. * value will take effect if the window is later made full screen.
  3170. *
  3171. * @param[in] window The window to set the attribute for.
  3172. * @param[in] attrib A supported window attribute.
  3173. * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
  3174. *
  3175. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3176. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  3177. *
  3178. * @remark Calling @ref glfwGetWindowAttrib will always return the latest
  3179. * value, even if that value is ignored by the current mode of the window.
  3180. *
  3181. * @thread_safety This function must only be called from the main thread.
  3182. *
  3183. * @sa @ref window_attribs
  3184. * @sa @ref glfwGetWindowAttrib
  3185. *
  3186. * @since Added in version 3.3.
  3187. *
  3188. * @ingroup window
  3189. */
  3190. GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
  3191. /*! @brief Sets the user pointer of the specified window.
  3192. *
  3193. * This function sets the user-defined pointer of the specified window. The
  3194. * current value is retained until the window is destroyed. The initial value
  3195. * is `NULL`.
  3196. *
  3197. * @param[in] window The window whose pointer to set.
  3198. * @param[in] pointer The new value.
  3199. *
  3200. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3201. *
  3202. * @thread_safety This function may be called from any thread. Access is not
  3203. * synchronized.
  3204. *
  3205. * @sa @ref window_userptr
  3206. * @sa @ref glfwGetWindowUserPointer
  3207. *
  3208. * @since Added in version 3.0.
  3209. *
  3210. * @ingroup window
  3211. */
  3212. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  3213. /*! @brief Returns the user pointer of the specified window.
  3214. *
  3215. * This function returns the current value of the user-defined pointer of the
  3216. * specified window. The initial value is `NULL`.
  3217. *
  3218. * @param[in] window The window whose pointer to return.
  3219. *
  3220. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3221. *
  3222. * @thread_safety This function may be called from any thread. Access is not
  3223. * synchronized.
  3224. *
  3225. * @sa @ref window_userptr
  3226. * @sa @ref glfwSetWindowUserPointer
  3227. *
  3228. * @since Added in version 3.0.
  3229. *
  3230. * @ingroup window
  3231. */
  3232. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  3233. /*! @brief Sets the position callback for the specified window.
  3234. *
  3235. * This function sets the position callback of the specified window, which is
  3236. * called when the window is moved. The callback is provided with the
  3237. * position, in screen coordinates, of the upper-left corner of the client area
  3238. * of the window.
  3239. *
  3240. * @param[in] window The window whose callback to set.
  3241. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3242. * callback.
  3243. * @return The previously set callback, or `NULL` if no callback was set or the
  3244. * library had not been [initialized](@ref intro_init).
  3245. *
  3246. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3247. *
  3248. * @remark @wayland This callback will never be called, as there is no way for
  3249. * an application to know its global position.
  3250. *
  3251. * @thread_safety This function must only be called from the main thread.
  3252. *
  3253. * @sa @ref window_pos
  3254. *
  3255. * @since Added in version 3.0.
  3256. *
  3257. * @ingroup window
  3258. */
  3259. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
  3260. /*! @brief Sets the size callback for the specified window.
  3261. *
  3262. * This function sets the size callback of the specified window, which is
  3263. * called when the window is resized. The callback is provided with the size,
  3264. * in screen coordinates, of the client area of the window.
  3265. *
  3266. * @param[in] window The window whose callback to set.
  3267. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3268. * callback.
  3269. * @return The previously set callback, or `NULL` if no callback was set or the
  3270. * library had not been [initialized](@ref intro_init).
  3271. *
  3272. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3273. *
  3274. * @thread_safety This function must only be called from the main thread.
  3275. *
  3276. * @sa @ref window_size
  3277. *
  3278. * @since Added in version 1.0.
  3279. * @glfw3 Added window handle parameter and return value.
  3280. *
  3281. * @ingroup window
  3282. */
  3283. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
  3284. /*! @brief Sets the close callback for the specified window.
  3285. *
  3286. * This function sets the close callback of the specified window, which is
  3287. * called when the user attempts to close the window, for example by clicking
  3288. * the close widget in the title bar.
  3289. *
  3290. * The close flag is set before this callback is called, but you can modify it
  3291. * at any time with @ref glfwSetWindowShouldClose.
  3292. *
  3293. * The close callback is not triggered by @ref glfwDestroyWindow.
  3294. *
  3295. * @param[in] window The window whose callback to set.
  3296. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3297. * callback.
  3298. * @return The previously set callback, or `NULL` if no callback was set or the
  3299. * library had not been [initialized](@ref intro_init).
  3300. *
  3301. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3302. *
  3303. * @remark @macos Selecting Quit from the application menu will trigger the
  3304. * close callback for all windows.
  3305. *
  3306. * @thread_safety This function must only be called from the main thread.
  3307. *
  3308. * @sa @ref window_close
  3309. *
  3310. * @since Added in version 2.5.
  3311. * @glfw3 Added window handle parameter and return value.
  3312. *
  3313. * @ingroup window
  3314. */
  3315. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
  3316. /*! @brief Sets the refresh callback for the specified window.
  3317. *
  3318. * This function sets the refresh callback of the specified window, which is
  3319. * called when the client area of the window needs to be redrawn, for example
  3320. * if the window has been exposed after having been covered by another window.
  3321. *
  3322. * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
  3323. * the window contents are saved off-screen, this callback may be called only
  3324. * very infrequently or never at all.
  3325. *
  3326. * @param[in] window The window whose callback to set.
  3327. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3328. * callback.
  3329. * @return The previously set callback, or `NULL` if no callback was set or the
  3330. * library had not been [initialized](@ref intro_init).
  3331. *
  3332. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3333. *
  3334. * @thread_safety This function must only be called from the main thread.
  3335. *
  3336. * @sa @ref window_refresh
  3337. *
  3338. * @since Added in version 2.5.
  3339. * @glfw3 Added window handle parameter and return value.
  3340. *
  3341. * @ingroup window
  3342. */
  3343. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
  3344. /*! @brief Sets the focus callback for the specified window.
  3345. *
  3346. * This function sets the focus callback of the specified window, which is
  3347. * called when the window gains or loses input focus.
  3348. *
  3349. * After the focus callback is called for a window that lost input focus,
  3350. * synthetic key and mouse button release events will be generated for all such
  3351. * that had been pressed. For more information, see @ref glfwSetKeyCallback
  3352. * and @ref glfwSetMouseButtonCallback.
  3353. *
  3354. * @param[in] window The window whose callback to set.
  3355. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3356. * callback.
  3357. * @return The previously set callback, or `NULL` if no callback was set or the
  3358. * library had not been [initialized](@ref intro_init).
  3359. *
  3360. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3361. *
  3362. * @thread_safety This function must only be called from the main thread.
  3363. *
  3364. * @sa @ref window_focus
  3365. *
  3366. * @since Added in version 3.0.
  3367. *
  3368. * @ingroup window
  3369. */
  3370. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
  3371. /*! @brief Sets the iconify callback for the specified window.
  3372. *
  3373. * This function sets the iconification callback of the specified window, which
  3374. * is called when the window is iconified or restored.
  3375. *
  3376. * @param[in] window The window whose callback to set.
  3377. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3378. * callback.
  3379. * @return The previously set callback, or `NULL` if no callback was set or the
  3380. * library had not been [initialized](@ref intro_init).
  3381. *
  3382. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3383. *
  3384. * @remark @wayland The wl_shell protocol has no concept of iconification,
  3385. * this callback will never be called when using this deprecated protocol.
  3386. *
  3387. * @thread_safety This function must only be called from the main thread.
  3388. *
  3389. * @sa @ref window_iconify
  3390. *
  3391. * @since Added in version 3.0.
  3392. *
  3393. * @ingroup window
  3394. */
  3395. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
  3396. /*! @brief Sets the maximize callback for the specified window.
  3397. *
  3398. * This function sets the maximization callback of the specified window, which
  3399. * is called when the window is maximized or restored.
  3400. *
  3401. * @param[in] window The window whose callback to set.
  3402. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3403. * callback.
  3404. * @return The previously set callback, or `NULL` if no callback was set or the
  3405. * library had not been [initialized](@ref intro_init).
  3406. *
  3407. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3408. *
  3409. * @thread_safety This function must only be called from the main thread.
  3410. *
  3411. * @sa @ref window_maximize
  3412. *
  3413. * @since Added in version 3.3.
  3414. *
  3415. * @ingroup window
  3416. */
  3417. GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun cbfun);
  3418. /*! @brief Sets the framebuffer resize callback for the specified window.
  3419. *
  3420. * This function sets the framebuffer resize callback of the specified window,
  3421. * which is called when the framebuffer of the specified window is resized.
  3422. *
  3423. * @param[in] window The window whose callback to set.
  3424. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3425. * callback.
  3426. * @return The previously set callback, or `NULL` if no callback was set or the
  3427. * library had not been [initialized](@ref intro_init).
  3428. *
  3429. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3430. *
  3431. * @thread_safety This function must only be called from the main thread.
  3432. *
  3433. * @sa @ref window_fbsize
  3434. *
  3435. * @since Added in version 3.0.
  3436. *
  3437. * @ingroup window
  3438. */
  3439. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
  3440. /*! @brief Sets the window content scale callback for the specified window.
  3441. *
  3442. * This function sets the window content scale callback of the specified window,
  3443. * which is called when the content scale of the specified window changes.
  3444. *
  3445. * @param[in] window The window whose callback to set.
  3446. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3447. * callback.
  3448. * @return The previously set callback, or `NULL` if no callback was set or the
  3449. * library had not been [initialized](@ref intro_init).
  3450. *
  3451. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3452. *
  3453. * @thread_safety This function must only be called from the main thread.
  3454. *
  3455. * @sa @ref window_scale
  3456. * @sa @ref glfwGetWindowContentScale
  3457. *
  3458. * @since Added in version 3.3.
  3459. *
  3460. * @ingroup window
  3461. */
  3462. GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun cbfun);
  3463. /*! @brief Processes all pending events.
  3464. *
  3465. * This function processes only those events that are already in the event
  3466. * queue and then returns immediately. Processing events will cause the window
  3467. * and input callbacks associated with those events to be called.
  3468. *
  3469. * On some platforms, a window move, resize or menu operation will cause event
  3470. * processing to block. This is due to how event processing is designed on
  3471. * those platforms. You can use the
  3472. * [window refresh callback](@ref window_refresh) to redraw the contents of
  3473. * your window when necessary during such operations.
  3474. *
  3475. * Do not assume that callbacks you set will _only_ be called in response to
  3476. * event processing functions like this one. While it is necessary to poll for
  3477. * events, window systems that require GLFW to register callbacks of its own
  3478. * can pass events to GLFW in response to many window system function calls.
  3479. * GLFW will pass those events on to the application callbacks before
  3480. * returning.
  3481. *
  3482. * Event processing is not required for joystick input to work.
  3483. *
  3484. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3485. * GLFW_PLATFORM_ERROR.
  3486. *
  3487. * @reentrancy This function must not be called from a callback.
  3488. *
  3489. * @thread_safety This function must only be called from the main thread.
  3490. *
  3491. * @sa @ref events
  3492. * @sa @ref glfwWaitEvents
  3493. * @sa @ref glfwWaitEventsTimeout
  3494. *
  3495. * @since Added in version 1.0.
  3496. *
  3497. * @ingroup window
  3498. */
  3499. GLFWAPI void glfwPollEvents(void);
  3500. /*! @brief Waits until events are queued and processes them.
  3501. *
  3502. * This function puts the calling thread to sleep until at least one event is
  3503. * available in the event queue. Once one or more events are available,
  3504. * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
  3505. * are processed and the function then returns immediately. Processing events
  3506. * will cause the window and input callbacks associated with those events to be
  3507. * called.
  3508. *
  3509. * Since not all events are associated with callbacks, this function may return
  3510. * without a callback having been called even if you are monitoring all
  3511. * callbacks.
  3512. *
  3513. * On some platforms, a window move, resize or menu operation will cause event
  3514. * processing to block. This is due to how event processing is designed on
  3515. * those platforms. You can use the
  3516. * [window refresh callback](@ref window_refresh) to redraw the contents of
  3517. * your window when necessary during such operations.
  3518. *
  3519. * Do not assume that callbacks you set will _only_ be called in response to
  3520. * event processing functions like this one. While it is necessary to poll for
  3521. * events, window systems that require GLFW to register callbacks of its own
  3522. * can pass events to GLFW in response to many window system function calls.
  3523. * GLFW will pass those events on to the application callbacks before
  3524. * returning.
  3525. *
  3526. * If no windows exist, this function returns immediately. For synchronization
  3527. * of threads in applications that do not create windows, use your threading
  3528. * library of choice.
  3529. *
  3530. * Event processing is not required for joystick input to work.
  3531. *
  3532. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3533. * GLFW_PLATFORM_ERROR.
  3534. *
  3535. * @reentrancy This function must not be called from a callback.
  3536. *
  3537. * @thread_safety This function must only be called from the main thread.
  3538. *
  3539. * @sa @ref events
  3540. * @sa @ref glfwPollEvents
  3541. * @sa @ref glfwWaitEventsTimeout
  3542. *
  3543. * @since Added in version 2.5.
  3544. *
  3545. * @ingroup window
  3546. */
  3547. GLFWAPI void glfwWaitEvents(void);
  3548. /*! @brief Waits with timeout until events are queued and processes them.
  3549. *
  3550. * This function puts the calling thread to sleep until at least one event is
  3551. * available in the event queue, or until the specified timeout is reached. If
  3552. * one or more events are available, it behaves exactly like @ref
  3553. * glfwPollEvents, i.e. the events in the queue are processed and the function
  3554. * then returns immediately. Processing events will cause the window and input
  3555. * callbacks associated with those events to be called.
  3556. *
  3557. * The timeout value must be a positive finite number.
  3558. *
  3559. * Since not all events are associated with callbacks, this function may return
  3560. * without a callback having been called even if you are monitoring all
  3561. * callbacks.
  3562. *
  3563. * On some platforms, a window move, resize or menu operation will cause event
  3564. * processing to block. This is due to how event processing is designed on
  3565. * those platforms. You can use the
  3566. * [window refresh callback](@ref window_refresh) to redraw the contents of
  3567. * your window when necessary during such operations.
  3568. *
  3569. * Do not assume that callbacks you set will _only_ be called in response to
  3570. * event processing functions like this one. While it is necessary to poll for
  3571. * events, window systems that require GLFW to register callbacks of its own
  3572. * can pass events to GLFW in response to many window system function calls.
  3573. * GLFW will pass those events on to the application callbacks before
  3574. * returning.
  3575. *
  3576. * If no windows exist, this function returns immediately. For synchronization
  3577. * of threads in applications that do not create windows, use your threading
  3578. * library of choice.
  3579. *
  3580. * Event processing is not required for joystick input to work.
  3581. *
  3582. * @param[in] timeout The maximum amount of time, in seconds, to wait.
  3583. *
  3584. * @reentrancy This function must not be called from a callback.
  3585. *
  3586. * @thread_safety This function must only be called from the main thread.
  3587. *
  3588. * @sa @ref events
  3589. * @sa @ref glfwPollEvents
  3590. * @sa @ref glfwWaitEvents
  3591. *
  3592. * @since Added in version 3.2.
  3593. *
  3594. * @ingroup window
  3595. */
  3596. GLFWAPI void glfwWaitEventsTimeout(double timeout);
  3597. /*! @brief Posts an empty event to the event queue.
  3598. *
  3599. * This function posts an empty event from the current thread to the event
  3600. * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
  3601. *
  3602. * If no windows exist, this function returns immediately. For synchronization
  3603. * of threads in applications that do not create windows, use your threading
  3604. * library of choice.
  3605. *
  3606. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3607. * GLFW_PLATFORM_ERROR.
  3608. *
  3609. * @thread_safety This function may be called from any thread.
  3610. *
  3611. * @sa @ref events
  3612. * @sa @ref glfwWaitEvents
  3613. * @sa @ref glfwWaitEventsTimeout
  3614. *
  3615. * @since Added in version 3.1.
  3616. *
  3617. * @ingroup window
  3618. */
  3619. GLFWAPI void glfwPostEmptyEvent(void);
  3620. /*! @brief Returns the value of an input option for the specified window.
  3621. *
  3622. * This function returns the value of an input option for the specified window.
  3623. * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  3624. * @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
  3625. *
  3626. * @param[in] window The window to query.
  3627. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  3628. * `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
  3629. *
  3630. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3631. * GLFW_INVALID_ENUM.
  3632. *
  3633. * @thread_safety This function must only be called from the main thread.
  3634. *
  3635. * @sa @ref glfwSetInputMode
  3636. *
  3637. * @since Added in version 3.0.
  3638. *
  3639. * @ingroup input
  3640. */
  3641. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  3642. /*! @brief Sets an input option for the specified window.
  3643. *
  3644. * This function sets an input mode option for the specified window. The mode
  3645. * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  3646. * @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
  3647. *
  3648. * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  3649. * modes:
  3650. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  3651. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
  3652. * area of the window but does not restrict the cursor from leaving.
  3653. * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  3654. * and unlimited cursor movement. This is useful for implementing for
  3655. * example 3D camera controls.
  3656. *
  3657. * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
  3658. * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
  3659. * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  3660. * the next time it is called even if the key had been released before the
  3661. * call. This is useful when you are only interested in whether keys have been
  3662. * pressed but not when or in which order.
  3663. *
  3664. * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  3665. * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
  3666. * If sticky mouse buttons are enabled, a mouse button press will ensure that
  3667. * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
  3668. * if the mouse button had been released before the call. This is useful when
  3669. * you are only interested in whether mouse buttons have been pressed but not
  3670. * when or in which order.
  3671. *
  3672. * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
  3673. * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
  3674. * callbacks that receive modifier bits will also have the @ref
  3675. * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
  3676. * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
  3677. *
  3678. * @param[in] window The window whose input mode to set.
  3679. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  3680. * `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
  3681. * @param[in] value The new value of the specified input mode.
  3682. *
  3683. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3684. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3685. *
  3686. * @thread_safety This function must only be called from the main thread.
  3687. *
  3688. * @sa @ref glfwGetInputMode
  3689. *
  3690. * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
  3691. *
  3692. * @ingroup input
  3693. */
  3694. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  3695. /*! @brief Returns the layout-specific name of the specified printable key.
  3696. *
  3697. * This function returns the name of the specified printable key, encoded as
  3698. * UTF-8. This is typically the character that key would produce without any
  3699. * modifier keys, intended for displaying key bindings to the user. For dead
  3700. * keys, it is typically the diacritic it would add to a character.
  3701. *
  3702. * __Do not use this function__ for [text input](@ref input_char). You will
  3703. * break text input for many languages even if it happens to work for yours.
  3704. *
  3705. * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
  3706. * otherwise the scancode is ignored. If you specify a non-printable key, or
  3707. * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
  3708. * function returns `NULL` but does not emit an error.
  3709. *
  3710. * This behavior allows you to always pass in the arguments in the
  3711. * [key callback](@ref input_key) without modification.
  3712. *
  3713. * The printable keys are:
  3714. * - `GLFW_KEY_APOSTROPHE`
  3715. * - `GLFW_KEY_COMMA`
  3716. * - `GLFW_KEY_MINUS`
  3717. * - `GLFW_KEY_PERIOD`
  3718. * - `GLFW_KEY_SLASH`
  3719. * - `GLFW_KEY_SEMICOLON`
  3720. * - `GLFW_KEY_EQUAL`
  3721. * - `GLFW_KEY_LEFT_BRACKET`
  3722. * - `GLFW_KEY_RIGHT_BRACKET`
  3723. * - `GLFW_KEY_BACKSLASH`
  3724. * - `GLFW_KEY_WORLD_1`
  3725. * - `GLFW_KEY_WORLD_2`
  3726. * - `GLFW_KEY_0` to `GLFW_KEY_9`
  3727. * - `GLFW_KEY_A` to `GLFW_KEY_Z`
  3728. * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
  3729. * - `GLFW_KEY_KP_DECIMAL`
  3730. * - `GLFW_KEY_KP_DIVIDE`
  3731. * - `GLFW_KEY_KP_MULTIPLY`
  3732. * - `GLFW_KEY_KP_SUBTRACT`
  3733. * - `GLFW_KEY_KP_ADD`
  3734. * - `GLFW_KEY_KP_EQUAL`
  3735. *
  3736. * Names for printable keys depend on keyboard layout, while names for
  3737. * non-printable keys are the same across layouts but depend on the application
  3738. * language and should be localized along with other user interface text.
  3739. *
  3740. * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
  3741. * @param[in] scancode The scancode of the key to query.
  3742. * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
  3743. *
  3744. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3745. * GLFW_PLATFORM_ERROR.
  3746. *
  3747. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  3748. * should not free it yourself. It is valid until the next call to @ref
  3749. * glfwGetKeyName, or until the library is terminated.
  3750. *
  3751. * @thread_safety This function must only be called from the main thread.
  3752. *
  3753. * @sa @ref input_key_name
  3754. *
  3755. * @since Added in version 3.2.
  3756. *
  3757. * @ingroup input
  3758. */
  3759. GLFWAPI const char* glfwGetKeyName(int key, int scancode);
  3760. /*! @brief Returns the platform-specific scancode of the specified key.
  3761. *
  3762. * This function returns the platform-specific scancode of the specified key.
  3763. *
  3764. * If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
  3765. * method will return `-1`.
  3766. *
  3767. * @param[in] key Any [named key](@ref keys).
  3768. * @return The platform-specific scancode for the key, or `-1` if an
  3769. * [error](@ref error_handling) occurred.
  3770. *
  3771. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3772. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3773. *
  3774. * @thread_safety This function may be called from any thread.
  3775. *
  3776. * @sa @ref input_key
  3777. *
  3778. * @since Added in version 3.3.
  3779. *
  3780. * @ingroup input
  3781. */
  3782. GLFWAPI int glfwGetKeyScancode(int key);
  3783. /*! @brief Returns the last reported state of a keyboard key for the specified
  3784. * window.
  3785. *
  3786. * This function returns the last state reported for the specified key to the
  3787. * specified window. The returned state is one of `GLFW_PRESS` or
  3788. * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
  3789. * the key callback.
  3790. *
  3791. * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
  3792. * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  3793. * that key has already been released.
  3794. *
  3795. * The key functions deal with physical keys, with [key tokens](@ref keys)
  3796. * named after their use on the standard US keyboard layout. If you want to
  3797. * input text, use the Unicode character callback instead.
  3798. *
  3799. * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  3800. * used with this function.
  3801. *
  3802. * __Do not use this function__ to implement [text input](@ref input_char).
  3803. *
  3804. * @param[in] window The desired window.
  3805. * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
  3806. * not a valid key for this function.
  3807. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  3808. *
  3809. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3810. * GLFW_INVALID_ENUM.
  3811. *
  3812. * @thread_safety This function must only be called from the main thread.
  3813. *
  3814. * @sa @ref input_key
  3815. *
  3816. * @since Added in version 1.0.
  3817. * @glfw3 Added window handle parameter.
  3818. *
  3819. * @ingroup input
  3820. */
  3821. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  3822. /*! @brief Returns the last reported state of a mouse button for the specified
  3823. * window.
  3824. *
  3825. * This function returns the last state reported for the specified mouse button
  3826. * to the specified window. The returned state is one of `GLFW_PRESS` or
  3827. * `GLFW_RELEASE`.
  3828. *
  3829. * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
  3830. * `GLFW_PRESS` the first time you call it for a mouse button that was pressed,
  3831. * even if that mouse button has already been released.
  3832. *
  3833. * @param[in] window The desired window.
  3834. * @param[in] button The desired [mouse button](@ref buttons).
  3835. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  3836. *
  3837. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3838. * GLFW_INVALID_ENUM.
  3839. *
  3840. * @thread_safety This function must only be called from the main thread.
  3841. *
  3842. * @sa @ref input_mouse_button
  3843. *
  3844. * @since Added in version 1.0.
  3845. * @glfw3 Added window handle parameter.
  3846. *
  3847. * @ingroup input
  3848. */
  3849. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  3850. /*! @brief Retrieves the position of the cursor relative to the client area of
  3851. * the window.
  3852. *
  3853. * This function returns the position of the cursor, in screen coordinates,
  3854. * relative to the upper-left corner of the client area of the specified
  3855. * window.
  3856. *
  3857. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  3858. * position is unbounded and limited only by the minimum and maximum values of
  3859. * a `double`.
  3860. *
  3861. * The coordinate can be converted to their integer equivalents with the
  3862. * `floor` function. Casting directly to an integer type works for positive
  3863. * coordinates, but fails for negative ones.
  3864. *
  3865. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  3866. * non-`NULL` position arguments will be set to zero.
  3867. *
  3868. * @param[in] window The desired window.
  3869. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  3870. * left edge of the client area, or `NULL`.
  3871. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  3872. * top edge of the client area, or `NULL`.
  3873. *
  3874. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3875. * GLFW_PLATFORM_ERROR.
  3876. *
  3877. * @thread_safety This function must only be called from the main thread.
  3878. *
  3879. * @sa @ref cursor_pos
  3880. * @sa @ref glfwSetCursorPos
  3881. *
  3882. * @since Added in version 3.0. Replaces `glfwGetMousePos`.
  3883. *
  3884. * @ingroup input
  3885. */
  3886. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  3887. /*! @brief Sets the position of the cursor, relative to the client area of the
  3888. * window.
  3889. *
  3890. * This function sets the position, in screen coordinates, of the cursor
  3891. * relative to the upper-left corner of the client area of the specified
  3892. * window. The window must have input focus. If the window does not have
  3893. * input focus when this function is called, it fails silently.
  3894. *
  3895. * __Do not use this function__ to implement things like camera controls. GLFW
  3896. * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  3897. * cursor, transparently re-centers it and provides unconstrained cursor
  3898. * motion. See @ref glfwSetInputMode for more information.
  3899. *
  3900. * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  3901. * unconstrained and limited only by the minimum and maximum values of
  3902. * a `double`.
  3903. *
  3904. * @param[in] window The desired window.
  3905. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  3906. * client area.
  3907. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  3908. * client area.
  3909. *
  3910. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3911. * GLFW_PLATFORM_ERROR.
  3912. *
  3913. * @remark @wayland This function will only work when the cursor mode is
  3914. * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
  3915. *
  3916. * @thread_safety This function must only be called from the main thread.
  3917. *
  3918. * @sa @ref cursor_pos
  3919. * @sa @ref glfwGetCursorPos
  3920. *
  3921. * @since Added in version 3.0. Replaces `glfwSetMousePos`.
  3922. *
  3923. * @ingroup input
  3924. */
  3925. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  3926. /*! @brief Creates a custom cursor.
  3927. *
  3928. * Creates a new custom cursor image that can be set for a window with @ref
  3929. * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
  3930. * Any remaining cursors are destroyed by @ref glfwTerminate.
  3931. *
  3932. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  3933. * bits per channel with the red channel first. They are arranged canonically
  3934. * as packed sequential rows, starting from the top-left corner.
  3935. *
  3936. * The cursor hotspot is specified in pixels, relative to the upper-left corner
  3937. * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
  3938. * points to the right and the Y-axis points down.
  3939. *
  3940. * @param[in] image The desired cursor image.
  3941. * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
  3942. * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
  3943. * @return The handle of the created cursor, or `NULL` if an
  3944. * [error](@ref error_handling) occurred.
  3945. *
  3946. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3947. * GLFW_PLATFORM_ERROR.
  3948. *
  3949. * @pointer_lifetime The specified image data is copied before this function
  3950. * returns.
  3951. *
  3952. * @thread_safety This function must only be called from the main thread.
  3953. *
  3954. * @sa @ref cursor_object
  3955. * @sa @ref glfwDestroyCursor
  3956. * @sa @ref glfwCreateStandardCursor
  3957. *
  3958. * @since Added in version 3.1.
  3959. *
  3960. * @ingroup input
  3961. */
  3962. GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
  3963. /*! @brief Creates a cursor with a standard shape.
  3964. *
  3965. * Returns a cursor with a [standard shape](@ref shapes), that can be set for
  3966. * a window with @ref glfwSetCursor.
  3967. *
  3968. * @param[in] shape One of the [standard shapes](@ref shapes).
  3969. * @return A new cursor ready to use or `NULL` if an
  3970. * [error](@ref error_handling) occurred.
  3971. *
  3972. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3973. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3974. *
  3975. * @thread_safety This function must only be called from the main thread.
  3976. *
  3977. * @sa @ref cursor_object
  3978. * @sa @ref glfwCreateCursor
  3979. *
  3980. * @since Added in version 3.1.
  3981. *
  3982. * @ingroup input
  3983. */
  3984. GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
  3985. /*! @brief Destroys a cursor.
  3986. *
  3987. * This function destroys a cursor previously created with @ref
  3988. * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
  3989. * glfwTerminate.
  3990. *
  3991. * If the specified cursor is current for any window, that window will be
  3992. * reverted to the default cursor. This does not affect the cursor mode.
  3993. *
  3994. * @param[in] cursor The cursor object to destroy.
  3995. *
  3996. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3997. * GLFW_PLATFORM_ERROR.
  3998. *
  3999. * @reentrancy This function must not be called from a callback.
  4000. *
  4001. * @thread_safety This function must only be called from the main thread.
  4002. *
  4003. * @sa @ref cursor_object
  4004. * @sa @ref glfwCreateCursor
  4005. *
  4006. * @since Added in version 3.1.
  4007. *
  4008. * @ingroup input
  4009. */
  4010. GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
  4011. /*! @brief Sets the cursor for the window.
  4012. *
  4013. * This function sets the cursor image to be used when the cursor is over the
  4014. * client area of the specified window. The set cursor will only be visible
  4015. * when the [cursor mode](@ref cursor_mode) of the window is
  4016. * `GLFW_CURSOR_NORMAL`.
  4017. *
  4018. * On some platforms, the set cursor may not be visible unless the window also
  4019. * has input focus.
  4020. *
  4021. * @param[in] window The window to set the cursor for.
  4022. * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  4023. * arrow cursor.
  4024. *
  4025. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4026. * GLFW_PLATFORM_ERROR.
  4027. *
  4028. * @thread_safety This function must only be called from the main thread.
  4029. *
  4030. * @sa @ref cursor_object
  4031. *
  4032. * @since Added in version 3.1.
  4033. *
  4034. * @ingroup input
  4035. */
  4036. GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
  4037. /*! @brief Sets the key callback.
  4038. *
  4039. * This function sets the key callback of the specified window, which is called
  4040. * when a key is pressed, repeated or released.
  4041. *
  4042. * The key functions deal with physical keys, with layout independent
  4043. * [key tokens](@ref keys) named after their values in the standard US keyboard
  4044. * layout. If you want to input text, use the
  4045. * [character callback](@ref glfwSetCharCallback) instead.
  4046. *
  4047. * When a window loses input focus, it will generate synthetic key release
  4048. * events for all pressed keys. You can tell these events from user-generated
  4049. * events by the fact that the synthetic ones are generated after the focus
  4050. * loss event has been processed, i.e. after the
  4051. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  4052. *
  4053. * The scancode of a key is specific to that platform or sometimes even to that
  4054. * machine. Scancodes are intended to allow users to bind keys that don't have
  4055. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  4056. * state is not saved and so it cannot be queried with @ref glfwGetKey.
  4057. *
  4058. * Sometimes GLFW needs to generate synthetic key events, in which case the
  4059. * scancode may be zero.
  4060. *
  4061. * @param[in] window The window whose callback to set.
  4062. * @param[in] cbfun The new key callback, or `NULL` to remove the currently
  4063. * set callback.
  4064. * @return The previously set callback, or `NULL` if no callback was set or the
  4065. * library had not been [initialized](@ref intro_init).
  4066. *
  4067. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4068. *
  4069. * @thread_safety This function must only be called from the main thread.
  4070. *
  4071. * @sa @ref input_key
  4072. *
  4073. * @since Added in version 1.0.
  4074. * @glfw3 Added window handle parameter and return value.
  4075. *
  4076. * @ingroup input
  4077. */
  4078. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
  4079. /*! @brief Sets the Unicode character callback.
  4080. *
  4081. * This function sets the character callback of the specified window, which is
  4082. * called when a Unicode character is input.
  4083. *
  4084. * The character callback is intended for Unicode text input. As it deals with
  4085. * characters, it is keyboard layout dependent, whereas the
  4086. * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
  4087. * to physical keys, as a key may produce zero, one or more characters. If you
  4088. * want to know whether a specific physical key was pressed or released, see
  4089. * the key callback instead.
  4090. *
  4091. * The character callback behaves as system text input normally does and will
  4092. * not be called if modifier keys are held down that would prevent normal text
  4093. * input on that platform, for example a Super (Command) key on macOS or Alt key
  4094. * on Windows. There is a
  4095. * [character with modifiers callback](@ref glfwSetCharModsCallback) that
  4096. * receives these events.
  4097. *
  4098. * @param[in] window The window whose callback to set.
  4099. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  4100. * callback.
  4101. * @return The previously set callback, or `NULL` if no callback was set or the
  4102. * library had not been [initialized](@ref intro_init).
  4103. *
  4104. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4105. *
  4106. * @thread_safety This function must only be called from the main thread.
  4107. *
  4108. * @sa @ref input_char
  4109. *
  4110. * @since Added in version 2.4.
  4111. * @glfw3 Added window handle parameter and return value.
  4112. *
  4113. * @ingroup input
  4114. */
  4115. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
  4116. /*! @brief Sets the Unicode character with modifiers callback.
  4117. *
  4118. * This function sets the character with modifiers callback of the specified
  4119. * window, which is called when a Unicode character is input regardless of what
  4120. * modifier keys are used.
  4121. *
  4122. * The character with modifiers callback is intended for implementing custom
  4123. * Unicode character input. For regular Unicode text input, see the
  4124. * [character callback](@ref glfwSetCharCallback). Like the character
  4125. * callback, the character with modifiers callback deals with characters and is
  4126. * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
  4127. * a key may produce zero, one or more characters. If you want to know whether
  4128. * a specific physical key was pressed or released, see the
  4129. * [key callback](@ref glfwSetKeyCallback) instead.
  4130. *
  4131. * @param[in] window The window whose callback to set.
  4132. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  4133. * callback.
  4134. * @return The previously set callback, or `NULL` if no callback was set or an
  4135. * [error](@ref error_handling) occurred.
  4136. *
  4137. * @deprecated Scheduled for removal in version 4.0.
  4138. *
  4139. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4140. *
  4141. * @thread_safety This function must only be called from the main thread.
  4142. *
  4143. * @sa @ref input_char
  4144. *
  4145. * @since Added in version 3.1.
  4146. *
  4147. * @ingroup input
  4148. */
  4149. GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);
  4150. /*! @brief Sets the mouse button callback.
  4151. *
  4152. * This function sets the mouse button callback of the specified window, which
  4153. * is called when a mouse button is pressed or released.
  4154. *
  4155. * When a window loses input focus, it will generate synthetic mouse button
  4156. * release events for all pressed mouse buttons. You can tell these events
  4157. * from user-generated events by the fact that the synthetic ones are generated
  4158. * after the focus loss event has been processed, i.e. after the
  4159. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  4160. *
  4161. * @param[in] window The window whose callback to set.
  4162. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  4163. * callback.
  4164. * @return The previously set callback, or `NULL` if no callback was set or the
  4165. * library had not been [initialized](@ref intro_init).
  4166. *
  4167. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4168. *
  4169. * @thread_safety This function must only be called from the main thread.
  4170. *
  4171. * @sa @ref input_mouse_button
  4172. *
  4173. * @since Added in version 1.0.
  4174. * @glfw3 Added window handle parameter and return value.
  4175. *
  4176. * @ingroup input
  4177. */
  4178. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
  4179. /*! @brief Sets the cursor position callback.
  4180. *
  4181. * This function sets the cursor position callback of the specified window,
  4182. * which is called when the cursor is moved. The callback is provided with the
  4183. * position, in screen coordinates, relative to the upper-left corner of the
  4184. * client area of the window.
  4185. *
  4186. * @param[in] window The window whose callback to set.
  4187. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  4188. * callback.
  4189. * @return The previously set callback, or `NULL` if no callback was set or the
  4190. * library had not been [initialized](@ref intro_init).
  4191. *
  4192. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4193. *
  4194. * @thread_safety This function must only be called from the main thread.
  4195. *
  4196. * @sa @ref cursor_pos
  4197. *
  4198. * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
  4199. *
  4200. * @ingroup input
  4201. */
  4202. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
  4203. /*! @brief Sets the cursor enter/exit callback.
  4204. *
  4205. * This function sets the cursor boundary crossing callback of the specified
  4206. * window, which is called when the cursor enters or leaves the client area of
  4207. * the window.
  4208. *
  4209. * @param[in] window The window whose callback to set.
  4210. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  4211. * callback.
  4212. * @return The previously set callback, or `NULL` if no callback was set or the
  4213. * library had not been [initialized](@ref intro_init).
  4214. *
  4215. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4216. *
  4217. * @thread_safety This function must only be called from the main thread.
  4218. *
  4219. * @sa @ref cursor_enter
  4220. *
  4221. * @since Added in version 3.0.
  4222. *
  4223. * @ingroup input
  4224. */
  4225. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
  4226. /*! @brief Sets the scroll callback.
  4227. *
  4228. * This function sets the scroll callback of the specified window, which is
  4229. * called when a scrolling device is used, such as a mouse wheel or scrolling
  4230. * area of a touchpad.
  4231. *
  4232. * The scroll callback receives all scrolling input, like that from a mouse
  4233. * wheel or a touchpad scrolling area.
  4234. *
  4235. * @param[in] window The window whose callback to set.
  4236. * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
  4237. * set callback.
  4238. * @return The previously set callback, or `NULL` if no callback was set or the
  4239. * library had not been [initialized](@ref intro_init).
  4240. *
  4241. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4242. *
  4243. * @thread_safety This function must only be called from the main thread.
  4244. *
  4245. * @sa @ref scrolling
  4246. *
  4247. * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
  4248. *
  4249. * @ingroup input
  4250. */
  4251. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
  4252. /*! @brief Sets the file drop callback.
  4253. *
  4254. * This function sets the file drop callback of the specified window, which is
  4255. * called when one or more dragged files are dropped on the window.
  4256. *
  4257. * Because the path array and its strings may have been generated specifically
  4258. * for that event, they are not guaranteed to be valid after the callback has
  4259. * returned. If you wish to use them after the callback returns, you need to
  4260. * make a deep copy.
  4261. *
  4262. * @param[in] window The window whose callback to set.
  4263. * @param[in] cbfun The new file drop callback, or `NULL` to remove the
  4264. * currently set callback.
  4265. * @return The previously set callback, or `NULL` if no callback was set or the
  4266. * library had not been [initialized](@ref intro_init).
  4267. *
  4268. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4269. *
  4270. * @remark @wayland File drop is currently unimplemented.
  4271. *
  4272. * @thread_safety This function must only be called from the main thread.
  4273. *
  4274. * @sa @ref path_drop
  4275. *
  4276. * @since Added in version 3.1.
  4277. *
  4278. * @ingroup input
  4279. */
  4280. GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);
  4281. /*! @brief Returns whether the specified joystick is present.
  4282. *
  4283. * This function returns whether the specified joystick is present.
  4284. *
  4285. * There is no need to call this function before other functions that accept
  4286. * a joystick ID, as they all check for presence before performing any other
  4287. * work.
  4288. *
  4289. * @param[in] jid The [joystick](@ref joysticks) to query.
  4290. * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
  4291. *
  4292. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4293. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4294. *
  4295. * @thread_safety This function must only be called from the main thread.
  4296. *
  4297. * @sa @ref joystick
  4298. *
  4299. * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
  4300. *
  4301. * @ingroup input
  4302. */
  4303. GLFWAPI int glfwJoystickPresent(int jid);
  4304. /*! @brief Returns the values of all axes of the specified joystick.
  4305. *
  4306. * This function returns the values of all axes of the specified joystick.
  4307. * Each element in the array is a value between -1.0 and 1.0.
  4308. *
  4309. * If the specified joystick is not present this function will return `NULL`
  4310. * but will not generate an error. This can be used instead of first calling
  4311. * @ref glfwJoystickPresent.
  4312. *
  4313. * @param[in] jid The [joystick](@ref joysticks) to query.
  4314. * @param[out] count Where to store the number of axis values in the returned
  4315. * array. This is set to zero if the joystick is not present or an error
  4316. * occurred.
  4317. * @return An array of axis values, or `NULL` if the joystick is not present or
  4318. * an [error](@ref error_handling) occurred.
  4319. *
  4320. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4321. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4322. *
  4323. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4324. * should not free it yourself. It is valid until the specified joystick is
  4325. * disconnected or the library is terminated.
  4326. *
  4327. * @thread_safety This function must only be called from the main thread.
  4328. *
  4329. * @sa @ref joystick_axis
  4330. *
  4331. * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
  4332. *
  4333. * @ingroup input
  4334. */
  4335. GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
  4336. /*! @brief Returns the state of all buttons of the specified joystick.
  4337. *
  4338. * This function returns the state of all buttons of the specified joystick.
  4339. * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
  4340. *
  4341. * For backward compatibility with earlier versions that did not have @ref
  4342. * glfwGetJoystickHats, the button array also includes all hats, each
  4343. * represented as four buttons. The hats are in the same order as returned by
  4344. * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
  4345. * _left_. To disable these extra buttons, set the @ref
  4346. * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
  4347. *
  4348. * If the specified joystick is not present this function will return `NULL`
  4349. * but will not generate an error. This can be used instead of first calling
  4350. * @ref glfwJoystickPresent.
  4351. *
  4352. * @param[in] jid The [joystick](@ref joysticks) to query.
  4353. * @param[out] count Where to store the number of button states in the returned
  4354. * array. This is set to zero if the joystick is not present or an error
  4355. * occurred.
  4356. * @return An array of button states, or `NULL` if the joystick is not present
  4357. * or an [error](@ref error_handling) occurred.
  4358. *
  4359. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4360. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4361. *
  4362. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4363. * should not free it yourself. It is valid until the specified joystick is
  4364. * disconnected or the library is terminated.
  4365. *
  4366. * @thread_safety This function must only be called from the main thread.
  4367. *
  4368. * @sa @ref joystick_button
  4369. *
  4370. * @since Added in version 2.2.
  4371. * @glfw3 Changed to return a dynamic array.
  4372. *
  4373. * @ingroup input
  4374. */
  4375. GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
  4376. /*! @brief Returns the state of all hats of the specified joystick.
  4377. *
  4378. * This function returns the state of all hats of the specified joystick.
  4379. * Each element in the array is one of the following values:
  4380. *
  4381. * Name | Value
  4382. * --------------------- | --------------------------------
  4383. * `GLFW_HAT_CENTERED` | 0
  4384. * `GLFW_HAT_UP` | 1
  4385. * `GLFW_HAT_RIGHT` | 2
  4386. * `GLFW_HAT_DOWN` | 4
  4387. * `GLFW_HAT_LEFT` | 8
  4388. * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
  4389. * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
  4390. * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
  4391. * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
  4392. *
  4393. * The diagonal directions are bitwise combinations of the primary (up, right,
  4394. * down and left) directions and you can test for these individually by ANDing
  4395. * it with the corresponding direction.
  4396. *
  4397. * @code
  4398. * if (hats[2] & GLFW_HAT_RIGHT)
  4399. * {
  4400. * // State of hat 2 could be right-up, right or right-down
  4401. * }
  4402. * @endcode
  4403. *
  4404. * If the specified joystick is not present this function will return `NULL`
  4405. * but will not generate an error. This can be used instead of first calling
  4406. * @ref glfwJoystickPresent.
  4407. *
  4408. * @param[in] jid The [joystick](@ref joysticks) to query.
  4409. * @param[out] count Where to store the number of hat states in the returned
  4410. * array. This is set to zero if the joystick is not present or an error
  4411. * occurred.
  4412. * @return An array of hat states, or `NULL` if the joystick is not present
  4413. * or an [error](@ref error_handling) occurred.
  4414. *
  4415. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4416. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4417. *
  4418. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4419. * should not free it yourself. It is valid until the specified joystick is
  4420. * disconnected, this function is called again for that joystick or the library
  4421. * is terminated.
  4422. *
  4423. * @thread_safety This function must only be called from the main thread.
  4424. *
  4425. * @sa @ref joystick_hat
  4426. *
  4427. * @since Added in version 3.3.
  4428. *
  4429. * @ingroup input
  4430. */
  4431. GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
  4432. /*! @brief Returns the name of the specified joystick.
  4433. *
  4434. * This function returns the name, encoded as UTF-8, of the specified joystick.
  4435. * The returned string is allocated and freed by GLFW. You should not free it
  4436. * yourself.
  4437. *
  4438. * If the specified joystick is not present this function will return `NULL`
  4439. * but will not generate an error. This can be used instead of first calling
  4440. * @ref glfwJoystickPresent.
  4441. *
  4442. * @param[in] jid The [joystick](@ref joysticks) to query.
  4443. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  4444. * is not present or an [error](@ref error_handling) occurred.
  4445. *
  4446. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4447. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4448. *
  4449. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4450. * should not free it yourself. It is valid until the specified joystick is
  4451. * disconnected or the library is terminated.
  4452. *
  4453. * @thread_safety This function must only be called from the main thread.
  4454. *
  4455. * @sa @ref joystick_name
  4456. *
  4457. * @since Added in version 3.0.
  4458. *
  4459. * @ingroup input
  4460. */
  4461. GLFWAPI const char* glfwGetJoystickName(int jid);
  4462. /*! @brief Returns the SDL comaptible GUID of the specified joystick.
  4463. *
  4464. * This function returns the SDL compatible GUID, as a UTF-8 encoded
  4465. * hexadecimal string, of the specified joystick. The returned string is
  4466. * allocated and freed by GLFW. You should not free it yourself.
  4467. *
  4468. * The GUID is what connects a joystick to a gamepad mapping. A connected
  4469. * joystick will always have a GUID even if there is no gamepad mapping
  4470. * assigned to it.
  4471. *
  4472. * If the specified joystick is not present this function will return `NULL`
  4473. * but will not generate an error. This can be used instead of first calling
  4474. * @ref glfwJoystickPresent.
  4475. *
  4476. * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
  4477. * uniquely identify the make and model of a joystick but does not identify
  4478. * a specific unit, e.g. all wired Xbox 360 controllers will have the same
  4479. * GUID on that platform. The GUID for a unit may vary between platforms
  4480. * depending on what hardware information the platform specific APIs provide.
  4481. *
  4482. * @param[in] jid The [joystick](@ref joysticks) to query.
  4483. * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
  4484. * is not present or an [error](@ref error_handling) occurred.
  4485. *
  4486. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4487. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4488. *
  4489. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4490. * should not free it yourself. It is valid until the specified joystick is
  4491. * disconnected or the library is terminated.
  4492. *
  4493. * @thread_safety This function must only be called from the main thread.
  4494. *
  4495. * @sa @ref gamepad
  4496. *
  4497. * @since Added in version 3.3.
  4498. *
  4499. * @ingroup input
  4500. */
  4501. GLFWAPI const char* glfwGetJoystickGUID(int jid);
  4502. /*! @brief Sets the user pointer of the specified joystick.
  4503. *
  4504. * This function sets the user-defined pointer of the specified joystick. The
  4505. * current value is retained until the joystick is disconnected. The initial
  4506. * value is `NULL`.
  4507. *
  4508. * This function may be called from the joystick callback, even for a joystick
  4509. * that is being disconnected.
  4510. *
  4511. * @param[in] jid The joystick whose pointer to set.
  4512. * @param[in] pointer The new value.
  4513. *
  4514. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4515. *
  4516. * @thread_safety This function may be called from any thread. Access is not
  4517. * synchronized.
  4518. *
  4519. * @sa @ref joystick_userptr
  4520. * @sa @ref glfwGetJoystickUserPointer
  4521. *
  4522. * @since Added in version 3.3.
  4523. *
  4524. * @ingroup input
  4525. */
  4526. GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
  4527. /*! @brief Returns the user pointer of the specified joystick.
  4528. *
  4529. * This function returns the current value of the user-defined pointer of the
  4530. * specified joystick. The initial value is `NULL`.
  4531. *
  4532. * This function may be called from the joystick callback, even for a joystick
  4533. * that is being disconnected.
  4534. *
  4535. * @param[in] jid The joystick whose pointer to return.
  4536. *
  4537. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4538. *
  4539. * @thread_safety This function may be called from any thread. Access is not
  4540. * synchronized.
  4541. *
  4542. * @sa @ref joystick_userptr
  4543. * @sa @ref glfwSetJoystickUserPointer
  4544. *
  4545. * @since Added in version 3.3.
  4546. *
  4547. * @ingroup input
  4548. */
  4549. GLFWAPI void* glfwGetJoystickUserPointer(int jid);
  4550. /*! @brief Returns whether the specified joystick has a gamepad mapping.
  4551. *
  4552. * This function returns whether the specified joystick is both present and has
  4553. * a gamepad mapping.
  4554. *
  4555. * If the specified joystick is present but does not have a gamepad mapping
  4556. * this function will return `GLFW_FALSE` but will not generate an error. Call
  4557. * @ref glfwJoystickPresent to check if a joystick is present regardless of
  4558. * whether it has a mapping.
  4559. *
  4560. * @param[in] jid The [joystick](@ref joysticks) to query.
  4561. * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
  4562. * or `GLFW_FALSE` otherwise.
  4563. *
  4564. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4565. * GLFW_INVALID_ENUM.
  4566. *
  4567. * @thread_safety This function must only be called from the main thread.
  4568. *
  4569. * @sa @ref gamepad
  4570. * @sa @ref glfwGetGamepadState
  4571. *
  4572. * @since Added in version 3.3.
  4573. *
  4574. * @ingroup input
  4575. */
  4576. GLFWAPI int glfwJoystickIsGamepad(int jid);
  4577. /*! @brief Sets the joystick configuration callback.
  4578. *
  4579. * This function sets the joystick configuration callback, or removes the
  4580. * currently set callback. This is called when a joystick is connected to or
  4581. * disconnected from the system.
  4582. *
  4583. * For joystick connection and disconnection events to be delivered on all
  4584. * platforms, you need to call one of the [event processing](@ref events)
  4585. * functions. Joystick disconnection may also be detected and the callback
  4586. * called by joystick functions. The function will then return whatever it
  4587. * returns if the joystick is not present.
  4588. *
  4589. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  4590. * callback.
  4591. * @return The previously set callback, or `NULL` if no callback was set or the
  4592. * library had not been [initialized](@ref intro_init).
  4593. *
  4594. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4595. *
  4596. * @thread_safety This function must only be called from the main thread.
  4597. *
  4598. * @sa @ref joystick_event
  4599. *
  4600. * @since Added in version 3.2.
  4601. *
  4602. * @ingroup input
  4603. */
  4604. GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun);
  4605. /*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
  4606. *
  4607. * This function parses the specified ASCII encoded string and updates the
  4608. * internal list with any gamepad mappings it finds. This string may
  4609. * contain either a single gamepad mapping or many mappings separated by
  4610. * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
  4611. * source file including empty lines and comments.
  4612. *
  4613. * See @ref gamepad_mapping for a description of the format.
  4614. *
  4615. * If there is already a gamepad mapping for a given GUID in the internal list,
  4616. * it will be replaced by the one passed to this function. If the library is
  4617. * terminated and re-initialized the internal list will revert to the built-in
  4618. * default.
  4619. *
  4620. * @param[in] string The string containing the gamepad mappings.
  4621. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  4622. * [error](@ref error_handling) occurred.
  4623. *
  4624. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4625. * GLFW_INVALID_VALUE.
  4626. *
  4627. * @thread_safety This function must only be called from the main thread.
  4628. *
  4629. * @sa @ref gamepad
  4630. * @sa @ref glfwJoystickIsGamepad
  4631. * @sa @ref glfwGetGamepadName
  4632. *
  4633. * @since Added in version 3.3.
  4634. *
  4635. * @ingroup input
  4636. */
  4637. GLFWAPI int glfwUpdateGamepadMappings(const char* string);
  4638. /*! @brief Returns the human-readable gamepad name for the specified joystick.
  4639. *
  4640. * This function returns the human-readable name of the gamepad from the
  4641. * gamepad mapping assigned to the specified joystick.
  4642. *
  4643. * If the specified joystick is not present or does not have a gamepad mapping
  4644. * this function will return `NULL` but will not generate an error. Call
  4645. * @ref glfwJoystickPresent to check whether it is present regardless of
  4646. * whether it has a mapping.
  4647. *
  4648. * @param[in] jid The [joystick](@ref joysticks) to query.
  4649. * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
  4650. * joystick is not present, does not have a mapping or an
  4651. * [error](@ref error_handling) occurred.
  4652. *
  4653. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4654. * should not free it yourself. It is valid until the specified joystick is
  4655. * disconnected, the gamepad mappings are updated or the library is terminated.
  4656. *
  4657. * @thread_safety This function must only be called from the main thread.
  4658. *
  4659. * @sa @ref gamepad
  4660. * @sa @ref glfwJoystickIsGamepad
  4661. *
  4662. * @since Added in version 3.3.
  4663. *
  4664. * @ingroup input
  4665. */
  4666. GLFWAPI const char* glfwGetGamepadName(int jid);
  4667. /*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
  4668. *
  4669. * This function retrives the state of the specified joystick remapped to
  4670. * an Xbox-like gamepad.
  4671. *
  4672. * If the specified joystick is not present or does not have a gamepad mapping
  4673. * this function will return `GLFW_FALSE` but will not generate an error. Call
  4674. * @ref glfwJoystickPresent to check whether it is present regardless of
  4675. * whether it has a mapping.
  4676. *
  4677. * The Guide button may not be available for input as it is often hooked by the
  4678. * system or the Steam client.
  4679. *
  4680. * Not all devices have all the buttons or axes provided by @ref
  4681. * GLFWgamepadstate. Unavailable buttons and axes will always report
  4682. * `GLFW_RELEASE` and 0.0 respectively.
  4683. *
  4684. * @param[in] jid The [joystick](@ref joysticks) to query.
  4685. * @param[out] state The gamepad input state of the joystick.
  4686. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
  4687. * connected, it has no gamepad mapping or an [error](@ref error_handling)
  4688. * occurred.
  4689. *
  4690. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4691. * GLFW_INVALID_ENUM.
  4692. *
  4693. * @sa @ref gamepad
  4694. * @sa @ref glfwUpdateGamepadMappings
  4695. * @sa @ref glfwJoystickIsGamepad
  4696. *
  4697. * @since Added in version 3.3.
  4698. *
  4699. * @ingroup input
  4700. */
  4701. GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
  4702. /*! @brief Sets the clipboard to the specified string.
  4703. *
  4704. * This function sets the system clipboard to the specified, UTF-8 encoded
  4705. * string.
  4706. *
  4707. * @param[in] window Deprecated. Any valid window or `NULL`.
  4708. * @param[in] string A UTF-8 encoded string.
  4709. *
  4710. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4711. * GLFW_PLATFORM_ERROR.
  4712. *
  4713. * @remark @wayland Clipboard is currently unimplemented.
  4714. *
  4715. * @pointer_lifetime The specified string is copied before this function
  4716. * returns.
  4717. *
  4718. * @thread_safety This function must only be called from the main thread.
  4719. *
  4720. * @sa @ref clipboard
  4721. * @sa @ref glfwGetClipboardString
  4722. *
  4723. * @since Added in version 3.0.
  4724. *
  4725. * @ingroup input
  4726. */
  4727. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  4728. /*! @brief Returns the contents of the clipboard as a string.
  4729. *
  4730. * This function returns the contents of the system clipboard, if it contains
  4731. * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
  4732. * if its contents cannot be converted, `NULL` is returned and a @ref
  4733. * GLFW_FORMAT_UNAVAILABLE error is generated.
  4734. *
  4735. * @param[in] window Deprecated. Any valid window or `NULL`.
  4736. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  4737. * if an [error](@ref error_handling) occurred.
  4738. *
  4739. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4740. * GLFW_PLATFORM_ERROR.
  4741. *
  4742. * @remark @wayland Clipboard is currently unimplemented.
  4743. *
  4744. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4745. * should not free it yourself. It is valid until the next call to @ref
  4746. * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
  4747. * is terminated.
  4748. *
  4749. * @thread_safety This function must only be called from the main thread.
  4750. *
  4751. * @sa @ref clipboard
  4752. * @sa @ref glfwSetClipboardString
  4753. *
  4754. * @since Added in version 3.0.
  4755. *
  4756. * @ingroup input
  4757. */
  4758. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  4759. /*! @brief Returns the value of the GLFW timer.
  4760. *
  4761. * This function returns the value of the GLFW timer. Unless the timer has
  4762. * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
  4763. * was initialized.
  4764. *
  4765. * The resolution of the timer is system dependent, but is usually on the order
  4766. * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
  4767. * time source on each supported platform.
  4768. *
  4769. * @return The current value, in seconds, or zero if an
  4770. * [error](@ref error_handling) occurred.
  4771. *
  4772. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4773. *
  4774. * @thread_safety This function may be called from any thread. Reading and
  4775. * writing of the internal timer offset is not atomic, so it needs to be
  4776. * externally synchronized with calls to @ref glfwSetTime.
  4777. *
  4778. * @sa @ref time
  4779. *
  4780. * @since Added in version 1.0.
  4781. *
  4782. * @ingroup input
  4783. */
  4784. GLFWAPI double glfwGetTime(void);
  4785. /*! @brief Sets the GLFW timer.
  4786. *
  4787. * This function sets the value of the GLFW timer. It then continues to count
  4788. * up from that value. The value must be a positive finite number less than
  4789. * or equal to 18446744073.0, which is approximately 584.5 years.
  4790. *
  4791. * @param[in] time The new value, in seconds.
  4792. *
  4793. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4794. * GLFW_INVALID_VALUE.
  4795. *
  4796. * @remark The upper limit of the timer is calculated as
  4797. * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
  4798. * storing nanoseconds in 64 bits. The limit may be increased in the future.
  4799. *
  4800. * @thread_safety This function may be called from any thread. Reading and
  4801. * writing of the internal timer offset is not atomic, so it needs to be
  4802. * externally synchronized with calls to @ref glfwGetTime.
  4803. *
  4804. * @sa @ref time
  4805. *
  4806. * @since Added in version 2.2.
  4807. *
  4808. * @ingroup input
  4809. */
  4810. GLFWAPI void glfwSetTime(double time);
  4811. /*! @brief Returns the current value of the raw timer.
  4812. *
  4813. * This function returns the current value of the raw timer, measured in
  4814. * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
  4815. * glfwGetTimerFrequency.
  4816. *
  4817. * @return The value of the timer, or zero if an
  4818. * [error](@ref error_handling) occurred.
  4819. *
  4820. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4821. *
  4822. * @thread_safety This function may be called from any thread.
  4823. *
  4824. * @sa @ref time
  4825. * @sa @ref glfwGetTimerFrequency
  4826. *
  4827. * @since Added in version 3.2.
  4828. *
  4829. * @ingroup input
  4830. */
  4831. GLFWAPI uint64_t glfwGetTimerValue(void);
  4832. /*! @brief Returns the frequency, in Hz, of the raw timer.
  4833. *
  4834. * This function returns the frequency, in Hz, of the raw timer.
  4835. *
  4836. * @return The frequency of the timer, in Hz, or zero if an
  4837. * [error](@ref error_handling) occurred.
  4838. *
  4839. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4840. *
  4841. * @thread_safety This function may be called from any thread.
  4842. *
  4843. * @sa @ref time
  4844. * @sa @ref glfwGetTimerValue
  4845. *
  4846. * @since Added in version 3.2.
  4847. *
  4848. * @ingroup input
  4849. */
  4850. GLFWAPI uint64_t glfwGetTimerFrequency(void);
  4851. /*! @brief Makes the context of the specified window current for the calling
  4852. * thread.
  4853. *
  4854. * This function makes the OpenGL or OpenGL ES context of the specified window
  4855. * current on the calling thread. A context must only be made current on
  4856. * a single thread at a time and each thread can have only a single current
  4857. * context at a time.
  4858. *
  4859. * When moving a context between threads, you must make it non-current on the
  4860. * old thread before making it current on the new one.
  4861. *
  4862. * By default, making a context non-current implicitly forces a pipeline flush.
  4863. * On machines that support `GL_KHR_context_flush_control`, you can control
  4864. * whether a context performs this flush by setting the
  4865. * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
  4866. * hint.
  4867. *
  4868. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  4869. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  4870. * error.
  4871. *
  4872. * @param[in] window The window whose context to make current, or `NULL` to
  4873. * detach the current context.
  4874. *
  4875. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4876. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  4877. *
  4878. * @thread_safety This function may be called from any thread.
  4879. *
  4880. * @sa @ref context_current
  4881. * @sa @ref glfwGetCurrentContext
  4882. *
  4883. * @since Added in version 3.0.
  4884. *
  4885. * @ingroup context
  4886. */
  4887. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  4888. /*! @brief Returns the window whose context is current on the calling thread.
  4889. *
  4890. * This function returns the window whose OpenGL or OpenGL ES context is
  4891. * current on the calling thread.
  4892. *
  4893. * @return The window whose context is current, or `NULL` if no window's
  4894. * context is current.
  4895. *
  4896. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4897. *
  4898. * @thread_safety This function may be called from any thread.
  4899. *
  4900. * @sa @ref context_current
  4901. * @sa @ref glfwMakeContextCurrent
  4902. *
  4903. * @since Added in version 3.0.
  4904. *
  4905. * @ingroup context
  4906. */
  4907. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  4908. /*! @brief Swaps the front and back buffers of the specified window.
  4909. *
  4910. * This function swaps the front and back buffers of the specified window when
  4911. * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
  4912. * zero, the GPU driver waits the specified number of screen updates before
  4913. * swapping the buffers.
  4914. *
  4915. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  4916. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  4917. * error.
  4918. *
  4919. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  4920. * see `vkQueuePresentKHR` instead.
  4921. *
  4922. * @param[in] window The window whose buffers to swap.
  4923. *
  4924. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4925. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  4926. *
  4927. * @remark __EGL:__ The context of the specified window must be current on the
  4928. * calling thread.
  4929. *
  4930. * @thread_safety This function may be called from any thread.
  4931. *
  4932. * @sa @ref buffer_swap
  4933. * @sa @ref glfwSwapInterval
  4934. *
  4935. * @since Added in version 1.0.
  4936. * @glfw3 Added window handle parameter.
  4937. *
  4938. * @ingroup window
  4939. */
  4940. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  4941. /*! @brief Sets the swap interval for the current context.
  4942. *
  4943. * This function sets the swap interval for the current OpenGL or OpenGL ES
  4944. * context, i.e. the number of screen updates to wait from the time @ref
  4945. * glfwSwapBuffers was called before swapping the buffers and returning. This
  4946. * is sometimes called _vertical synchronization_, _vertical retrace
  4947. * synchronization_ or just _vsync_.
  4948. *
  4949. * A context that supports either of the `WGL_EXT_swap_control_tear` and
  4950. * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
  4951. * intervals, which allows the driver to swap immediately even if a frame
  4952. * arrives a little bit late. You can check for these extensions with @ref
  4953. * glfwExtensionSupported.
  4954. *
  4955. * A context must be current on the calling thread. Calling this function
  4956. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  4957. *
  4958. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  4959. * see the present mode of your swapchain instead.
  4960. *
  4961. * @param[in] interval The minimum number of screen updates to wait for
  4962. * until the buffers are swapped by @ref glfwSwapBuffers.
  4963. *
  4964. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4965. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  4966. *
  4967. * @remark This function is not called during context creation, leaving the
  4968. * swap interval set to whatever is the default on that platform. This is done
  4969. * because some swap interval extensions used by GLFW do not allow the swap
  4970. * interval to be reset to zero once it has been set to a non-zero value.
  4971. *
  4972. * @remark Some GPU drivers do not honor the requested swap interval, either
  4973. * because of a user setting that overrides the application's request or due to
  4974. * bugs in the driver.
  4975. *
  4976. * @thread_safety This function may be called from any thread.
  4977. *
  4978. * @sa @ref buffer_swap
  4979. * @sa @ref glfwSwapBuffers
  4980. *
  4981. * @since Added in version 1.0.
  4982. *
  4983. * @ingroup context
  4984. */
  4985. GLFWAPI void glfwSwapInterval(int interval);
  4986. /*! @brief Returns whether the specified extension is available.
  4987. *
  4988. * This function returns whether the specified
  4989. * [API extension](@ref context_glext) is supported by the current OpenGL or
  4990. * OpenGL ES context. It searches both for client API extension and context
  4991. * creation API extensions.
  4992. *
  4993. * A context must be current on the calling thread. Calling this function
  4994. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  4995. *
  4996. * As this functions retrieves and searches one or more extension strings each
  4997. * call, it is recommended that you cache its results if it is going to be used
  4998. * frequently. The extension strings will not change during the lifetime of
  4999. * a context, so there is no danger in doing this.
  5000. *
  5001. * This function does not apply to Vulkan. If you are using Vulkan, see @ref
  5002. * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
  5003. * and `vkEnumerateDeviceExtensionProperties` instead.
  5004. *
  5005. * @param[in] extension The ASCII encoded name of the extension.
  5006. * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
  5007. * otherwise.
  5008. *
  5009. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5010. * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
  5011. * GLFW_PLATFORM_ERROR.
  5012. *
  5013. * @thread_safety This function may be called from any thread.
  5014. *
  5015. * @sa @ref context_glext
  5016. * @sa @ref glfwGetProcAddress
  5017. *
  5018. * @since Added in version 1.0.
  5019. *
  5020. * @ingroup context
  5021. */
  5022. GLFWAPI int glfwExtensionSupported(const char* extension);
  5023. /*! @brief Returns the address of the specified function for the current
  5024. * context.
  5025. *
  5026. * This function returns the address of the specified OpenGL or OpenGL ES
  5027. * [core or extension function](@ref context_glext), if it is supported
  5028. * by the current context.
  5029. *
  5030. * A context must be current on the calling thread. Calling this function
  5031. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5032. *
  5033. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5034. * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
  5035. * `vkGetDeviceProcAddr` instead.
  5036. *
  5037. * @param[in] procname The ASCII encoded name of the function.
  5038. * @return The address of the function, or `NULL` if an
  5039. * [error](@ref error_handling) occurred.
  5040. *
  5041. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5042. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5043. *
  5044. * @remark The address of a given function is not guaranteed to be the same
  5045. * between contexts.
  5046. *
  5047. * @remark This function may return a non-`NULL` address despite the
  5048. * associated version or extension not being available. Always check the
  5049. * context version or extension string first.
  5050. *
  5051. * @pointer_lifetime The returned function pointer is valid until the context
  5052. * is destroyed or the library is terminated.
  5053. *
  5054. * @thread_safety This function may be called from any thread.
  5055. *
  5056. * @sa @ref context_glext
  5057. * @sa @ref glfwExtensionSupported
  5058. *
  5059. * @since Added in version 1.0.
  5060. *
  5061. * @ingroup context
  5062. */
  5063. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  5064. /*! @brief Returns whether the Vulkan loader and an ICD have been found.
  5065. *
  5066. * This function returns whether the Vulkan loader and any minimally functional
  5067. * ICD have been found.
  5068. *
  5069. * The availability of a Vulkan loader and even an ICD does not by itself
  5070. * guarantee that surface creation or even instance creation is possible.
  5071. * For example, on Fermi systems Nvidia will install an ICD that provides no
  5072. * actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
  5073. * whether the extensions necessary for Vulkan surface creation are available
  5074. * and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
  5075. * family of a physical device supports image presentation.
  5076. *
  5077. * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
  5078. * otherwise.
  5079. *
  5080. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5081. *
  5082. * @thread_safety This function may be called from any thread.
  5083. *
  5084. * @sa @ref vulkan_support
  5085. *
  5086. * @since Added in version 3.2.
  5087. *
  5088. * @ingroup vulkan
  5089. */
  5090. GLFWAPI int glfwVulkanSupported(void);
  5091. /*! @brief Returns the Vulkan instance extensions required by GLFW.
  5092. *
  5093. * This function returns an array of names of Vulkan instance extensions required
  5094. * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
  5095. * list will always contains `VK_KHR_surface`, so if you don't require any
  5096. * additional extensions you can pass this list directly to the
  5097. * `VkInstanceCreateInfo` struct.
  5098. *
  5099. * If Vulkan is not available on the machine, this function returns `NULL` and
  5100. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5101. * to check whether Vulkan is at least minimally available.
  5102. *
  5103. * If Vulkan is available but no set of extensions allowing window surface
  5104. * creation was found, this function returns `NULL`. You may still use Vulkan
  5105. * for off-screen rendering and compute work.
  5106. *
  5107. * @param[out] count Where to store the number of extensions in the returned
  5108. * array. This is set to zero if an error occurred.
  5109. * @return An array of ASCII encoded extension names, or `NULL` if an
  5110. * [error](@ref error_handling) occurred.
  5111. *
  5112. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5113. * GLFW_API_UNAVAILABLE.
  5114. *
  5115. * @remark Additional extensions may be required by future versions of GLFW.
  5116. * You should check if any extensions you wish to enable are already in the
  5117. * returned array, as it is an error to specify an extension more than once in
  5118. * the `VkInstanceCreateInfo` struct.
  5119. *
  5120. * @remark @macos This function currently only supports the
  5121. * `VK_MVK_macos_surface` extension from MoltenVK.
  5122. *
  5123. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  5124. * should not free it yourself. It is guaranteed to be valid only until the
  5125. * library is terminated.
  5126. *
  5127. * @thread_safety This function may be called from any thread.
  5128. *
  5129. * @sa @ref vulkan_ext
  5130. * @sa @ref glfwCreateWindowSurface
  5131. *
  5132. * @since Added in version 3.2.
  5133. *
  5134. * @ingroup vulkan
  5135. */
  5136. GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
  5137. #if defined(VK_VERSION_1_0)
  5138. /*! @brief Returns the address of the specified Vulkan instance function.
  5139. *
  5140. * This function returns the address of the specified Vulkan core or extension
  5141. * function for the specified instance. If instance is set to `NULL` it can
  5142. * return any function exported from the Vulkan loader, including at least the
  5143. * following functions:
  5144. *
  5145. * - `vkEnumerateInstanceExtensionProperties`
  5146. * - `vkEnumerateInstanceLayerProperties`
  5147. * - `vkCreateInstance`
  5148. * - `vkGetInstanceProcAddr`
  5149. *
  5150. * If Vulkan is not available on the machine, this function returns `NULL` and
  5151. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5152. * to check whether Vulkan is at least minimally available.
  5153. *
  5154. * This function is equivalent to calling `vkGetInstanceProcAddr` with
  5155. * a platform-specific query of the Vulkan loader as a fallback.
  5156. *
  5157. * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
  5158. * functions related to instance creation.
  5159. * @param[in] procname The ASCII encoded name of the function.
  5160. * @return The address of the function, or `NULL` if an
  5161. * [error](@ref error_handling) occurred.
  5162. *
  5163. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5164. * GLFW_API_UNAVAILABLE.
  5165. *
  5166. * @pointer_lifetime The returned function pointer is valid until the library
  5167. * is terminated.
  5168. *
  5169. * @thread_safety This function may be called from any thread.
  5170. *
  5171. * @sa @ref vulkan_proc
  5172. *
  5173. * @since Added in version 3.2.
  5174. *
  5175. * @ingroup vulkan
  5176. */
  5177. GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
  5178. /*! @brief Returns whether the specified queue family can present images.
  5179. *
  5180. * This function returns whether the specified queue family of the specified
  5181. * physical device supports presentation to the platform GLFW was built for.
  5182. *
  5183. * If Vulkan or the required window surface creation instance extensions are
  5184. * not available on the machine, or if the specified instance was not created
  5185. * with the required extensions, this function returns `GLFW_FALSE` and
  5186. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5187. * to check whether Vulkan is at least minimally available and @ref
  5188. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  5189. * required.
  5190. *
  5191. * @param[in] instance The instance that the physical device belongs to.
  5192. * @param[in] device The physical device that the queue family belongs to.
  5193. * @param[in] queuefamily The index of the queue family to query.
  5194. * @return `GLFW_TRUE` if the queue family supports presentation, or
  5195. * `GLFW_FALSE` otherwise.
  5196. *
  5197. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5198. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  5199. *
  5200. * @remark @macos This function currently always returns `GLFW_TRUE`, as the
  5201. * `VK_MVK_macos_surface` extension does not provide
  5202. * a `vkGetPhysicalDevice*PresentationSupport` type function.
  5203. *
  5204. * @thread_safety This function may be called from any thread. For
  5205. * synchronization details of Vulkan objects, see the Vulkan specification.
  5206. *
  5207. * @sa @ref vulkan_present
  5208. *
  5209. * @since Added in version 3.2.
  5210. *
  5211. * @ingroup vulkan
  5212. */
  5213. GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
  5214. /*! @brief Creates a Vulkan surface for the specified window.
  5215. *
  5216. * This function creates a Vulkan surface for the specified window.
  5217. *
  5218. * If the Vulkan loader or at least one minimally functional ICD were not found,
  5219. * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
  5220. * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
  5221. * Vulkan is at least minimally available.
  5222. *
  5223. * If the required window surface creation instance extensions are not
  5224. * available or if the specified instance was not created with these extensions
  5225. * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
  5226. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
  5227. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  5228. * required.
  5229. *
  5230. * The window surface cannot be shared with another API so the window must
  5231. * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
  5232. * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
  5233. * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
  5234. *
  5235. * The window surface must be destroyed before the specified Vulkan instance.
  5236. * It is the responsibility of the caller to destroy the window surface. GLFW
  5237. * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
  5238. * surface.
  5239. *
  5240. * @param[in] instance The Vulkan instance to create the surface in.
  5241. * @param[in] window The window to create the surface for.
  5242. * @param[in] allocator The allocator to use, or `NULL` to use the default
  5243. * allocator.
  5244. * @param[out] surface Where to store the handle of the surface. This is set
  5245. * to `VK_NULL_HANDLE` if an error occurred.
  5246. * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
  5247. * [error](@ref error_handling) occurred.
  5248. *
  5249. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5250. * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
  5251. *
  5252. * @remark If an error occurs before the creation call is made, GLFW returns
  5253. * the Vulkan error code most appropriate for the error. Appropriate use of
  5254. * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
  5255. * eliminate almost all occurrences of these errors.
  5256. *
  5257. * @remark @macos This function currently only supports the
  5258. * `VK_MVK_macos_surface` extension from MoltenVK.
  5259. *
  5260. * @remark @macos This function creates and sets a `CAMetalLayer` instance for
  5261. * the window content view, which is required for MoltenVK to function.
  5262. *
  5263. * @thread_safety This function may be called from any thread. For
  5264. * synchronization details of Vulkan objects, see the Vulkan specification.
  5265. *
  5266. * @sa @ref vulkan_surface
  5267. * @sa @ref glfwGetRequiredInstanceExtensions
  5268. *
  5269. * @since Added in version 3.2.
  5270. *
  5271. * @ingroup vulkan
  5272. */
  5273. GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
  5274. #endif /*VK_VERSION_1_0*/
  5275. /*************************************************************************
  5276. * Global definition cleanup
  5277. *************************************************************************/
  5278. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  5279. #ifdef GLFW_WINGDIAPI_DEFINED
  5280. #undef WINGDIAPI
  5281. #undef GLFW_WINGDIAPI_DEFINED
  5282. #endif
  5283. #ifdef GLFW_CALLBACK_DEFINED
  5284. #undef CALLBACK
  5285. #undef GLFW_CALLBACK_DEFINED
  5286. #endif
  5287. /* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
  5288. * defined by some gl.h variants (OpenBSD) so define it after if needed.
  5289. */
  5290. #ifndef GLAPIENTRY
  5291. #define GLAPIENTRY APIENTRY
  5292. #endif
  5293. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  5294. #ifdef __cplusplus
  5295. }
  5296. #endif
  5297. #endif /* _glfw3_h_ */