glfw3.h 207 KB

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