glfw3.h 211 KB

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