glfw3.h 207 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817
  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. typedef struct GLFWDBUSNotificationData {
  1211. const char *app_name, *icon, *summary, *body, *category, **actions; size_t num_actions;
  1212. int32_t timeout; uint8_t urgency; uint32_t replaces; int muted;
  1213. } GLFWDBUSNotificationData;
  1214. /*! @brief The function pointer type for error callbacks.
  1215. *
  1216. * This is the function pointer type for error callbacks. An error callback
  1217. * function has the following signature:
  1218. * @code
  1219. * void callback_name(int error_code, const char* description)
  1220. * @endcode
  1221. *
  1222. * @param[in] error_code An [error code](@ref errors). Future releases may add
  1223. * more error codes.
  1224. * @param[in] description A UTF-8 encoded string describing the error.
  1225. *
  1226. * @pointer_lifetime The error description string is valid until the callback
  1227. * function returns.
  1228. *
  1229. * @sa @ref error_handling
  1230. * @sa @ref glfwSetErrorCallback
  1231. *
  1232. * @since Added in version 3.0.
  1233. *
  1234. * @ingroup init
  1235. */
  1236. typedef void (* GLFWerrorfun)(int,const char*);
  1237. /*! @brief The function pointer type for window position callbacks.
  1238. *
  1239. * This is the function pointer type for window position callbacks. A window
  1240. * position callback function has the following signature:
  1241. * @code
  1242. * void callback_name(GLFWwindow* window, int xpos, int ypos)
  1243. * @endcode
  1244. *
  1245. * @param[in] window The window that was moved.
  1246. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  1247. * upper-left corner of the content area of the window.
  1248. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  1249. * upper-left corner of the content area of the window.
  1250. *
  1251. * @sa @ref window_pos
  1252. * @sa @ref glfwSetWindowPosCallback
  1253. *
  1254. * @since Added in version 3.0.
  1255. *
  1256. * @ingroup window
  1257. */
  1258. typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
  1259. /*! @brief The function pointer type for window size callbacks.
  1260. *
  1261. * This is the function pointer type for window size callbacks. A window size
  1262. * callback function has the following signature:
  1263. * @code
  1264. * void callback_name(GLFWwindow* window, int width, int height)
  1265. * @endcode
  1266. *
  1267. * @param[in] window The window that was resized.
  1268. * @param[in] width The new width, in screen coordinates, of the window.
  1269. * @param[in] height The new height, in screen coordinates, of the window.
  1270. *
  1271. * @sa @ref window_size
  1272. * @sa @ref glfwSetWindowSizeCallback
  1273. *
  1274. * @since Added in version 1.0.
  1275. * @glfw3 Added window handle parameter.
  1276. *
  1277. * @ingroup window
  1278. */
  1279. typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
  1280. /*! @brief The function pointer type for window close callbacks.
  1281. *
  1282. * This is the function pointer type for window close callbacks. A window
  1283. * close callback function has the following signature:
  1284. * @code
  1285. * void function_name(GLFWwindow* window)
  1286. * @endcode
  1287. *
  1288. * @param[in] window The window that the user attempted to close.
  1289. *
  1290. * @sa @ref window_close
  1291. * @sa @ref glfwSetWindowCloseCallback
  1292. *
  1293. * @since Added in version 2.5.
  1294. * @glfw3 Added window handle parameter.
  1295. *
  1296. * @ingroup window
  1297. */
  1298. typedef void (* GLFWwindowclosefun)(GLFWwindow*);
  1299. /*! @brief The function pointer type for application close callbacks.
  1300. *
  1301. * This is the function pointer type for application close callbacks. A application
  1302. * close callback function has the following signature:
  1303. * @code
  1304. * void function_name(int flags)
  1305. * @endcode
  1306. *
  1307. * @param[in] flags 0 for a user requested application quit, 1 if a fatal error occurred and application should quit ASAP
  1308. *
  1309. * @sa @ref glfwSetApplicationCloseCallback
  1310. *
  1311. * @ingroup window
  1312. */
  1313. typedef void (* GLFWapplicationclosefun)(int);
  1314. /*! @brief The function pointer type for system color theme change callbacks.
  1315. *
  1316. * This is the function pointer type for system color theme changes.
  1317. * @code
  1318. * void function_name(GLFWColorScheme theme_type, bool is_initial_value)
  1319. * @endcode
  1320. *
  1321. * @param[in] theme_type 0 for unknown, 1 for dark and 2 for light
  1322. * @param[in] is_initial_value true if this is the initial read of the color theme on systems where it is asynchronous such as Linux
  1323. *
  1324. * @sa @ref glfwSetSystemColorThemeChangeCallback
  1325. *
  1326. * @ingroup window
  1327. */
  1328. typedef void (* GLFWsystemcolorthemechangefun)(GLFWColorScheme, bool);
  1329. /*! @brief The function pointer type for window content refresh callbacks.
  1330. *
  1331. * This is the function pointer type for window content refresh callbacks.
  1332. * A window content refresh callback function has the following signature:
  1333. * @code
  1334. * void function_name(GLFWwindow* window);
  1335. * @endcode
  1336. *
  1337. * @param[in] window The window whose content needs to be refreshed.
  1338. *
  1339. * @sa @ref window_refresh
  1340. * @sa @ref glfwSetWindowRefreshCallback
  1341. *
  1342. * @since Added in version 2.5.
  1343. * @glfw3 Added window handle parameter.
  1344. *
  1345. * @ingroup window
  1346. */
  1347. typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
  1348. /*! @brief The function pointer type for window focus callbacks.
  1349. *
  1350. * This is the function pointer type for window focus callbacks. A window
  1351. * focus callback function has the following signature:
  1352. * @code
  1353. * void function_name(GLFWwindow* window, int focused)
  1354. * @endcode
  1355. *
  1356. * @param[in] window The window that gained or lost input focus.
  1357. * @param[in] focused `true` if the window was given input focus, or
  1358. * `false` if it lost it.
  1359. *
  1360. * @sa @ref window_focus
  1361. * @sa @ref glfwSetWindowFocusCallback
  1362. *
  1363. * @since Added in version 3.0.
  1364. *
  1365. * @ingroup window
  1366. */
  1367. typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
  1368. /*! @brief The function signature for window occlusion callbacks.
  1369. *
  1370. * This is the function signature for window occlusion callback functions.
  1371. *
  1372. * @param[in] window The window whose occlusion state changed.
  1373. * @param[in] occluded `true` if the window was occluded, or `false`
  1374. * if the window is no longer occluded.
  1375. *
  1376. * @sa @ref window_occlusion
  1377. * @sa @ref glfwSetWindowOcclusionCallback
  1378. *
  1379. * @since Added in version 3.3.
  1380. *
  1381. * @ingroup window
  1382. */
  1383. typedef void (* GLFWwindowocclusionfun)(GLFWwindow*, bool);
  1384. /*! @brief The function pointer type for window iconify callbacks.
  1385. *
  1386. * This is the function pointer type for window iconify callbacks. A window
  1387. * iconify callback function has the following signature:
  1388. * @code
  1389. * void function_name(GLFWwindow* window, int iconified)
  1390. * @endcode
  1391. *
  1392. * @param[in] window The window that was iconified or restored.
  1393. * @param[in] iconified `true` if the window was iconified, or
  1394. * `false` if it was restored.
  1395. *
  1396. * @sa @ref window_iconify
  1397. * @sa @ref glfwSetWindowIconifyCallback
  1398. *
  1399. * @since Added in version 3.0.
  1400. *
  1401. * @ingroup window
  1402. */
  1403. typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
  1404. /*! @brief The function pointer type for window maximize callbacks.
  1405. *
  1406. * This is the function pointer type for window maximize callbacks. A window
  1407. * maximize callback function has the following signature:
  1408. * @code
  1409. * void function_name(GLFWwindow* window, int maximized)
  1410. * @endcode
  1411. *
  1412. * @param[in] window The window that was maximized or restored.
  1413. * @param[in] maximized `true` if the window was maximized, or
  1414. * `false` if it was restored.
  1415. *
  1416. * @sa @ref window_maximize
  1417. * @sa glfwSetWindowMaximizeCallback
  1418. *
  1419. * @since Added in version 3.3.
  1420. *
  1421. * @ingroup window
  1422. */
  1423. typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
  1424. /*! @brief The function pointer type for framebuffer size callbacks.
  1425. *
  1426. * This is the function pointer type for framebuffer size callbacks.
  1427. * A framebuffer size callback function has the following signature:
  1428. * @code
  1429. * void function_name(GLFWwindow* window, int width, int height)
  1430. * @endcode
  1431. *
  1432. * @param[in] window The window whose framebuffer was resized.
  1433. * @param[in] width The new width, in pixels, of the framebuffer.
  1434. * @param[in] height The new height, in pixels, of the framebuffer.
  1435. *
  1436. * @sa @ref window_fbsize
  1437. * @sa @ref glfwSetFramebufferSizeCallback
  1438. *
  1439. * @since Added in version 3.0.
  1440. *
  1441. * @ingroup window
  1442. */
  1443. typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
  1444. /*! @brief The function pointer type for window content scale callbacks.
  1445. *
  1446. * This is the function pointer type for window content scale callbacks.
  1447. * A window content scale callback function has the following signature:
  1448. * @code
  1449. * void function_name(GLFWwindow* window, float xscale, float yscale)
  1450. * @endcode
  1451. *
  1452. * @param[in] window The window whose content scale changed.
  1453. * @param[in] xscale The new x-axis content scale of the window.
  1454. * @param[in] yscale The new y-axis content scale of the window.
  1455. *
  1456. * @sa @ref window_scale
  1457. * @sa @ref glfwSetWindowContentScaleCallback
  1458. *
  1459. * @since Added in version 3.3.
  1460. *
  1461. * @ingroup window
  1462. */
  1463. typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
  1464. /*! @brief The function pointer type for mouse button callbacks.
  1465. *
  1466. * This is the function pointer type for mouse button callback functions.
  1467. * A mouse button callback function has the following signature:
  1468. * @code
  1469. * void function_name(GLFWwindow* window, int button, int action, int mods)
  1470. * @endcode
  1471. *
  1472. * @param[in] window The window that received the event.
  1473. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  1474. * released.
  1475. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. Future releases
  1476. * may add more actions.
  1477. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  1478. * held down.
  1479. *
  1480. * @sa @ref input_mouse_button
  1481. * @sa @ref glfwSetMouseButtonCallback
  1482. *
  1483. * @since Added in version 1.0.
  1484. * @glfw3 Added window handle and modifier mask parameters.
  1485. *
  1486. * @ingroup input
  1487. */
  1488. typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
  1489. /*! @brief The function pointer type for cursor position callbacks.
  1490. *
  1491. * This is the function pointer type for cursor position callbacks. A cursor
  1492. * position callback function has the following signature:
  1493. * @code
  1494. * void function_name(GLFWwindow* window, double xpos, double ypos);
  1495. * @endcode
  1496. *
  1497. * @param[in] window The window that received the event.
  1498. * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
  1499. * the content area.
  1500. * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
  1501. * content area.
  1502. *
  1503. * @sa @ref cursor_pos
  1504. * @sa @ref glfwSetCursorPosCallback
  1505. *
  1506. * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
  1507. *
  1508. * @ingroup input
  1509. */
  1510. typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
  1511. /*! @brief The function pointer type for cursor enter/leave callbacks.
  1512. *
  1513. * This is the function pointer type for cursor enter/leave callbacks.
  1514. * A cursor enter/leave callback function has the following signature:
  1515. * @code
  1516. * void function_name(GLFWwindow* window, int entered)
  1517. * @endcode
  1518. *
  1519. * @param[in] window The window that received the event.
  1520. * @param[in] entered `true` if the cursor entered the window's content
  1521. * area, or `false` if it left it.
  1522. *
  1523. * @sa @ref cursor_enter
  1524. * @sa @ref glfwSetCursorEnterCallback
  1525. *
  1526. * @since Added in version 3.0.
  1527. *
  1528. * @ingroup input
  1529. */
  1530. typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
  1531. /*! @brief The function pointer type for scroll callbacks.
  1532. *
  1533. * This is the function pointer type for scroll callbacks. A scroll callback
  1534. * function has the following signature:
  1535. * @code
  1536. * void function_name(GLFWwindow* window, double xoffset, double yoffset)
  1537. * @endcode
  1538. *
  1539. * @param[in] window The window that received the event.
  1540. * @param[in] xoffset The scroll offset along the x-axis.
  1541. * @param[in] yoffset The scroll offset along the y-axis.
  1542. * @param[in] flags A bit-mask providing extra data about the event.
  1543. * flags & 1 will be true if and only if the offset values are "high-precision",
  1544. * typically pixel values. Otherwise the offset values are number of lines.
  1545. * (flags >> 1) & 7 will have value 1 for the start of momentum scrolling,
  1546. * value 2 for stationary momentum scrolling, value 3 for momentum scrolling
  1547. * in progress, value 4 for momentum scrolling ended, value 5 for momentum
  1548. * scrolling cancelled and value 6 if scrolling may begin soon.
  1549. * @param[int] mods The keyboard modifiers
  1550. *
  1551. * @sa @ref scrolling
  1552. * @sa @ref glfwSetScrollCallback
  1553. *
  1554. * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
  1555. * @since Changed in version 4.0. Added `flags` parameter.
  1556. *
  1557. * @ingroup input
  1558. */
  1559. typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int,int);
  1560. /*! @brief The function pointer type for key callbacks.
  1561. *
  1562. * This is the function pointer type for key callbacks. A keyboard
  1563. * key callback function has the following signature:
  1564. * @code
  1565. * void function_name(GLFWwindow* window, uint32_t key, int native_key, int action, int mods)
  1566. * @endcode
  1567. * The semantics of this function are that the key that is interacted with on the
  1568. * keyboard is reported, and the text, if any generated by the key is reported.
  1569. * So, for example, if on a US-ASCII keyboard the user presses Shift+= GLFW
  1570. * will report the text "+" and the key as GLFW_KEY_EQUAL. The reported key takes into
  1571. * account any current keyboard maps defined in the OS. So with a dvorak mapping, pressing
  1572. * the "s" key will generate text "o" and GLFW_KEY_O.
  1573. *
  1574. * @param[in] window The window that received the event.
  1575. * @param[in] ev The key event, see GLFWkeyevent. The data in this event is only valid for
  1576. * the lifetime of the callback.
  1577. *
  1578. * @note On X11/Wayland if a modifier other than the modifiers GLFW reports
  1579. * (ctrl/shift/alt/super) is used, GLFW will report the shifted key rather
  1580. * than the unshifted key. So for example, if ISO_Shift_Level_5 is used to
  1581. * convert the key A into UP GLFW will report the key as UP with no modifiers.
  1582. *
  1583. * @sa @ref input_key
  1584. * @sa @ref glfwSetKeyboardCallback
  1585. *
  1586. * @since Added in version 4.0.
  1587. *
  1588. * @ingroup input
  1589. */
  1590. typedef void (* GLFWkeyboardfun)(GLFWwindow*, GLFWkeyevent*);
  1591. /*! @brief The function pointer type for drag and drop callbacks.
  1592. *
  1593. * This is the function pointer type for drop callbacks. A drop
  1594. * callback function has the following signature:
  1595. * @code
  1596. * int function_name(GLFWwindow* window, const char* mime, const char* text)
  1597. * @endcode
  1598. *
  1599. * @param[in] window The window that received the event.
  1600. * @param[in] mime The UTF-8 encoded drop mime-type
  1601. * @param[in] data The dropped data or NULL for drag enter events
  1602. * @param[in] sz The size of the dropped data
  1603. * @return For drag events should return the priority for the specified mime type. A priority of zero
  1604. * or lower means the mime type is not accepted. Highest priority will be the finally accepted mime-type.
  1605. *
  1606. * @pointer_lifetime The text is valid until the
  1607. * callback function returns.
  1608. *
  1609. * @sa @ref path_drop
  1610. * @sa @ref glfwSetDropCallback
  1611. *
  1612. * @since Added in version 3.1.
  1613. *
  1614. * @ingroup input
  1615. */
  1616. typedef int (* GLFWdropfun)(GLFWwindow*, const char *, const char*, size_t);
  1617. typedef void (* GLFWliveresizefun)(GLFWwindow*, bool);
  1618. /*! @brief The function pointer type for monitor configuration callbacks.
  1619. *
  1620. * This is the function pointer type for monitor configuration callbacks.
  1621. * A monitor callback function has the following signature:
  1622. * @code
  1623. * void function_name(GLFWmonitor* monitor, int event)
  1624. * @endcode
  1625. *
  1626. * @param[in] monitor The monitor that was connected or disconnected.
  1627. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
  1628. * releases may add more events.
  1629. *
  1630. * @sa @ref monitor_event
  1631. * @sa @ref glfwSetMonitorCallback
  1632. *
  1633. * @since Added in version 3.0.
  1634. *
  1635. * @ingroup monitor
  1636. */
  1637. typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
  1638. /*! @brief The function pointer type for joystick configuration callbacks.
  1639. *
  1640. * This is the function pointer type for joystick configuration callbacks.
  1641. * A joystick configuration callback function has the following signature:
  1642. * @code
  1643. * void function_name(int jid, int event)
  1644. * @endcode
  1645. *
  1646. * @param[in] jid The joystick that was connected or disconnected.
  1647. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. Future
  1648. * releases may add more events.
  1649. *
  1650. * @sa @ref joystick_event
  1651. * @sa @ref glfwSetJoystickCallback
  1652. *
  1653. * @since Added in version 3.2.
  1654. *
  1655. * @ingroup input
  1656. */
  1657. typedef void (* GLFWjoystickfun)(int,int);
  1658. typedef void (* GLFWuserdatafun)(unsigned long long, void*);
  1659. typedef void (* GLFWtickcallback)(void*);
  1660. typedef void (* GLFWactivationcallback)(GLFWwindow *window, const char *token, void *data);
  1661. 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);
  1662. typedef char* (* GLFWcurrentselectionfun)(void);
  1663. typedef bool (* GLFWhascurrentselectionfun)(void);
  1664. typedef void (* GLFWclipboarddatafreefun)(void* data);
  1665. typedef struct GLFWDataChunk {
  1666. const char *data;
  1667. size_t sz;
  1668. GLFWclipboarddatafreefun free;
  1669. void *iter, *free_data;
  1670. } GLFWDataChunk;
  1671. typedef enum {
  1672. GLFW_CLIPBOARD, GLFW_PRIMARY_SELECTION
  1673. } GLFWClipboardType;
  1674. typedef GLFWDataChunk (* GLFWclipboarditerfun)(const char *mime_type, void *iter, GLFWClipboardType ctype);
  1675. typedef bool (* GLFWclipboardwritedatafun)(void *object, const char *data, size_t sz);
  1676. typedef bool (* GLFWimecursorpositionfun)(GLFWwindow *window, GLFWIMEUpdateEvent *ev);
  1677. /*! @brief Video mode type.
  1678. *
  1679. * This describes a single video mode.
  1680. *
  1681. * @sa @ref monitor_modes
  1682. * @sa @ref glfwGetVideoMode
  1683. * @sa @ref glfwGetVideoModes
  1684. *
  1685. * @since Added in version 1.0.
  1686. * @glfw3 Added refresh rate member.
  1687. *
  1688. * @ingroup monitor
  1689. */
  1690. typedef struct GLFWvidmode
  1691. {
  1692. /*! The width, in screen coordinates, of the video mode.
  1693. */
  1694. int width;
  1695. /*! The height, in screen coordinates, of the video mode.
  1696. */
  1697. int height;
  1698. /*! The bit depth of the red channel of the video mode.
  1699. */
  1700. int redBits;
  1701. /*! The bit depth of the green channel of the video mode.
  1702. */
  1703. int greenBits;
  1704. /*! The bit depth of the blue channel of the video mode.
  1705. */
  1706. int blueBits;
  1707. /*! The refresh rate, in Hz, of the video mode.
  1708. */
  1709. int refreshRate;
  1710. } GLFWvidmode;
  1711. /*! @brief Gamma ramp.
  1712. *
  1713. * This describes the gamma ramp for a monitor.
  1714. *
  1715. * @sa @ref monitor_gamma
  1716. * @sa @ref glfwGetGammaRamp
  1717. * @sa @ref glfwSetGammaRamp
  1718. *
  1719. * @since Added in version 3.0.
  1720. *
  1721. * @ingroup monitor
  1722. */
  1723. typedef struct GLFWgammaramp
  1724. {
  1725. /*! An array of value describing the response of the red channel.
  1726. */
  1727. unsigned short* red;
  1728. /*! An array of value describing the response of the green channel.
  1729. */
  1730. unsigned short* green;
  1731. /*! An array of value describing the response of the blue channel.
  1732. */
  1733. unsigned short* blue;
  1734. /*! The number of elements in each array.
  1735. */
  1736. unsigned int size;
  1737. } GLFWgammaramp;
  1738. /*! @brief Image data.
  1739. *
  1740. * This describes a single 2D image. See the documentation for each related
  1741. * function what the expected pixel format is.
  1742. *
  1743. * @sa @ref cursor_custom
  1744. * @sa @ref window_icon
  1745. *
  1746. * @since Added in version 2.1.
  1747. * @glfw3 Removed format and bytes-per-pixel members.
  1748. *
  1749. * @ingroup window
  1750. */
  1751. typedef struct GLFWimage
  1752. {
  1753. /*! The width, in pixels, of this image.
  1754. */
  1755. int width;
  1756. /*! The height, in pixels, of this image.
  1757. */
  1758. int height;
  1759. /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
  1760. */
  1761. unsigned char* pixels;
  1762. } GLFWimage;
  1763. /*! @brief Gamepad input state
  1764. *
  1765. * This describes the input state of a gamepad.
  1766. *
  1767. * @sa @ref gamepad
  1768. * @sa @ref glfwGetGamepadState
  1769. *
  1770. * @since Added in version 3.3.
  1771. *
  1772. * @ingroup input
  1773. */
  1774. typedef struct GLFWgamepadstate
  1775. {
  1776. /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
  1777. * or `GLFW_RELEASE`.
  1778. */
  1779. unsigned char buttons[15];
  1780. /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
  1781. * to 1.0 inclusive.
  1782. */
  1783. float axes[6];
  1784. } GLFWgamepadstate;
  1785. /*************************************************************************
  1786. * GLFW API functions
  1787. *************************************************************************/
  1788. /*! @brief Initializes the GLFW library.
  1789. *
  1790. * This function initializes the GLFW library. Before most GLFW functions can
  1791. * be used, GLFW must be initialized, and before an application terminates GLFW
  1792. * should be terminated in order to free any resources allocated during or
  1793. * after initialization.
  1794. *
  1795. * If this function fails, it calls @ref glfwTerminate before returning. If it
  1796. * succeeds, you should call @ref glfwTerminate before the application exits.
  1797. *
  1798. * Additional calls to this function after successful initialization but before
  1799. * termination will return `true` immediately.
  1800. *
  1801. * @return `true` if successful, or `false` if an
  1802. * [error](@ref error_handling) occurred.
  1803. *
  1804. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1805. *
  1806. * @remark @macos This function will change the current directory of the
  1807. * application to the `Contents/Resources` subdirectory of the application's
  1808. * bundle, if present. This can be disabled with the @ref
  1809. * GLFW_COCOA_CHDIR_RESOURCES init hint.
  1810. *
  1811. * @thread_safety This function must only be called from the main thread.
  1812. *
  1813. * @sa @ref intro_init
  1814. * @sa @ref glfwTerminate
  1815. *
  1816. * @since Added in version 1.0.
  1817. *
  1818. * @ingroup init
  1819. */
  1820. GLFWAPI int glfwInit(monotonic_t start_time);
  1821. GLFWAPI void glfwRunMainLoop(GLFWtickcallback callback, void *callback_data);
  1822. GLFWAPI void glfwStopMainLoop(void);
  1823. GLFWAPI unsigned long long glfwAddTimer(monotonic_t interval, bool repeats, GLFWuserdatafun callback, void * callback_data, GLFWuserdatafun free_callback);
  1824. GLFWAPI void glfwUpdateTimer(unsigned long long timer_id, monotonic_t interval, bool enabled);
  1825. GLFWAPI void glfwRemoveTimer(unsigned long long);
  1826. GLFWAPI GLFWdrawtextfun glfwSetDrawTextFunction(GLFWdrawtextfun function);
  1827. GLFWAPI GLFWcurrentselectionfun glfwSetCurrentSelectionCallback(GLFWcurrentselectionfun callback);
  1828. GLFWAPI GLFWhascurrentselectionfun glfwSetHasCurrentSelectionCallback(GLFWhascurrentselectionfun callback);
  1829. GLFWAPI GLFWimecursorpositionfun glfwSetIMECursorPositionCallback(GLFWimecursorpositionfun callback);
  1830. /*! @brief Terminates the GLFW library.
  1831. *
  1832. * This function destroys all remaining windows and cursors, restores any
  1833. * modified gamma ramps and frees any other allocated resources. Once this
  1834. * function is called, you must again call @ref glfwInit successfully before
  1835. * you will be able to use most GLFW functions.
  1836. *
  1837. * If GLFW has been successfully initialized, this function should be called
  1838. * before the application exits. If initialization fails, there is no need to
  1839. * call this function, as it is called by @ref glfwInit before it returns
  1840. * failure.
  1841. *
  1842. * This function has no effect if GLFW is not initialized.
  1843. *
  1844. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1845. *
  1846. * @remark This function may be called before @ref glfwInit.
  1847. *
  1848. * @warning The contexts of any remaining windows must not be current on any
  1849. * other thread when this function is called.
  1850. *
  1851. * @reentrancy This function must not be called from a callback.
  1852. *
  1853. * @thread_safety This function must only be called from the main thread.
  1854. *
  1855. * @sa @ref intro_init
  1856. * @sa @ref glfwInit
  1857. *
  1858. * @since Added in version 1.0.
  1859. *
  1860. * @ingroup init
  1861. */
  1862. GLFWAPI void glfwTerminate(void);
  1863. /*! @brief Sets the specified init hint to the desired value.
  1864. *
  1865. * This function sets hints for the next initialization of GLFW.
  1866. *
  1867. * The values you set hints to are never reset by GLFW, but they only take
  1868. * effect during initialization. Once GLFW has been initialized, any values
  1869. * you set will be ignored until the library is terminated and initialized
  1870. * again.
  1871. *
  1872. * Some hints are platform specific. These may be set on any platform but they
  1873. * will only affect their specific platform. Other platforms will ignore them.
  1874. * Setting these hints requires no platform specific headers or functions.
  1875. *
  1876. * @param[in] hint The [init hint](@ref init_hints) to set.
  1877. * @param[in] value The new value of the init hint.
  1878. *
  1879. * @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
  1880. * GLFW_INVALID_VALUE.
  1881. *
  1882. * @remarks This function may be called before @ref glfwInit.
  1883. *
  1884. * @thread_safety This function must only be called from the main thread.
  1885. *
  1886. * @sa init_hints
  1887. * @sa glfwInit
  1888. *
  1889. * @since Added in version 3.3.
  1890. *
  1891. * @ingroup init
  1892. */
  1893. GLFWAPI void glfwInitHint(int hint, int value);
  1894. /*! @brief Retrieves the version of the GLFW library.
  1895. *
  1896. * This function retrieves the major, minor and revision numbers of the GLFW
  1897. * library. It is intended for when you are using GLFW as a shared library and
  1898. * want to ensure that you are using the minimum required version.
  1899. *
  1900. * Any or all of the version arguments may be `NULL`.
  1901. *
  1902. * @param[out] major Where to store the major version number, or `NULL`.
  1903. * @param[out] minor Where to store the minor version number, or `NULL`.
  1904. * @param[out] rev Where to store the revision number, or `NULL`.
  1905. *
  1906. * @errors None.
  1907. *
  1908. * @remark This function may be called before @ref glfwInit.
  1909. *
  1910. * @thread_safety This function may be called from any thread.
  1911. *
  1912. * @sa @ref intro_version
  1913. * @sa @ref glfwGetVersionString
  1914. *
  1915. * @since Added in version 1.0.
  1916. *
  1917. * @ingroup init
  1918. */
  1919. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  1920. /*! @brief Returns a string describing the compile-time configuration.
  1921. *
  1922. * This function returns the compile-time generated
  1923. * [version string](@ref intro_version_string) of the GLFW library binary. It
  1924. * describes the version, platform, compiler and any platform-specific
  1925. * compile-time options. It should not be confused with the OpenGL or OpenGL
  1926. * ES version string, queried with `glGetString`.
  1927. *
  1928. * __Do not use the version string__ to parse the GLFW library version. The
  1929. * @ref glfwGetVersion function provides the version of the running library
  1930. * binary in numerical format.
  1931. *
  1932. * @return The ASCII encoded GLFW version string.
  1933. *
  1934. * @errors None.
  1935. *
  1936. * @remark This function may be called before @ref glfwInit.
  1937. *
  1938. * @pointer_lifetime The returned string is static and compile-time generated.
  1939. *
  1940. * @thread_safety This function may be called from any thread.
  1941. *
  1942. * @sa @ref intro_version
  1943. * @sa @ref glfwGetVersion
  1944. *
  1945. * @since Added in version 3.0.
  1946. *
  1947. * @ingroup init
  1948. */
  1949. GLFWAPI const char* glfwGetVersionString(void);
  1950. /*! @brief Returns and clears the last error for the calling thread.
  1951. *
  1952. * This function returns and clears the [error code](@ref errors) of the last
  1953. * error that occurred on the calling thread, and optionally a UTF-8 encoded
  1954. * human-readable description of it. If no error has occurred since the last
  1955. * call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
  1956. * set to `NULL`.
  1957. *
  1958. * @param[in] description Where to store the error description pointer, or `NULL`.
  1959. * @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
  1960. * (zero).
  1961. *
  1962. * @errors None.
  1963. *
  1964. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  1965. * should not free it yourself. It is guaranteed to be valid only until the
  1966. * next error occurs or the library is terminated.
  1967. *
  1968. * @remark This function may be called before @ref glfwInit.
  1969. *
  1970. * @thread_safety This function may be called from any thread.
  1971. *
  1972. * @sa @ref error_handling
  1973. * @sa @ref glfwSetErrorCallback
  1974. *
  1975. * @since Added in version 3.3.
  1976. *
  1977. * @ingroup init
  1978. */
  1979. GLFWAPI int glfwGetError(const char** description);
  1980. /*! @brief Sets the error callback.
  1981. *
  1982. * This function sets the error callback, which is called with an error code
  1983. * and a human-readable description each time a GLFW error occurs.
  1984. *
  1985. * The error code is set before the callback is called. Calling @ref
  1986. * glfwGetError from the error callback will return the same value as the error
  1987. * code argument.
  1988. *
  1989. * The error callback is called on the thread where the error occurred. If you
  1990. * are using GLFW from multiple threads, your error callback needs to be
  1991. * written accordingly.
  1992. *
  1993. * Because the description string may have been generated specifically for that
  1994. * error, it is not guaranteed to be valid after the callback has returned. If
  1995. * you wish to use it after the callback returns, you need to make a copy.
  1996. *
  1997. * Once set, the error callback remains set even after the library has been
  1998. * terminated.
  1999. *
  2000. * @param[in] callback The new callback, or `NULL` to remove the currently set
  2001. * callback.
  2002. * @return The previously set callback, or `NULL` if no callback was set.
  2003. *
  2004. * @callback_signature
  2005. * @code
  2006. * void callback_name(int error_code, const char* description)
  2007. * @endcode
  2008. * For more information about the callback parameters, see the
  2009. * [callback pointer type](@ref GLFWerrorfun).
  2010. *
  2011. * @errors None.
  2012. *
  2013. * @remark This function may be called before @ref glfwInit.
  2014. *
  2015. * @thread_safety This function must only be called from the main thread.
  2016. *
  2017. * @sa @ref error_handling
  2018. * @sa @ref glfwGetError
  2019. *
  2020. * @since Added in version 3.0.
  2021. *
  2022. * @ingroup init
  2023. */
  2024. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
  2025. /*! @brief Returns the currently connected monitors.
  2026. *
  2027. * This function returns an array of handles for all currently connected
  2028. * monitors. The primary monitor is always first in the returned array. If no
  2029. * monitors were found, this function returns `NULL`.
  2030. *
  2031. * @param[out] count Where to store the number of monitors in the returned
  2032. * array. This is set to zero if an error occurred.
  2033. * @return An array of monitor handles, or `NULL` if no monitors were found or
  2034. * if an [error](@ref error_handling) occurred.
  2035. *
  2036. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2037. *
  2038. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  2039. * should not free it yourself. It is guaranteed to be valid only until the
  2040. * monitor configuration changes or the library is terminated.
  2041. *
  2042. * @thread_safety This function must only be called from the main thread.
  2043. *
  2044. * @sa @ref monitor_monitors
  2045. * @sa @ref monitor_event
  2046. * @sa @ref glfwGetPrimaryMonitor
  2047. *
  2048. * @since Added in version 3.0.
  2049. *
  2050. * @ingroup monitor
  2051. */
  2052. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  2053. /*! @brief Returns the primary monitor.
  2054. *
  2055. * This function returns the primary monitor. This is usually the monitor
  2056. * where elements like the task bar or global menu bar are located.
  2057. *
  2058. * @return The primary monitor, or `NULL` if no monitors were found or if an
  2059. * [error](@ref error_handling) occurred.
  2060. *
  2061. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2062. *
  2063. * @thread_safety This function must only be called from the main thread.
  2064. *
  2065. * @remark The primary monitor is always first in the array returned by @ref
  2066. * glfwGetMonitors.
  2067. *
  2068. * @sa @ref monitor_monitors
  2069. * @sa @ref glfwGetMonitors
  2070. *
  2071. * @since Added in version 3.0.
  2072. *
  2073. * @ingroup monitor
  2074. */
  2075. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  2076. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  2077. *
  2078. * This function returns the position, in screen coordinates, of the upper-left
  2079. * corner of the specified monitor.
  2080. *
  2081. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  2082. * non-`NULL` position arguments will be set to zero.
  2083. *
  2084. * @param[in] monitor The monitor to query.
  2085. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  2086. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  2087. *
  2088. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2089. * GLFW_PLATFORM_ERROR.
  2090. *
  2091. * @thread_safety This function must only be called from the main thread.
  2092. *
  2093. * @sa @ref monitor_properties
  2094. *
  2095. * @since Added in version 3.0.
  2096. *
  2097. * @ingroup monitor
  2098. */
  2099. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  2100. /*! @brief Retrieves the work area of the monitor.
  2101. *
  2102. * This function returns the position, in screen coordinates, of the upper-left
  2103. * corner of the work area of the specified monitor along with the work area
  2104. * size in screen coordinates. The work area is defined as the area of the
  2105. * monitor not occluded by the operating system task bar where present. If no
  2106. * task bar exists then the work area is the monitor resolution in screen
  2107. * coordinates.
  2108. *
  2109. * Any or all of the position and size arguments may be `NULL`. If an error
  2110. * occurs, all non-`NULL` position and size arguments will be set to zero.
  2111. *
  2112. * @param[in] monitor The monitor to query.
  2113. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  2114. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  2115. * @param[out] width Where to store the monitor width, or `NULL`.
  2116. * @param[out] height Where to store the monitor height, or `NULL`.
  2117. *
  2118. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2119. * GLFW_PLATFORM_ERROR.
  2120. *
  2121. * @thread_safety This function must only be called from the main thread.
  2122. *
  2123. * @sa @ref monitor_workarea
  2124. *
  2125. * @since Added in version 3.3.
  2126. *
  2127. * @ingroup monitor
  2128. */
  2129. GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
  2130. /*! @brief Returns the physical size of the monitor.
  2131. *
  2132. * This function returns the size, in millimetres, of the display area of the
  2133. * specified monitor.
  2134. *
  2135. * Some systems do not provide accurate monitor size information, either
  2136. * because the monitor
  2137. * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
  2138. * data is incorrect or because the driver does not report it accurately.
  2139. *
  2140. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2141. * non-`NULL` size arguments will be set to zero.
  2142. *
  2143. * @param[in] monitor The monitor to query.
  2144. * @param[out] widthMM Where to store the width, in millimetres, of the
  2145. * monitor's display area, or `NULL`.
  2146. * @param[out] heightMM Where to store the height, in millimetres, of the
  2147. * monitor's display area, or `NULL`.
  2148. *
  2149. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2150. *
  2151. * @remark @win32 calculates the returned physical size from the
  2152. * current resolution and system DPI instead of querying the monitor EDID data.
  2153. *
  2154. * @thread_safety This function must only be called from the main thread.
  2155. *
  2156. * @sa @ref monitor_properties
  2157. *
  2158. * @since Added in version 3.0.
  2159. *
  2160. * @ingroup monitor
  2161. */
  2162. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
  2163. /*! @brief Retrieves the content scale for the specified monitor.
  2164. *
  2165. * This function retrieves the content scale for the specified monitor. The
  2166. * content scale is the ratio between the current DPI and the platform's
  2167. * default DPI. This is especially important for text and any UI elements. If
  2168. * the pixel dimensions of your UI scaled by this look appropriate on your
  2169. * machine then it should appear at a reasonable size on other machines
  2170. * regardless of their DPI and scaling settings. This relies on the system DPI
  2171. * and scaling settings being somewhat correct.
  2172. *
  2173. * The content scale may depend on both the monitor resolution and pixel
  2174. * density and on user settings. It may be very different from the raw DPI
  2175. * calculated from the physical size and current resolution.
  2176. *
  2177. * @param[in] monitor The monitor to query.
  2178. * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
  2179. * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
  2180. *
  2181. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2182. * GLFW_PLATFORM_ERROR.
  2183. *
  2184. * @thread_safety This function must only be called from the main thread.
  2185. *
  2186. * @sa @ref monitor_scale
  2187. * @sa @ref glfwGetWindowContentScale
  2188. *
  2189. * @since Added in version 3.3.
  2190. *
  2191. * @ingroup monitor
  2192. */
  2193. GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
  2194. /*! @brief Returns the name of the specified monitor.
  2195. *
  2196. * This function returns a human-readable name, encoded as UTF-8, of the
  2197. * specified monitor. The name typically reflects the make and model of the
  2198. * monitor and is not guaranteed to be unique among the connected monitors.
  2199. *
  2200. * @param[in] monitor The monitor to query.
  2201. * @return The UTF-8 encoded name of the monitor, or `NULL` if an
  2202. * [error](@ref error_handling) occurred.
  2203. *
  2204. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2205. *
  2206. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  2207. * should not free it yourself. It is valid until the specified monitor is
  2208. * disconnected or the library is terminated.
  2209. *
  2210. * @thread_safety This function must only be called from the main thread.
  2211. *
  2212. * @sa @ref monitor_properties
  2213. *
  2214. * @since Added in version 3.0.
  2215. *
  2216. * @ingroup monitor
  2217. */
  2218. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  2219. /*! @brief Sets the user pointer of the specified monitor.
  2220. *
  2221. * This function sets the user-defined pointer of the specified monitor. The
  2222. * current value is retained until the monitor is disconnected. The initial
  2223. * value is `NULL`.
  2224. *
  2225. * This function may be called from the monitor callback, even for a monitor
  2226. * that is being disconnected.
  2227. *
  2228. * @param[in] monitor The monitor whose pointer to set.
  2229. * @param[in] pointer The new value.
  2230. *
  2231. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2232. *
  2233. * @thread_safety This function may be called from any thread. Access is not
  2234. * synchronized.
  2235. *
  2236. * @sa @ref monitor_userptr
  2237. * @sa @ref glfwGetMonitorUserPointer
  2238. *
  2239. * @since Added in version 3.3.
  2240. *
  2241. * @ingroup monitor
  2242. */
  2243. GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
  2244. /*! @brief Returns the user pointer of the specified monitor.
  2245. *
  2246. * This function returns the current value of the user-defined pointer of the
  2247. * specified monitor. The initial value is `NULL`.
  2248. *
  2249. * This function may be called from the monitor callback, even for a monitor
  2250. * that is being disconnected.
  2251. *
  2252. * @param[in] monitor The monitor whose pointer to return.
  2253. *
  2254. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2255. *
  2256. * @thread_safety This function may be called from any thread. Access is not
  2257. * synchronized.
  2258. *
  2259. * @sa @ref monitor_userptr
  2260. * @sa @ref glfwSetMonitorUserPointer
  2261. *
  2262. * @since Added in version 3.3.
  2263. *
  2264. * @ingroup monitor
  2265. */
  2266. GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
  2267. /*! @brief Sets the monitor configuration callback.
  2268. *
  2269. * This function sets the monitor configuration callback, or removes the
  2270. * currently set callback. This is called when a monitor is connected to or
  2271. * disconnected from the system.
  2272. *
  2273. * @param[in] callback The new callback, or `NULL` to remove the currently set
  2274. * callback.
  2275. * @return The previously set callback, or `NULL` if no callback was set or the
  2276. * library had not been [initialized](@ref intro_init).
  2277. *
  2278. * @callback_signature
  2279. * @code
  2280. * void function_name(GLFWmonitor* monitor, int event)
  2281. * @endcode
  2282. * For more information about the callback parameters, see the
  2283. * [function pointer type](@ref GLFWmonitorfun).
  2284. *
  2285. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2286. *
  2287. * @thread_safety This function must only be called from the main thread.
  2288. *
  2289. * @sa @ref monitor_event
  2290. *
  2291. * @since Added in version 3.0.
  2292. *
  2293. * @ingroup monitor
  2294. */
  2295. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
  2296. /*! @brief Returns the available video modes for the specified monitor.
  2297. *
  2298. * This function returns an array of all video modes supported by the specified
  2299. * monitor. The returned array is sorted in ascending order, first by color
  2300. * bit depth (the sum of all channel depths) and then by resolution area (the
  2301. * product of width and height).
  2302. *
  2303. * @param[in] monitor The monitor to query.
  2304. * @param[out] count Where to store the number of video modes in the returned
  2305. * array. This is set to zero if an error occurred.
  2306. * @return An array of video modes, or `NULL` if an
  2307. * [error](@ref error_handling) occurred.
  2308. *
  2309. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2310. * GLFW_PLATFORM_ERROR.
  2311. *
  2312. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  2313. * should not free it yourself. It is valid until the specified monitor is
  2314. * disconnected, this function is called again for that monitor or the library
  2315. * is terminated.
  2316. *
  2317. * @thread_safety This function must only be called from the main thread.
  2318. *
  2319. * @sa @ref monitor_modes
  2320. * @sa @ref glfwGetVideoMode
  2321. *
  2322. * @since Added in version 1.0.
  2323. * @glfw3 Changed to return an array of modes for a specific monitor.
  2324. *
  2325. * @ingroup monitor
  2326. */
  2327. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  2328. /*! @brief Returns the current mode of the specified monitor.
  2329. *
  2330. * This function returns the current video mode of the specified monitor. If
  2331. * you have created a full screen window for that monitor, the return value
  2332. * will depend on whether that window is iconified.
  2333. *
  2334. * @param[in] monitor The monitor to query.
  2335. * @return The current mode of the monitor, or `NULL` if an
  2336. * [error](@ref error_handling) occurred.
  2337. *
  2338. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2339. * GLFW_PLATFORM_ERROR.
  2340. *
  2341. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  2342. * should not free it yourself. It is valid until the specified monitor is
  2343. * disconnected or the library is terminated.
  2344. *
  2345. * @thread_safety This function must only be called from the main thread.
  2346. *
  2347. * @sa @ref monitor_modes
  2348. * @sa @ref glfwGetVideoModes
  2349. *
  2350. * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
  2351. *
  2352. * @ingroup monitor
  2353. */
  2354. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  2355. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  2356. *
  2357. * This function generates an appropriately sized gamma ramp from the specified
  2358. * exponent and then calls @ref glfwSetGammaRamp with it. The value must be
  2359. * a finite number greater than zero.
  2360. *
  2361. * The software controlled gamma ramp is applied _in addition_ to the hardware
  2362. * gamma correction, which today is usually an approximation of sRGB gamma.
  2363. * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
  2364. * the default (usually sRGB-like) behavior.
  2365. *
  2366. * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
  2367. * GLFW_SRGB_CAPABLE hint.
  2368. *
  2369. * @param[in] monitor The monitor whose gamma ramp to set.
  2370. * @param[in] gamma The desired exponent.
  2371. *
  2372. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2373. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2374. *
  2375. * @remark @wayland Gamma handling is a privileged protocol, this function
  2376. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
  2377. *
  2378. * @thread_safety This function must only be called from the main thread.
  2379. *
  2380. * @sa @ref monitor_gamma
  2381. *
  2382. * @since Added in version 3.0.
  2383. *
  2384. * @ingroup monitor
  2385. */
  2386. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  2387. /*! @brief Returns the current gamma ramp for the specified monitor.
  2388. *
  2389. * This function returns the current gamma ramp of the specified monitor.
  2390. *
  2391. * @param[in] monitor The monitor to query.
  2392. * @return The current gamma ramp, or `NULL` if an
  2393. * [error](@ref error_handling) occurred.
  2394. *
  2395. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2396. * GLFW_PLATFORM_ERROR.
  2397. *
  2398. * @remark @wayland Gamma handling is a privileged protocol, this function
  2399. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
  2400. * returning `NULL`.
  2401. *
  2402. * @pointer_lifetime The returned structure and its arrays are allocated and
  2403. * freed by GLFW. You should not free them yourself. They are valid until the
  2404. * specified monitor is disconnected, this function is called again for that
  2405. * monitor or the library is terminated.
  2406. *
  2407. * @thread_safety This function must only be called from the main thread.
  2408. *
  2409. * @sa @ref monitor_gamma
  2410. *
  2411. * @since Added in version 3.0.
  2412. *
  2413. * @ingroup monitor
  2414. */
  2415. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  2416. /*! @brief Sets the current gamma ramp for the specified monitor.
  2417. *
  2418. * This function sets the current gamma ramp for the specified monitor. The
  2419. * original gamma ramp for that monitor is saved by GLFW the first time this
  2420. * function is called and is restored by @ref glfwTerminate.
  2421. *
  2422. * The software controlled gamma ramp is applied _in addition_ to the hardware
  2423. * gamma correction, which today is usually an approximation of sRGB gamma.
  2424. * This means that setting a perfectly linear ramp, or gamma 1.0, will produce
  2425. * the default (usually sRGB-like) behavior.
  2426. *
  2427. * For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
  2428. * GLFW_SRGB_CAPABLE hint.
  2429. *
  2430. * @param[in] monitor The monitor whose gamma ramp to set.
  2431. * @param[in] ramp The gamma ramp to use.
  2432. *
  2433. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2434. * GLFW_PLATFORM_ERROR.
  2435. *
  2436. * @remark The size of the specified gamma ramp should match the size of the
  2437. * current ramp for that monitor.
  2438. *
  2439. * @remark @win32 The gamma ramp size must be 256.
  2440. *
  2441. * @remark @wayland Gamma handling is a privileged protocol, this function
  2442. * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
  2443. *
  2444. * @pointer_lifetime The specified gamma ramp is copied before this function
  2445. * returns.
  2446. *
  2447. * @thread_safety This function must only be called from the main thread.
  2448. *
  2449. * @sa @ref monitor_gamma
  2450. *
  2451. * @since Added in version 3.0.
  2452. *
  2453. * @ingroup monitor
  2454. */
  2455. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  2456. /*! @brief Resets all window hints to their default values.
  2457. *
  2458. * This function resets all window hints to their
  2459. * [default values](@ref window_hints_values).
  2460. *
  2461. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2462. *
  2463. * @thread_safety This function must only be called from the main thread.
  2464. *
  2465. * @sa @ref window_hints
  2466. * @sa @ref glfwWindowHint
  2467. * @sa @ref glfwWindowHintString
  2468. *
  2469. * @since Added in version 3.0.
  2470. *
  2471. * @ingroup window
  2472. */
  2473. GLFWAPI void glfwDefaultWindowHints(void);
  2474. /*! @brief Sets the specified window hint to the desired value.
  2475. *
  2476. * This function sets hints for the next call to @ref glfwCreateWindow. The
  2477. * hints, once set, retain their values until changed by a call to this
  2478. * function or @ref glfwDefaultWindowHints, or until the library is terminated.
  2479. *
  2480. * Only integer value hints can be set with this function. String value hints
  2481. * are set with @ref glfwWindowHintString.
  2482. *
  2483. * This function does not check whether the specified hint values are valid.
  2484. * If you set hints to invalid values this will instead be reported by the next
  2485. * call to @ref glfwCreateWindow.
  2486. *
  2487. * Some hints are platform specific. These may be set on any platform but they
  2488. * will only affect their specific platform. Other platforms will ignore them.
  2489. * Setting these hints requires no platform specific headers or functions.
  2490. *
  2491. * @param[in] hint The [window hint](@ref window_hints) to set.
  2492. * @param[in] value The new value of the window hint.
  2493. *
  2494. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2495. * GLFW_INVALID_ENUM.
  2496. *
  2497. * @thread_safety This function must only be called from the main thread.
  2498. *
  2499. * @sa @ref window_hints
  2500. * @sa @ref glfwWindowHintString
  2501. * @sa @ref glfwDefaultWindowHints
  2502. *
  2503. * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
  2504. *
  2505. * @ingroup window
  2506. */
  2507. GLFWAPI void glfwWindowHint(int hint, int value);
  2508. /*! @brief Sets the specified window hint to the desired value.
  2509. *
  2510. * This function sets hints for the next call to @ref glfwCreateWindow. The
  2511. * hints, once set, retain their values until changed by a call to this
  2512. * function or @ref glfwDefaultWindowHints, or until the library is terminated.
  2513. *
  2514. * Only string type hints can be set with this function. Integer value hints
  2515. * are set with @ref glfwWindowHint.
  2516. *
  2517. * This function does not check whether the specified hint values are valid.
  2518. * If you set hints to invalid values this will instead be reported by the next
  2519. * call to @ref glfwCreateWindow.
  2520. *
  2521. * Some hints are platform specific. These may be set on any platform but they
  2522. * will only affect their specific platform. Other platforms will ignore them.
  2523. * Setting these hints requires no platform specific headers or functions.
  2524. *
  2525. * @param[in] hint The [window hint](@ref window_hints) to set.
  2526. * @param[in] value The new value of the window hint.
  2527. *
  2528. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2529. * GLFW_INVALID_ENUM.
  2530. *
  2531. * @pointer_lifetime The specified string is copied before this function
  2532. * returns.
  2533. *
  2534. * @thread_safety This function must only be called from the main thread.
  2535. *
  2536. * @sa @ref window_hints
  2537. * @sa @ref glfwWindowHint
  2538. * @sa @ref glfwDefaultWindowHints
  2539. *
  2540. * @since Added in version 3.3.
  2541. *
  2542. * @ingroup window
  2543. */
  2544. GLFWAPI void glfwWindowHintString(int hint, const char* value);
  2545. /*! @brief Creates a window and its associated context.
  2546. *
  2547. * This function creates a window and its associated OpenGL or OpenGL ES
  2548. * context. Most of the options controlling how the window and its context
  2549. * should be created are specified with [window hints](@ref window_hints).
  2550. *
  2551. * Successful creation does not change which context is current. Before you
  2552. * can use the newly created context, you need to
  2553. * [make it current](@ref context_current). For information about the `share`
  2554. * parameter, see @ref context_sharing.
  2555. *
  2556. * The created window, framebuffer and context may differ from what you
  2557. * requested, as not all parameters and hints are
  2558. * [hard constraints](@ref window_hints_hard). This includes the size of the
  2559. * window, especially for full screen windows. To query the actual attributes
  2560. * of the created window, framebuffer and context, see @ref
  2561. * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
  2562. *
  2563. * To create a full screen window, you need to specify the monitor the window
  2564. * will cover. If no monitor is specified, the window will be windowed mode.
  2565. * Unless you have a way for the user to choose a specific monitor, it is
  2566. * recommended that you pick the primary monitor. For more information on how
  2567. * to query connected monitors, see @ref monitor_monitors.
  2568. *
  2569. * For full screen windows, the specified size becomes the resolution of the
  2570. * window's _desired video mode_. As long as a full screen window is not
  2571. * iconified, the supported video mode most closely matching the desired video
  2572. * mode is set for the specified monitor. For more information about full
  2573. * screen windows, including the creation of so called _windowed full screen_
  2574. * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
  2575. *
  2576. * Once you have created the window, you can switch it between windowed and
  2577. * full screen mode with @ref glfwSetWindowMonitor. This will not affect its
  2578. * OpenGL or OpenGL ES context.
  2579. *
  2580. * By default, newly created windows use the placement recommended by the
  2581. * window system. To create the window at a specific position, make it
  2582. * initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
  2583. * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
  2584. * it.
  2585. *
  2586. * As long as at least one full screen window is not iconified, the screensaver
  2587. * is prohibited from starting.
  2588. *
  2589. * Window systems put limits on window sizes. Very large or very small window
  2590. * dimensions may be overridden by the window system on creation. Check the
  2591. * actual [size](@ref window_size) after creation.
  2592. *
  2593. * The [swap interval](@ref buffer_swap) is not set during window creation and
  2594. * the initial value may vary depending on driver settings and defaults.
  2595. *
  2596. * @param[in] width The desired width, in screen coordinates, of the window.
  2597. * This must be greater than zero.
  2598. * @param[in] height The desired height, in screen coordinates, of the window.
  2599. * This must be greater than zero.
  2600. * @param[in] title The initial, UTF-8 encoded window title.
  2601. * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
  2602. * windowed mode.
  2603. * @param[in] share The window whose context to share resources with, or `NULL`
  2604. * to not share resources.
  2605. * @return The handle of the created window, or `NULL` if an
  2606. * [error](@ref error_handling) occurred.
  2607. *
  2608. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2609. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
  2610. * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
  2611. * GLFW_PLATFORM_ERROR.
  2612. *
  2613. * @remark @win32 Window creation will fail if the Microsoft GDI software
  2614. * OpenGL implementation is the only one available.
  2615. *
  2616. * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
  2617. * will be set as the initial icon for the window. If no such icon is present,
  2618. * the `IDI_APPLICATION` icon will be used instead. To set a different icon,
  2619. * see @ref glfwSetWindowIcon.
  2620. *
  2621. * @remark @win32 The context to share resources with must not be current on
  2622. * any other thread.
  2623. *
  2624. * @remark @macos The OS only supports forward-compatible core profile contexts
  2625. * for OpenGL versions 3.2 and later. Before creating an OpenGL context of
  2626. * version 3.2 or later you must set the
  2627. * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and
  2628. * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly.
  2629. * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
  2630. *
  2631. * @remark @macos The GLFW window has no icon, as it is not a document
  2632. * window, but the dock icon will be the same as the application bundle's icon.
  2633. * For more information on bundles, see the
  2634. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  2635. * in the Mac Developer Library.
  2636. *
  2637. * @remark @macos The first time a window is created the menu bar is created.
  2638. * If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu
  2639. * bar. Otherwise a minimal menu bar is created manually with common commands
  2640. * like Hide, Quit and About. The About entry opens a minimal about dialog
  2641. * with information from the application's bundle. Menu bar creation can be
  2642. * disabled entirely with the @ref GLFW_COCOA_MENUBAR init hint.
  2643. *
  2644. * @remark @macos On OS X 10.10 and later the window frame will not be rendered
  2645. * at full resolution on Retina displays unless the
  2646. * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
  2647. * hint is `true` and the `NSHighResolutionCapable` key is enabled in the
  2648. * application bundle's `Info.plist`. For more information, see
  2649. * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
  2650. * in the Mac Developer Library. The GLFW test and example programs use
  2651. * a custom `Info.plist` template for this, which can be found as
  2652. * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
  2653. *
  2654. * @remark @macos When activating frame autosaving with
  2655. * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
  2656. * window size and position may be overridden by previously saved values.
  2657. *
  2658. * @remark @x11 Some window managers will not respect the placement of
  2659. * initially hidden windows.
  2660. *
  2661. * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
  2662. * a window to reach its requested state. This means you may not be able to
  2663. * query the final size, position or other attributes directly after window
  2664. * creation.
  2665. *
  2666. * @remark @x11 The class part of the `WM_CLASS` window property will by
  2667. * default be set to the window title passed to this function. The instance
  2668. * part will use the contents of the `RESOURCE_NAME` environment variable, if
  2669. * present and not empty, or fall back to the window title. Set the
  2670. * [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
  2671. * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
  2672. * override this.
  2673. *
  2674. * @remark @wayland Compositors should implement the xdg-decoration protocol
  2675. * for GLFW to decorate the window properly. If this protocol isn't
  2676. * supported, or if the compositor prefers client-side decorations, a very
  2677. * simple fallback frame will be drawn using the wp_viewporter protocol. A
  2678. * compositor can still emit close, maximize or fullscreen events, using for
  2679. * instance a keybind mechanism. If neither of these protocols is supported,
  2680. * the window won't be decorated.
  2681. *
  2682. * @remark @wayland A full screen window will not attempt to change the mode,
  2683. * no matter what the requested size or refresh rate.
  2684. *
  2685. * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
  2686. * to be implemented in the user's compositor.
  2687. *
  2688. * @thread_safety This function must only be called from the main thread.
  2689. *
  2690. * @sa @ref window_creation
  2691. * @sa @ref glfwDestroyWindow
  2692. *
  2693. * @since Added in version 3.0. Replaces `glfwOpenWindow`.
  2694. *
  2695. * @ingroup window
  2696. */
  2697. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  2698. GLFWAPI bool glfwToggleFullscreen(GLFWwindow *window, unsigned int flags);
  2699. GLFWAPI bool glfwIsFullscreen(GLFWwindow *window, unsigned int flags);
  2700. GLFWAPI bool glfwAreSwapsAllowed(const GLFWwindow* window);
  2701. /*! @brief Destroys the specified window and its context.
  2702. *
  2703. * This function destroys the specified window and its context. On calling
  2704. * this function, no further callbacks will be called for that window.
  2705. *
  2706. * If the context of the specified window is current on the main thread, it is
  2707. * detached before being destroyed.
  2708. *
  2709. * @param[in] window The window to destroy.
  2710. *
  2711. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2712. * GLFW_PLATFORM_ERROR.
  2713. *
  2714. * @note The context of the specified window must not be current on any other
  2715. * thread when this function is called.
  2716. *
  2717. * @reentrancy This function must not be called from a callback.
  2718. *
  2719. * @thread_safety This function must only be called from the main thread.
  2720. *
  2721. * @sa @ref window_creation
  2722. * @sa @ref glfwCreateWindow
  2723. *
  2724. * @since Added in version 3.0. Replaces `glfwCloseWindow`.
  2725. *
  2726. * @ingroup window
  2727. */
  2728. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  2729. /*! @brief Checks the close flag of the specified window.
  2730. *
  2731. * This function returns the value of the close flag of the specified window.
  2732. *
  2733. * @param[in] window The window to query.
  2734. * @return The value of the close flag.
  2735. *
  2736. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2737. *
  2738. * @thread_safety This function may be called from any thread. Access is not
  2739. * synchronized.
  2740. *
  2741. * @sa @ref window_close
  2742. *
  2743. * @since Added in version 3.0.
  2744. *
  2745. * @ingroup window
  2746. */
  2747. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  2748. /*! @brief Sets the close flag of the specified window.
  2749. *
  2750. * This function sets the value of the close flag of the specified window.
  2751. * This can be used to override the user's attempt to close the window, or
  2752. * to signal that it should be closed.
  2753. *
  2754. * @param[in] window The window whose flag to change.
  2755. * @param[in] value The new value.
  2756. *
  2757. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2758. *
  2759. * @thread_safety This function may be called from any thread. Access is not
  2760. * synchronized.
  2761. *
  2762. * @sa @ref window_close
  2763. *
  2764. * @since Added in version 3.0.
  2765. *
  2766. * @ingroup window
  2767. */
  2768. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  2769. /*! @brief Sets the title of the specified window.
  2770. *
  2771. * This function sets the window title, encoded as UTF-8, of the specified
  2772. * window.
  2773. *
  2774. * @param[in] window The window whose title to change.
  2775. * @param[in] title The UTF-8 encoded window title.
  2776. *
  2777. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2778. * GLFW_PLATFORM_ERROR.
  2779. *
  2780. * @remark @macos The window title will not be updated until the next time you
  2781. * process events.
  2782. *
  2783. * @thread_safety This function must only be called from the main thread.
  2784. *
  2785. * @sa @ref window_title
  2786. *
  2787. * @since Added in version 1.0.
  2788. * @glfw3 Added window handle parameter.
  2789. *
  2790. * @ingroup window
  2791. */
  2792. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  2793. /*! @brief Sets the icon for the specified window.
  2794. *
  2795. * This function sets the icon of the specified window. If passed an array of
  2796. * candidate images, those of or closest to the sizes desired by the system are
  2797. * selected. If no images are specified, the window reverts to its default
  2798. * icon.
  2799. *
  2800. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  2801. * bits per channel with the red channel first. They are arranged canonically
  2802. * as packed sequential rows, starting from the top-left corner.
  2803. *
  2804. * The desired image sizes varies depending on platform and system settings.
  2805. * The selected images will be rescaled as needed. Good sizes include 16x16,
  2806. * 32x32 and 48x48.
  2807. *
  2808. * @param[in] window The window whose icon to set.
  2809. * @param[in] count The number of images in the specified array, or zero to
  2810. * revert to the default window icon.
  2811. * @param[in] images The images to create the icon from. This is ignored if
  2812. * count is zero.
  2813. *
  2814. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2815. * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
  2816. *
  2817. * @pointer_lifetime The specified image data is copied before this function
  2818. * returns.
  2819. *
  2820. * @remark @macos Regular windows do not have icons on macOS. This function
  2821. * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
  2822. * the application bundle's icon. For more information on bundles, see the
  2823. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  2824. * in the Mac Developer Library.
  2825. *
  2826. * @remark @wayland There is no existing protocol to change an icon, the
  2827. * window will thus inherit the one defined in the application's desktop file.
  2828. * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
  2829. *
  2830. * @thread_safety This function must only be called from the main thread.
  2831. *
  2832. * @sa @ref window_icon
  2833. *
  2834. * @since Added in version 3.2.
  2835. *
  2836. * @ingroup window
  2837. */
  2838. GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
  2839. /*! @brief Retrieves the position of the content area of the specified window.
  2840. *
  2841. * This function retrieves the position, in screen coordinates, of the
  2842. * upper-left corner of the content area of the specified window.
  2843. *
  2844. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  2845. * non-`NULL` position arguments will be set to zero.
  2846. *
  2847. * @param[in] window The window to query.
  2848. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  2849. * the content area, or `NULL`.
  2850. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  2851. * the content area, or `NULL`.
  2852. *
  2853. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2854. * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
  2855. *
  2856. * @remark @wayland There is no way for an application to retrieve the global
  2857. * position of its windows. This function will emit @ref
  2858. * GLFW_FEATURE_UNAVAILABLE.
  2859. *
  2860. * @thread_safety This function must only be called from the main thread.
  2861. *
  2862. * @sa @ref window_pos
  2863. * @sa @ref glfwSetWindowPos
  2864. *
  2865. * @since Added in version 3.0.
  2866. *
  2867. * @ingroup window
  2868. */
  2869. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  2870. /*! @brief Sets the position of the content area of the specified window.
  2871. *
  2872. * This function sets the position, in screen coordinates, of the upper-left
  2873. * corner of the content area of the specified windowed mode window. If the
  2874. * window is a full screen window, this function does nothing.
  2875. *
  2876. * __Do not use this function__ to move an already visible window unless you
  2877. * have very good reasons for doing so, as it will confuse and annoy the user.
  2878. *
  2879. * The window manager may put limits on what positions are allowed. GLFW
  2880. * cannot and should not override these limits.
  2881. *
  2882. * @param[in] window The window to query.
  2883. * @param[in] xpos The x-coordinate of the upper-left corner of the content area.
  2884. * @param[in] ypos The y-coordinate of the upper-left corner of the content area.
  2885. *
  2886. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2887. * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
  2888. *
  2889. * @remark @wayland There is no way for an application to set the global
  2890. * position of its windows. This function will emit @ref
  2891. * GLFW_FEATURE_UNAVAILABLE.
  2892. *
  2893. * @thread_safety This function must only be called from the main thread.
  2894. *
  2895. * @sa @ref window_pos
  2896. * @sa @ref glfwGetWindowPos
  2897. *
  2898. * @since Added in version 1.0.
  2899. * @glfw3 Added window handle parameter.
  2900. *
  2901. * @ingroup window
  2902. */
  2903. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  2904. /*! @brief Retrieves the size of the content area of the specified window.
  2905. *
  2906. * This function retrieves the size, in screen coordinates, of the content area
  2907. * of the specified window. If you wish to retrieve the size of the
  2908. * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
  2909. *
  2910. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2911. * non-`NULL` size arguments will be set to zero.
  2912. *
  2913. * @param[in] window The window whose size to retrieve.
  2914. * @param[out] width Where to store the width, in screen coordinates, of the
  2915. * content area, or `NULL`.
  2916. * @param[out] height Where to store the height, in screen coordinates, of the
  2917. * content area, or `NULL`.
  2918. *
  2919. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2920. * GLFW_PLATFORM_ERROR.
  2921. *
  2922. * @thread_safety This function must only be called from the main thread.
  2923. *
  2924. * @sa @ref window_size
  2925. * @sa @ref glfwSetWindowSize
  2926. *
  2927. * @since Added in version 1.0.
  2928. * @glfw3 Added window handle parameter.
  2929. *
  2930. * @ingroup window
  2931. */
  2932. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  2933. /*! @brief Sets the size limits of the specified window.
  2934. *
  2935. * This function sets the size limits of the content area of the specified
  2936. * window. If the window is full screen, the size limits only take effect
  2937. * once it is made windowed. If the window is not resizable, this function
  2938. * does nothing.
  2939. *
  2940. * The size limits are applied immediately to a windowed mode window and may
  2941. * cause it to be resized.
  2942. *
  2943. * The maximum dimensions must be greater than or equal to the minimum
  2944. * dimensions and all must be greater than or equal to zero.
  2945. *
  2946. * @param[in] window The window to set limits for.
  2947. * @param[in] minwidth The minimum width, in screen coordinates, of the content
  2948. * area, or `GLFW_DONT_CARE`.
  2949. * @param[in] minheight The minimum height, in screen coordinates, of the
  2950. * content area, or `GLFW_DONT_CARE`.
  2951. * @param[in] maxwidth The maximum width, in screen coordinates, of the content
  2952. * area, or `GLFW_DONT_CARE`.
  2953. * @param[in] maxheight The maximum height, in screen coordinates, of the
  2954. * content area, or `GLFW_DONT_CARE`.
  2955. *
  2956. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2957. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2958. *
  2959. * @remark If you set size limits and an aspect ratio that conflict, the
  2960. * results are undefined.
  2961. *
  2962. * @remark @wayland The size limits will not be applied until the window is
  2963. * actually resized, either by the user or by the compositor.
  2964. *
  2965. * @thread_safety This function must only be called from the main thread.
  2966. *
  2967. * @sa @ref window_sizelimits
  2968. * @sa @ref glfwSetWindowAspectRatio
  2969. *
  2970. * @since Added in version 3.2.
  2971. *
  2972. * @ingroup window
  2973. */
  2974. GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
  2975. /*! @brief Sets the aspect ratio of the specified window.
  2976. *
  2977. * This function sets the required aspect ratio of the content area of the
  2978. * specified window. If the window is full screen, the aspect ratio only takes
  2979. * effect once it is made windowed. If the window is not resizable, this
  2980. * function does nothing.
  2981. *
  2982. * The aspect ratio is specified as a numerator and a denominator and both
  2983. * values must be greater than zero. For example, the common 16:9 aspect ratio
  2984. * is specified as 16 and 9, respectively.
  2985. *
  2986. * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
  2987. * ratio limit is disabled.
  2988. *
  2989. * The aspect ratio is applied immediately to a windowed mode window and may
  2990. * cause it to be resized.
  2991. *
  2992. * @param[in] window The window to set limits for.
  2993. * @param[in] numer The numerator of the desired aspect ratio, or
  2994. * `GLFW_DONT_CARE`.
  2995. * @param[in] denom The denominator of the desired aspect ratio, or
  2996. * `GLFW_DONT_CARE`.
  2997. *
  2998. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2999. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  3000. *
  3001. * @remark If you set size limits and an aspect ratio that conflict, the
  3002. * results are undefined.
  3003. *
  3004. * @remark @wayland The aspect ratio will not be applied until the window is
  3005. * actually resized, either by the user or by the compositor.
  3006. *
  3007. * @thread_safety This function must only be called from the main thread.
  3008. *
  3009. * @sa @ref window_sizelimits
  3010. * @sa @ref glfwSetWindowSizeLimits
  3011. *
  3012. * @since Added in version 3.2.
  3013. *
  3014. * @ingroup window
  3015. */
  3016. GLFWAPI void glfwSetWindowSizeIncrements(GLFWwindow* window, int widthincr, int heightincr);
  3017. /*! @brief Sets the size increments of the specified window.
  3018. *
  3019. * This function sets the size increments of the content area of the specified
  3020. * window. If the window is full screen, the size limits only take effect
  3021. * once it is made windowed. If the window is not resizable, this function
  3022. * does nothing.
  3023. *
  3024. * The size increments are applied immediately to a windowed mode window and
  3025. * may cause it to be resized.
  3026. *
  3027. * The dimension increments must be greater than zero.
  3028. *
  3029. * @param[in] window The window to set limits for.
  3030. * @param[in] widthincr The width increments, in screen coordinates, of the
  3031. * content area, or `GLFW_DONT_CARE`.
  3032. * @param[in] heightincr The height increments, in screen coordinates, of the
  3033. * content area, or `GLFW_DONT_CARE`.
  3034. *
  3035. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3036. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  3037. *
  3038. * @remark If you set size limits and an aspect ratio that conflict, the
  3039. * results are undefined.
  3040. *
  3041. * @remark @wayland The size limits will not be applied until the window is
  3042. * actually resized, either by the user or by the compositor.
  3043. *
  3044. * @thread_safety This function must only be called from the main thread.
  3045. *
  3046. * @sa @ref window_sizelimits
  3047. * @sa @ref glfwSetWindowSizeLimits
  3048. *
  3049. * @since Added in version 3.2.
  3050. *
  3051. * @ingroup window
  3052. */
  3053. GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
  3054. /*! @brief Sets the size of the content area of the specified window.
  3055. *
  3056. * This function sets the size, in screen coordinates, of the content area of
  3057. * the specified window.
  3058. *
  3059. * For full screen windows, this function updates the resolution of its desired
  3060. * video mode and switches to the video mode closest to it, without affecting
  3061. * the window's context. As the context is unaffected, the bit depths of the
  3062. * framebuffer remain unchanged.
  3063. *
  3064. * If you wish to update the refresh rate of the desired video mode in addition
  3065. * to its resolution, see @ref glfwSetWindowMonitor.
  3066. *
  3067. * The window manager may put limits on what sizes are allowed. GLFW cannot
  3068. * and should not override these limits.
  3069. *
  3070. * @param[in] window The window to resize.
  3071. * @param[in] width The desired width, in screen coordinates, of the window
  3072. * content area.
  3073. * @param[in] height The desired height, in screen coordinates, of the window
  3074. * content area.
  3075. *
  3076. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3077. * GLFW_PLATFORM_ERROR.
  3078. *
  3079. * @remark @wayland A full screen window will not attempt to change the mode,
  3080. * no matter what the requested size.
  3081. *
  3082. * @thread_safety This function must only be called from the main thread.
  3083. *
  3084. * @sa @ref window_size
  3085. * @sa @ref glfwGetWindowSize
  3086. * @sa @ref glfwSetWindowMonitor
  3087. *
  3088. * @since Added in version 1.0.
  3089. * @glfw3 Added window handle parameter.
  3090. *
  3091. * @ingroup window
  3092. */
  3093. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  3094. /*! @brief Retrieves the size of the framebuffer of the specified window.
  3095. *
  3096. * This function retrieves the size, in pixels, of the framebuffer of the
  3097. * specified window. If you wish to retrieve the size of the window in screen
  3098. * coordinates, see @ref glfwGetWindowSize.
  3099. *
  3100. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  3101. * non-`NULL` size arguments will be set to zero.
  3102. *
  3103. * @param[in] window The window whose framebuffer to query.
  3104. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  3105. * or `NULL`.
  3106. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  3107. * or `NULL`.
  3108. *
  3109. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3110. * GLFW_PLATFORM_ERROR.
  3111. *
  3112. * @thread_safety This function must only be called from the main thread.
  3113. *
  3114. * @sa @ref window_fbsize
  3115. * @sa @ref glfwSetFramebufferSizeCallback
  3116. *
  3117. * @since Added in version 3.0.
  3118. *
  3119. * @ingroup window
  3120. */
  3121. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  3122. /*! @brief Retrieves the size of the frame of the window.
  3123. *
  3124. * This function retrieves the size, in screen coordinates, of each edge of the
  3125. * frame of the specified window. This size includes the title bar, if the
  3126. * window has one. The size of the frame may vary depending on the
  3127. * [window-related hints](@ref window_hints_wnd) used to create it.
  3128. *
  3129. * Because this function retrieves the size of each window frame edge and not
  3130. * the offset along a particular coordinate axis, the retrieved values will
  3131. * always be zero or positive.
  3132. *
  3133. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  3134. * non-`NULL` size arguments will be set to zero.
  3135. *
  3136. * @param[in] window The window whose frame size to query.
  3137. * @param[out] left Where to store the size, in screen coordinates, of the left
  3138. * edge of the window frame, or `NULL`.
  3139. * @param[out] top Where to store the size, in screen coordinates, of the top
  3140. * edge of the window frame, or `NULL`.
  3141. * @param[out] right Where to store the size, in screen coordinates, of the
  3142. * right edge of the window frame, or `NULL`.
  3143. * @param[out] bottom Where to store the size, in screen coordinates, of the
  3144. * bottom edge of the window frame, or `NULL`.
  3145. *
  3146. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3147. * GLFW_PLATFORM_ERROR.
  3148. *
  3149. * @thread_safety This function must only be called from the main thread.
  3150. *
  3151. * @sa @ref window_size
  3152. *
  3153. * @since Added in version 3.1.
  3154. *
  3155. * @ingroup window
  3156. */
  3157. GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
  3158. /*! @brief Retrieves the content scale for the specified window.
  3159. *
  3160. * This function retrieves the content scale for the specified window. The
  3161. * content scale is the ratio between the current DPI and the platform's
  3162. * default DPI. This is especially important for text and any UI elements. If
  3163. * the pixel dimensions of your UI scaled by this look appropriate on your
  3164. * machine then it should appear at a reasonable size on other machines
  3165. * regardless of their DPI and scaling settings. This relies on the system DPI
  3166. * and scaling settings being somewhat correct.
  3167. *
  3168. * On systems where each monitors can have its own content scale, the window
  3169. * content scale will depend on which monitor the system considers the window
  3170. * to be on.
  3171. *
  3172. * @param[in] window The window to query.
  3173. * @param[out] xscale Where to store the x-axis content scale, or `NULL`.
  3174. * @param[out] yscale Where to store the y-axis content scale, or `NULL`.
  3175. *
  3176. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3177. * GLFW_PLATFORM_ERROR.
  3178. *
  3179. * @thread_safety This function must only be called from the main thread.
  3180. *
  3181. * @sa @ref window_scale
  3182. * @sa @ref glfwSetWindowContentScaleCallback
  3183. * @sa @ref glfwGetMonitorContentScale
  3184. *
  3185. * @since Added in version 3.3.
  3186. *
  3187. * @ingroup window
  3188. */
  3189. GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
  3190. /*! @brief Returns the double click time interval.
  3191. *
  3192. * This function returns the maximum time between clicks to count as a
  3193. * double click.
  3194. *
  3195. * The double click interval is a positive finite number greater than zero,
  3196. * where zero means that no click is ever recognized as a double click. If the
  3197. * system does not support a double click interval, this function always returns one half.
  3198. *
  3199. * @return The double click interval.
  3200. *
  3201. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3202. * GLFW_PLATFORM_ERROR.
  3203. *
  3204. * @thread_safety This function must only be called from the main thread.
  3205. *
  3206. * @sa @ref double_click
  3207. * @sa @ref click_interval
  3208. * @sa @ref double_click_interval
  3209. *
  3210. * @since Added in version 3.3.
  3211. *
  3212. * @ingroup window
  3213. */
  3214. GLFWAPI monotonic_t glfwGetDoubleClickInterval(GLFWwindow* window);
  3215. /*! @brief Returns the opacity of the whole window.
  3216. *
  3217. * This function returns the opacity of the window, including any decorations.
  3218. *
  3219. * The opacity (or alpha) value is a positive finite number between zero and
  3220. * one, where zero is fully transparent and one is fully opaque. If the system
  3221. * does not support whole window transparency, this function always returns one.
  3222. *
  3223. * The initial opacity value for newly created windows is one.
  3224. *
  3225. * @param[in] window The window to query.
  3226. * @return The opacity value of the specified window.
  3227. *
  3228. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3229. * GLFW_PLATFORM_ERROR.
  3230. *
  3231. * @thread_safety This function must only be called from the main thread.
  3232. *
  3233. * @sa @ref window_transparency
  3234. * @sa @ref glfwSetWindowOpacity
  3235. *
  3236. * @since Added in version 3.3.
  3237. *
  3238. * @ingroup window
  3239. */
  3240. GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
  3241. /*! @brief Sets the opacity of the whole window.
  3242. *
  3243. * This function sets the opacity of the window, including any decorations.
  3244. *
  3245. * The opacity (or alpha) value is a positive finite number between zero and
  3246. * one, where zero is fully transparent and one is fully opaque.
  3247. *
  3248. * The initial opacity value for newly created windows is one.
  3249. *
  3250. * A window created with framebuffer transparency may not use whole window
  3251. * transparency. The results of doing this are undefined.
  3252. *
  3253. * @param[in] window The window to set the opacity for.
  3254. * @param[in] opacity The desired opacity of the specified window.
  3255. *
  3256. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3257. * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
  3258. *
  3259. * @remark @wayland There is no way to set an opacity factor for a window.
  3260. * This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
  3261. *
  3262. * @thread_safety This function must only be called from the main thread.
  3263. *
  3264. * @sa @ref window_transparency
  3265. * @sa @ref glfwGetWindowOpacity
  3266. *
  3267. * @since Added in version 3.3.
  3268. *
  3269. * @ingroup window
  3270. */
  3271. GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
  3272. /*! @brief Iconifies the specified window.
  3273. *
  3274. * This function iconifies (minimizes) the specified window if it was
  3275. * previously restored. If the window is already iconified, this function does
  3276. * nothing.
  3277. *
  3278. * If the specified window is a full screen window, the original monitor
  3279. * resolution is restored until the window is restored.
  3280. *
  3281. * @param[in] window The window to iconify.
  3282. *
  3283. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3284. * GLFW_PLATFORM_ERROR.
  3285. *
  3286. * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
  3287. * be able to restore it. This is a design decision of the xdg-shell
  3288. * protocol.
  3289. *
  3290. * @thread_safety This function must only be called from the main thread.
  3291. *
  3292. * @sa @ref window_iconify
  3293. * @sa @ref glfwRestoreWindow
  3294. * @sa @ref glfwMaximizeWindow
  3295. *
  3296. * @since Added in version 2.1.
  3297. * @glfw3 Added window handle parameter.
  3298. *
  3299. * @ingroup window
  3300. */
  3301. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  3302. /*! @brief Restores the specified window.
  3303. *
  3304. * This function restores the specified window if it was previously iconified
  3305. * (minimized) or maximized. If the window is already restored, this function
  3306. * does nothing.
  3307. *
  3308. * If the specified window is a full screen window, the resolution chosen for
  3309. * the window is restored on the selected monitor.
  3310. *
  3311. * @param[in] window The window to restore.
  3312. *
  3313. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3314. * GLFW_PLATFORM_ERROR.
  3315. *
  3316. * @thread_safety This function must only be called from the main thread.
  3317. *
  3318. * @sa @ref window_iconify
  3319. * @sa @ref glfwIconifyWindow
  3320. * @sa @ref glfwMaximizeWindow
  3321. *
  3322. * @since Added in version 2.1.
  3323. * @glfw3 Added window handle parameter.
  3324. *
  3325. * @ingroup window
  3326. */
  3327. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  3328. /*! @brief Maximizes the specified window.
  3329. *
  3330. * This function maximizes the specified window if it was previously not
  3331. * maximized. If the window is already maximized, this function does nothing.
  3332. *
  3333. * If the specified window is a full screen window, this function does nothing.
  3334. *
  3335. * @param[in] window The window to maximize.
  3336. *
  3337. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3338. * GLFW_PLATFORM_ERROR.
  3339. *
  3340. * @par Thread Safety
  3341. * This function may only be called from the main thread.
  3342. *
  3343. * @sa @ref window_iconify
  3344. * @sa @ref glfwIconifyWindow
  3345. * @sa @ref glfwRestoreWindow
  3346. *
  3347. * @since Added in GLFW 3.2.
  3348. *
  3349. * @ingroup window
  3350. */
  3351. GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
  3352. /*! @brief Makes the specified window visible.
  3353. *
  3354. * This function makes the specified window visible if it was previously
  3355. * hidden. If the window is already visible or is in full screen mode, this
  3356. * function does nothing.
  3357. *
  3358. * By default, windowed mode windows are focused when shown
  3359. * Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
  3360. * to change this behavior for all newly created windows, or change the
  3361. * behavior for an existing window with @ref glfwSetWindowAttrib.
  3362. *
  3363. * @param[in] window The window to make visible.
  3364. *
  3365. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3366. * GLFW_PLATFORM_ERROR.
  3367. *
  3368. * @thread_safety This function must only be called from the main thread.
  3369. *
  3370. * @sa @ref window_hide
  3371. * @sa @ref glfwHideWindow
  3372. *
  3373. * @since Added in version 3.0.
  3374. *
  3375. * @ingroup window
  3376. */
  3377. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  3378. /*! @brief Hides the specified window.
  3379. *
  3380. * This function hides the specified window if it was previously visible. If
  3381. * the window is already hidden or is in full screen mode, this function does
  3382. * nothing.
  3383. *
  3384. * @param[in] window The window to hide.
  3385. *
  3386. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3387. * GLFW_PLATFORM_ERROR.
  3388. *
  3389. * @thread_safety This function must only be called from the main thread.
  3390. *
  3391. * @sa @ref window_hide
  3392. * @sa @ref glfwShowWindow
  3393. *
  3394. * @since Added in version 3.0.
  3395. *
  3396. * @ingroup window
  3397. */
  3398. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  3399. /*! @brief Brings the specified window to front and sets input focus.
  3400. *
  3401. * This function brings the specified window to front and sets input focus.
  3402. * The window should already be visible and not iconified.
  3403. *
  3404. * By default, both windowed and full screen mode windows are focused when
  3405. * initially created. Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
  3406. * disable this behavior.
  3407. *
  3408. * Also by default, windowed mode windows are focused when shown
  3409. * with @ref glfwShowWindow. Set the
  3410. * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
  3411. *
  3412. * __Do not use this function__ to steal focus from other applications unless
  3413. * you are certain that is what the user wants. Focus stealing can be
  3414. * extremely disruptive.
  3415. *
  3416. * For a less disruptive way of getting the user's attention, see
  3417. * [attention requests](@ref window_attention).
  3418. *
  3419. * @param[in] window The window to give input focus.
  3420. *
  3421. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3422. * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
  3423. *
  3424. * @remark @wayland It is not possible for an application to set the input
  3425. * focus. This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
  3426. *
  3427. * @thread_safety This function must only be called from the main thread.
  3428. *
  3429. * @sa @ref window_focus
  3430. * @sa @ref window_attention
  3431. *
  3432. * @since Added in version 3.2.
  3433. *
  3434. * @ingroup window
  3435. */
  3436. GLFWAPI void glfwFocusWindow(GLFWwindow* window);
  3437. /*! @brief Requests user attention to the specified window.
  3438. *
  3439. * This function requests user attention to the specified window. On
  3440. * platforms where this is not supported, attention is requested to the
  3441. * application as a whole.
  3442. *
  3443. * Once the user has given attention, usually by focusing the window or
  3444. * application, the system will end the request automatically.
  3445. *
  3446. * @param[in] window The window to request attention to.
  3447. *
  3448. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3449. * GLFW_PLATFORM_ERROR.
  3450. *
  3451. * @remark @macos Attention is requested to the application as a whole, not the
  3452. * specific window.
  3453. *
  3454. * @thread_safety This function must only be called from the main thread.
  3455. *
  3456. * @sa @ref window_attention
  3457. *
  3458. * @since Added in version 3.3.
  3459. *
  3460. * @ingroup window
  3461. */
  3462. GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
  3463. /*! @brief Sounds an audible bell associated with the window
  3464. *
  3465. * This function sounds an audible bell, on platforms where it is
  3466. * supported. Currently (macOS, Windows, X11 and Wayland).
  3467. *
  3468. * @param[in] window The window with which the bell is associated.
  3469. * @return true if the bell succeeded otherwise false
  3470. *
  3471. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3472. * GLFW_PLATFORM_ERROR.
  3473. *
  3474. * @remark @macos Bell is associated to the application as a whole, not the
  3475. * specific window.
  3476. *
  3477. * @thread_safety This function must only be called from the main thread.
  3478. *
  3479. * @since Added in version 3.3.
  3480. *
  3481. * @ingroup window
  3482. */
  3483. GLFWAPI int glfwWindowBell(GLFWwindow* window);
  3484. /*! @brief Returns the monitor that the window uses for full screen mode.
  3485. *
  3486. * This function returns the handle of the monitor that the specified window is
  3487. * in full screen on.
  3488. *
  3489. * @param[in] window The window to query.
  3490. * @return The monitor, or `NULL` if the window is in windowed mode or an
  3491. * [error](@ref error_handling) occurred.
  3492. *
  3493. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3494. *
  3495. * @thread_safety This function must only be called from the main thread.
  3496. *
  3497. * @sa @ref window_monitor
  3498. * @sa @ref glfwSetWindowMonitor
  3499. *
  3500. * @since Added in version 3.0.
  3501. *
  3502. * @ingroup window
  3503. */
  3504. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  3505. /*! @brief Sets the mode, monitor, video mode and placement of a window.
  3506. *
  3507. * This function sets the monitor that the window uses for full screen mode or,
  3508. * if the monitor is `NULL`, makes it windowed mode.
  3509. *
  3510. * When setting a monitor, this function updates the width, height and refresh
  3511. * rate of the desired video mode and switches to the video mode closest to it.
  3512. * The window position is ignored when setting a monitor.
  3513. *
  3514. * When the monitor is `NULL`, the position, width and height are used to
  3515. * place the window content area. The refresh rate is ignored when no monitor
  3516. * is specified.
  3517. *
  3518. * If you only wish to update the resolution of a full screen window or the
  3519. * size of a windowed mode window, see @ref glfwSetWindowSize.
  3520. *
  3521. * When a window transitions from full screen to windowed mode, this function
  3522. * restores any previous window settings such as whether it is decorated,
  3523. * floating, resizable, has size or aspect ratio limits, etc.
  3524. *
  3525. * @param[in] window The window whose monitor, size or video mode to set.
  3526. * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
  3527. * @param[in] xpos The desired x-coordinate of the upper-left corner of the
  3528. * content area.
  3529. * @param[in] ypos The desired y-coordinate of the upper-left corner of the
  3530. * content area.
  3531. * @param[in] width The desired with, in screen coordinates, of the content
  3532. * area or video mode.
  3533. * @param[in] height The desired height, in screen coordinates, of the content
  3534. * area or video mode.
  3535. * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
  3536. * or `GLFW_DONT_CARE`.
  3537. *
  3538. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3539. * GLFW_PLATFORM_ERROR.
  3540. *
  3541. * @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
  3542. * affected by any resizing or mode switching, although you may need to update
  3543. * your viewport if the framebuffer size has changed.
  3544. *
  3545. * @remark @wayland The desired window position is ignored, as there is no way
  3546. * for an application to set this property.
  3547. *
  3548. * @remark @wayland Setting the window to full screen will not attempt to
  3549. * change the mode, no matter what the requested size or refresh rate.
  3550. *
  3551. * @thread_safety This function must only be called from the main thread.
  3552. *
  3553. * @sa @ref window_monitor
  3554. * @sa @ref window_full_screen
  3555. * @sa @ref glfwGetWindowMonitor
  3556. * @sa @ref glfwSetWindowSize
  3557. *
  3558. * @since Added in version 3.2.
  3559. *
  3560. * @ingroup window
  3561. */
  3562. GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
  3563. /*! @brief Returns an attribute of the specified window.
  3564. *
  3565. * This function returns the value of an attribute of the specified window or
  3566. * its OpenGL or OpenGL ES context.
  3567. *
  3568. * @param[in] window The window to query.
  3569. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  3570. * return.
  3571. * @return The value of the attribute, or zero if an
  3572. * [error](@ref error_handling) occurred.
  3573. *
  3574. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3575. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3576. *
  3577. * @remark Framebuffer related hints are not window attributes. See @ref
  3578. * window_attribs_fb for more information.
  3579. *
  3580. * @remark Zero is a valid value for many window and context related
  3581. * attributes so you cannot use a return value of zero as an indication of
  3582. * errors. However, this function should not fail as long as it is passed
  3583. * valid arguments and the library has been [initialized](@ref intro_init).
  3584. *
  3585. * @thread_safety This function must only be called from the main thread.
  3586. *
  3587. * @sa @ref window_attribs
  3588. * @sa @ref glfwSetWindowAttrib
  3589. *
  3590. * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
  3591. * `glfwGetGLVersion`.
  3592. *
  3593. * @ingroup window
  3594. */
  3595. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  3596. /*! @brief Sets an attribute of the specified window.
  3597. *
  3598. * This function sets the value of an attribute of the specified window.
  3599. *
  3600. * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
  3601. * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
  3602. * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
  3603. * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
  3604. * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
  3605. * [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
  3606. *
  3607. * Some of these attributes are ignored for full screen windows. The new
  3608. * value will take effect if the window is later made windowed.
  3609. *
  3610. * Some of these attributes are ignored for windowed mode windows. The new
  3611. * value will take effect if the window is later made full screen.
  3612. *
  3613. * @param[in] window The window to set the attribute for.
  3614. * @param[in] attrib A supported window attribute.
  3615. * @param[in] value `true` or `false`.
  3616. *
  3617. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3618. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  3619. *
  3620. * @remark Calling @ref glfwGetWindowAttrib will always return the latest
  3621. * value, even if that value is ignored by the current mode of the window.
  3622. *
  3623. * @thread_safety This function must only be called from the main thread.
  3624. *
  3625. * @sa @ref window_attribs
  3626. * @sa @ref glfwGetWindowAttrib
  3627. *
  3628. * @since Added in version 3.3.
  3629. *
  3630. * @ingroup window
  3631. */
  3632. GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
  3633. GLFWAPI int glfwSetWindowBlur(GLFWwindow* window, int value);
  3634. /*! @brief Sets the user pointer of the specified window.
  3635. *
  3636. * This function sets the user-defined pointer of the specified window. The
  3637. * current value is retained until the window is destroyed. The initial value
  3638. * is `NULL`.
  3639. *
  3640. * @param[in] window The window whose pointer to set.
  3641. * @param[in] pointer The new value.
  3642. *
  3643. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3644. *
  3645. * @thread_safety This function may be called from any thread. Access is not
  3646. * synchronized.
  3647. *
  3648. * @sa @ref window_userptr
  3649. * @sa @ref glfwGetWindowUserPointer
  3650. *
  3651. * @since Added in version 3.0.
  3652. *
  3653. * @ingroup window
  3654. */
  3655. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  3656. /*! @brief Returns the user pointer of the specified window.
  3657. *
  3658. * This function returns the current value of the user-defined pointer of the
  3659. * specified window. The initial value is `NULL`.
  3660. *
  3661. * @param[in] window The window whose pointer to return.
  3662. *
  3663. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3664. *
  3665. * @thread_safety This function may be called from any thread. Access is not
  3666. * synchronized.
  3667. *
  3668. * @sa @ref window_userptr
  3669. * @sa @ref glfwSetWindowUserPointer
  3670. *
  3671. * @since Added in version 3.0.
  3672. *
  3673. * @ingroup window
  3674. */
  3675. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  3676. /*! @brief Sets the position callback for the specified window.
  3677. *
  3678. * This function sets the position callback of the specified window, which is
  3679. * called when the window is moved. The callback is provided with the
  3680. * position, in screen coordinates, of the upper-left corner of the content
  3681. * area of the window.
  3682. *
  3683. * @param[in] window The window whose callback to set.
  3684. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3685. * callback.
  3686. * @return The previously set callback, or `NULL` if no callback was set or the
  3687. * library had not been [initialized](@ref intro_init).
  3688. *
  3689. * @callback_signature
  3690. * @code
  3691. * void function_name(GLFWwindow* window, int xpos, int ypos)
  3692. * @endcode
  3693. * For more information about the callback parameters, see the
  3694. * [function pointer type](@ref GLFWwindowposfun).
  3695. *
  3696. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3697. *
  3698. * @remark @wayland This callback will never be called, as there is no way for
  3699. * an application to know its global position.
  3700. *
  3701. * @thread_safety This function must only be called from the main thread.
  3702. *
  3703. * @sa @ref window_pos
  3704. *
  3705. * @since Added in version 3.0.
  3706. *
  3707. * @ingroup window
  3708. */
  3709. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
  3710. /*! @brief Sets the size callback for the specified window.
  3711. *
  3712. * This function sets the size callback of the specified window, which is
  3713. * called when the window is resized. The callback is provided with the size,
  3714. * in screen coordinates, of the content area of the window.
  3715. *
  3716. * @param[in] window The window whose callback to set.
  3717. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3718. * callback.
  3719. * @return The previously set callback, or `NULL` if no callback was set or the
  3720. * library had not been [initialized](@ref intro_init).
  3721. *
  3722. * @callback_signature
  3723. * @code
  3724. * void function_name(GLFWwindow* window, int width, int height)
  3725. * @endcode
  3726. * For more information about the callback parameters, see the
  3727. * [function pointer type](@ref GLFWwindowsizefun).
  3728. *
  3729. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3730. *
  3731. * @thread_safety This function must only be called from the main thread.
  3732. *
  3733. * @sa @ref window_size
  3734. *
  3735. * @since Added in version 1.0.
  3736. * @glfw3 Added window handle parameter and return value.
  3737. *
  3738. * @ingroup window
  3739. */
  3740. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
  3741. /*! @brief Sets the close callback for the specified window.
  3742. *
  3743. * This function sets the close callback of the specified window, which is
  3744. * called when the user attempts to close the window, for example by clicking
  3745. * the close widget in the title bar.
  3746. *
  3747. * The close flag is set before this callback is called, but you can modify it
  3748. * at any time with @ref glfwSetWindowShouldClose.
  3749. *
  3750. * The close callback is not triggered by @ref glfwDestroyWindow.
  3751. *
  3752. * @param[in] window The window whose callback to set.
  3753. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3754. * callback.
  3755. * @return The previously set callback, or `NULL` if no callback was set or the
  3756. * library had not been [initialized](@ref intro_init).
  3757. *
  3758. * @callback_signature
  3759. * @code
  3760. * void function_name(GLFWwindow* window)
  3761. * @endcode
  3762. * For more information about the callback parameters, see the
  3763. * [function pointer type](@ref GLFWwindowclosefun).
  3764. *
  3765. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3766. *
  3767. * @remark @macos Selecting Quit from the application menu will trigger the
  3768. * close callback for all windows.
  3769. *
  3770. * @thread_safety This function must only be called from the main thread.
  3771. *
  3772. * @sa @ref window_close
  3773. *
  3774. * @since Added in version 2.5.
  3775. * @glfw3 Added window handle parameter and return value.
  3776. *
  3777. * @ingroup window
  3778. */
  3779. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
  3780. GLFWAPI GLFWapplicationclosefun glfwSetApplicationCloseCallback(GLFWapplicationclosefun callback);
  3781. GLFWAPI GLFWsystemcolorthemechangefun glfwSetSystemColorThemeChangeCallback(GLFWsystemcolorthemechangefun callback);
  3782. GLFWAPI GLFWColorScheme glfwGetCurrentSystemColorTheme(bool query_if_unintialized);
  3783. /*! @brief Sets the refresh callback for the specified window.
  3784. *
  3785. * This function sets the refresh callback of the specified window, which is
  3786. * called when the content area of the window needs to be redrawn, for example
  3787. * if the window has been exposed after having been covered by another window.
  3788. *
  3789. * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
  3790. * the window contents are saved off-screen, this callback may be called only
  3791. * very infrequently or never at all.
  3792. *
  3793. * @param[in] window The window whose callback to set.
  3794. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3795. * callback.
  3796. * @return The previously set callback, or `NULL` if no callback was set or the
  3797. * library had not been [initialized](@ref intro_init).
  3798. *
  3799. * @callback_signature
  3800. * @code
  3801. * void function_name(GLFWwindow* window);
  3802. * @endcode
  3803. * For more information about the callback parameters, see the
  3804. * [function pointer type](@ref GLFWwindowrefreshfun).
  3805. *
  3806. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3807. *
  3808. * @thread_safety This function must only be called from the main thread.
  3809. *
  3810. * @sa @ref window_refresh
  3811. *
  3812. * @since Added in version 2.5.
  3813. * @glfw3 Added window handle parameter and return value.
  3814. *
  3815. * @ingroup window
  3816. */
  3817. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
  3818. /*! @brief Sets the focus callback for the specified window.
  3819. *
  3820. * This function sets the focus callback of the specified window, which is
  3821. * called when the window gains or loses input focus.
  3822. *
  3823. * After the focus callback is called for a window that lost input focus,
  3824. * synthetic key and mouse button release events will be generated for all such
  3825. * that had been pressed. For more information, see @ref glfwSetKeyCallback
  3826. * and @ref glfwSetMouseButtonCallback.
  3827. *
  3828. * @param[in] window The window whose callback to set.
  3829. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3830. * callback.
  3831. * @return The previously set callback, or `NULL` if no callback was set or the
  3832. * library had not been [initialized](@ref intro_init).
  3833. *
  3834. * @callback_signature
  3835. * @code
  3836. * void function_name(GLFWwindow* window, int focused)
  3837. * @endcode
  3838. * For more information about the callback parameters, see the
  3839. * [function pointer type](@ref GLFWwindowfocusfun).
  3840. *
  3841. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3842. *
  3843. * @thread_safety This function must only be called from the main thread.
  3844. *
  3845. * @sa @ref window_focus
  3846. *
  3847. * @since Added in version 3.0.
  3848. *
  3849. * @ingroup window
  3850. */
  3851. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
  3852. /*! @brief Sets the occlusion callback for the specified window.
  3853. *
  3854. * This function sets the occlusion callback of the specified window, which is
  3855. * called when the window becomes (fully) occluded by other windows or when (a
  3856. * part of) the window becomes visible again because an overlapping window is
  3857. * moved away.
  3858. *
  3859. * @param[in] window The window whose callback to set.
  3860. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3861. * callback.
  3862. * @return The previously set callback, or `NULL` if no callback was set or the
  3863. * library had not been [initialized](@ref intro_init).
  3864. *
  3865. * @callback_signature
  3866. * @code
  3867. * void function_name(GLFWwindow* window, int iconified)
  3868. * @endcode
  3869. * For more information about the callback parameters, see the
  3870. * [function pointer type](@ref GLFWwindowiconifyfun).
  3871. *
  3872. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3873. *
  3874. * @thread_safety This function must only be called from the main thread.
  3875. *
  3876. * @sa @ref window_occlusion
  3877. *
  3878. * @since Added in version 3.3.
  3879. *
  3880. * @ingroup window
  3881. */
  3882. GLFWAPI GLFWwindowocclusionfun glfwSetWindowOcclusionCallback(GLFWwindow* window, GLFWwindowocclusionfun callback);
  3883. /*! @brief Sets the iconify callback for the specified window.
  3884. *
  3885. * This function sets the iconification callback of the specified window, which
  3886. * is called when the window is iconified or restored.
  3887. *
  3888. * @param[in] window The window whose callback to set.
  3889. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3890. * callback.
  3891. * @return The previously set callback, or `NULL` if no callback was set or the
  3892. * library had not been [initialized](@ref intro_init).
  3893. *
  3894. * @callback_signature
  3895. * @code
  3896. * void function_name(GLFWwindow* window, int iconified)
  3897. * @endcode
  3898. * For more information about the callback parameters, see the
  3899. * [function pointer type](@ref GLFWwindowiconifyfun).
  3900. *
  3901. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3902. *
  3903. * @thread_safety This function must only be called from the main thread.
  3904. *
  3905. * @sa @ref window_iconify
  3906. *
  3907. * @since Added in version 3.0.
  3908. *
  3909. * @ingroup window
  3910. */
  3911. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
  3912. /*! @brief Sets the maximize callback for the specified window.
  3913. *
  3914. * This function sets the maximization callback of the specified window, which
  3915. * is called when the window is maximized or restored.
  3916. *
  3917. * @param[in] window The window whose callback to set.
  3918. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3919. * callback.
  3920. * @return The previously set callback, or `NULL` if no callback was set or the
  3921. * library had not been [initialized](@ref intro_init).
  3922. *
  3923. * @callback_signature
  3924. * @code
  3925. * void function_name(GLFWwindow* window, int maximized)
  3926. * @endcode
  3927. * For more information about the callback parameters, see the
  3928. * [function pointer type](@ref GLFWwindowmaximizefun).
  3929. *
  3930. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3931. *
  3932. * @thread_safety This function must only be called from the main thread.
  3933. *
  3934. * @sa @ref window_maximize
  3935. *
  3936. * @since Added in version 3.3.
  3937. *
  3938. * @ingroup window
  3939. */
  3940. GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
  3941. /*! @brief Sets the framebuffer resize callback for the specified window.
  3942. *
  3943. * This function sets the framebuffer resize callback of the specified window,
  3944. * which is called when the framebuffer of the specified window is resized.
  3945. *
  3946. * @param[in] window The window whose callback to set.
  3947. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3948. * callback.
  3949. * @return The previously set callback, or `NULL` if no callback was set or the
  3950. * library had not been [initialized](@ref intro_init).
  3951. *
  3952. * @callback_signature
  3953. * @code
  3954. * void function_name(GLFWwindow* window, int width, int height)
  3955. * @endcode
  3956. * For more information about the callback parameters, see the
  3957. * [function pointer type](@ref GLFWframebuffersizefun).
  3958. *
  3959. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3960. *
  3961. * @thread_safety This function must only be called from the main thread.
  3962. *
  3963. * @sa @ref window_fbsize
  3964. *
  3965. * @since Added in version 3.0.
  3966. *
  3967. * @ingroup window
  3968. */
  3969. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
  3970. /*! @brief Sets the window content scale callback for the specified window.
  3971. *
  3972. * This function sets the window content scale callback of the specified window,
  3973. * which is called when the content scale of the specified window changes.
  3974. *
  3975. * @param[in] window The window whose callback to set.
  3976. * @param[in] callback The new callback, or `NULL` to remove the currently set
  3977. * callback.
  3978. * @return The previously set callback, or `NULL` if no callback was set or the
  3979. * library had not been [initialized](@ref intro_init).
  3980. *
  3981. * @callback_signature
  3982. * @code
  3983. * void function_name(GLFWwindow* window, float xscale, float yscale)
  3984. * @endcode
  3985. * For more information about the callback parameters, see the
  3986. * [function pointer type](@ref GLFWwindowcontentscalefun).
  3987. *
  3988. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3989. *
  3990. * @thread_safety This function must only be called from the main thread.
  3991. *
  3992. * @sa @ref window_scale
  3993. * @sa @ref glfwGetWindowContentScale
  3994. *
  3995. * @since Added in version 3.3.
  3996. *
  3997. * @ingroup window
  3998. */
  3999. GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
  4000. /*! @brief Posts an empty event to the event queue.
  4001. *
  4002. * This function posts an empty event from the current thread to the event
  4003. * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
  4004. *
  4005. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4006. * GLFW_PLATFORM_ERROR.
  4007. *
  4008. * @thread_safety This function may be called from any thread.
  4009. *
  4010. * @sa @ref events
  4011. * @sa @ref glfwWaitEvents
  4012. * @sa @ref glfwWaitEventsTimeout
  4013. *
  4014. * @since Added in version 3.1.
  4015. *
  4016. * @ingroup window
  4017. */
  4018. GLFWAPI void glfwPostEmptyEvent(void);
  4019. GLFWAPI bool glfwGetIgnoreOSKeyboardProcessing(void);
  4020. GLFWAPI void glfwSetIgnoreOSKeyboardProcessing(bool enabled);
  4021. /*! @brief Returns the value of an input option for the specified window.
  4022. *
  4023. * This function returns the value of an input option for the specified window.
  4024. * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  4025. * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
  4026. * @ref GLFW_RAW_MOUSE_MOTION.
  4027. *
  4028. * @param[in] window The window to query.
  4029. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  4030. * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
  4031. * `GLFW_RAW_MOUSE_MOTION`.
  4032. *
  4033. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4034. * GLFW_INVALID_ENUM.
  4035. *
  4036. * @thread_safety This function must only be called from the main thread.
  4037. *
  4038. * @sa @ref glfwSetInputMode
  4039. *
  4040. * @since Added in version 3.0.
  4041. *
  4042. * @ingroup input
  4043. */
  4044. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  4045. /*! @brief Sets an input option for the specified window.
  4046. *
  4047. * This function sets an input mode option for the specified window. The mode
  4048. * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  4049. * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
  4050. * @ref GLFW_RAW_MOUSE_MOTION.
  4051. *
  4052. * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  4053. * modes:
  4054. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  4055. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
  4056. * content area of the window but does not restrict the cursor from leaving.
  4057. * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  4058. * and unlimited cursor movement. This is useful for implementing for
  4059. * example 3D camera controls.
  4060. *
  4061. * If the mode is `GLFW_STICKY_KEYS`, the value must be either `true` to
  4062. * enable sticky keys, or `false` to disable it. If sticky keys are
  4063. * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  4064. * the next time it is called even if the key had been released before the
  4065. * call. This is useful when you are only interested in whether keys have been
  4066. * pressed but not when or in which order.
  4067. *
  4068. * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  4069. * `true` to enable sticky mouse buttons, or `false` to disable it.
  4070. * If sticky mouse buttons are enabled, a mouse button press will ensure that
  4071. * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
  4072. * if the mouse button had been released before the call. This is useful when
  4073. * you are only interested in whether mouse buttons have been pressed but not
  4074. * when or in which order.
  4075. *
  4076. * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `true` to
  4077. * enable lock key modifier bits, or `false` to disable them. If enabled,
  4078. * callbacks that receive modifier bits will also have the @ref
  4079. * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
  4080. * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
  4081. *
  4082. * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `true`
  4083. * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
  4084. * disabled, or `false` to disable it. If raw motion is not supported,
  4085. * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
  4086. * glfwRawMouseMotionSupported to check for support.
  4087. *
  4088. * @param[in] window The window whose input mode to set.
  4089. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  4090. * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
  4091. * `GLFW_RAW_MOUSE_MOTION`.
  4092. * @param[in] value The new value of the specified input mode.
  4093. *
  4094. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4095. * GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
  4096. * GLFW_FEATURE_UNAVAILABLE (see above).
  4097. *
  4098. * @thread_safety This function must only be called from the main thread.
  4099. *
  4100. * @sa @ref glfwGetInputMode
  4101. *
  4102. * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
  4103. *
  4104. * @ingroup input
  4105. */
  4106. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  4107. /*! @brief Returns whether raw mouse motion is supported.
  4108. *
  4109. * This function returns whether raw mouse motion is supported on the current
  4110. * system. This status does not change after GLFW has been initialized so you
  4111. * only need to check this once. If you attempt to enable raw motion on
  4112. * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
  4113. *
  4114. * Raw mouse motion is closer to the actual motion of the mouse across
  4115. * a surface. It is not affected by the scaling and acceleration applied to
  4116. * the motion of the desktop cursor. That processing is suitable for a cursor
  4117. * while raw motion is better for controlling for example a 3D camera. Because
  4118. * of this, raw mouse motion is only provided when the cursor is disabled.
  4119. *
  4120. * @return `true` if raw mouse motion is supported on the current machine,
  4121. * or `false` otherwise.
  4122. *
  4123. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4124. *
  4125. * @thread_safety This function must only be called from the main thread.
  4126. *
  4127. * @sa @ref raw_mouse_motion
  4128. * @sa @ref glfwSetInputMode
  4129. *
  4130. * @since Added in version 3.3.
  4131. *
  4132. * @ingroup input
  4133. */
  4134. GLFWAPI int glfwRawMouseMotionSupported(void);
  4135. /*! @brief Returns the layout-specific name of the specified printable key.
  4136. *
  4137. * This function returns the name of the specified printable key, encoded as
  4138. * UTF-8. This is typically the character that key would produce without any
  4139. * modifier keys, intended for displaying key bindings to the user. For dead
  4140. * keys, it is typically the diacritic it would add to a character.
  4141. *
  4142. * __Do not use this function__ for [text input](@ref input_char). You will
  4143. * break text input for many languages even if it happens to work for yours.
  4144. *
  4145. * If the key is `0`, the keycode is used to identify the key,
  4146. * otherwise the keycode is ignored. If you specify a non-printable key, or
  4147. * `0` and a keycode that maps to a non-printable key, this
  4148. * function returns `NULL` but does not emit an error.
  4149. *
  4150. * This behavior allows you to always pass in the arguments in the
  4151. * [key callback](@ref input_key) without modification.
  4152. *
  4153. * Names for printable keys depend on keyboard layout, while names for
  4154. * non-printable keys are the same across layouts but depend on the application
  4155. * language and should be localized along with other user interface text.
  4156. *
  4157. * @param[in] key The key to query, or `0`.
  4158. * @param[in] native_key The platform-specifc identifier of the key to query.
  4159. * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
  4160. *
  4161. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4162. * GLFW_PLATFORM_ERROR.
  4163. *
  4164. * @remark The contents of the returned string may change when a keyboard
  4165. * layout change event is received.
  4166. *
  4167. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4168. * should not free it yourself. It is valid until the library is terminated.
  4169. *
  4170. * @thread_safety This function must only be called from the main thread.
  4171. *
  4172. * @sa @ref input_key_name
  4173. *
  4174. * @since Added in version 3.2.
  4175. *
  4176. * @ingroup input
  4177. */
  4178. GLFWAPI const char* glfwGetKeyName(uint32_t key, int native_key);
  4179. /*! @brief Returns the platform-specific identifier of the specified key.
  4180. *
  4181. * This function returns the platform-specific identifier of the specified key.
  4182. *
  4183. * If the key is `0` or does not exist on the keyboard this
  4184. * method will return `-1`.
  4185. *
  4186. * @param[in] key Any [named key](@ref keys).
  4187. * @return The platform-specific identifier for the key, or `-1` if an
  4188. * [error](@ref error_handling) occurred.
  4189. *
  4190. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4191. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4192. *
  4193. * @thread_safety This function may be called from any thread.
  4194. *
  4195. * @sa @ref input_key
  4196. *
  4197. * @since Added in version 3.3.
  4198. *
  4199. * @ingroup input
  4200. */
  4201. GLFWAPI int glfwGetNativeKeyForKey(uint32_t key);
  4202. /*! @brief Returns the last reported state of a keyboard key for the specified
  4203. * window.
  4204. *
  4205. * This function returns the last state reported for the specified key to the
  4206. * specified window. The returned state is one of `GLFW_PRESS` or
  4207. * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
  4208. * the key callback.
  4209. *
  4210. * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
  4211. * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  4212. * that key has already been released.
  4213. *
  4214. * The key functions deal with physical keys, with [key tokens](@ref keys)
  4215. * named after their use on the standard US keyboard layout. If you want to
  4216. * input text, use the Unicode character callback instead.
  4217. *
  4218. * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  4219. * used with this function.
  4220. *
  4221. * __Do not use this function__ to implement [text input](@ref input_char).
  4222. *
  4223. * @param[in] window The desired window.
  4224. * @param[in] key The desired [keyboard key](@ref keys). `0` is
  4225. * not a valid key for this function.
  4226. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  4227. *
  4228. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4229. * GLFW_INVALID_ENUM.
  4230. *
  4231. * @thread_safety This function must only be called from the main thread.
  4232. *
  4233. * @sa @ref input_key
  4234. *
  4235. * @since Added in version 1.0.
  4236. * @glfw3 Added window handle parameter.
  4237. *
  4238. * @ingroup input
  4239. */
  4240. GLFWAPI GLFWKeyAction glfwGetKey(GLFWwindow* window, uint32_t key);
  4241. /*! @brief Returns the last reported state of a mouse button for the specified
  4242. * window.
  4243. *
  4244. * This function returns the last state reported for the specified mouse button
  4245. * to the specified window. The returned state is one of `GLFW_PRESS` or
  4246. * `GLFW_RELEASE`.
  4247. *
  4248. * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
  4249. * returns `GLFW_PRESS` the first time you call it for a mouse button that was
  4250. * pressed, even if that mouse button has already been released.
  4251. *
  4252. * @param[in] window The desired window.
  4253. * @param[in] button The desired [mouse button](@ref buttons).
  4254. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  4255. *
  4256. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4257. * GLFW_INVALID_ENUM.
  4258. *
  4259. * @thread_safety This function must only be called from the main thread.
  4260. *
  4261. * @sa @ref input_mouse_button
  4262. *
  4263. * @since Added in version 1.0.
  4264. * @glfw3 Added window handle parameter.
  4265. *
  4266. * @ingroup input
  4267. */
  4268. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  4269. /*! @brief Retrieves the position of the cursor relative to the content area of
  4270. * the window.
  4271. *
  4272. * This function returns the position of the cursor, in screen coordinates,
  4273. * relative to the upper-left corner of the content area of the specified
  4274. * window.
  4275. *
  4276. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  4277. * position is unbounded and limited only by the minimum and maximum values of
  4278. * a `double`.
  4279. *
  4280. * The coordinate can be converted to their integer equivalents with the
  4281. * `floor` function. Casting directly to an integer type works for positive
  4282. * coordinates, but fails for negative ones.
  4283. *
  4284. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  4285. * non-`NULL` position arguments will be set to zero.
  4286. *
  4287. * @param[in] window The desired window.
  4288. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  4289. * left edge of the content area, or `NULL`.
  4290. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  4291. * top edge of the content area, or `NULL`.
  4292. *
  4293. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4294. * GLFW_PLATFORM_ERROR.
  4295. *
  4296. * @thread_safety This function must only be called from the main thread.
  4297. *
  4298. * @sa @ref cursor_pos
  4299. * @sa @ref glfwSetCursorPos
  4300. *
  4301. * @since Added in version 3.0. Replaces `glfwGetMousePos`.
  4302. *
  4303. * @ingroup input
  4304. */
  4305. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  4306. /*! @brief Sets the position of the cursor, relative to the content area of the
  4307. * window.
  4308. *
  4309. * This function sets the position, in screen coordinates, of the cursor
  4310. * relative to the upper-left corner of the content area of the specified
  4311. * window. The window must have input focus. If the window does not have
  4312. * input focus when this function is called, it fails silently.
  4313. *
  4314. * __Do not use this function__ to implement things like camera controls. GLFW
  4315. * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  4316. * cursor, transparently re-centers it and provides unconstrained cursor
  4317. * motion. See @ref glfwSetInputMode for more information.
  4318. *
  4319. * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  4320. * unconstrained and limited only by the minimum and maximum values of
  4321. * a `double`.
  4322. *
  4323. * @param[in] window The desired window.
  4324. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  4325. * content area.
  4326. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  4327. * content area.
  4328. *
  4329. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4330. * GLFW_PLATFORM_ERROR.
  4331. *
  4332. * @remark @wayland This function will only work when the cursor mode is
  4333. * `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
  4334. *
  4335. * @thread_safety This function must only be called from the main thread.
  4336. *
  4337. * @sa @ref cursor_pos
  4338. * @sa @ref glfwGetCursorPos
  4339. *
  4340. * @since Added in version 3.0. Replaces `glfwSetMousePos`.
  4341. *
  4342. * @ingroup input
  4343. */
  4344. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  4345. /*! @brief Creates a custom cursor.
  4346. *
  4347. * Creates a new custom cursor image that can be set for a window with @ref
  4348. * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
  4349. * Any remaining cursors are destroyed by @ref glfwTerminate.
  4350. *
  4351. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  4352. * bits per channel with the red channel first. They are arranged canonically
  4353. * as packed sequential rows, starting from the top-left corner.
  4354. *
  4355. * The cursor hotspot is specified in pixels, relative to the upper-left corner
  4356. * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
  4357. * points to the right and the Y-axis points down.
  4358. *
  4359. * @param[in] image The desired cursor image.
  4360. * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
  4361. * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
  4362. * @param[in] count The number of images. Used on Cocoa for retina cursors. The first image should be the 1:1 scale image.
  4363. * @return The handle of the created cursor, or `NULL` if an
  4364. * [error](@ref error_handling) occurred.
  4365. *
  4366. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4367. * GLFW_PLATFORM_ERROR.
  4368. *
  4369. * @pointer_lifetime The specified image data is copied before this function
  4370. * returns.
  4371. *
  4372. * @thread_safety This function must only be called from the main thread.
  4373. *
  4374. * @sa @ref cursor_object
  4375. * @sa @ref glfwDestroyCursor
  4376. * @sa @ref glfwCreateStandardCursor
  4377. *
  4378. * @since Added in version 3.1. Changed in 4.0 to add the count parameter.
  4379. *
  4380. * @ingroup input
  4381. */
  4382. GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot, int count);
  4383. /*! @brief Creates a cursor with a standard shape.
  4384. *
  4385. * Returns a cursor with a [standard shape](@ref shapes), that can be set for
  4386. * a window with @ref glfwSetCursor.
  4387. *
  4388. * @param[in] shape One of the [standard shapes](@ref shapes).
  4389. * @return A new cursor ready to use or `NULL` if an
  4390. * [error](@ref error_handling) occurred.
  4391. *
  4392. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4393. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4394. *
  4395. * @thread_safety This function must only be called from the main thread.
  4396. *
  4397. * @sa @ref cursor_object
  4398. * @sa @ref glfwCreateCursor
  4399. *
  4400. * @since Added in version 3.1.
  4401. *
  4402. * @ingroup input
  4403. */
  4404. GLFWAPI GLFWcursor* glfwCreateStandardCursor(GLFWCursorShape shape);
  4405. /*! @brief Destroys a cursor.
  4406. *
  4407. * This function destroys a cursor previously created with @ref
  4408. * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
  4409. * glfwTerminate.
  4410. *
  4411. * If the specified cursor is current for any window, that window will be
  4412. * reverted to the default cursor. This does not affect the cursor mode.
  4413. *
  4414. * @param[in] cursor The cursor object to destroy.
  4415. *
  4416. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4417. * GLFW_PLATFORM_ERROR.
  4418. *
  4419. * @reentrancy This function must not be called from a callback.
  4420. *
  4421. * @thread_safety This function must only be called from the main thread.
  4422. *
  4423. * @sa @ref cursor_object
  4424. * @sa @ref glfwCreateCursor
  4425. *
  4426. * @since Added in version 3.1.
  4427. *
  4428. * @ingroup input
  4429. */
  4430. GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
  4431. /*! @brief Sets the cursor for the window.
  4432. *
  4433. * This function sets the cursor image to be used when the cursor is over the
  4434. * content area of the specified window. The set cursor will only be visible
  4435. * when the [cursor mode](@ref cursor_mode) of the window is
  4436. * `GLFW_CURSOR_NORMAL`.
  4437. *
  4438. * On some platforms, the set cursor may not be visible unless the window also
  4439. * has input focus.
  4440. *
  4441. * @param[in] window The window to set the cursor for.
  4442. * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  4443. * arrow cursor.
  4444. *
  4445. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4446. * GLFW_PLATFORM_ERROR.
  4447. *
  4448. * @thread_safety This function must only be called from the main thread.
  4449. *
  4450. * @sa @ref cursor_object
  4451. *
  4452. * @since Added in version 3.1.
  4453. *
  4454. * @ingroup input
  4455. */
  4456. GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
  4457. /*! @brief Sets the callback for handling keyboard events.
  4458. *
  4459. * @ingroup input
  4460. */
  4461. GLFWAPI GLFWkeyboardfun glfwSetKeyboardCallback(GLFWwindow* window, GLFWkeyboardfun callback);
  4462. /*! @brief Notifies the OS Input Method Event system of changes to application input state
  4463. *
  4464. * Used to notify the IME system of changes in state such as focus gained/lost
  4465. * and text cursor position.
  4466. *
  4467. * @param ev: What data to notify.
  4468. *
  4469. * @ingroup input
  4470. * @since Added in version 4.0
  4471. */
  4472. GLFWAPI void glfwUpdateIMEState(GLFWwindow* window, const GLFWIMEUpdateEvent *ev);
  4473. /*! @brief Sets the mouse button callback.
  4474. *
  4475. * This function sets the mouse button callback of the specified window, which
  4476. * is called when a mouse button is pressed or released.
  4477. *
  4478. * When a window loses input focus, it will generate synthetic mouse button
  4479. * release events for all pressed mouse buttons. You can tell these events
  4480. * from user-generated events by the fact that the synthetic ones are generated
  4481. * after the focus loss event has been processed, i.e. after the
  4482. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  4483. *
  4484. * @param[in] window The window whose callback to set.
  4485. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4486. * callback.
  4487. * @return The previously set callback, or `NULL` if no callback was set or the
  4488. * library had not been [initialized](@ref intro_init).
  4489. *
  4490. * @callback_signature
  4491. * @code
  4492. * void function_name(GLFWwindow* window, int button, int action, int mods)
  4493. * @endcode
  4494. * For more information about the callback parameters, see the
  4495. * [function pointer type](@ref GLFWmousebuttonfun).
  4496. *
  4497. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4498. *
  4499. * @thread_safety This function must only be called from the main thread.
  4500. *
  4501. * @sa @ref input_mouse_button
  4502. *
  4503. * @since Added in version 1.0.
  4504. * @glfw3 Added window handle parameter and return value.
  4505. *
  4506. * @ingroup input
  4507. */
  4508. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
  4509. /*! @brief Sets the cursor position callback.
  4510. *
  4511. * This function sets the cursor position callback of the specified window,
  4512. * which is called when the cursor is moved. The callback is provided with the
  4513. * position, in screen coordinates, relative to the upper-left corner of the
  4514. * content area of the window.
  4515. *
  4516. * @param[in] window The window whose callback to set.
  4517. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4518. * callback.
  4519. * @return The previously set callback, or `NULL` if no callback was set or the
  4520. * library had not been [initialized](@ref intro_init).
  4521. *
  4522. * @callback_signature
  4523. * @code
  4524. * void function_name(GLFWwindow* window, double xpos, double ypos);
  4525. * @endcode
  4526. * For more information about the callback parameters, see the
  4527. * [function pointer type](@ref GLFWcursorposfun).
  4528. *
  4529. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4530. *
  4531. * @thread_safety This function must only be called from the main thread.
  4532. *
  4533. * @sa @ref cursor_pos
  4534. *
  4535. * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
  4536. *
  4537. * @ingroup input
  4538. */
  4539. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
  4540. /*! @brief Sets the cursor enter/leave callback.
  4541. *
  4542. * This function sets the cursor boundary crossing callback of the specified
  4543. * window, which is called when the cursor enters or leaves the content area of
  4544. * the window.
  4545. *
  4546. * @param[in] window The window whose callback to set.
  4547. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4548. * callback.
  4549. * @return The previously set callback, or `NULL` if no callback was set or the
  4550. * library had not been [initialized](@ref intro_init).
  4551. *
  4552. * @callback_signature
  4553. * @code
  4554. * void function_name(GLFWwindow* window, int entered)
  4555. * @endcode
  4556. * For more information about the callback parameters, see the
  4557. * [function pointer type](@ref GLFWcursorenterfun).
  4558. *
  4559. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4560. *
  4561. * @thread_safety This function must only be called from the main thread.
  4562. *
  4563. * @sa @ref cursor_enter
  4564. *
  4565. * @since Added in version 3.0.
  4566. *
  4567. * @ingroup input
  4568. */
  4569. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
  4570. /*! @brief Sets the scroll callback.
  4571. *
  4572. * This function sets the scroll callback of the specified window, which is
  4573. * called when a scrolling device is used, such as a mouse wheel or scrolling
  4574. * area of a touchpad.
  4575. *
  4576. * The scroll callback receives all scrolling input, like that from a mouse
  4577. * wheel or a touchpad scrolling area.
  4578. *
  4579. * @param[in] window The window whose callback to set.
  4580. * @param[in] callback The new scroll callback, or `NULL` to remove the
  4581. * currently set callback.
  4582. * @return The previously set callback, or `NULL` if no callback was set or the
  4583. * library had not been [initialized](@ref intro_init).
  4584. *
  4585. * @callback_signature
  4586. * @code
  4587. * void function_name(GLFWwindow* window, double xoffset, double yoffset)
  4588. * @endcode
  4589. * For more information about the callback parameters, see the
  4590. * [function pointer type](@ref GLFWscrollfun).
  4591. *
  4592. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4593. *
  4594. * @thread_safety This function must only be called from the main thread.
  4595. *
  4596. * @sa @ref scrolling
  4597. *
  4598. * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
  4599. *
  4600. * @ingroup input
  4601. */
  4602. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
  4603. /*! @brief Sets the path drop callback.
  4604. *
  4605. * This function sets the path drop callback of the specified window, which is
  4606. * called when one or more dragged paths are dropped on the window.
  4607. *
  4608. * Because the path array and its strings may have been generated specifically
  4609. * for that event, they are not guaranteed to be valid after the callback has
  4610. * returned. If you wish to use them after the callback returns, you need to
  4611. * make a deep copy.
  4612. *
  4613. * @param[in] window The window whose callback to set.
  4614. * @param[in] callback The new file drop callback, or `NULL` to remove the
  4615. * currently set callback.
  4616. * @return The previously set callback, or `NULL` if no callback was set or the
  4617. * library had not been [initialized](@ref intro_init).
  4618. *
  4619. * @callback_signature
  4620. * @code
  4621. * void function_name(GLFWwindow* window, int path_count, const char* paths[])
  4622. * @endcode
  4623. * For more information about the callback parameters, see the
  4624. * [function pointer type](@ref GLFWdropfun).
  4625. *
  4626. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4627. *
  4628. * @remark @wayland File drop is currently unimplemented.
  4629. *
  4630. * @thread_safety This function must only be called from the main thread.
  4631. *
  4632. * @sa @ref path_drop
  4633. *
  4634. * @since Added in version 3.1.
  4635. *
  4636. * @ingroup input
  4637. */
  4638. GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
  4639. GLFWAPI GLFWliveresizefun glfwSetLiveResizeCallback(GLFWwindow* window, GLFWliveresizefun callback);
  4640. /*! @brief Returns whether the specified joystick is present.
  4641. *
  4642. * This function returns whether the specified joystick is present.
  4643. *
  4644. * There is no need to call this function before other functions that accept
  4645. * a joystick ID, as they all check for presence before performing any other
  4646. * work.
  4647. *
  4648. * @param[in] jid The [joystick](@ref joysticks) to query.
  4649. * @return `true` if the joystick is present, or `false` otherwise.
  4650. *
  4651. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4652. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4653. *
  4654. * @thread_safety This function must only be called from the main thread.
  4655. *
  4656. * @sa @ref joystick
  4657. *
  4658. * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
  4659. *
  4660. * @ingroup input
  4661. */
  4662. GLFWAPI int glfwJoystickPresent(int jid);
  4663. /*! @brief Returns the values of all axes of the specified joystick.
  4664. *
  4665. * This function returns the values of all axes of the specified joystick.
  4666. * Each element in the array is a value between -1.0 and 1.0.
  4667. *
  4668. * If the specified joystick is not present this function will return `NULL`
  4669. * but will not generate an error. This can be used instead of first calling
  4670. * @ref glfwJoystickPresent.
  4671. *
  4672. * @param[in] jid The [joystick](@ref joysticks) to query.
  4673. * @param[out] count Where to store the number of axis values in the returned
  4674. * array. This is set to zero if the joystick is not present or an error
  4675. * occurred.
  4676. * @return An array of axis values, or `NULL` if the joystick is not present or
  4677. * an [error](@ref error_handling) occurred.
  4678. *
  4679. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4680. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4681. *
  4682. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4683. * should not free it yourself. It is valid until the specified joystick is
  4684. * disconnected or the library is terminated.
  4685. *
  4686. * @thread_safety This function must only be called from the main thread.
  4687. *
  4688. * @sa @ref joystick_axis
  4689. *
  4690. * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
  4691. *
  4692. * @ingroup input
  4693. */
  4694. GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
  4695. /*! @brief Returns the state of all buttons of the specified joystick.
  4696. *
  4697. * This function returns the state of all buttons of the specified joystick.
  4698. * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
  4699. *
  4700. * For backward compatibility with earlier versions that did not have @ref
  4701. * glfwGetJoystickHats, the button array also includes all hats, each
  4702. * represented as four buttons. The hats are in the same order as returned by
  4703. * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
  4704. * _left_. To disable these extra buttons, set the @ref
  4705. * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
  4706. *
  4707. * If the specified joystick is not present this function will return `NULL`
  4708. * but will not generate an error. This can be used instead of first calling
  4709. * @ref glfwJoystickPresent.
  4710. *
  4711. * @param[in] jid The [joystick](@ref joysticks) to query.
  4712. * @param[out] count Where to store the number of button states in the returned
  4713. * array. This is set to zero if the joystick is not present or an error
  4714. * occurred.
  4715. * @return An array of button states, or `NULL` if the joystick is not present
  4716. * or an [error](@ref error_handling) occurred.
  4717. *
  4718. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4719. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4720. *
  4721. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4722. * should not free it yourself. It is valid until the specified joystick is
  4723. * disconnected or the library is terminated.
  4724. *
  4725. * @thread_safety This function must only be called from the main thread.
  4726. *
  4727. * @sa @ref joystick_button
  4728. *
  4729. * @since Added in version 2.2.
  4730. * @glfw3 Changed to return a dynamic array.
  4731. *
  4732. * @ingroup input
  4733. */
  4734. GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
  4735. /*! @brief Returns the state of all hats of the specified joystick.
  4736. *
  4737. * This function returns the state of all hats of the specified joystick.
  4738. * Each element in the array is one of the following values:
  4739. *
  4740. * Name | Value
  4741. * ---- | -----
  4742. * `GLFW_HAT_CENTERED` | 0
  4743. * `GLFW_HAT_UP` | 1
  4744. * `GLFW_HAT_RIGHT` | 2
  4745. * `GLFW_HAT_DOWN` | 4
  4746. * `GLFW_HAT_LEFT` | 8
  4747. * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
  4748. * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
  4749. * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
  4750. * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
  4751. *
  4752. * The diagonal directions are bitwise combinations of the primary (up, right,
  4753. * down and left) directions and you can test for these individually by ANDing
  4754. * it with the corresponding direction.
  4755. *
  4756. * @code
  4757. * if (hats[2] & GLFW_HAT_RIGHT)
  4758. * {
  4759. * // State of hat 2 could be right-up, right or right-down
  4760. * }
  4761. * @endcode
  4762. *
  4763. * If the specified joystick is not present this function will return `NULL`
  4764. * but will not generate an error. This can be used instead of first calling
  4765. * @ref glfwJoystickPresent.
  4766. *
  4767. * @param[in] jid The [joystick](@ref joysticks) to query.
  4768. * @param[out] count Where to store the number of hat states in the returned
  4769. * array. This is set to zero if the joystick is not present or an error
  4770. * occurred.
  4771. * @return An array of hat states, or `NULL` if the joystick is not present
  4772. * or an [error](@ref error_handling) occurred.
  4773. *
  4774. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4775. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4776. *
  4777. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  4778. * should not free it yourself. It is valid until the specified joystick is
  4779. * disconnected, this function is called again for that joystick or the library
  4780. * is terminated.
  4781. *
  4782. * @thread_safety This function must only be called from the main thread.
  4783. *
  4784. * @sa @ref joystick_hat
  4785. *
  4786. * @since Added in version 3.3.
  4787. *
  4788. * @ingroup input
  4789. */
  4790. GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
  4791. /*! @brief Returns the name of the specified joystick.
  4792. *
  4793. * This function returns the name, encoded as UTF-8, of the specified joystick.
  4794. * The returned string is allocated and freed by GLFW. You should not free it
  4795. * yourself.
  4796. *
  4797. * If the specified joystick is not present this function will return `NULL`
  4798. * but will not generate an error. This can be used instead of first calling
  4799. * @ref glfwJoystickPresent.
  4800. *
  4801. * @param[in] jid The [joystick](@ref joysticks) to query.
  4802. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  4803. * is not present or an [error](@ref error_handling) occurred.
  4804. *
  4805. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4806. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4807. *
  4808. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4809. * should not free it yourself. It is valid until the specified joystick is
  4810. * disconnected or the library is terminated.
  4811. *
  4812. * @thread_safety This function must only be called from the main thread.
  4813. *
  4814. * @sa @ref joystick_name
  4815. *
  4816. * @since Added in version 3.0.
  4817. *
  4818. * @ingroup input
  4819. */
  4820. GLFWAPI const char* glfwGetJoystickName(int jid);
  4821. /*! @brief Returns the SDL compatible GUID of the specified joystick.
  4822. *
  4823. * This function returns the SDL compatible GUID, as a UTF-8 encoded
  4824. * hexadecimal string, of the specified joystick. The returned string is
  4825. * allocated and freed by GLFW. You should not free it yourself.
  4826. *
  4827. * The GUID is what connects a joystick to a gamepad mapping. A connected
  4828. * joystick will always have a GUID even if there is no gamepad mapping
  4829. * assigned to it.
  4830. *
  4831. * If the specified joystick is not present this function will return `NULL`
  4832. * but will not generate an error. This can be used instead of first calling
  4833. * @ref glfwJoystickPresent.
  4834. *
  4835. * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
  4836. * uniquely identify the make and model of a joystick but does not identify
  4837. * a specific unit, e.g. all wired Xbox 360 controllers will have the same
  4838. * GUID on that platform. The GUID for a unit may vary between platforms
  4839. * depending on what hardware information the platform specific APIs provide.
  4840. *
  4841. * @param[in] jid The [joystick](@ref joysticks) to query.
  4842. * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
  4843. * is not present or an [error](@ref error_handling) occurred.
  4844. *
  4845. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4846. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4847. *
  4848. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4849. * should not free it yourself. It is valid until the specified joystick is
  4850. * disconnected or the library is terminated.
  4851. *
  4852. * @thread_safety This function must only be called from the main thread.
  4853. *
  4854. * @sa @ref gamepad
  4855. *
  4856. * @since Added in version 3.3.
  4857. *
  4858. * @ingroup input
  4859. */
  4860. GLFWAPI const char* glfwGetJoystickGUID(int jid);
  4861. /*! @brief Sets the user pointer of the specified joystick.
  4862. *
  4863. * This function sets the user-defined pointer of the specified joystick. The
  4864. * current value is retained until the joystick is disconnected. The initial
  4865. * value is `NULL`.
  4866. *
  4867. * This function may be called from the joystick callback, even for a joystick
  4868. * that is being disconnected.
  4869. *
  4870. * @param[in] jid The joystick whose pointer to set.
  4871. * @param[in] pointer The new value.
  4872. *
  4873. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4874. *
  4875. * @thread_safety This function may be called from any thread. Access is not
  4876. * synchronized.
  4877. *
  4878. * @sa @ref joystick_userptr
  4879. * @sa @ref glfwGetJoystickUserPointer
  4880. *
  4881. * @since Added in version 3.3.
  4882. *
  4883. * @ingroup input
  4884. */
  4885. GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
  4886. /*! @brief Returns the user pointer of the specified joystick.
  4887. *
  4888. * This function returns the current value of the user-defined pointer of the
  4889. * specified joystick. The initial value is `NULL`.
  4890. *
  4891. * This function may be called from the joystick callback, even for a joystick
  4892. * that is being disconnected.
  4893. *
  4894. * @param[in] jid The joystick whose pointer to return.
  4895. *
  4896. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4897. *
  4898. * @thread_safety This function may be called from any thread. Access is not
  4899. * synchronized.
  4900. *
  4901. * @sa @ref joystick_userptr
  4902. * @sa @ref glfwSetJoystickUserPointer
  4903. *
  4904. * @since Added in version 3.3.
  4905. *
  4906. * @ingroup input
  4907. */
  4908. GLFWAPI void* glfwGetJoystickUserPointer(int jid);
  4909. /*! @brief Returns whether the specified joystick has a gamepad mapping.
  4910. *
  4911. * This function returns whether the specified joystick is both present and has
  4912. * a gamepad mapping.
  4913. *
  4914. * If the specified joystick is present but does not have a gamepad mapping
  4915. * this function will return `false` but will not generate an error. Call
  4916. * @ref glfwJoystickPresent to check if a joystick is present regardless of
  4917. * whether it has a mapping.
  4918. *
  4919. * @param[in] jid The [joystick](@ref joysticks) to query.
  4920. * @return `true` if a joystick is both present and has a gamepad mapping,
  4921. * or `false` otherwise.
  4922. *
  4923. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4924. * GLFW_INVALID_ENUM.
  4925. *
  4926. * @thread_safety This function must only be called from the main thread.
  4927. *
  4928. * @sa @ref gamepad
  4929. * @sa @ref glfwGetGamepadState
  4930. *
  4931. * @since Added in version 3.3.
  4932. *
  4933. * @ingroup input
  4934. */
  4935. GLFWAPI int glfwJoystickIsGamepad(int jid);
  4936. /*! @brief Sets the joystick configuration callback.
  4937. *
  4938. * This function sets the joystick configuration callback, or removes the
  4939. * currently set callback. This is called when a joystick is connected to or
  4940. * disconnected from the system.
  4941. *
  4942. * For joystick connection and disconnection events to be delivered on all
  4943. * platforms, you need to call one of the [event processing](@ref events)
  4944. * functions. Joystick disconnection may also be detected and the callback
  4945. * called by joystick functions. The function will then return whatever it
  4946. * returns if the joystick is not present.
  4947. *
  4948. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4949. * callback.
  4950. * @return The previously set callback, or `NULL` if no callback was set or the
  4951. * library had not been [initialized](@ref intro_init).
  4952. *
  4953. * @callback_signature
  4954. * @code
  4955. * void function_name(int jid, int event)
  4956. * @endcode
  4957. * For more information about the callback parameters, see the
  4958. * [function pointer type](@ref GLFWjoystickfun).
  4959. *
  4960. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4961. *
  4962. * @thread_safety This function must only be called from the main thread.
  4963. *
  4964. * @sa @ref joystick_event
  4965. *
  4966. * @since Added in version 3.2.
  4967. *
  4968. * @ingroup input
  4969. */
  4970. GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
  4971. /*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
  4972. *
  4973. * This function parses the specified ASCII encoded string and updates the
  4974. * internal list with any gamepad mappings it finds. This string may
  4975. * contain either a single gamepad mapping or many mappings separated by
  4976. * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
  4977. * source file including empty lines and comments.
  4978. *
  4979. * See @ref gamepad_mapping for a description of the format.
  4980. *
  4981. * If there is already a gamepad mapping for a given GUID in the internal list,
  4982. * it will be replaced by the one passed to this function. If the library is
  4983. * terminated and re-initialized the internal list will revert to the built-in
  4984. * default.
  4985. *
  4986. * @param[in] string The string containing the gamepad mappings.
  4987. * @return `true` if successful, or `false` if an
  4988. * [error](@ref error_handling) occurred.
  4989. *
  4990. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4991. * GLFW_INVALID_VALUE.
  4992. *
  4993. * @thread_safety This function must only be called from the main thread.
  4994. *
  4995. * @sa @ref gamepad
  4996. * @sa @ref glfwJoystickIsGamepad
  4997. * @sa @ref glfwGetGamepadName
  4998. *
  4999. * @since Added in version 3.3.
  5000. *
  5001. * @ingroup input
  5002. */
  5003. GLFWAPI int glfwUpdateGamepadMappings(const char* string);
  5004. /*! @brief Returns the human-readable gamepad name for the specified joystick.
  5005. *
  5006. * This function returns the human-readable name of the gamepad from the
  5007. * gamepad mapping assigned to the specified joystick.
  5008. *
  5009. * If the specified joystick is not present or does not have a gamepad mapping
  5010. * this function will return `NULL` but will not generate an error. Call
  5011. * @ref glfwJoystickPresent to check whether it is present regardless of
  5012. * whether it has a mapping.
  5013. *
  5014. * @param[in] jid The [joystick](@ref joysticks) to query.
  5015. * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
  5016. * joystick is not present, does not have a mapping or an
  5017. * [error](@ref error_handling) occurred.
  5018. *
  5019. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  5020. * should not free it yourself. It is valid until the specified joystick is
  5021. * disconnected, the gamepad mappings are updated or the library is terminated.
  5022. *
  5023. * @thread_safety This function must only be called from the main thread.
  5024. *
  5025. * @sa @ref gamepad
  5026. * @sa @ref glfwJoystickIsGamepad
  5027. *
  5028. * @since Added in version 3.3.
  5029. *
  5030. * @ingroup input
  5031. */
  5032. GLFWAPI const char* glfwGetGamepadName(int jid);
  5033. /*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
  5034. *
  5035. * This function retrieves the state of the specified joystick remapped to
  5036. * an Xbox-like gamepad.
  5037. *
  5038. * If the specified joystick is not present or does not have a gamepad mapping
  5039. * this function will return `false` but will not generate an error. Call
  5040. * @ref glfwJoystickPresent to check whether it is present regardless of
  5041. * whether it has a mapping.
  5042. *
  5043. * The Guide button may not be available for input as it is often hooked by the
  5044. * system or the Steam client.
  5045. *
  5046. * Not all devices have all the buttons or axes provided by @ref
  5047. * GLFWgamepadstate. Unavailable buttons and axes will always report
  5048. * `GLFW_RELEASE` and 0.0 respectively.
  5049. *
  5050. * @param[in] jid The [joystick](@ref joysticks) to query.
  5051. * @param[out] state The gamepad input state of the joystick.
  5052. * @return `true` if successful, or `false` if no joystick is
  5053. * connected, it has no gamepad mapping or an [error](@ref error_handling)
  5054. * occurred.
  5055. *
  5056. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5057. * GLFW_INVALID_ENUM.
  5058. *
  5059. * @thread_safety This function must only be called from the main thread.
  5060. *
  5061. * @sa @ref gamepad
  5062. * @sa @ref glfwUpdateGamepadMappings
  5063. * @sa @ref glfwJoystickIsGamepad
  5064. *
  5065. * @since Added in version 3.3.
  5066. *
  5067. * @ingroup input
  5068. */
  5069. GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
  5070. GLFWAPI void glfwSetClipboardDataTypes(GLFWClipboardType clipboard_type, const char* const *mime_types, size_t num_mime_types, GLFWclipboarditerfun get_iter);
  5071. GLFWAPI void glfwGetClipboard(GLFWClipboardType clipboard_type, const char* mime_type, GLFWclipboardwritedatafun write_data, void *object);
  5072. /*! @brief Returns the GLFW time.
  5073. *
  5074. * This function returns the current GLFW time, in seconds. Unless the time
  5075. * has been set using @ref glfwSetTime it measures time elapsed since GLFW was
  5076. * initialized.
  5077. *
  5078. * The resolution of the timer is system dependent, but is usually on the order
  5079. * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
  5080. * time source on each supported platform.
  5081. *
  5082. * @return The current time, in seconds, or zero if an
  5083. * [error](@ref error_handling) occurred.
  5084. *
  5085. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5086. *
  5087. * @thread_safety This function may be called from any thread. Reading and
  5088. * writing of the internal base time is not atomic, so it needs to be
  5089. * externally synchronized with calls to @ref glfwSetTime.
  5090. *
  5091. * @sa @ref time
  5092. *
  5093. * @since Added in version 1.0.
  5094. *
  5095. * @ingroup input
  5096. */
  5097. GLFWAPI monotonic_t glfwGetTime(void);
  5098. /*! @brief Makes the context of the specified window current for the calling
  5099. * thread.
  5100. *
  5101. * This function makes the OpenGL or OpenGL ES context of the specified window
  5102. * current on the calling thread. A context must only be made current on
  5103. * a single thread at a time and each thread can have only a single current
  5104. * context at a time.
  5105. *
  5106. * When moving a context between threads, you must make it non-current on the
  5107. * old thread before making it current on the new one.
  5108. *
  5109. * By default, making a context non-current implicitly forces a pipeline flush.
  5110. * On machines that support `GL_KHR_context_flush_control`, you can control
  5111. * whether a context performs this flush by setting the
  5112. * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
  5113. * hint.
  5114. *
  5115. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  5116. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  5117. * error.
  5118. *
  5119. * @param[in] window The window whose context to make current, or `NULL` to
  5120. * detach the current context.
  5121. *
  5122. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5123. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5124. *
  5125. * @thread_safety This function may be called from any thread.
  5126. *
  5127. * @sa @ref context_current
  5128. * @sa @ref glfwGetCurrentContext
  5129. *
  5130. * @since Added in version 3.0.
  5131. *
  5132. * @ingroup context
  5133. */
  5134. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  5135. /*! @brief Returns the window whose context is current on the calling thread.
  5136. *
  5137. * This function returns the window whose OpenGL or OpenGL ES context is
  5138. * current on the calling thread.
  5139. *
  5140. * @return The window whose context is current, or `NULL` if no window's
  5141. * context is current.
  5142. *
  5143. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5144. *
  5145. * @thread_safety This function may be called from any thread.
  5146. *
  5147. * @sa @ref context_current
  5148. * @sa @ref glfwMakeContextCurrent
  5149. *
  5150. * @since Added in version 3.0.
  5151. *
  5152. * @ingroup context
  5153. */
  5154. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  5155. /*! @brief Swaps the front and back buffers of the specified window.
  5156. *
  5157. * This function swaps the front and back buffers of the specified window when
  5158. * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
  5159. * zero, the GPU driver waits the specified number of screen updates before
  5160. * swapping the buffers.
  5161. *
  5162. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  5163. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  5164. * error.
  5165. *
  5166. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5167. * see `vkQueuePresentKHR` instead.
  5168. *
  5169. * @param[in] window The window whose buffers to swap.
  5170. *
  5171. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5172. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5173. *
  5174. * @remark __EGL:__ The context of the specified window must be current on the
  5175. * calling thread.
  5176. *
  5177. * @thread_safety This function may be called from any thread.
  5178. *
  5179. * @sa @ref buffer_swap
  5180. * @sa @ref glfwSwapInterval
  5181. *
  5182. * @since Added in version 1.0.
  5183. * @glfw3 Added window handle parameter.
  5184. *
  5185. * @ingroup window
  5186. */
  5187. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  5188. /*! @brief Sets the swap interval for the current context.
  5189. *
  5190. * This function sets the swap interval for the current OpenGL or OpenGL ES
  5191. * context, i.e. the number of screen updates to wait from the time @ref
  5192. * glfwSwapBuffers was called before swapping the buffers and returning. This
  5193. * is sometimes called _vertical synchronization_, _vertical retrace
  5194. * synchronization_ or just _vsync_.
  5195. *
  5196. * A context that supports either of the `WGL_EXT_swap_control_tear` and
  5197. * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
  5198. * intervals, which allows the driver to swap immediately even if a frame
  5199. * arrives a little bit late. You can check for these extensions with @ref
  5200. * glfwExtensionSupported.
  5201. *
  5202. * A context must be current on the calling thread. Calling this function
  5203. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5204. *
  5205. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5206. * see the present mode of your swapchain instead.
  5207. *
  5208. * @param[in] interval The minimum number of screen updates to wait for
  5209. * until the buffers are swapped by @ref glfwSwapBuffers.
  5210. *
  5211. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5212. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5213. *
  5214. * @remark This function is not called during context creation, leaving the
  5215. * swap interval set to whatever is the default on that platform. This is done
  5216. * because some swap interval extensions used by GLFW do not allow the swap
  5217. * interval to be reset to zero once it has been set to a non-zero value.
  5218. *
  5219. * @remark Some GPU drivers do not honor the requested swap interval, either
  5220. * because of a user setting that overrides the application's request or due to
  5221. * bugs in the driver.
  5222. *
  5223. * @thread_safety This function may be called from any thread.
  5224. *
  5225. * @sa @ref buffer_swap
  5226. * @sa @ref glfwSwapBuffers
  5227. *
  5228. * @since Added in version 1.0.
  5229. *
  5230. * @ingroup context
  5231. */
  5232. GLFWAPI void glfwSwapInterval(int interval);
  5233. /*! @brief Returns whether the specified extension is available.
  5234. *
  5235. * This function returns whether the specified
  5236. * [API extension](@ref context_glext) is supported by the current OpenGL or
  5237. * OpenGL ES context. It searches both for client API extension and context
  5238. * creation API extensions.
  5239. *
  5240. * A context must be current on the calling thread. Calling this function
  5241. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5242. *
  5243. * As this functions retrieves and searches one or more extension strings each
  5244. * call, it is recommended that you cache its results if it is going to be used
  5245. * frequently. The extension strings will not change during the lifetime of
  5246. * a context, so there is no danger in doing this.
  5247. *
  5248. * This function does not apply to Vulkan. If you are using Vulkan, see @ref
  5249. * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
  5250. * and `vkEnumerateDeviceExtensionProperties` instead.
  5251. *
  5252. * @param[in] extension The ASCII encoded name of the extension.
  5253. * @return `true` if the extension is available, or `false`
  5254. * otherwise.
  5255. *
  5256. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5257. * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
  5258. * GLFW_PLATFORM_ERROR.
  5259. *
  5260. * @thread_safety This function may be called from any thread.
  5261. *
  5262. * @sa @ref context_glext
  5263. * @sa @ref glfwGetProcAddress
  5264. *
  5265. * @since Added in version 1.0.
  5266. *
  5267. * @ingroup context
  5268. */
  5269. GLFWAPI int glfwExtensionSupported(const char* extension);
  5270. /*! @brief Returns the address of the specified function for the current
  5271. * context.
  5272. *
  5273. * This function returns the address of the specified OpenGL or OpenGL ES
  5274. * [core or extension function](@ref context_glext), if it is supported
  5275. * by the current context.
  5276. *
  5277. * A context must be current on the calling thread. Calling this function
  5278. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5279. *
  5280. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5281. * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
  5282. * `vkGetDeviceProcAddr` instead.
  5283. *
  5284. * @param[in] procname The ASCII encoded name of the function.
  5285. * @return The address of the function, or `NULL` if an
  5286. * [error](@ref error_handling) occurred.
  5287. *
  5288. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5289. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5290. *
  5291. * @remark The address of a given function is not guaranteed to be the same
  5292. * between contexts.
  5293. *
  5294. * @remark This function may return a non-`NULL` address despite the
  5295. * associated version or extension not being available. Always check the
  5296. * context version or extension string first.
  5297. *
  5298. * @pointer_lifetime The returned function pointer is valid until the context
  5299. * is destroyed or the library is terminated.
  5300. *
  5301. * @thread_safety This function may be called from any thread.
  5302. *
  5303. * @sa @ref context_glext
  5304. * @sa @ref glfwExtensionSupported
  5305. *
  5306. * @since Added in version 1.0.
  5307. *
  5308. * @ingroup context
  5309. */
  5310. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  5311. /*! @brief Returns whether the Vulkan loader and an ICD have been found.
  5312. *
  5313. * This function returns whether the Vulkan loader and any minimally functional
  5314. * ICD have been found.
  5315. *
  5316. * The availability of a Vulkan loader and even an ICD does not by itself
  5317. * guarantee that surface creation or even instance creation is possible.
  5318. * For example, on Fermi systems Nvidia will install an ICD that provides no
  5319. * actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
  5320. * whether the extensions necessary for Vulkan surface creation are available
  5321. * and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
  5322. * family of a physical device supports image presentation.
  5323. *
  5324. * @return `true` if Vulkan is minimally available, or `false`
  5325. * otherwise.
  5326. *
  5327. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5328. *
  5329. * @thread_safety This function may be called from any thread.
  5330. *
  5331. * @sa @ref vulkan_support
  5332. *
  5333. * @since Added in version 3.2.
  5334. *
  5335. * @ingroup vulkan
  5336. */
  5337. GLFWAPI int glfwVulkanSupported(void);
  5338. /*! @brief Returns the Vulkan instance extensions required by GLFW.
  5339. *
  5340. * This function returns an array of names of Vulkan instance extensions required
  5341. * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
  5342. * list will always contain `VK_KHR_surface`, so if you don't require any
  5343. * additional extensions you can pass this list directly to the
  5344. * `VkInstanceCreateInfo` struct.
  5345. *
  5346. * If Vulkan is not available on the machine, this function returns `NULL` and
  5347. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5348. * to check whether Vulkan is at least minimally available.
  5349. *
  5350. * If Vulkan is available but no set of extensions allowing window surface
  5351. * creation was found, this function returns `NULL`. You may still use Vulkan
  5352. * for off-screen rendering and compute work.
  5353. *
  5354. * @param[out] count Where to store the number of extensions in the returned
  5355. * array. This is set to zero if an error occurred.
  5356. * @return An array of ASCII encoded extension names, or `NULL` if an
  5357. * [error](@ref error_handling) occurred.
  5358. *
  5359. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5360. * GLFW_API_UNAVAILABLE.
  5361. *
  5362. * @remark Additional extensions may be required by future versions of GLFW.
  5363. * You should check if any extensions you wish to enable are already in the
  5364. * returned array, as it is an error to specify an extension more than once in
  5365. * the `VkInstanceCreateInfo` struct.
  5366. *
  5367. * @remark @macos This function currently supports either the
  5368. * `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
  5369. * extension.
  5370. *
  5371. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  5372. * should not free it yourself. It is guaranteed to be valid only until the
  5373. * library is terminated.
  5374. *
  5375. * @thread_safety This function may be called from any thread.
  5376. *
  5377. * @sa @ref vulkan_ext
  5378. * @sa @ref glfwCreateWindowSurface
  5379. *
  5380. * @since Added in version 3.2.
  5381. *
  5382. * @ingroup vulkan
  5383. */
  5384. GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
  5385. #if defined(VK_VERSION_1_0)
  5386. /*! @brief Returns the address of the specified Vulkan instance function.
  5387. *
  5388. * This function returns the address of the specified Vulkan core or extension
  5389. * function for the specified instance. If instance is set to `NULL` it can
  5390. * return any function exported from the Vulkan loader, including at least the
  5391. * following functions:
  5392. *
  5393. * - `vkEnumerateInstanceExtensionProperties`
  5394. * - `vkEnumerateInstanceLayerProperties`
  5395. * - `vkCreateInstance`
  5396. * - `vkGetInstanceProcAddr`
  5397. *
  5398. * If Vulkan is not available on the machine, this function returns `NULL` and
  5399. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5400. * to check whether Vulkan is at least minimally available.
  5401. *
  5402. * This function is equivalent to calling `vkGetInstanceProcAddr` with
  5403. * a platform-specific query of the Vulkan loader as a fallback.
  5404. *
  5405. * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
  5406. * functions related to instance creation.
  5407. * @param[in] procname The ASCII encoded name of the function.
  5408. * @return The address of the function, or `NULL` if an
  5409. * [error](@ref error_handling) occurred.
  5410. *
  5411. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5412. * GLFW_API_UNAVAILABLE.
  5413. *
  5414. * @pointer_lifetime The returned function pointer is valid until the library
  5415. * is terminated.
  5416. *
  5417. * @thread_safety This function may be called from any thread.
  5418. *
  5419. * @sa @ref vulkan_proc
  5420. *
  5421. * @since Added in version 3.2.
  5422. *
  5423. * @ingroup vulkan
  5424. */
  5425. GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
  5426. /*! @brief Returns whether the specified queue family can present images.
  5427. *
  5428. * This function returns whether the specified queue family of the specified
  5429. * physical device supports presentation to the platform GLFW was built for.
  5430. *
  5431. * If Vulkan or the required window surface creation instance extensions are
  5432. * not available on the machine, or if the specified instance was not created
  5433. * with the required extensions, this function returns `false` and
  5434. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  5435. * to check whether Vulkan is at least minimally available and @ref
  5436. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  5437. * required.
  5438. *
  5439. * @param[in] instance The instance that the physical device belongs to.
  5440. * @param[in] device The physical device that the queue family belongs to.
  5441. * @param[in] queuefamily The index of the queue family to query.
  5442. * @return `true` if the queue family supports presentation, or
  5443. * `false` otherwise.
  5444. *
  5445. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5446. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  5447. *
  5448. * @remark @macos This function currently always returns `true`, as the
  5449. * `VK_MVK_macos_surface` extension does not provide
  5450. * a `vkGetPhysicalDevice*PresentationSupport` type function.
  5451. *
  5452. * @thread_safety This function may be called from any thread. For
  5453. * synchronization details of Vulkan objects, see the Vulkan specification.
  5454. *
  5455. * @sa @ref vulkan_present
  5456. *
  5457. * @since Added in version 3.2.
  5458. *
  5459. * @ingroup vulkan
  5460. */
  5461. GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
  5462. /*! @brief Creates a Vulkan surface for the specified window.
  5463. *
  5464. * This function creates a Vulkan surface for the specified window.
  5465. *
  5466. * If the Vulkan loader or at least one minimally functional ICD were not found,
  5467. * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
  5468. * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
  5469. * Vulkan is at least minimally available.
  5470. *
  5471. * If the required window surface creation instance extensions are not
  5472. * available or if the specified instance was not created with these extensions
  5473. * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
  5474. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
  5475. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  5476. * required.
  5477. *
  5478. * The window surface cannot be shared with another API so the window must
  5479. * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
  5480. * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
  5481. * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
  5482. *
  5483. * The window surface must be destroyed before the specified Vulkan instance.
  5484. * It is the responsibility of the caller to destroy the window surface. GLFW
  5485. * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
  5486. * surface.
  5487. *
  5488. * @param[in] instance The Vulkan instance to create the surface in.
  5489. * @param[in] window The window to create the surface for.
  5490. * @param[in] allocator The allocator to use, or `NULL` to use the default
  5491. * allocator.
  5492. * @param[out] surface Where to store the handle of the surface. This is set
  5493. * to `VK_NULL_HANDLE` if an error occurred.
  5494. * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
  5495. * [error](@ref error_handling) occurred.
  5496. *
  5497. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5498. * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
  5499. *
  5500. * @remark If an error occurs before the creation call is made, GLFW returns
  5501. * the Vulkan error code most appropriate for the error. Appropriate use of
  5502. * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
  5503. * eliminate almost all occurrences of these errors.
  5504. *
  5505. * @remark @macos This function currently only supports the
  5506. * `VK_MVK_macos_surface` extension from MoltenVK.
  5507. *
  5508. * @remark @macos This function creates and sets a `CAMetalLayer` instance for
  5509. * the window content view, which is required for MoltenVK to function.
  5510. *
  5511. * @thread_safety This function may be called from any thread. For
  5512. * synchronization details of Vulkan objects, see the Vulkan specification.
  5513. *
  5514. * @sa @ref vulkan_surface
  5515. * @sa @ref glfwGetRequiredInstanceExtensions
  5516. *
  5517. * @since Added in version 3.2.
  5518. *
  5519. * @ingroup vulkan
  5520. */
  5521. GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
  5522. #endif /*VK_VERSION_1_0*/
  5523. /*************************************************************************
  5524. * Global definition cleanup
  5525. *************************************************************************/
  5526. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  5527. #ifdef GLFW_WINGDIAPI_DEFINED
  5528. #undef WINGDIAPI
  5529. #undef GLFW_WINGDIAPI_DEFINED
  5530. #endif
  5531. #ifdef GLFW_CALLBACK_DEFINED
  5532. #undef CALLBACK
  5533. #undef GLFW_CALLBACK_DEFINED
  5534. #endif
  5535. /* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
  5536. * defined by some gl.h variants (OpenBSD) so define it after if needed.
  5537. */
  5538. #ifndef GLAPIENTRY
  5539. #define GLAPIENTRY APIENTRY
  5540. #endif
  5541. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  5542. #ifdef __cplusplus
  5543. }
  5544. #endif
  5545. #endif /* _glfw3_h_ */