glfw3.h 210 KB

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