glfw3.h 210 KB

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