glfw3.h 207 KB

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