glfw3.h 237 KB

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