glfw3.h 238 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569
  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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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:__ Monitor gamma is a privileged protocol, so this function
  2766. * cannot 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:__ Monitor gamma is a privileged protocol, so this function
  2789. * cannot 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:__ Monitor gamma is a privileged protocol, so this function
  2832. * cannot 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:__ The window frame will not be rendered at full resolution
  3028. * 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. * __GLFW 3:__ 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:__ Window positions are not currently part of any common
  3268. * Wayland protocol, so this function cannot be implemented and 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:__ Window positions are not currently part of any common
  3301. * Wayland protocol, so this function cannot be implemented and 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * __GLFW 3:__ 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. * @thread_safety This function must only be called from the main thread.
  3634. *
  3635. * @sa @ref window_iconify
  3636. * @sa @ref glfwRestoreWindow
  3637. * @sa @ref glfwMaximizeWindow
  3638. *
  3639. * @since Added in version 2.1.
  3640. * __GLFW 3:__ Added window handle parameter.
  3641. *
  3642. * @ingroup window
  3643. */
  3644. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  3645. /*! @brief Restores the specified window.
  3646. *
  3647. * This function restores the specified window if it was previously iconified
  3648. * (minimized) or maximized. If the window is already restored, this function
  3649. * does nothing.
  3650. *
  3651. * If the specified window is an iconified full screen window, its desired
  3652. * video mode is set again for its monitor when the window is restored.
  3653. *
  3654. * @param[in] window The window to restore.
  3655. *
  3656. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3657. * GLFW_PLATFORM_ERROR.
  3658. *
  3659. * @remark __Wayland:__ Restoring a window from maximization is not currently
  3660. * part of any common Wayland protocol, so this function can only restore
  3661. * windows from maximization.
  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. * __GLFW 3:__ 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:__ Window positions are not currently part of any common
  3877. * Wayland protocol. The window position arguments are ignored.
  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:__ Checking whether a window is iconified is not currently
  3914. * part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute
  3915. * cannot be implemented and is always `GLFW_FALSE`.
  3916. *
  3917. * @thread_safety This function must only be called from the main thread.
  3918. *
  3919. * @sa @ref window_attribs
  3920. * @sa @ref glfwSetWindowAttrib
  3921. *
  3922. * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
  3923. * `glfwGetGLVersion`.
  3924. *
  3925. * @ingroup window
  3926. */
  3927. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  3928. /*! @brief Sets an attribute of the specified window.
  3929. *
  3930. * This function sets the value of an attribute of the specified window.
  3931. *
  3932. * The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
  3933. * [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
  3934. * [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
  3935. * [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
  3936. * [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
  3937. * [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
  3938. *
  3939. * Some of these attributes are ignored for full screen windows. The new
  3940. * value will take effect if the window is later made windowed.
  3941. *
  3942. * Some of these attributes are ignored for windowed mode windows. The new
  3943. * value will take effect if the window is later made full screen.
  3944. *
  3945. * @param[in] window The window to set the attribute for.
  3946. * @param[in] attrib A supported window attribute.
  3947. * @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
  3948. *
  3949. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3950. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref
  3951. * GLFW_FEATURE_UNAVAILABLE (see remarks).
  3952. *
  3953. * @remark Calling @ref glfwGetWindowAttrib will always return the latest
  3954. * value, even if that value is ignored by the current mode of the window.
  3955. *
  3956. * @remark __Wayland:__ The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is
  3957. * not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE.
  3958. *
  3959. * @thread_safety This function must only be called from the main thread.
  3960. *
  3961. * @sa @ref window_attribs
  3962. * @sa @ref glfwGetWindowAttrib
  3963. *
  3964. * @since Added in version 3.3.
  3965. *
  3966. * @ingroup window
  3967. */
  3968. GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
  3969. /*! @brief Sets the user pointer of the specified window.
  3970. *
  3971. * This function sets the user-defined pointer of the specified window. The
  3972. * current value is retained until the window is destroyed. The initial value
  3973. * is `NULL`.
  3974. *
  3975. * @param[in] window The window whose pointer to set.
  3976. * @param[in] pointer The new value.
  3977. *
  3978. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3979. *
  3980. * @thread_safety This function may be called from any thread. Access is not
  3981. * synchronized.
  3982. *
  3983. * @sa @ref window_userptr
  3984. * @sa @ref glfwGetWindowUserPointer
  3985. *
  3986. * @since Added in version 3.0.
  3987. *
  3988. * @ingroup window
  3989. */
  3990. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  3991. /*! @brief Returns the user pointer of the specified window.
  3992. *
  3993. * This function returns the current value of the user-defined pointer of the
  3994. * specified window. The initial value is `NULL`.
  3995. *
  3996. * @param[in] window The window whose pointer to return.
  3997. *
  3998. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3999. *
  4000. * @thread_safety This function may be called from any thread. Access is not
  4001. * synchronized.
  4002. *
  4003. * @sa @ref window_userptr
  4004. * @sa @ref glfwSetWindowUserPointer
  4005. *
  4006. * @since Added in version 3.0.
  4007. *
  4008. * @ingroup window
  4009. */
  4010. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  4011. /*! @brief Sets the position callback for the specified window.
  4012. *
  4013. * This function sets the position callback of the specified window, which is
  4014. * called when the window is moved. The callback is provided with the
  4015. * position, in screen coordinates, of the upper-left corner of the content
  4016. * area of the window.
  4017. *
  4018. * @param[in] window The window whose callback to set.
  4019. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4020. * callback.
  4021. * @return The previously set callback, or `NULL` if no callback was set or the
  4022. * library had not been [initialized](@ref intro_init).
  4023. *
  4024. * @callback_signature
  4025. * @code
  4026. * void function_name(GLFWwindow* window, int xpos, int ypos)
  4027. * @endcode
  4028. * For more information about the callback parameters, see the
  4029. * [function pointer type](@ref GLFWwindowposfun).
  4030. *
  4031. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4032. *
  4033. * @remark __Wayland:__ This callback will not be called. The Wayland protocol
  4034. * provides no way to be notified of when a window is moved.
  4035. *
  4036. * @thread_safety This function must only be called from the main thread.
  4037. *
  4038. * @sa @ref window_pos
  4039. *
  4040. * @since Added in version 3.0.
  4041. *
  4042. * @ingroup window
  4043. */
  4044. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
  4045. /*! @brief Sets the size callback for the specified window.
  4046. *
  4047. * This function sets the size callback of the specified window, which is
  4048. * called when the window is resized. The callback is provided with the size,
  4049. * in screen coordinates, of the content area of the window.
  4050. *
  4051. * @param[in] window The window whose callback to set.
  4052. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4053. * callback.
  4054. * @return The previously set callback, or `NULL` if no callback was set or the
  4055. * library had not been [initialized](@ref intro_init).
  4056. *
  4057. * @callback_signature
  4058. * @code
  4059. * void function_name(GLFWwindow* window, int width, int height)
  4060. * @endcode
  4061. * For more information about the callback parameters, see the
  4062. * [function pointer type](@ref GLFWwindowsizefun).
  4063. *
  4064. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4065. *
  4066. * @thread_safety This function must only be called from the main thread.
  4067. *
  4068. * @sa @ref window_size
  4069. *
  4070. * @since Added in version 1.0.
  4071. * __GLFW 3:__ Added window handle parameter and return value.
  4072. *
  4073. * @ingroup window
  4074. */
  4075. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
  4076. /*! @brief Sets the close callback for the specified window.
  4077. *
  4078. * This function sets the close callback of the specified window, which is
  4079. * called when the user attempts to close the window, for example by clicking
  4080. * the close widget in the title bar.
  4081. *
  4082. * The close flag is set before this callback is called, but you can modify it
  4083. * at any time with @ref glfwSetWindowShouldClose.
  4084. *
  4085. * The close callback is not triggered by @ref glfwDestroyWindow.
  4086. *
  4087. * @param[in] window The window whose callback to set.
  4088. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4089. * callback.
  4090. * @return The previously set callback, or `NULL` if no callback was set or the
  4091. * library had not been [initialized](@ref intro_init).
  4092. *
  4093. * @callback_signature
  4094. * @code
  4095. * void function_name(GLFWwindow* window)
  4096. * @endcode
  4097. * For more information about the callback parameters, see the
  4098. * [function pointer type](@ref GLFWwindowclosefun).
  4099. *
  4100. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4101. *
  4102. * @remark __macOS:__ Selecting Quit from the application menu will trigger the
  4103. * close callback for all windows.
  4104. *
  4105. * @thread_safety This function must only be called from the main thread.
  4106. *
  4107. * @sa @ref window_close
  4108. *
  4109. * @since Added in version 2.5.
  4110. * __GLFW 3:__ Added window handle parameter and return value.
  4111. *
  4112. * @ingroup window
  4113. */
  4114. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
  4115. /*! @brief Sets the refresh callback for the specified window.
  4116. *
  4117. * This function sets the refresh callback of the specified window, which is
  4118. * called when the content area of the window needs to be redrawn, for example
  4119. * if the window has been exposed after having been covered by another window.
  4120. *
  4121. * On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
  4122. * the window contents are saved off-screen, this callback may be called only
  4123. * very infrequently or never at all.
  4124. *
  4125. * @param[in] window The window whose callback to set.
  4126. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4127. * callback.
  4128. * @return The previously set callback, or `NULL` if no callback was set or the
  4129. * library had not been [initialized](@ref intro_init).
  4130. *
  4131. * @callback_signature
  4132. * @code
  4133. * void function_name(GLFWwindow* window);
  4134. * @endcode
  4135. * For more information about the callback parameters, see the
  4136. * [function pointer type](@ref GLFWwindowrefreshfun).
  4137. *
  4138. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4139. *
  4140. * @thread_safety This function must only be called from the main thread.
  4141. *
  4142. * @sa @ref window_refresh
  4143. *
  4144. * @since Added in version 2.5.
  4145. * __GLFW 3:__ Added window handle parameter and return value.
  4146. *
  4147. * @ingroup window
  4148. */
  4149. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
  4150. /*! @brief Sets the focus callback for the specified window.
  4151. *
  4152. * This function sets the focus callback of the specified window, which is
  4153. * called when the window gains or loses input focus.
  4154. *
  4155. * After the focus callback is called for a window that lost input focus,
  4156. * synthetic key and mouse button release events will be generated for all such
  4157. * that had been pressed. For more information, see @ref glfwSetKeyCallback
  4158. * and @ref glfwSetMouseButtonCallback.
  4159. *
  4160. * @param[in] window The window whose callback to set.
  4161. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4162. * callback.
  4163. * @return The previously set callback, or `NULL` if no callback was set or the
  4164. * library had not been [initialized](@ref intro_init).
  4165. *
  4166. * @callback_signature
  4167. * @code
  4168. * void function_name(GLFWwindow* window, int focused)
  4169. * @endcode
  4170. * For more information about the callback parameters, see the
  4171. * [function pointer type](@ref GLFWwindowfocusfun).
  4172. *
  4173. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4174. *
  4175. * @thread_safety This function must only be called from the main thread.
  4176. *
  4177. * @sa @ref window_focus
  4178. *
  4179. * @since Added in version 3.0.
  4180. *
  4181. * @ingroup window
  4182. */
  4183. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
  4184. /*! @brief Sets the iconify callback for the specified window.
  4185. *
  4186. * This function sets the iconification callback of the specified window, which
  4187. * is called when the window is iconified or restored.
  4188. *
  4189. * @param[in] window The window whose callback to set.
  4190. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4191. * callback.
  4192. * @return The previously set callback, or `NULL` if no callback was set or the
  4193. * library had not been [initialized](@ref intro_init).
  4194. *
  4195. * @callback_signature
  4196. * @code
  4197. * void function_name(GLFWwindow* window, int iconified)
  4198. * @endcode
  4199. * For more information about the callback parameters, see the
  4200. * [function pointer type](@ref GLFWwindowiconifyfun).
  4201. *
  4202. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4203. *
  4204. * @remark __Wayland:__ This callback will not be called. The Wayland protocol
  4205. * provides no way to be notified of when a window is iconified, and no way to
  4206. * check whether a window is currently iconified.
  4207. *
  4208. * @thread_safety This function must only be called from the main thread.
  4209. *
  4210. * @sa @ref window_iconify
  4211. *
  4212. * @since Added in version 3.0.
  4213. *
  4214. * @ingroup window
  4215. */
  4216. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
  4217. /*! @brief Sets the maximize callback for the specified window.
  4218. *
  4219. * This function sets the maximization callback of the specified window, which
  4220. * is called when the window is maximized or restored.
  4221. *
  4222. * @param[in] window The window whose callback to set.
  4223. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4224. * callback.
  4225. * @return The previously set callback, or `NULL` if no callback was set or the
  4226. * library had not been [initialized](@ref intro_init).
  4227. *
  4228. * @callback_signature
  4229. * @code
  4230. * void function_name(GLFWwindow* window, int maximized)
  4231. * @endcode
  4232. * For more information about the callback parameters, see the
  4233. * [function pointer type](@ref GLFWwindowmaximizefun).
  4234. *
  4235. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4236. *
  4237. * @thread_safety This function must only be called from the main thread.
  4238. *
  4239. * @sa @ref window_maximize
  4240. *
  4241. * @since Added in version 3.3.
  4242. *
  4243. * @ingroup window
  4244. */
  4245. GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
  4246. /*! @brief Sets the framebuffer resize callback for the specified window.
  4247. *
  4248. * This function sets the framebuffer resize callback of the specified window,
  4249. * which is called when the framebuffer of the specified window is resized.
  4250. *
  4251. * @param[in] window The window whose callback to set.
  4252. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4253. * callback.
  4254. * @return The previously set callback, or `NULL` if no callback was set or the
  4255. * library had not been [initialized](@ref intro_init).
  4256. *
  4257. * @callback_signature
  4258. * @code
  4259. * void function_name(GLFWwindow* window, int width, int height)
  4260. * @endcode
  4261. * For more information about the callback parameters, see the
  4262. * [function pointer type](@ref GLFWframebuffersizefun).
  4263. *
  4264. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4265. *
  4266. * @thread_safety This function must only be called from the main thread.
  4267. *
  4268. * @sa @ref window_fbsize
  4269. *
  4270. * @since Added in version 3.0.
  4271. *
  4272. * @ingroup window
  4273. */
  4274. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
  4275. /*! @brief Sets the window content scale callback for the specified window.
  4276. *
  4277. * This function sets the window content scale callback of the specified window,
  4278. * which is called when the content scale of the specified window changes.
  4279. *
  4280. * @param[in] window The window whose callback to set.
  4281. * @param[in] callback The new callback, or `NULL` to remove the currently set
  4282. * callback.
  4283. * @return The previously set callback, or `NULL` if no callback was set or the
  4284. * library had not been [initialized](@ref intro_init).
  4285. *
  4286. * @callback_signature
  4287. * @code
  4288. * void function_name(GLFWwindow* window, float xscale, float yscale)
  4289. * @endcode
  4290. * For more information about the callback parameters, see the
  4291. * [function pointer type](@ref GLFWwindowcontentscalefun).
  4292. *
  4293. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4294. *
  4295. * @thread_safety This function must only be called from the main thread.
  4296. *
  4297. * @sa @ref window_scale
  4298. * @sa @ref glfwGetWindowContentScale
  4299. *
  4300. * @since Added in version 3.3.
  4301. *
  4302. * @ingroup window
  4303. */
  4304. GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
  4305. /*! @brief Processes all pending events.
  4306. *
  4307. * This function processes only those events that are already in the event
  4308. * queue and then returns immediately. Processing events will cause the window
  4309. * and input callbacks associated with those events to be called.
  4310. *
  4311. * On some platforms, a window move, resize or menu operation will cause event
  4312. * processing to block. This is due to how event processing is designed on
  4313. * those platforms. You can use the
  4314. * [window refresh callback](@ref window_refresh) to redraw the contents of
  4315. * your window when necessary during such operations.
  4316. *
  4317. * Do not assume that callbacks you set will _only_ be called in response to
  4318. * event processing functions like this one. While it is necessary to poll for
  4319. * events, window systems that require GLFW to register callbacks of its own
  4320. * can pass events to GLFW in response to many window system function calls.
  4321. * GLFW will pass those events on to the application callbacks before
  4322. * returning.
  4323. *
  4324. * Event processing is not required to receive joystick input. Joystick state
  4325. * is polled when a joystick input or gamepad input function is called.
  4326. *
  4327. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4328. * GLFW_PLATFORM_ERROR.
  4329. *
  4330. * @reentrancy This function must not be called from a callback.
  4331. *
  4332. * @thread_safety This function must only be called from the main thread.
  4333. *
  4334. * @sa @ref events
  4335. * @sa @ref glfwWaitEvents
  4336. * @sa @ref glfwWaitEventsTimeout
  4337. *
  4338. * @since Added in version 1.0.
  4339. *
  4340. * @ingroup window
  4341. */
  4342. GLFWAPI void glfwPollEvents(void);
  4343. /*! @brief Waits until events are queued and processes them.
  4344. *
  4345. * This function puts the calling thread to sleep until at least one event is
  4346. * available in the event queue. Once one or more events are available,
  4347. * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
  4348. * are processed and the function then returns immediately. Processing events
  4349. * will cause the window and input callbacks associated with those events to be
  4350. * called.
  4351. *
  4352. * Since not all events are associated with callbacks, this function may return
  4353. * without a callback having been called even if you are monitoring all
  4354. * callbacks.
  4355. *
  4356. * On some platforms, a window move, resize or menu operation will cause event
  4357. * processing to block. This is due to how event processing is designed on
  4358. * those platforms. You can use the
  4359. * [window refresh callback](@ref window_refresh) to redraw the contents of
  4360. * your window when necessary during such operations.
  4361. *
  4362. * Do not assume that callbacks you set will _only_ be called in response to
  4363. * event processing functions like this one. While it is necessary to poll for
  4364. * events, window systems that require GLFW to register callbacks of its own
  4365. * can pass events to GLFW in response to many window system function calls.
  4366. * GLFW will pass those events on to the application callbacks before
  4367. * returning.
  4368. *
  4369. * Event processing is not required to receive joystick input. Joystick state
  4370. * is polled when a joystick input or gamepad input function is called.
  4371. *
  4372. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4373. * GLFW_PLATFORM_ERROR.
  4374. *
  4375. * @reentrancy This function must not be called from a callback.
  4376. *
  4377. * @thread_safety This function must only be called from the main thread.
  4378. *
  4379. * @sa @ref events
  4380. * @sa @ref glfwPollEvents
  4381. * @sa @ref glfwWaitEventsTimeout
  4382. *
  4383. * @since Added in version 2.5.
  4384. *
  4385. * @ingroup window
  4386. */
  4387. GLFWAPI void glfwWaitEvents(void);
  4388. /*! @brief Waits with timeout until events are queued and processes them.
  4389. *
  4390. * This function puts the calling thread to sleep until at least one event is
  4391. * available in the event queue, or until the specified timeout is reached. If
  4392. * one or more events are available, it behaves exactly like @ref
  4393. * glfwPollEvents, i.e. the events in the queue are processed and the function
  4394. * then returns immediately. Processing events will cause the window and input
  4395. * callbacks associated with those events to be called.
  4396. *
  4397. * The timeout value must be a positive finite number.
  4398. *
  4399. * Since not all events are associated with callbacks, this function may return
  4400. * without a callback having been called even if you are monitoring all
  4401. * callbacks.
  4402. *
  4403. * On some platforms, a window move, resize or menu operation will cause event
  4404. * processing to block. This is due to how event processing is designed on
  4405. * those platforms. You can use the
  4406. * [window refresh callback](@ref window_refresh) to redraw the contents of
  4407. * your window when necessary during such operations.
  4408. *
  4409. * Do not assume that callbacks you set will _only_ be called in response to
  4410. * event processing functions like this one. While it is necessary to poll for
  4411. * events, window systems that require GLFW to register callbacks of its own
  4412. * can pass events to GLFW in response to many window system function calls.
  4413. * GLFW will pass those events on to the application callbacks before
  4414. * returning.
  4415. *
  4416. * Event processing is not required to receive joystick input. Joystick state
  4417. * is polled when a joystick input or gamepad input function is called.
  4418. *
  4419. * @param[in] timeout The maximum amount of time, in seconds, to wait.
  4420. *
  4421. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4422. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  4423. *
  4424. * @reentrancy This function must not be called from a callback.
  4425. *
  4426. * @thread_safety This function must only be called from the main thread.
  4427. *
  4428. * @sa @ref events
  4429. * @sa @ref glfwPollEvents
  4430. * @sa @ref glfwWaitEvents
  4431. *
  4432. * @since Added in version 3.2.
  4433. *
  4434. * @ingroup window
  4435. */
  4436. GLFWAPI void glfwWaitEventsTimeout(double timeout);
  4437. /*! @brief Posts an empty event to the event queue.
  4438. *
  4439. * This function posts an empty event from the current thread to the event
  4440. * queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
  4441. *
  4442. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4443. * GLFW_PLATFORM_ERROR.
  4444. *
  4445. * @thread_safety This function may be called from any thread.
  4446. *
  4447. * @sa @ref events
  4448. * @sa @ref glfwWaitEvents
  4449. * @sa @ref glfwWaitEventsTimeout
  4450. *
  4451. * @since Added in version 3.1.
  4452. *
  4453. * @ingroup window
  4454. */
  4455. GLFWAPI void glfwPostEmptyEvent(void);
  4456. /*! @brief Returns the value of an input option for the specified window.
  4457. *
  4458. * This function returns the value of an input option for the specified window.
  4459. * The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  4460. * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
  4461. * @ref GLFW_RAW_MOUSE_MOTION.
  4462. *
  4463. * @param[in] window The window to query.
  4464. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  4465. * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
  4466. * `GLFW_RAW_MOUSE_MOTION`.
  4467. *
  4468. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4469. * GLFW_INVALID_ENUM.
  4470. *
  4471. * @thread_safety This function must only be called from the main thread.
  4472. *
  4473. * @sa @ref glfwSetInputMode
  4474. *
  4475. * @since Added in version 3.0.
  4476. *
  4477. * @ingroup input
  4478. */
  4479. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  4480. /*! @brief Sets an input option for the specified window.
  4481. *
  4482. * This function sets an input mode option for the specified window. The mode
  4483. * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
  4484. * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS
  4485. * @ref GLFW_RAW_MOUSE_MOTION, or @ref GLFW_UNLIMITED_MOUSE_BUTTONS.
  4486. *
  4487. * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  4488. * modes:
  4489. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  4490. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
  4491. * content area of the window but does not restrict the cursor from leaving.
  4492. * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  4493. * and unlimited cursor movement. This is useful for implementing for
  4494. * example 3D camera controls.
  4495. * - `GLFW_CURSOR_CAPTURED` makes the cursor visible and confines it to the
  4496. * content area of the window.
  4497. *
  4498. * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
  4499. * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
  4500. * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  4501. * the next time it is called even if the key had been released before the
  4502. * call. This is useful when you are only interested in whether keys have been
  4503. * pressed but not when or in which order.
  4504. *
  4505. * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  4506. * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
  4507. * If sticky mouse buttons are enabled, a mouse button press will ensure that
  4508. * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
  4509. * if the mouse button had been released before the call. This is useful when
  4510. * you are only interested in whether mouse buttons have been pressed but not
  4511. * when or in which order.
  4512. *
  4513. * If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
  4514. * enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
  4515. * callbacks that receive modifier bits will also have the @ref
  4516. * GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
  4517. * and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
  4518. *
  4519. * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
  4520. * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
  4521. * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported,
  4522. * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
  4523. * glfwRawMouseMotionSupported to check for support.
  4524. *
  4525. * If the mode is `GLFW_UNLIMITED_MOUSE_BUTTONS`, the value must be either
  4526. * `GLFW_TRUE` to disable the mouse button limit when calling the mouse button
  4527. * callback, or `GLFW_FALSE` to limit the mouse buttons sent to the callback
  4528. * to the mouse button token values up to `GLFW_MOUSE_BUTTON_LAST`.
  4529. *
  4530. * @param[in] window The window whose input mode to set.
  4531. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
  4532. * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
  4533. * `GLFW_RAW_MOUSE_MOTION`.
  4534. * @param[in] value The new value of the specified input mode.
  4535. *
  4536. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4537. * GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
  4538. * GLFW_FEATURE_UNAVAILABLE (see above).
  4539. *
  4540. * @thread_safety This function must only be called from the main thread.
  4541. *
  4542. * @sa @ref glfwGetInputMode
  4543. *
  4544. * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
  4545. *
  4546. * @ingroup input
  4547. */
  4548. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  4549. /*! @brief Returns whether raw mouse motion is supported.
  4550. *
  4551. * This function returns whether raw mouse motion is supported on the current
  4552. * system. This status does not change after GLFW has been initialized so you
  4553. * only need to check this once. If you attempt to enable raw motion on
  4554. * a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
  4555. *
  4556. * Raw mouse motion is closer to the actual motion of the mouse across
  4557. * a surface. It is not affected by the scaling and acceleration applied to
  4558. * the motion of the desktop cursor. That processing is suitable for a cursor
  4559. * while raw motion is better for controlling for example a 3D camera. Because
  4560. * of this, raw mouse motion is only provided when the cursor is disabled.
  4561. *
  4562. * @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
  4563. * or `GLFW_FALSE` otherwise.
  4564. *
  4565. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4566. *
  4567. * @thread_safety This function must only be called from the main thread.
  4568. *
  4569. * @sa @ref raw_mouse_motion
  4570. * @sa @ref glfwSetInputMode
  4571. *
  4572. * @since Added in version 3.3.
  4573. *
  4574. * @ingroup input
  4575. */
  4576. GLFWAPI int glfwRawMouseMotionSupported(void);
  4577. /*! @brief Returns the layout-specific name of the specified printable key.
  4578. *
  4579. * This function returns the name of the specified printable key, encoded as
  4580. * UTF-8. This is typically the character that key would produce without any
  4581. * modifier keys, intended for displaying key bindings to the user. For dead
  4582. * keys, it is typically the diacritic it would add to a character.
  4583. *
  4584. * __Do not use this function__ for [text input](@ref input_char). You will
  4585. * break text input for many languages even if it happens to work for yours.
  4586. *
  4587. * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
  4588. * otherwise the scancode is ignored. If you specify a non-printable key, or
  4589. * `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
  4590. * function returns `NULL` but does not emit an error.
  4591. *
  4592. * This behavior allows you to always pass in the arguments in the
  4593. * [key callback](@ref input_key) without modification.
  4594. *
  4595. * The printable keys are:
  4596. * - `GLFW_KEY_APOSTROPHE`
  4597. * - `GLFW_KEY_COMMA`
  4598. * - `GLFW_KEY_MINUS`
  4599. * - `GLFW_KEY_PERIOD`
  4600. * - `GLFW_KEY_SLASH`
  4601. * - `GLFW_KEY_SEMICOLON`
  4602. * - `GLFW_KEY_EQUAL`
  4603. * - `GLFW_KEY_LEFT_BRACKET`
  4604. * - `GLFW_KEY_RIGHT_BRACKET`
  4605. * - `GLFW_KEY_BACKSLASH`
  4606. * - `GLFW_KEY_WORLD_1`
  4607. * - `GLFW_KEY_WORLD_2`
  4608. * - `GLFW_KEY_0` to `GLFW_KEY_9`
  4609. * - `GLFW_KEY_A` to `GLFW_KEY_Z`
  4610. * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
  4611. * - `GLFW_KEY_KP_DECIMAL`
  4612. * - `GLFW_KEY_KP_DIVIDE`
  4613. * - `GLFW_KEY_KP_MULTIPLY`
  4614. * - `GLFW_KEY_KP_SUBTRACT`
  4615. * - `GLFW_KEY_KP_ADD`
  4616. * - `GLFW_KEY_KP_EQUAL`
  4617. *
  4618. * Names for printable keys depend on keyboard layout, while names for
  4619. * non-printable keys are the same across layouts but depend on the application
  4620. * language and should be localized along with other user interface text.
  4621. *
  4622. * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
  4623. * @param[in] scancode The scancode of the key to query.
  4624. * @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
  4625. *
  4626. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4627. * GLFW_INVALID_VALUE, @ref GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  4628. *
  4629. * @remark The contents of the returned string may change when a keyboard
  4630. * layout change event is received.
  4631. *
  4632. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  4633. * should not free it yourself. It is valid until the library is terminated.
  4634. *
  4635. * @thread_safety This function must only be called from the main thread.
  4636. *
  4637. * @sa @ref input_key_name
  4638. *
  4639. * @since Added in version 3.2.
  4640. *
  4641. * @ingroup input
  4642. */
  4643. GLFWAPI const char* glfwGetKeyName(int key, int scancode);
  4644. /*! @brief Returns the platform-specific scancode of the specified key.
  4645. *
  4646. * This function returns the platform-specific scancode of the specified key.
  4647. *
  4648. * If the specified [key token](@ref keys) corresponds to a physical key not
  4649. * supported on the current platform then this method will return `-1`.
  4650. * Calling this function with anything other than a key token will return `-1`
  4651. * and generate a @ref GLFW_INVALID_ENUM error.
  4652. *
  4653. * @param[in] key Any [key token](@ref keys).
  4654. * @return The platform-specific scancode for the key, or `-1` if the key is
  4655. * not supported on the current platform or an [error](@ref error_handling)
  4656. * occurred.
  4657. *
  4658. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4659. * GLFW_INVALID_ENUM.
  4660. *
  4661. * @thread_safety This function may be called from any thread.
  4662. *
  4663. * @sa @ref input_key
  4664. *
  4665. * @since Added in version 3.3.
  4666. *
  4667. * @ingroup input
  4668. */
  4669. GLFWAPI int glfwGetKeyScancode(int key);
  4670. /*! @brief Returns the last reported state of a keyboard key for the specified
  4671. * window.
  4672. *
  4673. * This function returns the last state reported for the specified key to the
  4674. * specified window. The returned state is one of `GLFW_PRESS` or
  4675. * `GLFW_RELEASE`. The action `GLFW_REPEAT` is only reported to the key callback.
  4676. *
  4677. * If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
  4678. * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  4679. * that key has already been released.
  4680. *
  4681. * The key functions deal with physical keys, with [key tokens](@ref keys)
  4682. * named after their use on the standard US keyboard layout. If you want to
  4683. * input text, use the Unicode character callback instead.
  4684. *
  4685. * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  4686. * used with this function.
  4687. *
  4688. * __Do not use this function__ to implement [text input](@ref input_char).
  4689. *
  4690. * @param[in] window The desired window.
  4691. * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
  4692. * not a valid key for this function.
  4693. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  4694. *
  4695. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4696. * GLFW_INVALID_ENUM.
  4697. *
  4698. * @thread_safety This function must only be called from the main thread.
  4699. *
  4700. * @sa @ref input_key
  4701. *
  4702. * @since Added in version 1.0.
  4703. * __GLFW 3:__ Added window handle parameter.
  4704. *
  4705. * @ingroup input
  4706. */
  4707. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  4708. /*! @brief Returns the last reported state of a mouse button for the specified
  4709. * window.
  4710. *
  4711. * This function returns the last state reported for the specified mouse button
  4712. * to the specified window. The returned state is one of `GLFW_PRESS` or
  4713. * `GLFW_RELEASE`.
  4714. *
  4715. * If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
  4716. * returns `GLFW_PRESS` the first time you call it for a mouse button that was
  4717. * pressed, even if that mouse button has already been released.
  4718. *
  4719. * The @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode does not effect the
  4720. * limit on buttons which can be polled with this function.
  4721. *
  4722. * @param[in] window The desired window.
  4723. * @param[in] button The desired [mouse button token](@ref buttons).
  4724. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  4725. *
  4726. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4727. * GLFW_INVALID_ENUM.
  4728. *
  4729. * @thread_safety This function must only be called from the main thread.
  4730. *
  4731. * @sa @ref input_mouse_button
  4732. *
  4733. * @since Added in version 1.0.
  4734. * __GLFW 3:__ Added window handle parameter.
  4735. *
  4736. * @ingroup input
  4737. */
  4738. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  4739. /*! @brief Retrieves the position of the cursor relative to the content area of
  4740. * the window.
  4741. *
  4742. * This function returns the position of the cursor, in screen coordinates,
  4743. * relative to the upper-left corner of the content area of the specified
  4744. * window.
  4745. *
  4746. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  4747. * position is unbounded and limited only by the minimum and maximum values of
  4748. * a `double`.
  4749. *
  4750. * The coordinate can be converted to their integer equivalents with the
  4751. * `floor` function. Casting directly to an integer type works for positive
  4752. * coordinates, but fails for negative ones.
  4753. *
  4754. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  4755. * non-`NULL` position arguments will be set to zero.
  4756. *
  4757. * @param[in] window The desired window.
  4758. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  4759. * left edge of the content area, or `NULL`.
  4760. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  4761. * top edge of the content area, or `NULL`.
  4762. *
  4763. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4764. * GLFW_PLATFORM_ERROR.
  4765. *
  4766. * @thread_safety This function must only be called from the main thread.
  4767. *
  4768. * @sa @ref cursor_pos
  4769. * @sa @ref glfwSetCursorPos
  4770. *
  4771. * @since Added in version 3.0. Replaces `glfwGetMousePos`.
  4772. *
  4773. * @ingroup input
  4774. */
  4775. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  4776. /*! @brief Sets the position of the cursor, relative to the content area of the
  4777. * window.
  4778. *
  4779. * This function sets the position, in screen coordinates, of the cursor
  4780. * relative to the upper-left corner of the content area of the specified
  4781. * window. The window must have input focus. If the window does not have
  4782. * input focus when this function is called, it fails silently.
  4783. *
  4784. * __Do not use this function__ to implement things like camera controls. GLFW
  4785. * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  4786. * cursor, transparently re-centers it and provides unconstrained cursor
  4787. * motion. See @ref glfwSetInputMode for more information.
  4788. *
  4789. * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  4790. * unconstrained and limited only by the minimum and maximum values of
  4791. * a `double`.
  4792. *
  4793. * @param[in] window The desired window.
  4794. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  4795. * content area.
  4796. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  4797. * content area.
  4798. *
  4799. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4800. * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
  4801. *
  4802. * @remark __Wayland:__ This function will only work when the cursor mode is
  4803. * `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE.
  4804. *
  4805. * @thread_safety This function must only be called from the main thread.
  4806. *
  4807. * @sa @ref cursor_pos
  4808. * @sa @ref glfwGetCursorPos
  4809. *
  4810. * @since Added in version 3.0. Replaces `glfwSetMousePos`.
  4811. *
  4812. * @ingroup input
  4813. */
  4814. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  4815. /*! @brief Creates a custom cursor.
  4816. *
  4817. * Creates a new custom cursor image that can be set for a window with @ref
  4818. * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
  4819. * Any remaining cursors are destroyed by @ref glfwTerminate.
  4820. *
  4821. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  4822. * bits per channel with the red channel first. They are arranged canonically
  4823. * as packed sequential rows, starting from the top-left corner.
  4824. *
  4825. * The cursor hotspot is specified in pixels, relative to the upper-left corner
  4826. * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
  4827. * points to the right and the Y-axis points down.
  4828. *
  4829. * @param[in] image The desired cursor image.
  4830. * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
  4831. * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
  4832. * @return The handle of the created cursor, or `NULL` if an
  4833. * [error](@ref error_handling) occurred.
  4834. *
  4835. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4836. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  4837. *
  4838. * @pointer_lifetime The specified image data is copied before this function
  4839. * returns.
  4840. *
  4841. * @thread_safety This function must only be called from the main thread.
  4842. *
  4843. * @sa @ref cursor_object
  4844. * @sa @ref glfwDestroyCursor
  4845. * @sa @ref glfwCreateStandardCursor
  4846. *
  4847. * @since Added in version 3.1.
  4848. *
  4849. * @ingroup input
  4850. */
  4851. GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
  4852. /*! @brief Creates a cursor with a standard shape.
  4853. *
  4854. * Returns a cursor with a standard shape, that can be set for a window with
  4855. * @ref glfwSetCursor. The images for these cursors come from the system
  4856. * cursor theme and their exact appearance will vary between platforms.
  4857. *
  4858. * Most of these shapes are guaranteed to exist on every supported platform but
  4859. * a few may not be present. See the table below for details.
  4860. *
  4861. * Cursor shape | Windows | macOS | X11 | Wayland
  4862. * ------------------------------ | ------- | ----- | ------ | -------
  4863. * @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes
  4864. * @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes
  4865. * @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes
  4866. * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes
  4867. * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes
  4868. * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes
  4869. * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
  4870. * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
  4871. * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes
  4872. * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe<sup>2</sup> | Maybe<sup>2</sup>
  4873. *
  4874. * 1) This uses a private system API and may fail in the future.
  4875. *
  4876. * 2) This uses a newer standard that not all cursor themes support.
  4877. *
  4878. * If the requested shape is not available, this function emits a @ref
  4879. * GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
  4880. *
  4881. * @param[in] shape One of the [standard shapes](@ref shapes).
  4882. * @return A new cursor ready to use or `NULL` if an
  4883. * [error](@ref error_handling) occurred.
  4884. *
  4885. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4886. * GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
  4887. * GLFW_PLATFORM_ERROR.
  4888. *
  4889. * @thread_safety This function must only be called from the main thread.
  4890. *
  4891. * @sa @ref cursor_standard
  4892. * @sa @ref glfwCreateCursor
  4893. *
  4894. * @since Added in version 3.1.
  4895. *
  4896. * @ingroup input
  4897. */
  4898. GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
  4899. /*! @brief Destroys a cursor.
  4900. *
  4901. * This function destroys a cursor previously created with @ref
  4902. * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
  4903. * glfwTerminate.
  4904. *
  4905. * If the specified cursor is current for any window, that window will be
  4906. * reverted to the default cursor. This does not affect the cursor mode.
  4907. *
  4908. * @param[in] cursor The cursor object to destroy.
  4909. *
  4910. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4911. * GLFW_PLATFORM_ERROR.
  4912. *
  4913. * @reentrancy This function must not be called from a callback.
  4914. *
  4915. * @thread_safety This function must only be called from the main thread.
  4916. *
  4917. * @sa @ref cursor_object
  4918. * @sa @ref glfwCreateCursor
  4919. *
  4920. * @since Added in version 3.1.
  4921. *
  4922. * @ingroup input
  4923. */
  4924. GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
  4925. /*! @brief Sets the cursor for the window.
  4926. *
  4927. * This function sets the cursor image to be used when the cursor is over the
  4928. * content area of the specified window. The set cursor will only be visible
  4929. * when the [cursor mode](@ref cursor_mode) of the window is
  4930. * `GLFW_CURSOR_NORMAL`.
  4931. *
  4932. * On some platforms, the set cursor may not be visible unless the window also
  4933. * has input focus.
  4934. *
  4935. * @param[in] window The window to set the cursor for.
  4936. * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  4937. * arrow cursor.
  4938. *
  4939. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  4940. * GLFW_PLATFORM_ERROR.
  4941. *
  4942. * @thread_safety This function must only be called from the main thread.
  4943. *
  4944. * @sa @ref cursor_object
  4945. *
  4946. * @since Added in version 3.1.
  4947. *
  4948. * @ingroup input
  4949. */
  4950. GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
  4951. /*! @brief Sets the key callback.
  4952. *
  4953. * This function sets the key callback of the specified window, which is called
  4954. * when a key is pressed, repeated or released.
  4955. *
  4956. * The key functions deal with physical keys, with layout independent
  4957. * [key tokens](@ref keys) named after their values in the standard US keyboard
  4958. * layout. If you want to input text, use the
  4959. * [character callback](@ref glfwSetCharCallback) instead.
  4960. *
  4961. * When a window loses input focus, it will generate synthetic key release
  4962. * events for all pressed keys with associated key tokens. You can tell these
  4963. * events from user-generated events by the fact that the synthetic ones are
  4964. * generated after the focus loss event has been processed, i.e. after the
  4965. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  4966. *
  4967. * The scancode of a key is specific to that platform or sometimes even to that
  4968. * machine. Scancodes are intended to allow users to bind keys that don't have
  4969. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  4970. * state is not saved and so it cannot be queried with @ref glfwGetKey.
  4971. *
  4972. * Sometimes GLFW needs to generate synthetic key events, in which case the
  4973. * scancode may be zero.
  4974. *
  4975. * @param[in] window The window whose callback to set.
  4976. * @param[in] callback The new key callback, or `NULL` to remove the currently
  4977. * set callback.
  4978. * @return The previously set callback, or `NULL` if no callback was set or the
  4979. * library had not been [initialized](@ref intro_init).
  4980. *
  4981. * @callback_signature
  4982. * @code
  4983. * void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
  4984. * @endcode
  4985. * For more information about the callback parameters, see the
  4986. * [function pointer type](@ref GLFWkeyfun).
  4987. *
  4988. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  4989. *
  4990. * @thread_safety This function must only be called from the main thread.
  4991. *
  4992. * @sa @ref input_key
  4993. *
  4994. * @since Added in version 1.0.
  4995. * __GLFW 3:__ Added window handle parameter and return value.
  4996. *
  4997. * @ingroup input
  4998. */
  4999. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
  5000. /*! @brief Sets the Unicode character callback.
  5001. *
  5002. * This function sets the character callback of the specified window, which is
  5003. * called when a Unicode character is input.
  5004. *
  5005. * The character callback is intended for Unicode text input. As it deals with
  5006. * characters, it is keyboard layout dependent, whereas the
  5007. * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
  5008. * to physical keys, as a key may produce zero, one or more characters. If you
  5009. * want to know whether a specific physical key was pressed or released, see
  5010. * the key callback instead.
  5011. *
  5012. * The character callback behaves as system text input normally does and will
  5013. * not be called if modifier keys are held down that would prevent normal text
  5014. * input on that platform, for example a Super (Command) key on macOS or Alt key
  5015. * on Windows.
  5016. *
  5017. * @param[in] window The window whose callback to set.
  5018. * @param[in] callback The new callback, or `NULL` to remove the currently set
  5019. * callback.
  5020. * @return The previously set callback, or `NULL` if no callback was set or the
  5021. * library had not been [initialized](@ref intro_init).
  5022. *
  5023. * @callback_signature
  5024. * @code
  5025. * void function_name(GLFWwindow* window, unsigned int codepoint)
  5026. * @endcode
  5027. * For more information about the callback parameters, see the
  5028. * [function pointer type](@ref GLFWcharfun).
  5029. *
  5030. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5031. *
  5032. * @thread_safety This function must only be called from the main thread.
  5033. *
  5034. * @sa @ref input_char
  5035. *
  5036. * @since Added in version 2.4.
  5037. * __GLFW 3:__ Added window handle parameter and return value.
  5038. *
  5039. * @ingroup input
  5040. */
  5041. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
  5042. /*! @brief Sets the Unicode character with modifiers callback.
  5043. *
  5044. * This function sets the character with modifiers callback of the specified
  5045. * window, which is called when a Unicode character is input regardless of what
  5046. * modifier keys are used.
  5047. *
  5048. * The character with modifiers callback is intended for implementing custom
  5049. * Unicode character input. For regular Unicode text input, see the
  5050. * [character callback](@ref glfwSetCharCallback). Like the character
  5051. * callback, the character with modifiers callback deals with characters and is
  5052. * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
  5053. * a key may produce zero, one or more characters. If you want to know whether
  5054. * a specific physical key was pressed or released, see the
  5055. * [key callback](@ref glfwSetKeyCallback) instead.
  5056. *
  5057. * @param[in] window The window whose callback to set.
  5058. * @param[in] callback The new callback, or `NULL` to remove the currently set
  5059. * callback.
  5060. * @return The previously set callback, or `NULL` if no callback was set or an
  5061. * [error](@ref error_handling) occurred.
  5062. *
  5063. * @callback_signature
  5064. * @code
  5065. * void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
  5066. * @endcode
  5067. * For more information about the callback parameters, see the
  5068. * [function pointer type](@ref GLFWcharmodsfun).
  5069. *
  5070. * @deprecated Scheduled for removal in version 4.0.
  5071. *
  5072. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5073. *
  5074. * @thread_safety This function must only be called from the main thread.
  5075. *
  5076. * @sa @ref input_char
  5077. *
  5078. * @since Added in version 3.1.
  5079. *
  5080. * @ingroup input
  5081. */
  5082. GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
  5083. /*! @brief Sets the mouse button callback.
  5084. *
  5085. * This function sets the mouse button callback of the specified window, which
  5086. * is called when a mouse button is pressed or released.
  5087. *
  5088. * When a window loses input focus, it will generate synthetic mouse button
  5089. * release events for all pressed mouse buttons with associated button tokens.
  5090. * You can tell these events from user-generated events by the fact that the
  5091. * synthetic ones are generated after the focus loss event has been processed,
  5092. * i.e. after the [window focus callback](@ref glfwSetWindowFocusCallback) has
  5093. * been called.
  5094. *
  5095. * The reported `button` value can be higher than `GLFW_MOUSE_BUTTON_LAST` if
  5096. * the button does not have an associated [button token](@ref buttons) and the
  5097. * @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set.
  5098. *
  5099. * @param[in] window The window whose callback to set.
  5100. * @param[in] callback The new callback, or `NULL` to remove the currently set
  5101. * callback.
  5102. * @return The previously set callback, or `NULL` if no callback was set or the
  5103. * library had not been [initialized](@ref intro_init).
  5104. *
  5105. * @callback_signature
  5106. * @code
  5107. * void function_name(GLFWwindow* window, int button, int action, int mods)
  5108. * @endcode
  5109. * For more information about the callback parameters, see the
  5110. * [function pointer type](@ref GLFWmousebuttonfun).
  5111. *
  5112. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5113. *
  5114. * @thread_safety This function must only be called from the main thread.
  5115. *
  5116. * @sa @ref input_mouse_button
  5117. *
  5118. * @since Added in version 1.0.
  5119. * __GLFW 3:__ Added window handle parameter and return value.
  5120. *
  5121. * @ingroup input
  5122. */
  5123. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
  5124. /*! @brief Sets the cursor position callback.
  5125. *
  5126. * This function sets the cursor position callback of the specified window,
  5127. * which is called when the cursor is moved. The callback is provided with the
  5128. * position, in screen coordinates, relative to the upper-left corner of the
  5129. * content area of the window.
  5130. *
  5131. * @param[in] window The window whose callback to set.
  5132. * @param[in] callback The new callback, or `NULL` to remove the currently set
  5133. * callback.
  5134. * @return The previously set callback, or `NULL` if no callback was set or the
  5135. * library had not been [initialized](@ref intro_init).
  5136. *
  5137. * @callback_signature
  5138. * @code
  5139. * void function_name(GLFWwindow* window, double xpos, double ypos);
  5140. * @endcode
  5141. * For more information about the callback parameters, see the
  5142. * [function pointer type](@ref GLFWcursorposfun).
  5143. *
  5144. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5145. *
  5146. * @thread_safety This function must only be called from the main thread.
  5147. *
  5148. * @sa @ref cursor_pos
  5149. *
  5150. * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
  5151. *
  5152. * @ingroup input
  5153. */
  5154. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
  5155. /*! @brief Sets the cursor enter/leave callback.
  5156. *
  5157. * This function sets the cursor boundary crossing callback of the specified
  5158. * window, which is called when the cursor enters or leaves the content area of
  5159. * the window.
  5160. *
  5161. * @param[in] window The window whose callback to set.
  5162. * @param[in] callback The new callback, or `NULL` to remove the currently set
  5163. * callback.
  5164. * @return The previously set callback, or `NULL` if no callback was set or the
  5165. * library had not been [initialized](@ref intro_init).
  5166. *
  5167. * @callback_signature
  5168. * @code
  5169. * void function_name(GLFWwindow* window, int entered)
  5170. * @endcode
  5171. * For more information about the callback parameters, see the
  5172. * [function pointer type](@ref GLFWcursorenterfun).
  5173. *
  5174. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5175. *
  5176. * @thread_safety This function must only be called from the main thread.
  5177. *
  5178. * @sa @ref cursor_enter
  5179. *
  5180. * @since Added in version 3.0.
  5181. *
  5182. * @ingroup input
  5183. */
  5184. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
  5185. /*! @brief Sets the scroll callback.
  5186. *
  5187. * This function sets the scroll callback of the specified window, which is
  5188. * called when a scrolling device is used, such as a mouse wheel or scrolling
  5189. * area of a touchpad.
  5190. *
  5191. * The scroll callback receives all scrolling input, like that from a mouse
  5192. * wheel or a touchpad scrolling area.
  5193. *
  5194. * @param[in] window The window whose callback to set.
  5195. * @param[in] callback The new scroll callback, or `NULL` to remove the
  5196. * currently set callback.
  5197. * @return The previously set callback, or `NULL` if no callback was set or the
  5198. * library had not been [initialized](@ref intro_init).
  5199. *
  5200. * @callback_signature
  5201. * @code
  5202. * void function_name(GLFWwindow* window, double xoffset, double yoffset)
  5203. * @endcode
  5204. * For more information about the callback parameters, see the
  5205. * [function pointer type](@ref GLFWscrollfun).
  5206. *
  5207. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5208. *
  5209. * @thread_safety This function must only be called from the main thread.
  5210. *
  5211. * @sa @ref scrolling
  5212. *
  5213. * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
  5214. *
  5215. * @ingroup input
  5216. */
  5217. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
  5218. /*! @brief Sets the path drop callback.
  5219. *
  5220. * This function sets the path drop callback of the specified window, which is
  5221. * called when one or more dragged paths are dropped on the window.
  5222. *
  5223. * Because the path array and its strings may have been generated specifically
  5224. * for that event, they are not guaranteed to be valid after the callback has
  5225. * returned. If you wish to use them after the callback returns, you need to
  5226. * make a deep copy.
  5227. *
  5228. * @param[in] window The window whose callback to set.
  5229. * @param[in] callback The new file drop callback, or `NULL` to remove the
  5230. * currently set callback.
  5231. * @return The previously set callback, or `NULL` if no callback was set or the
  5232. * library had not been [initialized](@ref intro_init).
  5233. *
  5234. * @callback_signature
  5235. * @code
  5236. * void function_name(GLFWwindow* window, int path_count, const char* paths[])
  5237. * @endcode
  5238. * For more information about the callback parameters, see the
  5239. * [function pointer type](@ref GLFWdropfun).
  5240. *
  5241. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5242. *
  5243. * @thread_safety This function must only be called from the main thread.
  5244. *
  5245. * @sa @ref path_drop
  5246. *
  5247. * @since Added in version 3.1.
  5248. *
  5249. * @ingroup input
  5250. */
  5251. GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
  5252. /*! @brief Returns whether the specified joystick is present.
  5253. *
  5254. * This function returns whether the specified joystick is present.
  5255. *
  5256. * There is no need to call this function before other functions that accept
  5257. * a joystick ID, as they all check for presence before performing any other
  5258. * work.
  5259. *
  5260. * @param[in] jid The [joystick](@ref joysticks) to query.
  5261. * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
  5262. *
  5263. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5264. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  5265. *
  5266. * @thread_safety This function must only be called from the main thread.
  5267. *
  5268. * @sa @ref joystick
  5269. *
  5270. * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
  5271. *
  5272. * @ingroup input
  5273. */
  5274. GLFWAPI int glfwJoystickPresent(int jid);
  5275. /*! @brief Returns the values of all axes of the specified joystick.
  5276. *
  5277. * This function returns the values of all axes of the specified joystick.
  5278. * Each element in the array is a value between -1.0 and 1.0.
  5279. *
  5280. * If the specified joystick is not present this function will return `NULL`
  5281. * but will not generate an error. This can be used instead of first calling
  5282. * @ref glfwJoystickPresent.
  5283. *
  5284. * @param[in] jid The [joystick](@ref joysticks) to query.
  5285. * @param[out] count Where to store the number of axis values in the returned
  5286. * array. This is set to zero if the joystick is not present or an error
  5287. * occurred.
  5288. * @return An array of axis values, or `NULL` if the joystick is not present or
  5289. * an [error](@ref error_handling) occurred.
  5290. *
  5291. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5292. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  5293. *
  5294. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  5295. * should not free it yourself. It is valid until the specified joystick is
  5296. * disconnected or the library is terminated.
  5297. *
  5298. * @thread_safety This function must only be called from the main thread.
  5299. *
  5300. * @sa @ref joystick_axis
  5301. *
  5302. * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
  5303. *
  5304. * @ingroup input
  5305. */
  5306. GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
  5307. /*! @brief Returns the state of all buttons of the specified joystick.
  5308. *
  5309. * This function returns the state of all buttons of the specified joystick.
  5310. * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
  5311. *
  5312. * For backward compatibility with earlier versions that did not have @ref
  5313. * glfwGetJoystickHats, the button array also includes all hats, each
  5314. * represented as four buttons. The hats are in the same order as returned by
  5315. * __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
  5316. * _left_. To disable these extra buttons, set the @ref
  5317. * GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
  5318. *
  5319. * If the specified joystick is not present this function will return `NULL`
  5320. * but will not generate an error. This can be used instead of first calling
  5321. * @ref glfwJoystickPresent.
  5322. *
  5323. * @param[in] jid The [joystick](@ref joysticks) to query.
  5324. * @param[out] count Where to store the number of button states in the returned
  5325. * array. This is set to zero if the joystick is not present or an error
  5326. * occurred.
  5327. * @return An array of button states, or `NULL` if the joystick is not present
  5328. * or an [error](@ref error_handling) occurred.
  5329. *
  5330. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5331. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  5332. *
  5333. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  5334. * should not free it yourself. It is valid until the specified joystick is
  5335. * disconnected or the library is terminated.
  5336. *
  5337. * @thread_safety This function must only be called from the main thread.
  5338. *
  5339. * @sa @ref joystick_button
  5340. *
  5341. * @since Added in version 2.2.
  5342. * __GLFW 3:__ Changed to return a dynamic array.
  5343. *
  5344. * @ingroup input
  5345. */
  5346. GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
  5347. /*! @brief Returns the state of all hats of the specified joystick.
  5348. *
  5349. * This function returns the state of all hats of the specified joystick.
  5350. * Each element in the array is one of the following values:
  5351. *
  5352. * Name | Value
  5353. * ---- | -----
  5354. * `GLFW_HAT_CENTERED` | 0
  5355. * `GLFW_HAT_UP` | 1
  5356. * `GLFW_HAT_RIGHT` | 2
  5357. * `GLFW_HAT_DOWN` | 4
  5358. * `GLFW_HAT_LEFT` | 8
  5359. * `GLFW_HAT_RIGHT_UP` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
  5360. * `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
  5361. * `GLFW_HAT_LEFT_UP` | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
  5362. * `GLFW_HAT_LEFT_DOWN` | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
  5363. *
  5364. * The diagonal directions are bitwise combinations of the primary (up, right,
  5365. * down and left) directions and you can test for these individually by ANDing
  5366. * it with the corresponding direction.
  5367. *
  5368. * @code
  5369. * if (hats[2] & GLFW_HAT_RIGHT)
  5370. * {
  5371. * // State of hat 2 could be right-up, right or right-down
  5372. * }
  5373. * @endcode
  5374. *
  5375. * If the specified joystick is not present this function will return `NULL`
  5376. * but will not generate an error. This can be used instead of first calling
  5377. * @ref glfwJoystickPresent.
  5378. *
  5379. * @param[in] jid The [joystick](@ref joysticks) to query.
  5380. * @param[out] count Where to store the number of hat states in the returned
  5381. * array. This is set to zero if the joystick is not present or an error
  5382. * occurred.
  5383. * @return An array of hat states, or `NULL` if the joystick is not present
  5384. * or an [error](@ref error_handling) occurred.
  5385. *
  5386. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5387. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  5388. *
  5389. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  5390. * should not free it yourself. It is valid until the specified joystick is
  5391. * disconnected, this function is called again for that joystick or the library
  5392. * is terminated.
  5393. *
  5394. * @thread_safety This function must only be called from the main thread.
  5395. *
  5396. * @sa @ref joystick_hat
  5397. *
  5398. * @since Added in version 3.3.
  5399. *
  5400. * @ingroup input
  5401. */
  5402. GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
  5403. /*! @brief Returns the name of the specified joystick.
  5404. *
  5405. * This function returns the name, encoded as UTF-8, of the specified joystick.
  5406. * The returned string is allocated and freed by GLFW. You should not free it
  5407. * yourself.
  5408. *
  5409. * If the specified joystick is not present this function will return `NULL`
  5410. * but will not generate an error. This can be used instead of first calling
  5411. * @ref glfwJoystickPresent.
  5412. *
  5413. * @param[in] jid The [joystick](@ref joysticks) to query.
  5414. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  5415. * is not present or an [error](@ref error_handling) occurred.
  5416. *
  5417. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5418. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  5419. *
  5420. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  5421. * should not free it yourself. It is valid until the specified joystick is
  5422. * disconnected or the library is terminated.
  5423. *
  5424. * @thread_safety This function must only be called from the main thread.
  5425. *
  5426. * @sa @ref joystick_name
  5427. *
  5428. * @since Added in version 3.0.
  5429. *
  5430. * @ingroup input
  5431. */
  5432. GLFWAPI const char* glfwGetJoystickName(int jid);
  5433. /*! @brief Returns the SDL compatible GUID of the specified joystick.
  5434. *
  5435. * This function returns the SDL compatible GUID, as a UTF-8 encoded
  5436. * hexadecimal string, of the specified joystick. The returned string is
  5437. * allocated and freed by GLFW. You should not free it yourself.
  5438. *
  5439. * The GUID is what connects a joystick to a gamepad mapping. A connected
  5440. * joystick will always have a GUID even if there is no gamepad mapping
  5441. * assigned to it.
  5442. *
  5443. * If the specified joystick is not present this function will return `NULL`
  5444. * but will not generate an error. This can be used instead of first calling
  5445. * @ref glfwJoystickPresent.
  5446. *
  5447. * The GUID uses the format introduced in SDL 2.0.5. This GUID tries to
  5448. * uniquely identify the make and model of a joystick but does not identify
  5449. * a specific unit, e.g. all wired Xbox 360 controllers will have the same
  5450. * GUID on that platform. The GUID for a unit may vary between platforms
  5451. * depending on what hardware information the platform specific APIs provide.
  5452. *
  5453. * @param[in] jid The [joystick](@ref joysticks) to query.
  5454. * @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
  5455. * is not present or an [error](@ref error_handling) occurred.
  5456. *
  5457. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5458. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  5459. *
  5460. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  5461. * should not free it yourself. It is valid until the specified joystick is
  5462. * disconnected or the library is terminated.
  5463. *
  5464. * @thread_safety This function must only be called from the main thread.
  5465. *
  5466. * @sa @ref gamepad
  5467. *
  5468. * @since Added in version 3.3.
  5469. *
  5470. * @ingroup input
  5471. */
  5472. GLFWAPI const char* glfwGetJoystickGUID(int jid);
  5473. /*! @brief Sets the user pointer of the specified joystick.
  5474. *
  5475. * This function sets the user-defined pointer of the specified joystick. The
  5476. * current value is retained until the joystick is disconnected. The initial
  5477. * value is `NULL`.
  5478. *
  5479. * This function may be called from the joystick callback, even for a joystick
  5480. * that is being disconnected.
  5481. *
  5482. * @param[in] jid The joystick whose pointer to set.
  5483. * @param[in] pointer The new value.
  5484. *
  5485. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5486. *
  5487. * @thread_safety This function may be called from any thread. Access is not
  5488. * synchronized.
  5489. *
  5490. * @sa @ref joystick_userptr
  5491. * @sa @ref glfwGetJoystickUserPointer
  5492. *
  5493. * @since Added in version 3.3.
  5494. *
  5495. * @ingroup input
  5496. */
  5497. GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
  5498. /*! @brief Returns the user pointer of the specified joystick.
  5499. *
  5500. * This function returns the current value of the user-defined pointer of the
  5501. * specified joystick. The initial value is `NULL`.
  5502. *
  5503. * This function may be called from the joystick callback, even for a joystick
  5504. * that is being disconnected.
  5505. *
  5506. * @param[in] jid The joystick whose pointer to return.
  5507. *
  5508. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5509. *
  5510. * @thread_safety This function may be called from any thread. Access is not
  5511. * synchronized.
  5512. *
  5513. * @sa @ref joystick_userptr
  5514. * @sa @ref glfwSetJoystickUserPointer
  5515. *
  5516. * @since Added in version 3.3.
  5517. *
  5518. * @ingroup input
  5519. */
  5520. GLFWAPI void* glfwGetJoystickUserPointer(int jid);
  5521. /*! @brief Returns whether the specified joystick has a gamepad mapping.
  5522. *
  5523. * This function returns whether the specified joystick is both present and has
  5524. * a gamepad mapping.
  5525. *
  5526. * If the specified joystick is present but does not have a gamepad mapping
  5527. * this function will return `GLFW_FALSE` but will not generate an error. Call
  5528. * @ref glfwJoystickPresent to check if a joystick is present regardless of
  5529. * whether it has a mapping.
  5530. *
  5531. * @param[in] jid The [joystick](@ref joysticks) to query.
  5532. * @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
  5533. * or `GLFW_FALSE` otherwise.
  5534. *
  5535. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5536. * GLFW_INVALID_ENUM.
  5537. *
  5538. * @thread_safety This function must only be called from the main thread.
  5539. *
  5540. * @sa @ref gamepad
  5541. * @sa @ref glfwGetGamepadState
  5542. *
  5543. * @since Added in version 3.3.
  5544. *
  5545. * @ingroup input
  5546. */
  5547. GLFWAPI int glfwJoystickIsGamepad(int jid);
  5548. /*! @brief Sets the joystick configuration callback.
  5549. *
  5550. * This function sets the joystick configuration callback, or removes the
  5551. * currently set callback. This is called when a joystick is connected to or
  5552. * disconnected from the system.
  5553. *
  5554. * For joystick connection and disconnection events to be delivered on all
  5555. * platforms, you need to call one of the [event processing](@ref events)
  5556. * functions. Joystick disconnection may also be detected and the callback
  5557. * called by joystick functions. The function will then return whatever it
  5558. * returns if the joystick is not present.
  5559. *
  5560. * @param[in] callback The new callback, or `NULL` to remove the currently set
  5561. * callback.
  5562. * @return The previously set callback, or `NULL` if no callback was set or the
  5563. * library had not been [initialized](@ref intro_init).
  5564. *
  5565. * @callback_signature
  5566. * @code
  5567. * void function_name(int jid, int event)
  5568. * @endcode
  5569. * For more information about the callback parameters, see the
  5570. * [function pointer type](@ref GLFWjoystickfun).
  5571. *
  5572. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5573. *
  5574. * @thread_safety This function must only be called from the main thread.
  5575. *
  5576. * @sa @ref joystick_event
  5577. *
  5578. * @since Added in version 3.2.
  5579. *
  5580. * @ingroup input
  5581. */
  5582. GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
  5583. /*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
  5584. *
  5585. * This function parses the specified ASCII encoded string and updates the
  5586. * internal list with any gamepad mappings it finds. This string may
  5587. * contain either a single gamepad mapping or many mappings separated by
  5588. * newlines. The parser supports the full format of the `gamecontrollerdb.txt`
  5589. * source file including empty lines and comments.
  5590. *
  5591. * See @ref gamepad_mapping for a description of the format.
  5592. *
  5593. * If there is already a gamepad mapping for a given GUID in the internal list,
  5594. * it will be replaced by the one passed to this function. If the library is
  5595. * terminated and re-initialized the internal list will revert to the built-in
  5596. * default.
  5597. *
  5598. * @param[in] string The string containing the gamepad mappings.
  5599. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  5600. * [error](@ref error_handling) occurred.
  5601. *
  5602. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5603. * GLFW_INVALID_VALUE.
  5604. *
  5605. * @thread_safety This function must only be called from the main thread.
  5606. *
  5607. * @sa @ref gamepad
  5608. * @sa @ref glfwJoystickIsGamepad
  5609. * @sa @ref glfwGetGamepadName
  5610. *
  5611. * @since Added in version 3.3.
  5612. *
  5613. * @ingroup input
  5614. */
  5615. GLFWAPI int glfwUpdateGamepadMappings(const char* string);
  5616. /*! @brief Returns the human-readable gamepad name for the specified joystick.
  5617. *
  5618. * This function returns the human-readable name of the gamepad from the
  5619. * gamepad mapping assigned to the specified joystick.
  5620. *
  5621. * If the specified joystick is not present or does not have a gamepad mapping
  5622. * this function will return `NULL` but will not generate an error. Call
  5623. * @ref glfwJoystickPresent to check whether it is present regardless of
  5624. * whether it has a mapping.
  5625. *
  5626. * @param[in] jid The [joystick](@ref joysticks) to query.
  5627. * @return The UTF-8 encoded name of the gamepad, or `NULL` if the
  5628. * joystick is not present, does not have a mapping or an
  5629. * [error](@ref error_handling) occurred.
  5630. *
  5631. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_INVALID_ENUM.
  5632. *
  5633. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  5634. * should not free it yourself. It is valid until the specified joystick is
  5635. * disconnected, the gamepad mappings are updated or the library is terminated.
  5636. *
  5637. * @thread_safety This function must only be called from the main thread.
  5638. *
  5639. * @sa @ref gamepad
  5640. * @sa @ref glfwJoystickIsGamepad
  5641. *
  5642. * @since Added in version 3.3.
  5643. *
  5644. * @ingroup input
  5645. */
  5646. GLFWAPI const char* glfwGetGamepadName(int jid);
  5647. /*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
  5648. *
  5649. * This function retrieves the state of the specified joystick remapped to
  5650. * an Xbox-like gamepad.
  5651. *
  5652. * If the specified joystick is not present or does not have a gamepad mapping
  5653. * this function will return `GLFW_FALSE` but will not generate an error. Call
  5654. * @ref glfwJoystickPresent to check whether it is present regardless of
  5655. * whether it has a mapping.
  5656. *
  5657. * The Guide button may not be available for input as it is often hooked by the
  5658. * system or the Steam client.
  5659. *
  5660. * Not all devices have all the buttons or axes provided by @ref
  5661. * GLFWgamepadstate. Unavailable buttons and axes will always report
  5662. * `GLFW_RELEASE` and 0.0 respectively.
  5663. *
  5664. * @param[in] jid The [joystick](@ref joysticks) to query.
  5665. * @param[out] state The gamepad input state of the joystick.
  5666. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
  5667. * connected, it has no gamepad mapping or an [error](@ref error_handling)
  5668. * occurred.
  5669. *
  5670. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5671. * GLFW_INVALID_ENUM.
  5672. *
  5673. * @thread_safety This function must only be called from the main thread.
  5674. *
  5675. * @sa @ref gamepad
  5676. * @sa @ref glfwUpdateGamepadMappings
  5677. * @sa @ref glfwJoystickIsGamepad
  5678. *
  5679. * @since Added in version 3.3.
  5680. *
  5681. * @ingroup input
  5682. */
  5683. GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
  5684. /*! @brief Sets the clipboard to the specified string.
  5685. *
  5686. * This function sets the system clipboard to the specified, UTF-8 encoded
  5687. * string.
  5688. *
  5689. * @param[in] window Deprecated. Any valid window or `NULL`.
  5690. * @param[in] string A UTF-8 encoded string.
  5691. *
  5692. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5693. * GLFW_PLATFORM_ERROR.
  5694. *
  5695. * @remark __Win32:__ The clipboard on Windows has a single global lock for reading and
  5696. * writing. GLFW tries to acquire it a few times, which is almost always enough. If it
  5697. * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
  5698. * It is safe to try this multiple times.
  5699. *
  5700. * @pointer_lifetime The specified string is copied before this function
  5701. * returns.
  5702. *
  5703. * @thread_safety This function must only be called from the main thread.
  5704. *
  5705. * @sa @ref clipboard
  5706. * @sa @ref glfwGetClipboardString
  5707. *
  5708. * @since Added in version 3.0.
  5709. *
  5710. * @ingroup input
  5711. */
  5712. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  5713. /*! @brief Returns the contents of the clipboard as a string.
  5714. *
  5715. * This function returns the contents of the system clipboard, if it contains
  5716. * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
  5717. * if its contents cannot be converted, `NULL` is returned and a @ref
  5718. * GLFW_FORMAT_UNAVAILABLE error is generated.
  5719. *
  5720. * @param[in] window Deprecated. Any valid window or `NULL`.
  5721. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  5722. * if an [error](@ref error_handling) occurred.
  5723. *
  5724. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5725. * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  5726. *
  5727. * @remark __Win32:__ The clipboard on Windows has a single global lock for reading and
  5728. * writing. GLFW tries to acquire it a few times, which is almost always enough. If it
  5729. * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
  5730. * It is safe to try this multiple times.
  5731. *
  5732. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  5733. * should not free it yourself. It is valid until the next call to @ref
  5734. * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
  5735. * is terminated.
  5736. *
  5737. * @thread_safety This function must only be called from the main thread.
  5738. *
  5739. * @sa @ref clipboard
  5740. * @sa @ref glfwSetClipboardString
  5741. *
  5742. * @since Added in version 3.0.
  5743. *
  5744. * @ingroup input
  5745. */
  5746. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  5747. /*! @brief Returns the GLFW time.
  5748. *
  5749. * This function returns the current GLFW time, in seconds. Unless the time
  5750. * has been set using @ref glfwSetTime it measures time elapsed since GLFW was
  5751. * initialized.
  5752. *
  5753. * This function and @ref glfwSetTime are helper functions on top of @ref
  5754. * glfwGetTimerFrequency and @ref glfwGetTimerValue.
  5755. *
  5756. * The resolution of the timer is system dependent, but is usually on the order
  5757. * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
  5758. * time source on each operating system.
  5759. *
  5760. * @return The current time, in seconds, or zero if an
  5761. * [error](@ref error_handling) occurred.
  5762. *
  5763. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5764. *
  5765. * @thread_safety This function may be called from any thread. Reading and
  5766. * writing of the internal base time is not atomic, so it needs to be
  5767. * externally synchronized with calls to @ref glfwSetTime.
  5768. *
  5769. * @sa @ref time
  5770. *
  5771. * @since Added in version 1.0.
  5772. *
  5773. * @ingroup input
  5774. */
  5775. GLFWAPI double glfwGetTime(void);
  5776. /*! @brief Sets the GLFW time.
  5777. *
  5778. * This function sets the current GLFW time, in seconds. The value must be
  5779. * a positive finite number less than or equal to 18446744073.0, which is
  5780. * approximately 584.5 years.
  5781. *
  5782. * This function and @ref glfwGetTime are helper functions on top of @ref
  5783. * glfwGetTimerFrequency and @ref glfwGetTimerValue.
  5784. *
  5785. * @param[in] time The new value, in seconds.
  5786. *
  5787. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  5788. * GLFW_INVALID_VALUE.
  5789. *
  5790. * @remark The upper limit of GLFW time is calculated as
  5791. * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
  5792. * storing nanoseconds in 64 bits. The limit may be increased in the future.
  5793. *
  5794. * @thread_safety This function may be called from any thread. Reading and
  5795. * writing of the internal base time is not atomic, so it needs to be
  5796. * externally synchronized with calls to @ref glfwGetTime.
  5797. *
  5798. * @sa @ref time
  5799. *
  5800. * @since Added in version 2.2.
  5801. *
  5802. * @ingroup input
  5803. */
  5804. GLFWAPI void glfwSetTime(double time);
  5805. /*! @brief Returns the current value of the raw timer.
  5806. *
  5807. * This function returns the current value of the raw timer, measured in
  5808. * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
  5809. * glfwGetTimerFrequency.
  5810. *
  5811. * @return The value of the timer, or zero if an
  5812. * [error](@ref error_handling) occurred.
  5813. *
  5814. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5815. *
  5816. * @thread_safety This function may be called from any thread.
  5817. *
  5818. * @sa @ref time
  5819. * @sa @ref glfwGetTimerFrequency
  5820. *
  5821. * @since Added in version 3.2.
  5822. *
  5823. * @ingroup input
  5824. */
  5825. GLFWAPI uint64_t glfwGetTimerValue(void);
  5826. /*! @brief Returns the frequency, in Hz, of the raw timer.
  5827. *
  5828. * This function returns the frequency, in Hz, of the raw timer.
  5829. *
  5830. * @return The frequency of the timer, in Hz, or zero if an
  5831. * [error](@ref error_handling) occurred.
  5832. *
  5833. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5834. *
  5835. * @thread_safety This function may be called from any thread.
  5836. *
  5837. * @sa @ref time
  5838. * @sa @ref glfwGetTimerValue
  5839. *
  5840. * @since Added in version 3.2.
  5841. *
  5842. * @ingroup input
  5843. */
  5844. GLFWAPI uint64_t glfwGetTimerFrequency(void);
  5845. /*! @brief Makes the context of the specified window current for the calling
  5846. * thread.
  5847. *
  5848. * This function makes the OpenGL or OpenGL ES context of the specified window
  5849. * current on the calling thread. It can also detach the current context from
  5850. * the calling thread without making a new one current by passing in `NULL`.
  5851. *
  5852. * A context must only be made current on a single thread at a time and each
  5853. * thread can have only a single current context at a time. Making a context
  5854. * current detaches any previously current context on the calling thread.
  5855. *
  5856. * When moving a context between threads, you must detach it (make it
  5857. * non-current) on the old thread before making it current on the new one.
  5858. *
  5859. * By default, making a context non-current implicitly forces a pipeline flush.
  5860. * On machines that support `GL_KHR_context_flush_control`, you can control
  5861. * whether a context performs this flush by setting the
  5862. * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
  5863. * hint.
  5864. *
  5865. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  5866. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  5867. * error.
  5868. *
  5869. * @param[in] window The window whose context to make current, or `NULL` to
  5870. * detach the current context.
  5871. *
  5872. * @remarks If the previously current context was created via a different
  5873. * context creation API than the one passed to this function, GLFW will still
  5874. * detach the previous one from its API before making the new one current.
  5875. *
  5876. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5877. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5878. *
  5879. * @thread_safety This function may be called from any thread.
  5880. *
  5881. * @sa @ref context_current
  5882. * @sa @ref glfwGetCurrentContext
  5883. *
  5884. * @since Added in version 3.0.
  5885. *
  5886. * @ingroup context
  5887. */
  5888. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  5889. /*! @brief Returns the window whose context is current on the calling thread.
  5890. *
  5891. * This function returns the window whose OpenGL or OpenGL ES context is
  5892. * current on the calling thread.
  5893. *
  5894. * @return The window whose context is current, or `NULL` if no window's
  5895. * context is current.
  5896. *
  5897. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  5898. *
  5899. * @thread_safety This function may be called from any thread.
  5900. *
  5901. * @sa @ref context_current
  5902. * @sa @ref glfwMakeContextCurrent
  5903. *
  5904. * @since Added in version 3.0.
  5905. *
  5906. * @ingroup context
  5907. */
  5908. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  5909. /*! @brief Swaps the front and back buffers of the specified window.
  5910. *
  5911. * This function swaps the front and back buffers of the specified window when
  5912. * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
  5913. * zero, the GPU driver waits the specified number of screen updates before
  5914. * swapping the buffers.
  5915. *
  5916. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  5917. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  5918. * error.
  5919. *
  5920. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5921. * see `vkQueuePresentKHR` instead.
  5922. *
  5923. * @param[in] window The window whose buffers to swap.
  5924. *
  5925. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5926. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5927. *
  5928. * @remark __EGL:__ The context of the specified window must be current on the
  5929. * calling thread.
  5930. *
  5931. * @thread_safety This function may be called from any thread.
  5932. *
  5933. * @sa @ref buffer_swap
  5934. * @sa @ref glfwSwapInterval
  5935. *
  5936. * @since Added in version 1.0.
  5937. * __GLFW 3:__ Added window handle parameter.
  5938. *
  5939. * @ingroup window
  5940. */
  5941. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  5942. /*! @brief Sets the swap interval for the current context.
  5943. *
  5944. * This function sets the swap interval for the current OpenGL or OpenGL ES
  5945. * context, i.e. the number of screen updates to wait from the time @ref
  5946. * glfwSwapBuffers was called before swapping the buffers and returning. This
  5947. * is sometimes called _vertical synchronization_, _vertical retrace
  5948. * synchronization_ or just _vsync_.
  5949. *
  5950. * A context that supports either of the `WGL_EXT_swap_control_tear` and
  5951. * `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
  5952. * intervals, which allows the driver to swap immediately even if a frame
  5953. * arrives a little bit late. You can check for these extensions with @ref
  5954. * glfwExtensionSupported.
  5955. *
  5956. * A context must be current on the calling thread. Calling this function
  5957. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5958. *
  5959. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  5960. * see the present mode of your swapchain instead.
  5961. *
  5962. * @param[in] interval The minimum number of screen updates to wait for
  5963. * until the buffers are swapped by @ref glfwSwapBuffers.
  5964. *
  5965. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  5966. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  5967. *
  5968. * @remark This function is not called during context creation, leaving the
  5969. * swap interval set to whatever is the default for that API. This is done
  5970. * because some swap interval extensions used by GLFW do not allow the swap
  5971. * interval to be reset to zero once it has been set to a non-zero value.
  5972. *
  5973. * @remark Some GPU drivers do not honor the requested swap interval, either
  5974. * because of a user setting that overrides the application's request or due to
  5975. * bugs in the driver.
  5976. *
  5977. * @thread_safety This function may be called from any thread.
  5978. *
  5979. * @sa @ref buffer_swap
  5980. * @sa @ref glfwSwapBuffers
  5981. *
  5982. * @since Added in version 1.0.
  5983. *
  5984. * @ingroup context
  5985. */
  5986. GLFWAPI void glfwSwapInterval(int interval);
  5987. /*! @brief Returns whether the specified extension is available.
  5988. *
  5989. * This function returns whether the specified
  5990. * [API extension](@ref context_glext) is supported by the current OpenGL or
  5991. * OpenGL ES context. It searches both for client API extension and context
  5992. * creation API extensions.
  5993. *
  5994. * A context must be current on the calling thread. Calling this function
  5995. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  5996. *
  5997. * As this functions retrieves and searches one or more extension strings each
  5998. * call, it is recommended that you cache its results if it is going to be used
  5999. * frequently. The extension strings will not change during the lifetime of
  6000. * a context, so there is no danger in doing this.
  6001. *
  6002. * This function does not apply to Vulkan. If you are using Vulkan, see @ref
  6003. * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
  6004. * and `vkEnumerateDeviceExtensionProperties` instead.
  6005. *
  6006. * @param[in] extension The ASCII encoded name of the extension.
  6007. * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
  6008. * otherwise.
  6009. *
  6010. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  6011. * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
  6012. * GLFW_PLATFORM_ERROR.
  6013. *
  6014. * @thread_safety This function may be called from any thread.
  6015. *
  6016. * @sa @ref context_glext
  6017. * @sa @ref glfwGetProcAddress
  6018. *
  6019. * @since Added in version 1.0.
  6020. *
  6021. * @ingroup context
  6022. */
  6023. GLFWAPI int glfwExtensionSupported(const char* extension);
  6024. /*! @brief Returns the address of the specified function for the current
  6025. * context.
  6026. *
  6027. * This function returns the address of the specified OpenGL or OpenGL ES
  6028. * [core or extension function](@ref context_glext), if it is supported
  6029. * by the current context.
  6030. *
  6031. * A context must be current on the calling thread. Calling this function
  6032. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  6033. *
  6034. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  6035. * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
  6036. * `vkGetDeviceProcAddr` instead.
  6037. *
  6038. * @param[in] procname The ASCII encoded name of the function.
  6039. * @return The address of the function, or `NULL` if an
  6040. * [error](@ref error_handling) occurred.
  6041. *
  6042. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  6043. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  6044. *
  6045. * @remark The address of a given function is not guaranteed to be the same
  6046. * between contexts.
  6047. *
  6048. * @remark This function may return a non-`NULL` address despite the
  6049. * associated version or extension not being available. Always check the
  6050. * context version or extension string first.
  6051. *
  6052. * @pointer_lifetime The returned function pointer is valid until the context
  6053. * is destroyed or the library is terminated.
  6054. *
  6055. * @thread_safety This function may be called from any thread.
  6056. *
  6057. * @sa @ref context_glext
  6058. * @sa @ref glfwExtensionSupported
  6059. *
  6060. * @since Added in version 1.0.
  6061. *
  6062. * @ingroup context
  6063. */
  6064. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  6065. /*! @brief Returns whether the Vulkan loader and an ICD have been found.
  6066. *
  6067. * This function returns whether the Vulkan loader and any minimally functional
  6068. * ICD have been found.
  6069. *
  6070. * The availability of a Vulkan loader and even an ICD does not by itself guarantee that
  6071. * surface creation or even instance creation is possible. Call @ref
  6072. * glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
  6073. * surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
  6074. * check whether a queue family of a physical device supports image presentation.
  6075. *
  6076. * @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
  6077. * otherwise.
  6078. *
  6079. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  6080. *
  6081. * @thread_safety This function may be called from any thread.
  6082. *
  6083. * @sa @ref vulkan_support
  6084. *
  6085. * @since Added in version 3.2.
  6086. *
  6087. * @ingroup vulkan
  6088. */
  6089. GLFWAPI int glfwVulkanSupported(void);
  6090. /*! @brief Returns the Vulkan instance extensions required by GLFW.
  6091. *
  6092. * This function returns an array of names of Vulkan instance extensions required
  6093. * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
  6094. * list will always contain `VK_KHR_surface`, so if you don't require any
  6095. * additional extensions you can pass this list directly to the
  6096. * `VkInstanceCreateInfo` struct.
  6097. *
  6098. * If Vulkan is not available on the machine, this function returns `NULL` and
  6099. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  6100. * to check whether Vulkan is at least minimally available.
  6101. *
  6102. * If Vulkan is available but no set of extensions allowing window surface
  6103. * creation was found, this function returns `NULL`. You may still use Vulkan
  6104. * for off-screen rendering and compute work.
  6105. *
  6106. * @param[out] count Where to store the number of extensions in the returned
  6107. * array. This is set to zero if an error occurred.
  6108. * @return An array of ASCII encoded extension names, or `NULL` if an
  6109. * [error](@ref error_handling) occurred.
  6110. *
  6111. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  6112. * GLFW_API_UNAVAILABLE.
  6113. *
  6114. * @remark Additional extensions may be required by future versions of GLFW.
  6115. * You should check if any extensions you wish to enable are already in the
  6116. * returned array, as it is an error to specify an extension more than once in
  6117. * the `VkInstanceCreateInfo` struct.
  6118. *
  6119. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  6120. * should not free it yourself. It is guaranteed to be valid only until the
  6121. * library is terminated.
  6122. *
  6123. * @thread_safety This function may be called from any thread.
  6124. *
  6125. * @sa @ref vulkan_ext
  6126. * @sa @ref glfwCreateWindowSurface
  6127. *
  6128. * @since Added in version 3.2.
  6129. *
  6130. * @ingroup vulkan
  6131. */
  6132. GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
  6133. #if defined(VK_VERSION_1_0)
  6134. /*! @brief Returns the address of the specified Vulkan instance function.
  6135. *
  6136. * This function returns the address of the specified Vulkan core or extension
  6137. * function for the specified instance. If instance is set to `NULL` it can
  6138. * return any function exported from the Vulkan loader, including at least the
  6139. * following functions:
  6140. *
  6141. * - `vkEnumerateInstanceExtensionProperties`
  6142. * - `vkEnumerateInstanceLayerProperties`
  6143. * - `vkCreateInstance`
  6144. * - `vkGetInstanceProcAddr`
  6145. *
  6146. * If Vulkan is not available on the machine, this function returns `NULL` and
  6147. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  6148. * to check whether Vulkan is at least minimally available.
  6149. *
  6150. * This function is equivalent to calling `vkGetInstanceProcAddr` with
  6151. * a platform-specific query of the Vulkan loader as a fallback.
  6152. *
  6153. * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
  6154. * functions related to instance creation.
  6155. * @param[in] procname The ASCII encoded name of the function.
  6156. * @return The address of the function, or `NULL` if an
  6157. * [error](@ref error_handling) occurred.
  6158. *
  6159. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  6160. * GLFW_API_UNAVAILABLE.
  6161. *
  6162. * @pointer_lifetime The returned function pointer is valid until the library
  6163. * is terminated.
  6164. *
  6165. * @thread_safety This function may be called from any thread.
  6166. *
  6167. * @sa @ref vulkan_proc
  6168. *
  6169. * @since Added in version 3.2.
  6170. *
  6171. * @ingroup vulkan
  6172. */
  6173. GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
  6174. /*! @brief Returns whether the specified queue family can present images.
  6175. *
  6176. * This function returns whether the specified queue family of the specified
  6177. * physical device supports presentation to the platform GLFW was built for.
  6178. *
  6179. * If Vulkan or the required window surface creation instance extensions are
  6180. * not available on the machine, or if the specified instance was not created
  6181. * with the required extensions, this function returns `GLFW_FALSE` and
  6182. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  6183. * to check whether Vulkan is at least minimally available and @ref
  6184. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  6185. * required.
  6186. *
  6187. * @param[in] instance The instance that the physical device belongs to.
  6188. * @param[in] device The physical device that the queue family belongs to.
  6189. * @param[in] queuefamily The index of the queue family to query.
  6190. * @return `GLFW_TRUE` if the queue family supports presentation, or
  6191. * `GLFW_FALSE` otherwise.
  6192. *
  6193. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  6194. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  6195. *
  6196. * @remark __macOS:__ This function currently always returns `GLFW_TRUE`, as the
  6197. * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
  6198. * a `vkGetPhysicalDevice*PresentationSupport` type function.
  6199. *
  6200. * @thread_safety This function may be called from any thread. For
  6201. * synchronization details of Vulkan objects, see the Vulkan specification.
  6202. *
  6203. * @sa @ref vulkan_present
  6204. *
  6205. * @since Added in version 3.2.
  6206. *
  6207. * @ingroup vulkan
  6208. */
  6209. GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
  6210. /*! @brief Creates a Vulkan surface for the specified window.
  6211. *
  6212. * This function creates a Vulkan surface for the specified window.
  6213. *
  6214. * If the Vulkan loader or at least one minimally functional ICD were not found,
  6215. * this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
  6216. * GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether
  6217. * Vulkan is at least minimally available.
  6218. *
  6219. * If the required window surface creation instance extensions are not
  6220. * available or if the specified instance was not created with these extensions
  6221. * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
  6222. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
  6223. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  6224. * required.
  6225. *
  6226. * The window surface cannot be shared with another API so the window must
  6227. * have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
  6228. * set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
  6229. * and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
  6230. *
  6231. * The window surface must be destroyed before the specified Vulkan instance.
  6232. * It is the responsibility of the caller to destroy the window surface. GLFW
  6233. * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
  6234. * surface.
  6235. *
  6236. * @param[in] instance The Vulkan instance to create the surface in.
  6237. * @param[in] window The window to create the surface for.
  6238. * @param[in] allocator The allocator to use, or `NULL` to use the default
  6239. * allocator.
  6240. * @param[out] surface Where to store the handle of the surface. This is set
  6241. * to `VK_NULL_HANDLE` if an error occurred.
  6242. * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
  6243. * [error](@ref error_handling) occurred.
  6244. *
  6245. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  6246. * GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
  6247. *
  6248. * @remark If an error occurs before the creation call is made, GLFW returns
  6249. * the Vulkan error code most appropriate for the error. Appropriate use of
  6250. * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
  6251. * eliminate almost all occurrences of these errors.
  6252. *
  6253. * @remark __macOS:__ GLFW prefers the `VK_EXT_metal_surface` extension, with the
  6254. * `VK_MVK_macos_surface` extension as a fallback. The name of the selected
  6255. * extension, if any, is included in the array returned by @ref
  6256. * glfwGetRequiredInstanceExtensions.
  6257. *
  6258. * @remark __macOS:__ This function creates and sets a `CAMetalLayer` instance for
  6259. * the window content view, which is required for MoltenVK to function.
  6260. *
  6261. * @remark __X11:__ By default GLFW prefers the `VK_KHR_xcb_surface` extension,
  6262. * with the `VK_KHR_xlib_surface` extension as a fallback. You can make
  6263. * `VK_KHR_xlib_surface` the preferred extension by setting the
  6264. * [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
  6265. * hint. The name of the selected extension, if any, is included in the array
  6266. * returned by @ref glfwGetRequiredInstanceExtensions.
  6267. *
  6268. * @thread_safety This function may be called from any thread. For
  6269. * synchronization details of Vulkan objects, see the Vulkan specification.
  6270. *
  6271. * @sa @ref vulkan_surface
  6272. * @sa @ref glfwGetRequiredInstanceExtensions
  6273. *
  6274. * @since Added in version 3.2.
  6275. *
  6276. * @ingroup vulkan
  6277. */
  6278. GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
  6279. #endif /*VK_VERSION_1_0*/
  6280. /*************************************************************************
  6281. * Global definition cleanup
  6282. *************************************************************************/
  6283. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  6284. #ifdef GLFW_WINGDIAPI_DEFINED
  6285. #undef WINGDIAPI
  6286. #undef GLFW_WINGDIAPI_DEFINED
  6287. #endif
  6288. #ifdef GLFW_CALLBACK_DEFINED
  6289. #undef CALLBACK
  6290. #undef GLFW_CALLBACK_DEFINED
  6291. #endif
  6292. /* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
  6293. * defined by some gl.h variants (OpenBSD) so define it after if needed.
  6294. */
  6295. #ifndef GLAPIENTRY
  6296. #define GLAPIENTRY APIENTRY
  6297. #define GLFW_GLAPIENTRY_DEFINED
  6298. #endif
  6299. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  6300. #ifdef __cplusplus
  6301. }
  6302. #endif
  6303. #endif /* _glfw3_h_ */