glfw3.h 190 KB

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