glfw3.h 190 KB

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