glfw3.h 148 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235
  1. /*************************************************************************
  2. * GLFW 3.2 - www.glfw.org
  3. * A library for OpenGL, window and input
  4. *------------------------------------------------------------------------
  5. * Copyright (c) 2002-2006 Marcus Geelnard
  6. * Copyright (c) 2006-2016 Camilla Berglund <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. *
  46. * This is the reference documentation for OpenGL and OpenGL ES context related
  47. * functions. For more task-oriented information, see the @ref context_guide.
  48. */
  49. /*! @defgroup vulkan Vulkan reference
  50. *
  51. * This is the reference documentation for Vulkan related functions and types.
  52. * For more task-oriented information, see the @ref vulkan_guide.
  53. */
  54. /*! @defgroup init Initialization, version and error reference
  55. *
  56. * This is the reference documentation for initialization and termination of
  57. * the library, version management and error handling. For more task-oriented
  58. * information, see the @ref intro_guide.
  59. */
  60. /*! @defgroup input Input reference
  61. *
  62. * This is the reference documentation for input related functions and types.
  63. * For more task-oriented information, see the @ref input_guide.
  64. */
  65. /*! @defgroup monitor Monitor reference
  66. *
  67. * This is the reference documentation for monitor related functions and types.
  68. * For more task-oriented information, see the @ref monitor_guide.
  69. */
  70. /*! @defgroup window Window reference
  71. *
  72. * This is the reference documentation for window related functions and types,
  73. * including creation, deletion and event polling. For more task-oriented
  74. * information, see the @ref window_guide.
  75. */
  76. /*************************************************************************
  77. * Compiler- and platform-specific preprocessor work
  78. *************************************************************************/
  79. /* If we are we on Windows, we want a single define for it.
  80. */
  81. #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
  82. #define _WIN32
  83. #endif /* _WIN32 */
  84. /* It is customary to use APIENTRY for OpenGL function pointer declarations on
  85. * all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
  86. */
  87. #ifndef APIENTRY
  88. #ifdef _WIN32
  89. #define APIENTRY __stdcall
  90. #else
  91. #define APIENTRY
  92. #endif
  93. #endif /* APIENTRY */
  94. /* Some Windows OpenGL headers need this.
  95. */
  96. #if !defined(WINGDIAPI) && defined(_WIN32)
  97. #define WINGDIAPI __declspec(dllimport)
  98. #define GLFW_WINGDIAPI_DEFINED
  99. #endif /* WINGDIAPI */
  100. /* Some Windows GLU headers need this.
  101. */
  102. #if !defined(CALLBACK) && defined(_WIN32)
  103. #define CALLBACK __stdcall
  104. #define GLFW_CALLBACK_DEFINED
  105. #endif /* CALLBACK */
  106. /* Most Windows GLU headers need wchar_t.
  107. * The OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.
  108. * Include it unconditionally to avoid surprising side-effects.
  109. */
  110. #include <stddef.h>
  111. #include <stdint.h>
  112. /* Include the chosen client API headers.
  113. */
  114. #if defined(__APPLE__)
  115. #if defined(GLFW_INCLUDE_GLCOREARB)
  116. #include <OpenGL/gl3.h>
  117. #if defined(GLFW_INCLUDE_GLEXT)
  118. #include <OpenGL/gl3ext.h>
  119. #endif
  120. #elif !defined(GLFW_INCLUDE_NONE)
  121. #if !defined(GLFW_INCLUDE_GLEXT)
  122. #define GL_GLEXT_LEGACY
  123. #endif
  124. #include <OpenGL/gl.h>
  125. #endif
  126. #if defined(GLFW_INCLUDE_GLU)
  127. #include <OpenGL/glu.h>
  128. #endif
  129. #else
  130. #if defined(GLFW_INCLUDE_GLCOREARB)
  131. #include <GL/glcorearb.h>
  132. #elif defined(GLFW_INCLUDE_ES1)
  133. #include <GLES/gl.h>
  134. #if defined(GLFW_INCLUDE_GLEXT)
  135. #include <GLES/glext.h>
  136. #endif
  137. #elif defined(GLFW_INCLUDE_ES2)
  138. #include <GLES2/gl2.h>
  139. #if defined(GLFW_INCLUDE_GLEXT)
  140. #include <GLES2/gl2ext.h>
  141. #endif
  142. #elif defined(GLFW_INCLUDE_ES3)
  143. #include <GLES3/gl3.h>
  144. #if defined(GLFW_INCLUDE_GLEXT)
  145. #include <GLES2/gl2ext.h>
  146. #endif
  147. #elif defined(GLFW_INCLUDE_ES31)
  148. #include <GLES3/gl31.h>
  149. #if defined(GLFW_INCLUDE_GLEXT)
  150. #include <GLES2/gl2ext.h>
  151. #endif
  152. #elif defined(GLFW_INCLUDE_VULKAN)
  153. #include <vulkan/vulkan.h>
  154. #elif !defined(GLFW_INCLUDE_NONE)
  155. #include <GL/gl.h>
  156. #if defined(GLFW_INCLUDE_GLEXT)
  157. #include <GL/glext.h>
  158. #endif
  159. #endif
  160. #if defined(GLFW_INCLUDE_GLU)
  161. #include <GL/glu.h>
  162. #endif
  163. #endif
  164. #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
  165. /* GLFW_DLL must be defined by applications that are linking against the DLL
  166. * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW
  167. * configuration header when compiling the DLL version of the library.
  168. */
  169. #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
  170. #endif
  171. /* GLFWAPI is used to declare public API functions for export
  172. * from the DLL / shared library / dynamic library.
  173. */
  174. #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
  175. /* We are building GLFW as a Win32 DLL */
  176. #define GLFWAPI __declspec(dllexport)
  177. #elif defined(_WIN32) && defined(GLFW_DLL)
  178. /* We are calling GLFW as a Win32 DLL */
  179. #define GLFWAPI __declspec(dllimport)
  180. #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
  181. /* We are building GLFW as a shared / dynamic library */
  182. #define GLFWAPI __attribute__((visibility("default")))
  183. #else
  184. /* We are building or calling GLFW as a static library */
  185. #define GLFWAPI
  186. #endif
  187. /*************************************************************************
  188. * GLFW API tokens
  189. *************************************************************************/
  190. /*! @name GLFW version macros
  191. * @{ */
  192. /*! @brief The major version number of the GLFW library.
  193. *
  194. * This is incremented when the API is changed in non-compatible ways.
  195. * @ingroup init
  196. */
  197. #define GLFW_VERSION_MAJOR 3
  198. /*! @brief The minor version number of the GLFW library.
  199. *
  200. * This is incremented when features are added to the API but it remains
  201. * backward-compatible.
  202. * @ingroup init
  203. */
  204. #define GLFW_VERSION_MINOR 2
  205. /*! @brief The revision number of the GLFW library.
  206. *
  207. * This is incremented when a bug fix release is made that does not contain any
  208. * API changes.
  209. * @ingroup init
  210. */
  211. #define GLFW_VERSION_REVISION 0
  212. /*! @} */
  213. /*! @name Boolean values
  214. * @{ */
  215. /*! @brief One.
  216. *
  217. * One. Seriously. You don't _need_ to use this symbol in your code. It's
  218. * just semantic sugar for the number 1. You can use `1` or `true` or `_True`
  219. * or `GL_TRUE` or whatever you want.
  220. */
  221. #define GLFW_TRUE 1
  222. /*! @brief Zero.
  223. *
  224. * Zero. Seriously. You don't _need_ to use this symbol in your code. It's
  225. * just just semantic sugar for the number 0. You can use `0` or `false` or
  226. * `_False` or `GL_FALSE` or whatever you want.
  227. */
  228. #define GLFW_FALSE 0
  229. /*! @} */
  230. /*! @name Key and button actions
  231. * @{ */
  232. /*! @brief The key or mouse button was released.
  233. *
  234. * The key or mouse button was released.
  235. *
  236. * @ingroup input
  237. */
  238. #define GLFW_RELEASE 0
  239. /*! @brief The key or mouse button was pressed.
  240. *
  241. * The key or mouse button was pressed.
  242. *
  243. * @ingroup input
  244. */
  245. #define GLFW_PRESS 1
  246. /*! @brief The key was held down until it repeated.
  247. *
  248. * The key was held down until it repeated.
  249. *
  250. * @ingroup input
  251. */
  252. #define GLFW_REPEAT 2
  253. /*! @} */
  254. /*! @defgroup keys Keyboard keys
  255. *
  256. * See [key input](@ref input_key) for how these are used.
  257. *
  258. * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
  259. * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
  260. * put in the 256+ range).
  261. *
  262. * The naming of the key codes follow these rules:
  263. * - The US keyboard layout is used
  264. * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
  265. * "3", etc.)
  266. * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
  267. * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
  268. * correspond to the Unicode standard (usually for brevity)
  269. * - Keys that lack a clear US mapping are named "WORLD_x"
  270. * - For non-printable keys, custom names are used (e.g. "F4",
  271. * "BACKSPACE", etc.)
  272. *
  273. * @ingroup input
  274. * @{
  275. */
  276. /* The unknown key */
  277. #define GLFW_KEY_UNKNOWN -1
  278. /* Printable keys */
  279. #define GLFW_KEY_SPACE 32
  280. #define GLFW_KEY_APOSTROPHE 39 /* ' */
  281. #define GLFW_KEY_COMMA 44 /* , */
  282. #define GLFW_KEY_MINUS 45 /* - */
  283. #define GLFW_KEY_PERIOD 46 /* . */
  284. #define GLFW_KEY_SLASH 47 /* / */
  285. #define GLFW_KEY_0 48
  286. #define GLFW_KEY_1 49
  287. #define GLFW_KEY_2 50
  288. #define GLFW_KEY_3 51
  289. #define GLFW_KEY_4 52
  290. #define GLFW_KEY_5 53
  291. #define GLFW_KEY_6 54
  292. #define GLFW_KEY_7 55
  293. #define GLFW_KEY_8 56
  294. #define GLFW_KEY_9 57
  295. #define GLFW_KEY_SEMICOLON 59 /* ; */
  296. #define GLFW_KEY_EQUAL 61 /* = */
  297. #define GLFW_KEY_A 65
  298. #define GLFW_KEY_B 66
  299. #define GLFW_KEY_C 67
  300. #define GLFW_KEY_D 68
  301. #define GLFW_KEY_E 69
  302. #define GLFW_KEY_F 70
  303. #define GLFW_KEY_G 71
  304. #define GLFW_KEY_H 72
  305. #define GLFW_KEY_I 73
  306. #define GLFW_KEY_J 74
  307. #define GLFW_KEY_K 75
  308. #define GLFW_KEY_L 76
  309. #define GLFW_KEY_M 77
  310. #define GLFW_KEY_N 78
  311. #define GLFW_KEY_O 79
  312. #define GLFW_KEY_P 80
  313. #define GLFW_KEY_Q 81
  314. #define GLFW_KEY_R 82
  315. #define GLFW_KEY_S 83
  316. #define GLFW_KEY_T 84
  317. #define GLFW_KEY_U 85
  318. #define GLFW_KEY_V 86
  319. #define GLFW_KEY_W 87
  320. #define GLFW_KEY_X 88
  321. #define GLFW_KEY_Y 89
  322. #define GLFW_KEY_Z 90
  323. #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
  324. #define GLFW_KEY_BACKSLASH 92 /* \ */
  325. #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
  326. #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
  327. #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
  328. #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
  329. /* Function keys */
  330. #define GLFW_KEY_ESCAPE 256
  331. #define GLFW_KEY_ENTER 257
  332. #define GLFW_KEY_TAB 258
  333. #define GLFW_KEY_BACKSPACE 259
  334. #define GLFW_KEY_INSERT 260
  335. #define GLFW_KEY_DELETE 261
  336. #define GLFW_KEY_RIGHT 262
  337. #define GLFW_KEY_LEFT 263
  338. #define GLFW_KEY_DOWN 264
  339. #define GLFW_KEY_UP 265
  340. #define GLFW_KEY_PAGE_UP 266
  341. #define GLFW_KEY_PAGE_DOWN 267
  342. #define GLFW_KEY_HOME 268
  343. #define GLFW_KEY_END 269
  344. #define GLFW_KEY_CAPS_LOCK 280
  345. #define GLFW_KEY_SCROLL_LOCK 281
  346. #define GLFW_KEY_NUM_LOCK 282
  347. #define GLFW_KEY_PRINT_SCREEN 283
  348. #define GLFW_KEY_PAUSE 284
  349. #define GLFW_KEY_F1 290
  350. #define GLFW_KEY_F2 291
  351. #define GLFW_KEY_F3 292
  352. #define GLFW_KEY_F4 293
  353. #define GLFW_KEY_F5 294
  354. #define GLFW_KEY_F6 295
  355. #define GLFW_KEY_F7 296
  356. #define GLFW_KEY_F8 297
  357. #define GLFW_KEY_F9 298
  358. #define GLFW_KEY_F10 299
  359. #define GLFW_KEY_F11 300
  360. #define GLFW_KEY_F12 301
  361. #define GLFW_KEY_F13 302
  362. #define GLFW_KEY_F14 303
  363. #define GLFW_KEY_F15 304
  364. #define GLFW_KEY_F16 305
  365. #define GLFW_KEY_F17 306
  366. #define GLFW_KEY_F18 307
  367. #define GLFW_KEY_F19 308
  368. #define GLFW_KEY_F20 309
  369. #define GLFW_KEY_F21 310
  370. #define GLFW_KEY_F22 311
  371. #define GLFW_KEY_F23 312
  372. #define GLFW_KEY_F24 313
  373. #define GLFW_KEY_F25 314
  374. #define GLFW_KEY_KP_0 320
  375. #define GLFW_KEY_KP_1 321
  376. #define GLFW_KEY_KP_2 322
  377. #define GLFW_KEY_KP_3 323
  378. #define GLFW_KEY_KP_4 324
  379. #define GLFW_KEY_KP_5 325
  380. #define GLFW_KEY_KP_6 326
  381. #define GLFW_KEY_KP_7 327
  382. #define GLFW_KEY_KP_8 328
  383. #define GLFW_KEY_KP_9 329
  384. #define GLFW_KEY_KP_DECIMAL 330
  385. #define GLFW_KEY_KP_DIVIDE 331
  386. #define GLFW_KEY_KP_MULTIPLY 332
  387. #define GLFW_KEY_KP_SUBTRACT 333
  388. #define GLFW_KEY_KP_ADD 334
  389. #define GLFW_KEY_KP_ENTER 335
  390. #define GLFW_KEY_KP_EQUAL 336
  391. #define GLFW_KEY_LEFT_SHIFT 340
  392. #define GLFW_KEY_LEFT_CONTROL 341
  393. #define GLFW_KEY_LEFT_ALT 342
  394. #define GLFW_KEY_LEFT_SUPER 343
  395. #define GLFW_KEY_RIGHT_SHIFT 344
  396. #define GLFW_KEY_RIGHT_CONTROL 345
  397. #define GLFW_KEY_RIGHT_ALT 346
  398. #define GLFW_KEY_RIGHT_SUPER 347
  399. #define GLFW_KEY_MENU 348
  400. #define GLFW_KEY_LAST GLFW_KEY_MENU
  401. /*! @} */
  402. /*! @defgroup mods Modifier key flags
  403. *
  404. * See [key input](@ref input_key) for how these are used.
  405. *
  406. * @ingroup input
  407. * @{ */
  408. /*! @brief If this bit is set one or more Shift keys were held down.
  409. */
  410. #define GLFW_MOD_SHIFT 0x0001
  411. /*! @brief If this bit is set one or more Control keys were held down.
  412. */
  413. #define GLFW_MOD_CONTROL 0x0002
  414. /*! @brief If this bit is set one or more Alt keys were held down.
  415. */
  416. #define GLFW_MOD_ALT 0x0004
  417. /*! @brief If this bit is set one or more Super keys were held down.
  418. */
  419. #define GLFW_MOD_SUPER 0x0008
  420. /*! @} */
  421. /*! @defgroup buttons Mouse buttons
  422. *
  423. * See [mouse button input](@ref input_mouse_button) for how these are used.
  424. *
  425. * @ingroup input
  426. * @{ */
  427. #define GLFW_MOUSE_BUTTON_1 0
  428. #define GLFW_MOUSE_BUTTON_2 1
  429. #define GLFW_MOUSE_BUTTON_3 2
  430. #define GLFW_MOUSE_BUTTON_4 3
  431. #define GLFW_MOUSE_BUTTON_5 4
  432. #define GLFW_MOUSE_BUTTON_6 5
  433. #define GLFW_MOUSE_BUTTON_7 6
  434. #define GLFW_MOUSE_BUTTON_8 7
  435. #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
  436. #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
  437. #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
  438. #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
  439. /*! @} */
  440. /*! @defgroup joysticks Joysticks
  441. *
  442. * See [joystick input](@ref joystick) for how these are used.
  443. *
  444. * @ingroup input
  445. * @{ */
  446. #define GLFW_JOYSTICK_1 0
  447. #define GLFW_JOYSTICK_2 1
  448. #define GLFW_JOYSTICK_3 2
  449. #define GLFW_JOYSTICK_4 3
  450. #define GLFW_JOYSTICK_5 4
  451. #define GLFW_JOYSTICK_6 5
  452. #define GLFW_JOYSTICK_7 6
  453. #define GLFW_JOYSTICK_8 7
  454. #define GLFW_JOYSTICK_9 8
  455. #define GLFW_JOYSTICK_10 9
  456. #define GLFW_JOYSTICK_11 10
  457. #define GLFW_JOYSTICK_12 11
  458. #define GLFW_JOYSTICK_13 12
  459. #define GLFW_JOYSTICK_14 13
  460. #define GLFW_JOYSTICK_15 14
  461. #define GLFW_JOYSTICK_16 15
  462. #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
  463. /*! @} */
  464. /*! @defgroup errors Error codes
  465. *
  466. * See [error handling](@ref error_handling) for how these are used.
  467. *
  468. * @ingroup init
  469. * @{ */
  470. /*! @brief GLFW has not been initialized.
  471. *
  472. * This occurs if a GLFW function was called that must not be called unless the
  473. * library is [initialized](@ref intro_init).
  474. *
  475. * @analysis Application programmer error. Initialize GLFW before calling any
  476. * function that requires initialization.
  477. */
  478. #define GLFW_NOT_INITIALIZED 0x00010001
  479. /*! @brief No context is current for this thread.
  480. *
  481. * This occurs if a GLFW function was called that needs and operates on the
  482. * current OpenGL or OpenGL ES context but no context is current on the calling
  483. * thread. One such function is @ref glfwSwapInterval.
  484. *
  485. * @analysis Application programmer error. Ensure a context is current before
  486. * calling functions that require a current context.
  487. */
  488. #define GLFW_NO_CURRENT_CONTEXT 0x00010002
  489. /*! @brief One of the arguments to the function was an invalid enum value.
  490. *
  491. * One of the arguments to the function was an invalid enum value, for example
  492. * requesting [GLFW_RED_BITS](@ref window_hints_fb) with @ref
  493. * glfwGetWindowAttrib.
  494. *
  495. * @analysis Application programmer error. Fix the offending call.
  496. */
  497. #define GLFW_INVALID_ENUM 0x00010003
  498. /*! @brief One of the arguments to the function was an invalid value.
  499. *
  500. * One of the arguments to the function was an invalid value, for example
  501. * requesting a non-existent OpenGL or OpenGL ES version like 2.7.
  502. *
  503. * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
  504. * result in a @ref GLFW_VERSION_UNAVAILABLE error.
  505. *
  506. * @analysis Application programmer error. Fix the offending call.
  507. */
  508. #define GLFW_INVALID_VALUE 0x00010004
  509. /*! @brief A memory allocation failed.
  510. *
  511. * A memory allocation failed.
  512. *
  513. * @analysis A bug in GLFW or the underlying operating system. Report the bug
  514. * to our [issue tracker](https://github.com/glfw/glfw/issues).
  515. */
  516. #define GLFW_OUT_OF_MEMORY 0x00010005
  517. /*! @brief GLFW could not find support for the requested API on the system.
  518. *
  519. * GLFW could not find support for the requested API on the system.
  520. *
  521. * @analysis The installed graphics driver does not support the requested
  522. * API, or does not support it via the chosen context creation backend.
  523. * Below are a few examples.
  524. *
  525. * @par
  526. * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only
  527. * supports OpenGL ES via EGL, while Nvidia and Intel only support it via
  528. * a WGL or GLX extension. OS X does not provide OpenGL ES at all. The Mesa
  529. * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
  530. * driver. Older graphics drivers do not support Vulkan.
  531. */
  532. #define GLFW_API_UNAVAILABLE 0x00010006
  533. /*! @brief The requested OpenGL or OpenGL ES version is not available.
  534. *
  535. * The requested OpenGL or OpenGL ES version (including any requested context
  536. * or framebuffer hints) is not available on this machine.
  537. *
  538. * @analysis The machine does not support your requirements. If your
  539. * application is sufficiently flexible, downgrade your requirements and try
  540. * again. Otherwise, inform the user that their machine does not match your
  541. * requirements.
  542. *
  543. * @par
  544. * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
  545. * comes out before the 4.x series gets that far, also fail with this error and
  546. * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
  547. * will exist.
  548. */
  549. #define GLFW_VERSION_UNAVAILABLE 0x00010007
  550. /*! @brief A platform-specific error occurred that does not match any of the
  551. * more specific categories.
  552. *
  553. * A platform-specific error occurred that does not match any of the more
  554. * specific categories.
  555. *
  556. * @analysis A bug or configuration error in GLFW, the underlying operating
  557. * system or its drivers, or a lack of required resources. Report the issue to
  558. * our [issue tracker](https://github.com/glfw/glfw/issues).
  559. */
  560. #define GLFW_PLATFORM_ERROR 0x00010008
  561. /*! @brief The requested format is not supported or available.
  562. *
  563. * If emitted during window creation, the requested pixel format is not
  564. * supported.
  565. *
  566. * If emitted when querying the clipboard, the contents of the clipboard could
  567. * not be converted to the requested format.
  568. *
  569. * @analysis If emitted during window creation, one or more
  570. * [hard constraints](@ref window_hints_hard) did not match any of the
  571. * available pixel formats. If your application is sufficiently flexible,
  572. * downgrade your requirements and try again. Otherwise, inform the user that
  573. * their machine does not match your requirements.
  574. *
  575. * @par
  576. * If emitted when querying the clipboard, ignore the error or report it to
  577. * the user, as appropriate.
  578. */
  579. #define GLFW_FORMAT_UNAVAILABLE 0x00010009
  580. /*! @brief The specified window does not have an OpenGL or OpenGL ES context.
  581. *
  582. * A window that does not have an OpenGL or OpenGL ES context was passed to
  583. * a function that requires it to have one.
  584. *
  585. * @analysis Application programmer error. Fix the offending call.
  586. */
  587. #define GLFW_NO_WINDOW_CONTEXT 0x0001000A
  588. /*! @} */
  589. #define GLFW_FOCUSED 0x00020001
  590. #define GLFW_ICONIFIED 0x00020002
  591. #define GLFW_RESIZABLE 0x00020003
  592. #define GLFW_VISIBLE 0x00020004
  593. #define GLFW_DECORATED 0x00020005
  594. #define GLFW_AUTO_ICONIFY 0x00020006
  595. #define GLFW_FLOATING 0x00020007
  596. #define GLFW_MAXIMIZED 0x00020008
  597. #define GLFW_RED_BITS 0x00021001
  598. #define GLFW_GREEN_BITS 0x00021002
  599. #define GLFW_BLUE_BITS 0x00021003
  600. #define GLFW_ALPHA_BITS 0x00021004
  601. #define GLFW_DEPTH_BITS 0x00021005
  602. #define GLFW_STENCIL_BITS 0x00021006
  603. #define GLFW_ACCUM_RED_BITS 0x00021007
  604. #define GLFW_ACCUM_GREEN_BITS 0x00021008
  605. #define GLFW_ACCUM_BLUE_BITS 0x00021009
  606. #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
  607. #define GLFW_AUX_BUFFERS 0x0002100B
  608. #define GLFW_STEREO 0x0002100C
  609. #define GLFW_SAMPLES 0x0002100D
  610. #define GLFW_SRGB_CAPABLE 0x0002100E
  611. #define GLFW_REFRESH_RATE 0x0002100F
  612. #define GLFW_DOUBLEBUFFER 0x00021010
  613. #define GLFW_CLIENT_API 0x00022001
  614. #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
  615. #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
  616. #define GLFW_CONTEXT_REVISION 0x00022004
  617. #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
  618. #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
  619. #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
  620. #define GLFW_OPENGL_PROFILE 0x00022008
  621. #define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
  622. #define GLFW_CONTEXT_NO_ERROR 0x0002200A
  623. #define GLFW_CONTEXT_CREATION_API 0x0002200B
  624. #define GLFW_NO_API 0
  625. #define GLFW_OPENGL_API 0x00030001
  626. #define GLFW_OPENGL_ES_API 0x00030002
  627. #define GLFW_NO_ROBUSTNESS 0
  628. #define GLFW_NO_RESET_NOTIFICATION 0x00031001
  629. #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
  630. #define GLFW_OPENGL_ANY_PROFILE 0
  631. #define GLFW_OPENGL_CORE_PROFILE 0x00032001
  632. #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
  633. #define GLFW_CURSOR 0x00033001
  634. #define GLFW_STICKY_KEYS 0x00033002
  635. #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
  636. #define GLFW_CURSOR_NORMAL 0x00034001
  637. #define GLFW_CURSOR_HIDDEN 0x00034002
  638. #define GLFW_CURSOR_DISABLED 0x00034003
  639. #define GLFW_ANY_RELEASE_BEHAVIOR 0
  640. #define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
  641. #define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002
  642. #define GLFW_NATIVE_CONTEXT_API 0x00036001
  643. #define GLFW_EGL_CONTEXT_API 0x00036002
  644. /*! @defgroup shapes Standard cursor shapes
  645. *
  646. * See [standard cursor creation](@ref cursor_standard) for how these are used.
  647. *
  648. * @ingroup input
  649. * @{ */
  650. /*! @brief The regular arrow cursor shape.
  651. *
  652. * The regular arrow cursor.
  653. */
  654. #define GLFW_ARROW_CURSOR 0x00036001
  655. /*! @brief The text input I-beam cursor shape.
  656. *
  657. * The text input I-beam cursor shape.
  658. */
  659. #define GLFW_IBEAM_CURSOR 0x00036002
  660. /*! @brief The crosshair shape.
  661. *
  662. * The crosshair shape.
  663. */
  664. #define GLFW_CROSSHAIR_CURSOR 0x00036003
  665. /*! @brief The hand shape.
  666. *
  667. * The hand shape.
  668. */
  669. #define GLFW_HAND_CURSOR 0x00036004
  670. /*! @brief The horizontal resize arrow shape.
  671. *
  672. * The horizontal resize arrow shape.
  673. */
  674. #define GLFW_HRESIZE_CURSOR 0x00036005
  675. /*! @brief The vertical resize arrow shape.
  676. *
  677. * The vertical resize arrow shape.
  678. */
  679. #define GLFW_VRESIZE_CURSOR 0x00036006
  680. /*! @} */
  681. #define GLFW_CONNECTED 0x00040001
  682. #define GLFW_DISCONNECTED 0x00040002
  683. #define GLFW_DONT_CARE -1
  684. /*************************************************************************
  685. * GLFW API types
  686. *************************************************************************/
  687. /*! @brief Client API function pointer type.
  688. *
  689. * Generic function pointer used for returning client API function pointers
  690. * without forcing a cast from a regular pointer.
  691. *
  692. * @sa @ref context_glext
  693. * @sa glfwGetProcAddress
  694. *
  695. * @since Added in version 3.0.
  696. * @ingroup context
  697. */
  698. typedef void (*GLFWglproc)(void);
  699. /*! @brief Vulkan API function pointer type.
  700. *
  701. * Generic function pointer used for returning Vulkan API function pointers
  702. * without forcing a cast from a regular pointer.
  703. *
  704. * @sa @ref vulkan_proc
  705. * @sa glfwGetInstanceProcAddress
  706. *
  707. * @since Added in version 3.2.
  708. *
  709. * @ingroup vulkan
  710. */
  711. typedef void (*GLFWvkproc)(void);
  712. /*! @brief Opaque monitor object.
  713. *
  714. * Opaque monitor object.
  715. *
  716. * @see @ref monitor_object
  717. *
  718. * @since Added in version 3.0.
  719. *
  720. * @ingroup monitor
  721. */
  722. typedef struct GLFWmonitor GLFWmonitor;
  723. /*! @brief Opaque window object.
  724. *
  725. * Opaque window object.
  726. *
  727. * @see @ref window_object
  728. *
  729. * @since Added in version 3.0.
  730. *
  731. * @ingroup window
  732. */
  733. typedef struct GLFWwindow GLFWwindow;
  734. /*! @brief Opaque cursor object.
  735. *
  736. * Opaque cursor object.
  737. *
  738. * @see @ref cursor_object
  739. *
  740. * @since Added in version 3.1.
  741. *
  742. * @ingroup cursor
  743. */
  744. typedef struct GLFWcursor GLFWcursor;
  745. /*! @brief The function signature for error callbacks.
  746. *
  747. * This is the function signature for error callback functions.
  748. *
  749. * @param[in] error An [error code](@ref errors).
  750. * @param[in] description A UTF-8 encoded string describing the error.
  751. *
  752. * @sa @ref error_handling
  753. * @sa glfwSetErrorCallback
  754. *
  755. * @since Added in version 3.0.
  756. *
  757. * @ingroup init
  758. */
  759. typedef void (* GLFWerrorfun)(int,const char*);
  760. /*! @brief The function signature for window position callbacks.
  761. *
  762. * This is the function signature for window position callback functions.
  763. *
  764. * @param[in] window The window that was moved.
  765. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  766. * upper-left corner of the client area of the window.
  767. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  768. * upper-left corner of the client area of the window.
  769. *
  770. * @sa @ref window_pos
  771. * @sa glfwSetWindowPosCallback
  772. *
  773. * @since Added in version 3.0.
  774. *
  775. * @ingroup window
  776. */
  777. typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
  778. /*! @brief The function signature for window resize callbacks.
  779. *
  780. * This is the function signature for window size callback functions.
  781. *
  782. * @param[in] window The window that was resized.
  783. * @param[in] width The new width, in screen coordinates, of the window.
  784. * @param[in] height The new height, in screen coordinates, of the window.
  785. *
  786. * @sa @ref window_size
  787. * @sa glfwSetWindowSizeCallback
  788. *
  789. * @since Added in version 1.0.
  790. * @glfw3 Added window handle parameter.
  791. *
  792. * @ingroup window
  793. */
  794. typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
  795. /*! @brief The function signature for window close callbacks.
  796. *
  797. * This is the function signature for window close callback functions.
  798. *
  799. * @param[in] window The window that the user attempted to close.
  800. *
  801. * @sa @ref window_close
  802. * @sa glfwSetWindowCloseCallback
  803. *
  804. * @since Added in version 2.5.
  805. * @glfw3 Added window handle parameter.
  806. *
  807. * @ingroup window
  808. */
  809. typedef void (* GLFWwindowclosefun)(GLFWwindow*);
  810. /*! @brief The function signature for window content refresh callbacks.
  811. *
  812. * This is the function signature for window refresh callback functions.
  813. *
  814. * @param[in] window The window whose content needs to be refreshed.
  815. *
  816. * @sa @ref window_refresh
  817. * @sa glfwSetWindowRefreshCallback
  818. *
  819. * @since Added in version 2.5.
  820. * @glfw3 Added window handle parameter.
  821. *
  822. * @ingroup window
  823. */
  824. typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
  825. /*! @brief The function signature for window focus/defocus callbacks.
  826. *
  827. * This is the function signature for window focus callback functions.
  828. *
  829. * @param[in] window The window that gained or lost input focus.
  830. * @param[in] focused `GLFW_TRUE` if the window was given input focus, or
  831. * `GLFW_FALSE` if it lost it.
  832. *
  833. * @sa @ref window_focus
  834. * @sa glfwSetWindowFocusCallback
  835. *
  836. * @since Added in version 3.0.
  837. *
  838. * @ingroup window
  839. */
  840. typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
  841. /*! @brief The function signature for window iconify/restore callbacks.
  842. *
  843. * This is the function signature for window iconify/restore callback
  844. * functions.
  845. *
  846. * @param[in] window The window that was iconified or restored.
  847. * @param[in] iconified `GLFW_TRUE` if the window was iconified, or
  848. * `GLFW_FALSE` if it was restored.
  849. *
  850. * @sa @ref window_iconify
  851. * @sa glfwSetWindowIconifyCallback
  852. *
  853. * @since Added in version 3.0.
  854. *
  855. * @ingroup window
  856. */
  857. typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
  858. /*! @brief The function signature for framebuffer resize callbacks.
  859. *
  860. * This is the function signature for framebuffer resize callback
  861. * functions.
  862. *
  863. * @param[in] window The window whose framebuffer was resized.
  864. * @param[in] width The new width, in pixels, of the framebuffer.
  865. * @param[in] height The new height, in pixels, of the framebuffer.
  866. *
  867. * @sa @ref window_fbsize
  868. * @sa glfwSetFramebufferSizeCallback
  869. *
  870. * @since Added in version 3.0.
  871. *
  872. * @ingroup window
  873. */
  874. typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
  875. /*! @brief The function signature for mouse button callbacks.
  876. *
  877. * This is the function signature for mouse button callback functions.
  878. *
  879. * @param[in] window The window that received the event.
  880. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  881. * released.
  882. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
  883. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  884. * held down.
  885. *
  886. * @sa @ref input_mouse_button
  887. * @sa glfwSetMouseButtonCallback
  888. *
  889. * @since Added in version 1.0.
  890. * @glfw3 Added window handle and modifier mask parameters.
  891. *
  892. * @ingroup input
  893. */
  894. typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
  895. /*! @brief The function signature for cursor position callbacks.
  896. *
  897. * This is the function signature for cursor position callback functions.
  898. *
  899. * @param[in] window The window that received the event.
  900. * @param[in] xpos The new cursor x-coordinate, relative to the left edge of
  901. * the client area.
  902. * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
  903. * client area.
  904. *
  905. * @sa @ref cursor_pos
  906. * @sa glfwSetCursorPosCallback
  907. *
  908. * @since Added in version 3.0. Replaces `GLFWmouseposfun`.
  909. *
  910. * @ingroup input
  911. */
  912. typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
  913. /*! @brief The function signature for cursor enter/leave callbacks.
  914. *
  915. * This is the function signature for cursor enter/leave callback functions.
  916. *
  917. * @param[in] window The window that received the event.
  918. * @param[in] entered `GLFW_TRUE` if the cursor entered the window's client
  919. * area, or `GLFW_FALSE` if it left it.
  920. *
  921. * @sa @ref cursor_enter
  922. * @sa glfwSetCursorEnterCallback
  923. *
  924. * @since Added in version 3.0.
  925. *
  926. * @ingroup input
  927. */
  928. typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
  929. /*! @brief The function signature for scroll callbacks.
  930. *
  931. * This is the function signature for scroll callback functions.
  932. *
  933. * @param[in] window The window that received the event.
  934. * @param[in] xoffset The scroll offset along the x-axis.
  935. * @param[in] yoffset The scroll offset along the y-axis.
  936. *
  937. * @sa @ref scrolling
  938. * @sa glfwSetScrollCallback
  939. *
  940. * @since Added in version 3.0. Replaces `GLFWmousewheelfun`.
  941. *
  942. * @ingroup input
  943. */
  944. typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
  945. /*! @brief The function signature for keyboard key callbacks.
  946. *
  947. * This is the function signature for keyboard key callback functions.
  948. *
  949. * @param[in] window The window that received the event.
  950. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
  951. * @param[in] scancode The system-specific scancode of the key.
  952. * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.
  953. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  954. * held down.
  955. *
  956. * @sa @ref input_key
  957. * @sa glfwSetKeyCallback
  958. *
  959. * @since Added in version 1.0.
  960. * @glfw3 Added window handle, scancode and modifier mask parameters.
  961. *
  962. * @ingroup input
  963. */
  964. typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
  965. /*! @brief The function signature for Unicode character callbacks.
  966. *
  967. * This is the function signature for Unicode character callback functions.
  968. *
  969. * @param[in] window The window that received the event.
  970. * @param[in] codepoint The Unicode code point of the character.
  971. *
  972. * @sa @ref input_char
  973. * @sa glfwSetCharCallback
  974. *
  975. * @since Added in version 2.4.
  976. * @glfw3 Added window handle parameter.
  977. *
  978. * @ingroup input
  979. */
  980. typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
  981. /*! @brief The function signature for Unicode character with modifiers
  982. * callbacks.
  983. *
  984. * This is the function signature for Unicode character with modifiers callback
  985. * functions. It is called for each input character, regardless of what
  986. * modifier keys are held down.
  987. *
  988. * @param[in] window The window that received the event.
  989. * @param[in] codepoint The Unicode code point of the character.
  990. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  991. * held down.
  992. *
  993. * @sa @ref input_char
  994. * @sa glfwSetCharModsCallback
  995. *
  996. * @since Added in version 3.1.
  997. *
  998. * @ingroup input
  999. */
  1000. typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
  1001. /*! @brief The function signature for file drop callbacks.
  1002. *
  1003. * This is the function signature for file drop callbacks.
  1004. *
  1005. * @param[in] window The window that received the event.
  1006. * @param[in] count The number of dropped files.
  1007. * @param[in] paths The UTF-8 encoded file and/or directory path names.
  1008. *
  1009. * @sa @ref path_drop
  1010. * @sa glfwSetDropCallback
  1011. *
  1012. * @since Added in version 3.1.
  1013. *
  1014. * @ingroup input
  1015. */
  1016. typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);
  1017. /*! @brief The function signature for monitor configuration callbacks.
  1018. *
  1019. * This is the function signature for monitor configuration callback functions.
  1020. *
  1021. * @param[in] monitor The monitor that was connected or disconnected.
  1022. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
  1023. *
  1024. * @sa @ref monitor_event
  1025. * @sa glfwSetMonitorCallback
  1026. *
  1027. * @since Added in version 3.0.
  1028. *
  1029. * @ingroup monitor
  1030. */
  1031. typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
  1032. /*! @brief The function signature for joystick configuration callbacks.
  1033. *
  1034. * This is the function signature for joystick configuration callback
  1035. * functions.
  1036. *
  1037. * @param[in] joy The joystick that was connected or disconnected.
  1038. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
  1039. *
  1040. * @sa @ref joystick_event
  1041. * @sa glfwSetJoystickCallback
  1042. *
  1043. * @since Added in version 3.2.
  1044. *
  1045. * @ingroup input
  1046. */
  1047. typedef void (* GLFWjoystickfun)(int,int);
  1048. /*! @brief Video mode type.
  1049. *
  1050. * This describes a single video mode.
  1051. *
  1052. * @sa @ref monitor_modes
  1053. * @sa glfwGetVideoMode glfwGetVideoModes
  1054. *
  1055. * @since Added in version 1.0.
  1056. * @glfw3 Added refresh rate member.
  1057. *
  1058. * @ingroup monitor
  1059. */
  1060. typedef struct GLFWvidmode
  1061. {
  1062. /*! The width, in screen coordinates, of the video mode.
  1063. */
  1064. int width;
  1065. /*! The height, in screen coordinates, of the video mode.
  1066. */
  1067. int height;
  1068. /*! The bit depth of the red channel of the video mode.
  1069. */
  1070. int redBits;
  1071. /*! The bit depth of the green channel of the video mode.
  1072. */
  1073. int greenBits;
  1074. /*! The bit depth of the blue channel of the video mode.
  1075. */
  1076. int blueBits;
  1077. /*! The refresh rate, in Hz, of the video mode.
  1078. */
  1079. int refreshRate;
  1080. } GLFWvidmode;
  1081. /*! @brief Gamma ramp.
  1082. *
  1083. * This describes the gamma ramp for a monitor.
  1084. *
  1085. * @sa @ref monitor_gamma
  1086. * @sa glfwGetGammaRamp glfwSetGammaRamp
  1087. *
  1088. * @since Added in version 3.0.
  1089. *
  1090. * @ingroup monitor
  1091. */
  1092. typedef struct GLFWgammaramp
  1093. {
  1094. /*! An array of value describing the response of the red channel.
  1095. */
  1096. unsigned short* red;
  1097. /*! An array of value describing the response of the green channel.
  1098. */
  1099. unsigned short* green;
  1100. /*! An array of value describing the response of the blue channel.
  1101. */
  1102. unsigned short* blue;
  1103. /*! The number of elements in each array.
  1104. */
  1105. unsigned int size;
  1106. } GLFWgammaramp;
  1107. /*! @brief Image data.
  1108. *
  1109. * @sa @ref cursor_custom
  1110. *
  1111. * @since Added in version 2.1.
  1112. * @glfw3 Removed format and bytes-per-pixel members.
  1113. */
  1114. typedef struct GLFWimage
  1115. {
  1116. /*! The width, in pixels, of this image.
  1117. */
  1118. int width;
  1119. /*! The height, in pixels, of this image.
  1120. */
  1121. int height;
  1122. /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
  1123. */
  1124. unsigned char* pixels;
  1125. } GLFWimage;
  1126. /*************************************************************************
  1127. * GLFW API functions
  1128. *************************************************************************/
  1129. /*! @brief Initializes the GLFW library.
  1130. *
  1131. * This function initializes the GLFW library. Before most GLFW functions can
  1132. * be used, GLFW must be initialized, and before an application terminates GLFW
  1133. * should be terminated in order to free any resources allocated during or
  1134. * after initialization.
  1135. *
  1136. * If this function fails, it calls @ref glfwTerminate before returning. If it
  1137. * succeeds, you should call @ref glfwTerminate before the application exits.
  1138. *
  1139. * Additional calls to this function after successful initialization but before
  1140. * termination will return `GLFW_TRUE` immediately.
  1141. *
  1142. * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
  1143. * [error](@ref error_handling) occurred.
  1144. *
  1145. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1146. *
  1147. * @remark @osx This function will change the current directory of the
  1148. * application to the `Contents/Resources` subdirectory of the application's
  1149. * bundle, if present. This can be disabled with a
  1150. * [compile-time option](@ref compile_options_osx).
  1151. *
  1152. * @thread_safety This function must only be called from the main thread.
  1153. *
  1154. * @sa @ref intro_init
  1155. * @sa glfwTerminate
  1156. *
  1157. * @since Added in version 1.0.
  1158. *
  1159. * @ingroup init
  1160. */
  1161. GLFWAPI int glfwInit(void);
  1162. /*! @brief Terminates the GLFW library.
  1163. *
  1164. * This function destroys all remaining windows and cursors, restores any
  1165. * modified gamma ramps and frees any other allocated resources. Once this
  1166. * function is called, you must again call @ref glfwInit successfully before
  1167. * you will be able to use most GLFW functions.
  1168. *
  1169. * If GLFW has been successfully initialized, this function should be called
  1170. * before the application exits. If initialization fails, there is no need to
  1171. * call this function, as it is called by @ref glfwInit before it returns
  1172. * failure.
  1173. *
  1174. * @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
  1175. *
  1176. * @remark This function may be called before @ref glfwInit.
  1177. *
  1178. * @warning The contexts of any remaining windows must not be current on any
  1179. * other thread when this function is called.
  1180. *
  1181. * @reentrancy This function must not be called from a callback.
  1182. *
  1183. * @thread_safety This function must only be called from the main thread.
  1184. *
  1185. * @sa @ref intro_init
  1186. * @sa glfwInit
  1187. *
  1188. * @since Added in version 1.0.
  1189. *
  1190. * @ingroup init
  1191. */
  1192. GLFWAPI void glfwTerminate(void);
  1193. /*! @brief Retrieves the version of the GLFW library.
  1194. *
  1195. * This function retrieves the major, minor and revision numbers of the GLFW
  1196. * library. It is intended for when you are using GLFW as a shared library and
  1197. * want to ensure that you are using the minimum required version.
  1198. *
  1199. * Any or all of the version arguments may be `NULL`.
  1200. *
  1201. * @param[out] major Where to store the major version number, or `NULL`.
  1202. * @param[out] minor Where to store the minor version number, or `NULL`.
  1203. * @param[out] rev Where to store the revision number, or `NULL`.
  1204. *
  1205. * @errors None.
  1206. *
  1207. * @remark This function may be called before @ref glfwInit.
  1208. *
  1209. * @thread_safety This function may be called from any thread.
  1210. *
  1211. * @sa @ref intro_version
  1212. * @sa glfwGetVersionString
  1213. *
  1214. * @since Added in version 1.0.
  1215. *
  1216. * @ingroup init
  1217. */
  1218. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  1219. /*! @brief Returns a string describing the compile-time configuration.
  1220. *
  1221. * This function returns the compile-time generated
  1222. * [version string](@ref intro_version_string) of the GLFW library binary. It
  1223. * describes the version, platform, compiler and any platform-specific
  1224. * compile-time options. It should not be confused with the OpenGL or OpenGL
  1225. * ES version string, queried with `glGetString`.
  1226. *
  1227. * __Do not use the version string__ to parse the GLFW library version. The
  1228. * @ref glfwGetVersion function provides the version of the running library
  1229. * binary in numerical format.
  1230. *
  1231. * @return The ASCII encoded GLFW version string.
  1232. *
  1233. * @errors None.
  1234. *
  1235. * @remark This function may be called before @ref glfwInit.
  1236. *
  1237. * @pointer_lifetime The returned string is static and compile-time generated.
  1238. *
  1239. * @thread_safety This function may be called from any thread.
  1240. *
  1241. * @sa @ref intro_version
  1242. * @sa glfwGetVersion
  1243. *
  1244. * @since Added in version 3.0.
  1245. *
  1246. * @ingroup init
  1247. */
  1248. GLFWAPI const char* glfwGetVersionString(void);
  1249. /*! @brief Sets the error callback.
  1250. *
  1251. * This function sets the error callback, which is called with an error code
  1252. * and a human-readable description each time a GLFW error occurs.
  1253. *
  1254. * The error callback is called on the thread where the error occurred. If you
  1255. * are using GLFW from multiple threads, your error callback needs to be
  1256. * written accordingly.
  1257. *
  1258. * Because the description string may have been generated specifically for that
  1259. * error, it is not guaranteed to be valid after the callback has returned. If
  1260. * you wish to use it after the callback returns, you need to make a copy.
  1261. *
  1262. * Once set, the error callback remains set even after the library has been
  1263. * terminated.
  1264. *
  1265. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1266. * callback.
  1267. * @return The previously set callback, or `NULL` if no callback was set.
  1268. *
  1269. * @errors None.
  1270. *
  1271. * @remark This function may be called before @ref glfwInit.
  1272. *
  1273. * @thread_safety This function must only be called from the main thread.
  1274. *
  1275. * @sa @ref error_handling
  1276. *
  1277. * @since Added in version 3.0.
  1278. *
  1279. * @ingroup init
  1280. */
  1281. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
  1282. /*! @brief Returns the currently connected monitors.
  1283. *
  1284. * This function returns an array of handles for all currently connected
  1285. * monitors. The primary monitor is always first in the returned array. If no
  1286. * monitors were found, this function returns `NULL`.
  1287. *
  1288. * @param[out] count Where to store the number of monitors in the returned
  1289. * array. This is set to zero if an error occurred.
  1290. * @return An array of monitor handles, or `NULL` if no monitors were found or
  1291. * if an [error](@ref error_handling) occurred.
  1292. *
  1293. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1294. *
  1295. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1296. * should not free it yourself. It is guaranteed to be valid only until the
  1297. * monitor configuration changes or the library is terminated.
  1298. *
  1299. * @thread_safety This function must only be called from the main thread.
  1300. *
  1301. * @sa @ref monitor_monitors
  1302. * @sa @ref monitor_event
  1303. * @sa glfwGetPrimaryMonitor
  1304. *
  1305. * @since Added in version 3.0.
  1306. *
  1307. * @ingroup monitor
  1308. */
  1309. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  1310. /*! @brief Returns the primary monitor.
  1311. *
  1312. * This function returns the primary monitor. This is usually the monitor
  1313. * where elements like the task bar or global menu bar are located.
  1314. *
  1315. * @return The primary monitor, or `NULL` if no monitors were found or if an
  1316. * [error](@ref error_handling) occurred.
  1317. *
  1318. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1319. *
  1320. * @thread_safety This function must only be called from the main thread.
  1321. *
  1322. * @remark The primary monitor is always first in the array returned by @ref
  1323. * glfwGetMonitors.
  1324. *
  1325. * @sa @ref monitor_monitors
  1326. * @sa glfwGetMonitors
  1327. *
  1328. * @since Added in version 3.0.
  1329. *
  1330. * @ingroup monitor
  1331. */
  1332. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  1333. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  1334. *
  1335. * This function returns the position, in screen coordinates, of the upper-left
  1336. * corner of the specified monitor.
  1337. *
  1338. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1339. * non-`NULL` position arguments will be set to zero.
  1340. *
  1341. * @param[in] monitor The monitor to query.
  1342. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  1343. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  1344. *
  1345. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1346. * GLFW_PLATFORM_ERROR.
  1347. *
  1348. * @thread_safety This function must only be called from the main thread.
  1349. *
  1350. * @sa @ref monitor_properties
  1351. *
  1352. * @since Added in version 3.0.
  1353. *
  1354. * @ingroup monitor
  1355. */
  1356. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  1357. /*! @brief Returns the physical size of the monitor.
  1358. *
  1359. * This function returns the size, in millimetres, of the display area of the
  1360. * specified monitor.
  1361. *
  1362. * Some systems do not provide accurate monitor size information, either
  1363. * because the monitor
  1364. * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
  1365. * data is incorrect or because the driver does not report it accurately.
  1366. *
  1367. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1368. * non-`NULL` size arguments will be set to zero.
  1369. *
  1370. * @param[in] monitor The monitor to query.
  1371. * @param[out] widthMM Where to store the width, in millimetres, of the
  1372. * monitor's display area, or `NULL`.
  1373. * @param[out] heightMM Where to store the height, in millimetres, of the
  1374. * monitor's display area, or `NULL`.
  1375. *
  1376. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1377. *
  1378. * @remark @win32 calculates the returned physical size from the
  1379. * current resolution and system DPI instead of querying the monitor EDID data.
  1380. *
  1381. * @thread_safety This function must only be called from the main thread.
  1382. *
  1383. * @sa @ref monitor_properties
  1384. *
  1385. * @since Added in version 3.0.
  1386. *
  1387. * @ingroup monitor
  1388. */
  1389. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
  1390. /*! @brief Returns the name of the specified monitor.
  1391. *
  1392. * This function returns a human-readable name, encoded as UTF-8, of the
  1393. * specified monitor. The name typically reflects the make and model of the
  1394. * monitor and is not guaranteed to be unique among the connected monitors.
  1395. *
  1396. * @param[in] monitor The monitor to query.
  1397. * @return The UTF-8 encoded name of the monitor, or `NULL` if an
  1398. * [error](@ref error_handling) occurred.
  1399. *
  1400. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1401. *
  1402. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  1403. * should not free it yourself. It is valid until the specified monitor is
  1404. * disconnected or the library is terminated.
  1405. *
  1406. * @thread_safety This function must only be called from the main thread.
  1407. *
  1408. * @sa @ref monitor_properties
  1409. *
  1410. * @since Added in version 3.0.
  1411. *
  1412. * @ingroup monitor
  1413. */
  1414. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  1415. /*! @brief Sets the monitor configuration callback.
  1416. *
  1417. * This function sets the monitor configuration callback, or removes the
  1418. * currently set callback. This is called when a monitor is connected to or
  1419. * disconnected from the system.
  1420. *
  1421. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1422. * callback.
  1423. * @return The previously set callback, or `NULL` if no callback was set or the
  1424. * library had not been [initialized](@ref intro_init).
  1425. *
  1426. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1427. *
  1428. * @thread_safety This function must only be called from the main thread.
  1429. *
  1430. * @sa @ref monitor_event
  1431. *
  1432. * @since Added in version 3.0.
  1433. *
  1434. * @ingroup monitor
  1435. */
  1436. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
  1437. /*! @brief Returns the available video modes for the specified monitor.
  1438. *
  1439. * This function returns an array of all video modes supported by the specified
  1440. * monitor. The returned array is sorted in ascending order, first by color
  1441. * bit depth (the sum of all channel depths) and then by resolution area (the
  1442. * product of width and height).
  1443. *
  1444. * @param[in] monitor The monitor to query.
  1445. * @param[out] count Where to store the number of video modes in the returned
  1446. * array. This is set to zero if an error occurred.
  1447. * @return An array of video modes, or `NULL` if an
  1448. * [error](@ref error_handling) occurred.
  1449. *
  1450. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1451. * GLFW_PLATFORM_ERROR.
  1452. *
  1453. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1454. * should not free it yourself. It is valid until the specified monitor is
  1455. * disconnected, this function is called again for that monitor or the library
  1456. * is terminated.
  1457. *
  1458. * @thread_safety This function must only be called from the main thread.
  1459. *
  1460. * @sa @ref monitor_modes
  1461. * @sa glfwGetVideoMode
  1462. *
  1463. * @since Added in version 1.0.
  1464. * @glfw3 Changed to return an array of modes for a specific monitor.
  1465. *
  1466. * @ingroup monitor
  1467. */
  1468. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  1469. /*! @brief Returns the current mode of the specified monitor.
  1470. *
  1471. * This function returns the current video mode of the specified monitor. If
  1472. * you have created a full screen window for that monitor, the return value
  1473. * will depend on whether that window is iconified.
  1474. *
  1475. * @param[in] monitor The monitor to query.
  1476. * @return The current mode of the monitor, or `NULL` if an
  1477. * [error](@ref error_handling) occurred.
  1478. *
  1479. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1480. * GLFW_PLATFORM_ERROR.
  1481. *
  1482. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  1483. * should not free it yourself. It is valid until the specified monitor is
  1484. * disconnected or the library is terminated.
  1485. *
  1486. * @thread_safety This function must only be called from the main thread.
  1487. *
  1488. * @sa @ref monitor_modes
  1489. * @sa glfwGetVideoModes
  1490. *
  1491. * @since Added in version 3.0. Replaces `glfwGetDesktopMode`.
  1492. *
  1493. * @ingroup monitor
  1494. */
  1495. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  1496. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  1497. *
  1498. * This function generates a 256-element gamma ramp from the specified exponent
  1499. * and then calls @ref glfwSetGammaRamp with it. The value must be a finite
  1500. * number greater than zero.
  1501. *
  1502. * @param[in] monitor The monitor whose gamma ramp to set.
  1503. * @param[in] gamma The desired exponent.
  1504. *
  1505. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  1506. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  1507. *
  1508. * @thread_safety This function must only be called from the main thread.
  1509. *
  1510. * @sa @ref monitor_gamma
  1511. *
  1512. * @since Added in version 3.0.
  1513. *
  1514. * @ingroup monitor
  1515. */
  1516. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  1517. /*! @brief Returns the current gamma ramp for the specified monitor.
  1518. *
  1519. * This function returns the current gamma ramp of the specified monitor.
  1520. *
  1521. * @param[in] monitor The monitor to query.
  1522. * @return The current gamma ramp, or `NULL` if an
  1523. * [error](@ref error_handling) occurred.
  1524. *
  1525. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1526. * GLFW_PLATFORM_ERROR.
  1527. *
  1528. * @pointer_lifetime The returned structure and its arrays are allocated and
  1529. * freed by GLFW. You should not free them yourself. They are valid until the
  1530. * specified monitor is disconnected, this function is called again for that
  1531. * monitor or the library is terminated.
  1532. *
  1533. * @thread_safety This function must only be called from the main thread.
  1534. *
  1535. * @sa @ref monitor_gamma
  1536. *
  1537. * @since Added in version 3.0.
  1538. *
  1539. * @ingroup monitor
  1540. */
  1541. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  1542. /*! @brief Sets the current gamma ramp for the specified monitor.
  1543. *
  1544. * This function sets the current gamma ramp for the specified monitor. The
  1545. * original gamma ramp for that monitor is saved by GLFW the first time this
  1546. * function is called and is restored by @ref glfwTerminate.
  1547. *
  1548. * @param[in] monitor The monitor whose gamma ramp to set.
  1549. * @param[in] ramp The gamma ramp to use.
  1550. *
  1551. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1552. * GLFW_PLATFORM_ERROR.
  1553. *
  1554. * @remark Gamma ramp sizes other than 256 are not supported by all platforms
  1555. * or graphics hardware.
  1556. *
  1557. * @remark @win32 The gamma ramp size must be 256.
  1558. *
  1559. * @pointer_lifetime The specified gamma ramp is copied before this function
  1560. * returns.
  1561. *
  1562. * @thread_safety This function must only be called from the main thread.
  1563. *
  1564. * @sa @ref monitor_gamma
  1565. *
  1566. * @since Added in version 3.0.
  1567. *
  1568. * @ingroup monitor
  1569. */
  1570. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  1571. /*! @brief Resets all window hints to their default values.
  1572. *
  1573. * This function resets all window hints to their
  1574. * [default values](@ref window_hints_values).
  1575. *
  1576. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1577. *
  1578. * @thread_safety This function must only be called from the main thread.
  1579. *
  1580. * @sa @ref window_hints
  1581. * @sa glfwWindowHint
  1582. *
  1583. * @since Added in version 3.0.
  1584. *
  1585. * @ingroup window
  1586. */
  1587. GLFWAPI void glfwDefaultWindowHints(void);
  1588. /*! @brief Sets the specified window hint to the desired value.
  1589. *
  1590. * This function sets hints for the next call to @ref glfwCreateWindow. The
  1591. * hints, once set, retain their values until changed by a call to @ref
  1592. * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
  1593. * terminated.
  1594. *
  1595. * This function does not check whether the specified hint values are valid.
  1596. * If you set hints to invalid values this will instead be reported by the next
  1597. * call to @ref glfwCreateWindow.
  1598. *
  1599. * @param[in] hint The [window hint](@ref window_hints) to set.
  1600. * @param[in] value The new value of the window hint.
  1601. *
  1602. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1603. * GLFW_INVALID_ENUM.
  1604. *
  1605. * @thread_safety This function must only be called from the main thread.
  1606. *
  1607. * @sa @ref window_hints
  1608. * @sa glfwDefaultWindowHints
  1609. *
  1610. * @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
  1611. *
  1612. * @ingroup window
  1613. */
  1614. GLFWAPI void glfwWindowHint(int hint, int value);
  1615. /*! @brief Creates a window and its associated context.
  1616. *
  1617. * This function creates a window and its associated OpenGL or OpenGL ES
  1618. * context. Most of the options controlling how the window and its context
  1619. * should be created are specified with [window hints](@ref window_hints).
  1620. *
  1621. * Successful creation does not change which context is current. Before you
  1622. * can use the newly created context, you need to
  1623. * [make it current](@ref context_current). For information about the `share`
  1624. * parameter, see @ref context_sharing.
  1625. *
  1626. * The created window, framebuffer and context may differ from what you
  1627. * requested, as not all parameters and hints are
  1628. * [hard constraints](@ref window_hints_hard). This includes the size of the
  1629. * window, especially for full screen windows. To query the actual attributes
  1630. * of the created window, framebuffer and context, see @ref
  1631. * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
  1632. *
  1633. * To create a full screen window, you need to specify the monitor the window
  1634. * will cover. If no monitor is specified, the window will be windowed mode.
  1635. * Unless you have a way for the user to choose a specific monitor, it is
  1636. * recommended that you pick the primary monitor. For more information on how
  1637. * to query connected monitors, see @ref monitor_monitors.
  1638. *
  1639. * For full screen windows, the specified size becomes the resolution of the
  1640. * window's _desired video mode_. As long as a full screen window is not
  1641. * iconified, the supported video mode most closely matching the desired video
  1642. * mode is set for the specified monitor. For more information about full
  1643. * screen windows, including the creation of so called _windowed full screen_
  1644. * or _borderless full screen_ windows, see @ref window_windowed_full_screen.
  1645. *
  1646. * By default, newly created windows use the placement recommended by the
  1647. * window system. To create the window at a specific position, make it
  1648. * initially invisible using the [GLFW_VISIBLE](@ref window_hints_wnd) window
  1649. * hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
  1650. * it.
  1651. *
  1652. * As long as at least one full screen window is not iconified, the screensaver
  1653. * is prohibited from starting.
  1654. *
  1655. * Window systems put limits on window sizes. Very large or very small window
  1656. * dimensions may be overridden by the window system on creation. Check the
  1657. * actual [size](@ref window_size) after creation.
  1658. *
  1659. * The [swap interval](@ref buffer_swap) is not set during window creation and
  1660. * the initial value may vary depending on driver settings and defaults.
  1661. *
  1662. * @param[in] width The desired width, in screen coordinates, of the window.
  1663. * This must be greater than zero.
  1664. * @param[in] height The desired height, in screen coordinates, of the window.
  1665. * This must be greater than zero.
  1666. * @param[in] title The initial, UTF-8 encoded window title.
  1667. * @param[in] monitor The monitor to use for full screen mode, or `NULL` for
  1668. * windowed mode.
  1669. * @param[in] share The window whose context to share resources with, or `NULL`
  1670. * to not share resources.
  1671. * @return The handle of the created window, or `NULL` if an
  1672. * [error](@ref error_handling) occurred.
  1673. *
  1674. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  1675. * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
  1676. * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
  1677. * GLFW_PLATFORM_ERROR.
  1678. *
  1679. * @remark @win32 Window creation will fail if the Microsoft GDI software
  1680. * OpenGL implementation is the only one available.
  1681. *
  1682. * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
  1683. * will be set as the initial icon for the window. If no such icon is present,
  1684. * the `IDI_WINLOGO` icon will be used instead. To set a different icon, see
  1685. * @ref glfwSetWindowIcon.
  1686. *
  1687. * @remark @win32 The context to share resources with must not be current on
  1688. * any other thread.
  1689. *
  1690. * @remark @osx The GLFW window has no icon, as it is not a document
  1691. * window, but the dock icon will be the same as the application bundle's icon.
  1692. * For more information on bundles, see the
  1693. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  1694. * in the Mac Developer Library.
  1695. *
  1696. * @remark @osx The first time a window is created the menu bar is populated
  1697. * with common commands like Hide, Quit and About. The About entry opens
  1698. * a minimal about dialog with information from the application's bundle. The
  1699. * menu bar can be disabled with a
  1700. * [compile-time option](@ref compile_options_osx).
  1701. *
  1702. * @remark @osx On OS X 10.10 and later the window frame will not be rendered
  1703. * at full resolution on Retina displays unless the `NSHighResolutionCapable`
  1704. * key is enabled in the application bundle's `Info.plist`. For more
  1705. * information, see
  1706. * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
  1707. * in the Mac Developer Library. The GLFW test and example programs use
  1708. * a custom `Info.plist` template for this, which can be found as
  1709. * `CMake/MacOSXBundleInfo.plist.in` in the source tree.
  1710. *
  1711. * @remark @x11 Some window managers will not respect the placement of
  1712. * initially hidden windows.
  1713. *
  1714. * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
  1715. * a window to reach its requested state. This means you may not be able to
  1716. * query the final size, position or other attributes directly after window
  1717. * creation.
  1718. *
  1719. * @reentrancy This function must not be called from a callback.
  1720. *
  1721. * @thread_safety This function must only be called from the main thread.
  1722. *
  1723. * @sa @ref window_creation
  1724. * @sa glfwDestroyWindow
  1725. *
  1726. * @since Added in version 3.0. Replaces `glfwOpenWindow`.
  1727. *
  1728. * @ingroup window
  1729. */
  1730. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  1731. /*! @brief Destroys the specified window and its context.
  1732. *
  1733. * This function destroys the specified window and its context. On calling
  1734. * this function, no further callbacks will be called for that window.
  1735. *
  1736. * If the context of the specified window is current on the main thread, it is
  1737. * detached before being destroyed.
  1738. *
  1739. * @param[in] window The window to destroy.
  1740. *
  1741. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1742. * GLFW_PLATFORM_ERROR.
  1743. *
  1744. * @note The context of the specified window must not be current on any other
  1745. * thread when this function is called.
  1746. *
  1747. * @reentrancy This function must not be called from a callback.
  1748. *
  1749. * @thread_safety This function must only be called from the main thread.
  1750. *
  1751. * @sa @ref window_creation
  1752. * @sa glfwCreateWindow
  1753. *
  1754. * @since Added in version 3.0. Replaces `glfwCloseWindow`.
  1755. *
  1756. * @ingroup window
  1757. */
  1758. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  1759. /*! @brief Checks the close flag of the specified window.
  1760. *
  1761. * This function returns the value of the close flag of the specified window.
  1762. *
  1763. * @param[in] window The window to query.
  1764. * @return The value of the close flag.
  1765. *
  1766. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1767. *
  1768. * @thread_safety This function may be called from any thread. Access is not
  1769. * synchronized.
  1770. *
  1771. * @sa @ref window_close
  1772. *
  1773. * @since Added in version 3.0.
  1774. *
  1775. * @ingroup window
  1776. */
  1777. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  1778. /*! @brief Sets the close flag of the specified window.
  1779. *
  1780. * This function sets the value of the close flag of the specified window.
  1781. * This can be used to override the user's attempt to close the window, or
  1782. * to signal that it should be closed.
  1783. *
  1784. * @param[in] window The window whose flag to change.
  1785. * @param[in] value The new value.
  1786. *
  1787. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  1788. *
  1789. * @thread_safety This function may be called from any thread. Access is not
  1790. * synchronized.
  1791. *
  1792. * @sa @ref window_close
  1793. *
  1794. * @since Added in version 3.0.
  1795. *
  1796. * @ingroup window
  1797. */
  1798. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  1799. /*! @brief Sets the title of the specified window.
  1800. *
  1801. * This function sets the window title, encoded as UTF-8, of the specified
  1802. * window.
  1803. *
  1804. * @param[in] window The window whose title to change.
  1805. * @param[in] title The UTF-8 encoded window title.
  1806. *
  1807. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1808. * GLFW_PLATFORM_ERROR.
  1809. *
  1810. * @remark @osx The window title will not be updated until the next time you
  1811. * process events.
  1812. *
  1813. * @thread_safety This function must only be called from the main thread.
  1814. *
  1815. * @sa @ref window_title
  1816. *
  1817. * @since Added in version 1.0.
  1818. * @glfw3 Added window handle parameter.
  1819. *
  1820. * @ingroup window
  1821. */
  1822. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  1823. /*! @brief Sets the icon for the specified window.
  1824. *
  1825. * This function sets the icon of the specified window. If passed an array of
  1826. * candidate images, those of or closest to the sizes desired by the system are
  1827. * selected. If no images are specified, the window reverts to its default
  1828. * icon.
  1829. *
  1830. * The desired image sizes varies depending on platform and system settings.
  1831. * The selected images will be rescaled as needed. Good sizes include 16x16,
  1832. * 32x32 and 48x48.
  1833. *
  1834. * @param[in] window The window whose icon to set.
  1835. * @param[in] count The number of images in the specified array, or zero to
  1836. * revert to the default window icon.
  1837. * @param[in] images The images to create the icon from. This is ignored if
  1838. * count is zero.
  1839. *
  1840. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1841. * GLFW_PLATFORM_ERROR.
  1842. *
  1843. * @pointer_lifetime The specified image data is copied before this function
  1844. * returns.
  1845. *
  1846. * @remark @osx The GLFW window has no icon, as it is not a document
  1847. * window, so this function does nothing. The dock icon will be the same as
  1848. * the application bundle's icon. For more information on bundles, see the
  1849. * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
  1850. * in the Mac Developer Library.
  1851. *
  1852. * @thread_safety This function must only be called from the main thread.
  1853. *
  1854. * @sa @ref window_icon
  1855. *
  1856. * @since Added in version 3.2.
  1857. *
  1858. * @ingroup window
  1859. */
  1860. GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
  1861. /*! @brief Retrieves the position of the client area of the specified window.
  1862. *
  1863. * This function retrieves the position, in screen coordinates, of the
  1864. * upper-left corner of the client area of the specified window.
  1865. *
  1866. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  1867. * non-`NULL` position arguments will be set to zero.
  1868. *
  1869. * @param[in] window The window to query.
  1870. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  1871. * the client area, or `NULL`.
  1872. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  1873. * the client area, or `NULL`.
  1874. *
  1875. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1876. * GLFW_PLATFORM_ERROR.
  1877. *
  1878. * @thread_safety This function must only be called from the main thread.
  1879. *
  1880. * @sa @ref window_pos
  1881. * @sa glfwSetWindowPos
  1882. *
  1883. * @since Added in version 3.0.
  1884. *
  1885. * @ingroup window
  1886. */
  1887. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  1888. /*! @brief Sets the position of the client area of the specified window.
  1889. *
  1890. * This function sets the position, in screen coordinates, of the upper-left
  1891. * corner of the client area of the specified windowed mode window. If the
  1892. * window is a full screen window, this function does nothing.
  1893. *
  1894. * __Do not use this function__ to move an already visible window unless you
  1895. * have very good reasons for doing so, as it will confuse and annoy the user.
  1896. *
  1897. * The window manager may put limits on what positions are allowed. GLFW
  1898. * cannot and should not override these limits.
  1899. *
  1900. * @param[in] window The window to query.
  1901. * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
  1902. * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
  1903. *
  1904. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1905. * GLFW_PLATFORM_ERROR.
  1906. *
  1907. * @thread_safety This function must only be called from the main thread.
  1908. *
  1909. * @sa @ref window_pos
  1910. * @sa glfwGetWindowPos
  1911. *
  1912. * @since Added in version 1.0.
  1913. * @glfw3 Added window handle parameter.
  1914. *
  1915. * @ingroup window
  1916. */
  1917. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  1918. /*! @brief Retrieves the size of the client area of the specified window.
  1919. *
  1920. * This function retrieves the size, in screen coordinates, of the client area
  1921. * of the specified window. If you wish to retrieve the size of the
  1922. * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
  1923. *
  1924. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  1925. * non-`NULL` size arguments will be set to zero.
  1926. *
  1927. * @param[in] window The window whose size to retrieve.
  1928. * @param[out] width Where to store the width, in screen coordinates, of the
  1929. * client area, or `NULL`.
  1930. * @param[out] height Where to store the height, in screen coordinates, of the
  1931. * client area, or `NULL`.
  1932. *
  1933. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  1934. * GLFW_PLATFORM_ERROR.
  1935. *
  1936. * @thread_safety This function must only be called from the main thread.
  1937. *
  1938. * @sa @ref window_size
  1939. * @sa glfwSetWindowSize
  1940. *
  1941. * @since Added in version 1.0.
  1942. * @glfw3 Added window handle parameter.
  1943. *
  1944. * @ingroup window
  1945. */
  1946. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  1947. /*! @brief Sets the size limits of the specified window.
  1948. *
  1949. * This function sets the size limits of the client area of the specified
  1950. * window. If the window is full screen, the size limits only take effect
  1951. * once it is made windowed. If the window is not resizable, this function
  1952. * does nothing.
  1953. *
  1954. * The size limits are applied immediately to a windowed mode window and may
  1955. * cause it to be resized.
  1956. *
  1957. * The maximum dimensions must be greater than or equal to the minimum
  1958. * dimensions and all must be greater than or equal to zero.
  1959. *
  1960. * @param[in] window The window to set limits for.
  1961. * @param[in] minwidth The minimum width, in screen coordinates, of the client
  1962. * area, or `GLFW_DONT_CARE`.
  1963. * @param[in] minheight The minimum height, in screen coordinates, of the
  1964. * client area, or `GLFW_DONT_CARE`.
  1965. * @param[in] maxwidth The maximum width, in screen coordinates, of the client
  1966. * area, or `GLFW_DONT_CARE`.
  1967. * @param[in] maxheight The maximum height, in screen coordinates, of the
  1968. * client area, or `GLFW_DONT_CARE`.
  1969. *
  1970. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  1971. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  1972. *
  1973. * @remark If you set size limits and an aspect ratio that conflict, the
  1974. * results are undefined.
  1975. *
  1976. * @thread_safety This function must only be called from the main thread.
  1977. *
  1978. * @sa @ref window_sizelimits
  1979. * @sa glfwSetWindowAspectRatio
  1980. *
  1981. * @since Added in version 3.2.
  1982. *
  1983. * @ingroup window
  1984. */
  1985. GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
  1986. /*! @brief Sets the aspect ratio of the specified window.
  1987. *
  1988. * This function sets the required aspect ratio of the client area of the
  1989. * specified window. If the window is full screen, the aspect ratio only takes
  1990. * effect once it is made windowed. If the window is not resizable, this
  1991. * function does nothing.
  1992. *
  1993. * The aspect ratio is specified as a numerator and a denominator and both
  1994. * values must be greater than zero. For example, the common 16:9 aspect ratio
  1995. * is specified as 16 and 9, respectively.
  1996. *
  1997. * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
  1998. * ratio limit is disabled.
  1999. *
  2000. * The aspect ratio is applied immediately to a windowed mode window and may
  2001. * cause it to be resized.
  2002. *
  2003. * @param[in] window The window to set limits for.
  2004. * @param[in] numer The numerator of the desired aspect ratio, or
  2005. * `GLFW_DONT_CARE`.
  2006. * @param[in] denom The denominator of the desired aspect ratio, or
  2007. * `GLFW_DONT_CARE`.
  2008. *
  2009. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2010. * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
  2011. *
  2012. * @remark If you set size limits and an aspect ratio that conflict, the
  2013. * results are undefined.
  2014. *
  2015. * @thread_safety This function must only be called from the main thread.
  2016. *
  2017. * @sa @ref window_sizelimits
  2018. * @sa glfwSetWindowSizeLimits
  2019. *
  2020. * @since Added in version 3.2.
  2021. *
  2022. * @ingroup window
  2023. */
  2024. GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
  2025. /*! @brief Sets the size of the client area of the specified window.
  2026. *
  2027. * This function sets the size, in screen coordinates, of the client area of
  2028. * the specified window.
  2029. *
  2030. * For full screen windows, this function updates the resolution of its desired
  2031. * video mode and switches to the video mode closest to it, without affecting
  2032. * the window's context. As the context is unaffected, the bit depths of the
  2033. * framebuffer remain unchanged.
  2034. *
  2035. * If you wish to update the refresh rate of the desired video mode in addition
  2036. * to its resolution, see @ref glfwSetWindowMonitor.
  2037. *
  2038. * The window manager may put limits on what sizes are allowed. GLFW cannot
  2039. * and should not override these limits.
  2040. *
  2041. * @param[in] window The window to resize.
  2042. * @param[in] width The desired width, in screen coordinates, of the window
  2043. * client area.
  2044. * @param[in] height The desired height, in screen coordinates, of the window
  2045. * client area.
  2046. *
  2047. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2048. * GLFW_PLATFORM_ERROR.
  2049. *
  2050. * @thread_safety This function must only be called from the main thread.
  2051. *
  2052. * @sa @ref window_size
  2053. * @sa glfwGetWindowSize
  2054. * @sa glfwSetWindowMonitor
  2055. *
  2056. * @since Added in version 1.0.
  2057. * @glfw3 Added window handle parameter.
  2058. *
  2059. * @ingroup window
  2060. */
  2061. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  2062. /*! @brief Retrieves the size of the framebuffer of the specified window.
  2063. *
  2064. * This function retrieves the size, in pixels, of the framebuffer of the
  2065. * specified window. If you wish to retrieve the size of the window in screen
  2066. * coordinates, see @ref glfwGetWindowSize.
  2067. *
  2068. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2069. * non-`NULL` size arguments will be set to zero.
  2070. *
  2071. * @param[in] window The window whose framebuffer to query.
  2072. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  2073. * or `NULL`.
  2074. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  2075. * or `NULL`.
  2076. *
  2077. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2078. * GLFW_PLATFORM_ERROR.
  2079. *
  2080. * @thread_safety This function must only be called from the main thread.
  2081. *
  2082. * @sa @ref window_fbsize
  2083. * @sa glfwSetFramebufferSizeCallback
  2084. *
  2085. * @since Added in version 3.0.
  2086. *
  2087. * @ingroup window
  2088. */
  2089. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  2090. /*! @brief Retrieves the size of the frame of the window.
  2091. *
  2092. * This function retrieves the size, in screen coordinates, of each edge of the
  2093. * frame of the specified window. This size includes the title bar, if the
  2094. * window has one. The size of the frame may vary depending on the
  2095. * [window-related hints](@ref window_hints_wnd) used to create it.
  2096. *
  2097. * Because this function retrieves the size of each window frame edge and not
  2098. * the offset along a particular coordinate axis, the retrieved values will
  2099. * always be zero or positive.
  2100. *
  2101. * Any or all of the size arguments may be `NULL`. If an error occurs, all
  2102. * non-`NULL` size arguments will be set to zero.
  2103. *
  2104. * @param[in] window The window whose frame size to query.
  2105. * @param[out] left Where to store the size, in screen coordinates, of the left
  2106. * edge of the window frame, or `NULL`.
  2107. * @param[out] top Where to store the size, in screen coordinates, of the top
  2108. * edge of the window frame, or `NULL`.
  2109. * @param[out] right Where to store the size, in screen coordinates, of the
  2110. * right edge of the window frame, or `NULL`.
  2111. * @param[out] bottom Where to store the size, in screen coordinates, of the
  2112. * bottom edge of the window frame, or `NULL`.
  2113. *
  2114. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2115. * GLFW_PLATFORM_ERROR.
  2116. *
  2117. * @thread_safety This function must only be called from the main thread.
  2118. *
  2119. * @sa @ref window_size
  2120. *
  2121. * @since Added in version 3.1.
  2122. *
  2123. * @ingroup window
  2124. */
  2125. GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
  2126. /*! @brief Iconifies the specified window.
  2127. *
  2128. * This function iconifies (minimizes) the specified window if it was
  2129. * previously restored. If the window is already iconified, this function does
  2130. * nothing.
  2131. *
  2132. * If the specified window is a full screen window, the original monitor
  2133. * resolution is restored until the window is restored.
  2134. *
  2135. * @param[in] window The window to iconify.
  2136. *
  2137. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2138. * GLFW_PLATFORM_ERROR.
  2139. *
  2140. * @thread_safety This function must only be called from the main thread.
  2141. *
  2142. * @sa @ref window_iconify
  2143. * @sa glfwRestoreWindow
  2144. * @sa glfwMaximizeWindow
  2145. *
  2146. * @since Added in version 2.1.
  2147. * @glfw3 Added window handle parameter.
  2148. *
  2149. * @ingroup window
  2150. */
  2151. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  2152. /*! @brief Restores the specified window.
  2153. *
  2154. * This function restores the specified window if it was previously iconified
  2155. * (minimized) or maximized. If the window is already restored, this function
  2156. * does nothing.
  2157. *
  2158. * If the specified window is a full screen window, the resolution chosen for
  2159. * the window is restored on the selected monitor.
  2160. *
  2161. * @param[in] window The window to restore.
  2162. *
  2163. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2164. * GLFW_PLATFORM_ERROR.
  2165. *
  2166. * @thread_safety This function must only be called from the main thread.
  2167. *
  2168. * @sa @ref window_iconify
  2169. * @sa glfwIconifyWindow
  2170. * @sa glfwMaximizeWindow
  2171. *
  2172. * @since Added in version 2.1.
  2173. * @glfw3 Added window handle parameter.
  2174. *
  2175. * @ingroup window
  2176. */
  2177. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  2178. /*! @brief Maximizes the specified window.
  2179. *
  2180. * This function maximizes the specified window if it was previously not
  2181. * maximized. If the window is already maximized, this function does nothing.
  2182. *
  2183. * If the specified window is a full screen window, this function does nothing.
  2184. *
  2185. * @param[in] window The window to maximize.
  2186. *
  2187. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2188. * GLFW_PLATFORM_ERROR.
  2189. *
  2190. * @par Thread Safety
  2191. * This function may only be called from the main thread.
  2192. *
  2193. * @sa @ref window_iconify
  2194. * @sa glfwIconifyWindow
  2195. * @sa glfwRestoreWindow
  2196. *
  2197. * @since Added in GLFW 3.2.
  2198. *
  2199. * @ingroup window
  2200. */
  2201. GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
  2202. /*! @brief Makes the specified window visible.
  2203. *
  2204. * This function makes the specified window visible if it was previously
  2205. * hidden. If the window is already visible or is in full screen mode, this
  2206. * function does nothing.
  2207. *
  2208. * @param[in] window The window to make visible.
  2209. *
  2210. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2211. * GLFW_PLATFORM_ERROR.
  2212. *
  2213. * @thread_safety This function must only be called from the main thread.
  2214. *
  2215. * @sa @ref window_hide
  2216. * @sa glfwHideWindow
  2217. *
  2218. * @since Added in version 3.0.
  2219. *
  2220. * @ingroup window
  2221. */
  2222. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  2223. /*! @brief Hides the specified window.
  2224. *
  2225. * This function hides the specified window if it was previously visible. If
  2226. * the window is already hidden or is in full screen mode, this function does
  2227. * nothing.
  2228. *
  2229. * @param[in] window The window to hide.
  2230. *
  2231. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2232. * GLFW_PLATFORM_ERROR.
  2233. *
  2234. * @thread_safety This function must only be called from the main thread.
  2235. *
  2236. * @sa @ref window_hide
  2237. * @sa glfwShowWindow
  2238. *
  2239. * @since Added in version 3.0.
  2240. *
  2241. * @ingroup window
  2242. */
  2243. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  2244. /*! @brief Brings the specified window to front and sets input focus.
  2245. *
  2246. * This function brings the specified window to front and sets input focus.
  2247. * The window should already be visible and not iconified.
  2248. *
  2249. * By default, both windowed and full screen mode windows are focused when
  2250. * initially created. Set the [GLFW_FOCUSED](@ref window_hints_wnd) to disable
  2251. * this behavior.
  2252. *
  2253. * __Do not use this function__ to steal focus from other applications unless
  2254. * you are certain that is what the user wants. Focus stealing can be
  2255. * extremely disruptive.
  2256. *
  2257. * @param[in] window The window to give input focus.
  2258. *
  2259. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2260. * GLFW_PLATFORM_ERROR.
  2261. *
  2262. * @thread_safety This function must only be called from the main thread.
  2263. *
  2264. * @sa @ref window_focus
  2265. *
  2266. * @since Added in version 3.2.
  2267. *
  2268. * @ingroup window
  2269. */
  2270. GLFWAPI void glfwFocusWindow(GLFWwindow* window);
  2271. /*! @brief Returns the monitor that the window uses for full screen mode.
  2272. *
  2273. * This function returns the handle of the monitor that the specified window is
  2274. * in full screen on.
  2275. *
  2276. * @param[in] window The window to query.
  2277. * @return The monitor, or `NULL` if the window is in windowed mode or an error
  2278. * occurred.
  2279. *
  2280. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2281. *
  2282. * @thread_safety This function must only be called from the main thread.
  2283. *
  2284. * @sa @ref window_monitor
  2285. * @sa glfwSetWindowMonitor
  2286. *
  2287. * @since Added in version 3.0.
  2288. *
  2289. * @ingroup window
  2290. */
  2291. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  2292. /*! @brief Sets the mode, monitor, video mode and placement of a window.
  2293. *
  2294. * This function sets the monitor that the window uses for full screen mode or,
  2295. * if the monitor is `NULL`, makes it windowed mode.
  2296. *
  2297. * When setting a monitor, this function updates the width, height and refresh
  2298. * rate of the desired video mode and switches to the video mode closest to it.
  2299. * The window position is ignored when setting a monitor.
  2300. *
  2301. * When the monitor is `NULL`, the position, width and height are used to
  2302. * place the window client area. The refresh rate is ignored when no monitor
  2303. * is specified.
  2304. *
  2305. * If you only wish to update the resolution of a full screen window or the
  2306. * size of a windowed mode window, see @ref glfwSetWindowSize.
  2307. *
  2308. * When a window transitions from full screen to windowed mode, this function
  2309. * restores any previous window settings such as whether it is decorated,
  2310. * floating, resizable, has size or aspect ratio limits, etc..
  2311. *
  2312. * @param[in] window The window whose monitor, size or video mode to set.
  2313. * @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
  2314. * @param[in] xpos The desired x-coordinate of the upper-left corner of the
  2315. * client area.
  2316. * @param[in] ypos The desired y-coordinate of the upper-left corner of the
  2317. * client area.
  2318. * @param[in] width The desired with, in screen coordinates, of the client area
  2319. * or video mode.
  2320. * @param[in] height The desired height, in screen coordinates, of the client
  2321. * area or video mode.
  2322. * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
  2323. * or `GLFW_DONT_CARE`.
  2324. *
  2325. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2326. * GLFW_PLATFORM_ERROR.
  2327. *
  2328. * @thread_safety This function must only be called from the main thread.
  2329. *
  2330. * @sa @ref window_monitor
  2331. * @sa @ref window_full_screen
  2332. * @sa glfwGetWindowMonitor
  2333. * @sa glfwSetWindowSize
  2334. *
  2335. * @since Added in version 3.2.
  2336. *
  2337. * @ingroup window
  2338. */
  2339. GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
  2340. /*! @brief Returns an attribute of the specified window.
  2341. *
  2342. * This function returns the value of an attribute of the specified window or
  2343. * its OpenGL or OpenGL ES context.
  2344. *
  2345. * @param[in] window The window to query.
  2346. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  2347. * return.
  2348. * @return The value of the attribute, or zero if an
  2349. * [error](@ref error_handling) occurred.
  2350. *
  2351. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2352. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  2353. *
  2354. * @remark Framebuffer related hints are not window attributes. See @ref
  2355. * window_attribs_fb for more information.
  2356. *
  2357. * @remark Zero is a valid value for many window and context related
  2358. * attributes so you cannot use a return value of zero as an indication of
  2359. * errors. However, this function should not fail as long as it is passed
  2360. * valid arguments and the library has been [initialized](@ref intro_init).
  2361. *
  2362. * @thread_safety This function must only be called from the main thread.
  2363. *
  2364. * @sa @ref window_attribs
  2365. *
  2366. * @since Added in version 3.0. Replaces `glfwGetWindowParam` and
  2367. * `glfwGetGLVersion`.
  2368. *
  2369. * @ingroup window
  2370. */
  2371. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  2372. /*! @brief Sets the user pointer of the specified window.
  2373. *
  2374. * This function sets the user-defined pointer of the specified window. The
  2375. * current value is retained until the window is destroyed. The initial value
  2376. * is `NULL`.
  2377. *
  2378. * @param[in] window The window whose pointer to set.
  2379. * @param[in] pointer The new value.
  2380. *
  2381. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2382. *
  2383. * @thread_safety This function may be called from any thread. Access is not
  2384. * synchronized.
  2385. *
  2386. * @sa @ref window_userptr
  2387. * @sa glfwGetWindowUserPointer
  2388. *
  2389. * @since Added in version 3.0.
  2390. *
  2391. * @ingroup window
  2392. */
  2393. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  2394. /*! @brief Returns the user pointer of the specified window.
  2395. *
  2396. * This function returns the current value of the user-defined pointer of the
  2397. * specified window. The initial value is `NULL`.
  2398. *
  2399. * @param[in] window The window whose pointer to return.
  2400. *
  2401. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2402. *
  2403. * @thread_safety This function may be called from any thread. Access is not
  2404. * synchronized.
  2405. *
  2406. * @sa @ref window_userptr
  2407. * @sa glfwSetWindowUserPointer
  2408. *
  2409. * @since Added in version 3.0.
  2410. *
  2411. * @ingroup window
  2412. */
  2413. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  2414. /*! @brief Sets the position callback for the specified window.
  2415. *
  2416. * This function sets the position callback of the specified window, which is
  2417. * called when the window is moved. The callback is provided with the screen
  2418. * position of the upper-left corner of the client area of the window.
  2419. *
  2420. * @param[in] window The window whose callback to set.
  2421. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2422. * callback.
  2423. * @return The previously set callback, or `NULL` if no callback was set or the
  2424. * library had not been [initialized](@ref intro_init).
  2425. *
  2426. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2427. *
  2428. * @thread_safety This function must only be called from the main thread.
  2429. *
  2430. * @sa @ref window_pos
  2431. *
  2432. * @since Added in version 3.0.
  2433. *
  2434. * @ingroup window
  2435. */
  2436. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
  2437. /*! @brief Sets the size callback for the specified window.
  2438. *
  2439. * This function sets the size callback of the specified window, which is
  2440. * called when the window is resized. The callback is provided with the size,
  2441. * in screen coordinates, of the client area of the window.
  2442. *
  2443. * @param[in] window The window whose callback to set.
  2444. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2445. * callback.
  2446. * @return The previously set callback, or `NULL` if no callback was set or the
  2447. * library had not been [initialized](@ref intro_init).
  2448. *
  2449. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2450. *
  2451. * @thread_safety This function must only be called from the main thread.
  2452. *
  2453. * @sa @ref window_size
  2454. *
  2455. * @since Added in version 1.0.
  2456. * @glfw3 Added window handle parameter and return value.
  2457. *
  2458. * @ingroup window
  2459. */
  2460. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
  2461. /*! @brief Sets the close callback for the specified window.
  2462. *
  2463. * This function sets the close callback of the specified window, which is
  2464. * called when the user attempts to close the window, for example by clicking
  2465. * the close widget in the title bar.
  2466. *
  2467. * The close flag is set before this callback is called, but you can modify it
  2468. * at any time with @ref glfwSetWindowShouldClose.
  2469. *
  2470. * The close callback is not triggered by @ref glfwDestroyWindow.
  2471. *
  2472. * @param[in] window The window whose callback to set.
  2473. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2474. * callback.
  2475. * @return The previously set callback, or `NULL` if no callback was set or the
  2476. * library had not been [initialized](@ref intro_init).
  2477. *
  2478. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2479. *
  2480. * @remark @osx Selecting Quit from the application menu will trigger the close
  2481. * callback for all windows.
  2482. *
  2483. * @thread_safety This function must only be called from the main thread.
  2484. *
  2485. * @sa @ref window_close
  2486. *
  2487. * @since Added in version 2.5.
  2488. * @glfw3 Added window handle parameter and return value.
  2489. *
  2490. * @ingroup window
  2491. */
  2492. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
  2493. /*! @brief Sets the refresh callback for the specified window.
  2494. *
  2495. * This function sets the refresh callback of the specified window, which is
  2496. * called when the client area of the window needs to be redrawn, for example
  2497. * if the window has been exposed after having been covered by another window.
  2498. *
  2499. * On compositing window systems such as Aero, Compiz or Aqua, where the window
  2500. * contents are saved off-screen, this callback may be called only very
  2501. * infrequently or never at all.
  2502. *
  2503. * @param[in] window The window whose callback to set.
  2504. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2505. * callback.
  2506. * @return The previously set callback, or `NULL` if no callback was set or the
  2507. * library had not been [initialized](@ref intro_init).
  2508. *
  2509. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2510. *
  2511. * @thread_safety This function must only be called from the main thread.
  2512. *
  2513. * @sa @ref window_refresh
  2514. *
  2515. * @since Added in version 2.5.
  2516. * @glfw3 Added window handle parameter and return value.
  2517. *
  2518. * @ingroup window
  2519. */
  2520. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
  2521. /*! @brief Sets the focus callback for the specified window.
  2522. *
  2523. * This function sets the focus callback of the specified window, which is
  2524. * called when the window gains or loses input focus.
  2525. *
  2526. * After the focus callback is called for a window that lost input focus,
  2527. * synthetic key and mouse button release events will be generated for all such
  2528. * that had been pressed. For more information, see @ref glfwSetKeyCallback
  2529. * and @ref glfwSetMouseButtonCallback.
  2530. *
  2531. * @param[in] window The window whose callback to set.
  2532. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2533. * callback.
  2534. * @return The previously set callback, or `NULL` if no callback was set or the
  2535. * library had not been [initialized](@ref intro_init).
  2536. *
  2537. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2538. *
  2539. * @thread_safety This function must only be called from the main thread.
  2540. *
  2541. * @sa @ref window_focus
  2542. *
  2543. * @since Added in version 3.0.
  2544. *
  2545. * @ingroup window
  2546. */
  2547. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
  2548. /*! @brief Sets the iconify callback for the specified window.
  2549. *
  2550. * This function sets the iconification callback of the specified window, which
  2551. * is called when the window is iconified or restored.
  2552. *
  2553. * @param[in] window The window whose callback to set.
  2554. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2555. * callback.
  2556. * @return The previously set callback, or `NULL` if no callback was set or the
  2557. * library had not been [initialized](@ref intro_init).
  2558. *
  2559. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2560. *
  2561. * @thread_safety This function must only be called from the main thread.
  2562. *
  2563. * @sa @ref window_iconify
  2564. *
  2565. * @since Added in version 3.0.
  2566. *
  2567. * @ingroup window
  2568. */
  2569. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
  2570. /*! @brief Sets the framebuffer resize callback for the specified window.
  2571. *
  2572. * This function sets the framebuffer resize callback of the specified window,
  2573. * which is called when the framebuffer of the specified window is resized.
  2574. *
  2575. * @param[in] window The window whose callback to set.
  2576. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  2577. * callback.
  2578. * @return The previously set callback, or `NULL` if no callback was set or the
  2579. * library had not been [initialized](@ref intro_init).
  2580. *
  2581. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  2582. *
  2583. * @thread_safety This function must only be called from the main thread.
  2584. *
  2585. * @sa @ref window_fbsize
  2586. *
  2587. * @since Added in version 3.0.
  2588. *
  2589. * @ingroup window
  2590. */
  2591. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
  2592. /*! @brief Processes all pending events.
  2593. *
  2594. * This function processes only those events that are already in the event
  2595. * queue and then returns immediately. Processing events will cause the window
  2596. * and input callbacks associated with those events to be called.
  2597. *
  2598. * On some platforms, a window move, resize or menu operation will cause event
  2599. * processing to block. This is due to how event processing is designed on
  2600. * those platforms. You can use the
  2601. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2602. * your window when necessary during such operations.
  2603. *
  2604. * On some platforms, certain events are sent directly to the application
  2605. * without going through the event queue, causing callbacks to be called
  2606. * outside of a call to one of the event processing functions.
  2607. *
  2608. * Event processing is not required for joystick input to work.
  2609. *
  2610. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2611. * GLFW_PLATFORM_ERROR.
  2612. *
  2613. * @reentrancy This function must not be called from a callback.
  2614. *
  2615. * @thread_safety This function must only be called from the main thread.
  2616. *
  2617. * @sa @ref events
  2618. * @sa glfwWaitEvents
  2619. * @sa glfwWaitEventsTimeout
  2620. *
  2621. * @since Added in version 1.0.
  2622. *
  2623. * @ingroup window
  2624. */
  2625. GLFWAPI void glfwPollEvents(void);
  2626. /*! @brief Waits until events are queued and processes them.
  2627. *
  2628. * This function puts the calling thread to sleep until at least one event is
  2629. * available in the event queue. Once one or more events are available,
  2630. * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
  2631. * are processed and the function then returns immediately. Processing events
  2632. * will cause the window and input callbacks associated with those events to be
  2633. * called.
  2634. *
  2635. * Since not all events are associated with callbacks, this function may return
  2636. * without a callback having been called even if you are monitoring all
  2637. * callbacks.
  2638. *
  2639. * On some platforms, a window move, resize or menu operation will cause event
  2640. * processing to block. This is due to how event processing is designed on
  2641. * those platforms. You can use the
  2642. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2643. * your window when necessary during such operations.
  2644. *
  2645. * On some platforms, certain callbacks may be called outside of a call to one
  2646. * of the event processing functions.
  2647. *
  2648. * If no windows exist, this function returns immediately. For synchronization
  2649. * of threads in applications that do not create windows, use your threading
  2650. * library of choice.
  2651. *
  2652. * Event processing is not required for joystick input to work.
  2653. *
  2654. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2655. * GLFW_PLATFORM_ERROR.
  2656. *
  2657. * @reentrancy This function must not be called from a callback.
  2658. *
  2659. * @thread_safety This function must only be called from the main thread.
  2660. *
  2661. * @sa @ref events
  2662. * @sa glfwPollEvents
  2663. * @sa glfwWaitEventsTimeout
  2664. *
  2665. * @since Added in version 2.5.
  2666. *
  2667. * @ingroup window
  2668. */
  2669. GLFWAPI void glfwWaitEvents(void);
  2670. /*! @brief Waits with timeout until events are queued and processes them.
  2671. *
  2672. * This function puts the calling thread to sleep until at least one event is
  2673. * available in the event queue, or until the specified timeout is reached. If
  2674. * one or more events are available, it behaves exactly like @ref
  2675. * glfwPollEvents, i.e. the events in the queue are processed and the function
  2676. * then returns immediately. Processing events will cause the window and input
  2677. * callbacks associated with those events to be called.
  2678. *
  2679. * The timeout value must be a positive finite number.
  2680. *
  2681. * Since not all events are associated with callbacks, this function may return
  2682. * without a callback having been called even if you are monitoring all
  2683. * callbacks.
  2684. *
  2685. * On some platforms, a window move, resize or menu operation will cause event
  2686. * processing to block. This is due to how event processing is designed on
  2687. * those platforms. You can use the
  2688. * [window refresh callback](@ref window_refresh) to redraw the contents of
  2689. * your window when necessary during such operations.
  2690. *
  2691. * On some platforms, certain callbacks may be called outside of a call to one
  2692. * of the event processing functions.
  2693. *
  2694. * If no windows exist, this function returns immediately. For synchronization
  2695. * of threads in applications that do not create windows, use your threading
  2696. * library of choice.
  2697. *
  2698. * Event processing is not required for joystick input to work.
  2699. *
  2700. * @param[in] timeout The maximum amount of time, in seconds, to wait.
  2701. *
  2702. * @reentrancy This function must not be called from a callback.
  2703. *
  2704. * @thread_safety This function must only be called from the main thread.
  2705. *
  2706. * @sa @ref events
  2707. * @sa glfwPollEvents
  2708. * @sa glfwWaitEvents
  2709. *
  2710. * @since Added in version 3.2.
  2711. *
  2712. * @ingroup window
  2713. */
  2714. GLFWAPI void glfwWaitEventsTimeout(double timeout);
  2715. /*! @brief Posts an empty event to the event queue.
  2716. *
  2717. * This function posts an empty event from the current thread to the event
  2718. * queue, causing @ref glfwWaitEvents to return.
  2719. *
  2720. * If no windows exist, this function returns immediately. For synchronization
  2721. * of threads in applications that do not create windows, use your threading
  2722. * library of choice.
  2723. *
  2724. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2725. * GLFW_PLATFORM_ERROR.
  2726. *
  2727. * @thread_safety This function may be called from any thread.
  2728. *
  2729. * @sa @ref events
  2730. * @sa glfwWaitEvents
  2731. *
  2732. * @since Added in version 3.1.
  2733. *
  2734. * @ingroup window
  2735. */
  2736. GLFWAPI void glfwPostEmptyEvent(void);
  2737. /*! @brief Returns the value of an input option for the specified window.
  2738. *
  2739. * This function returns the value of an input option for the specified window.
  2740. * The mode must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2741. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2742. *
  2743. * @param[in] window The window to query.
  2744. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2745. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2746. *
  2747. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2748. * GLFW_INVALID_ENUM.
  2749. *
  2750. * @thread_safety This function must only be called from the main thread.
  2751. *
  2752. * @sa glfwSetInputMode
  2753. *
  2754. * @since Added in version 3.0.
  2755. *
  2756. * @ingroup input
  2757. */
  2758. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  2759. /*! @brief Sets an input option for the specified window.
  2760. *
  2761. * This function sets an input mode option for the specified window. The mode
  2762. * must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2763. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2764. *
  2765. * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
  2766. * modes:
  2767. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  2768. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
  2769. * area of the window but does not restrict the cursor from leaving.
  2770. * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
  2771. * and unlimited cursor movement. This is useful for implementing for
  2772. * example 3D camera controls.
  2773. *
  2774. * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
  2775. * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are
  2776. * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
  2777. * the next time it is called even if the key had been released before the
  2778. * call. This is useful when you are only interested in whether keys have been
  2779. * pressed but not when or in which order.
  2780. *
  2781. * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
  2782. * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
  2783. * If sticky mouse buttons are enabled, a mouse button press will ensure that
  2784. * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
  2785. * if the mouse button had been released before the call. This is useful when
  2786. * you are only interested in whether mouse buttons have been pressed but not
  2787. * when or in which order.
  2788. *
  2789. * @param[in] window The window whose input mode to set.
  2790. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  2791. * `GLFW_STICKY_MOUSE_BUTTONS`.
  2792. * @param[in] value The new value of the specified input mode.
  2793. *
  2794. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  2795. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  2796. *
  2797. * @thread_safety This function must only be called from the main thread.
  2798. *
  2799. * @sa glfwGetInputMode
  2800. *
  2801. * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`.
  2802. *
  2803. * @ingroup input
  2804. */
  2805. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  2806. /*! @brief Returns the localized name of the specified printable key.
  2807. *
  2808. * This function returns the localized name of the specified printable key.
  2809. * This is intended for displaying key bindings to the user.
  2810. *
  2811. * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used instead, otherwise
  2812. * the scancode is ignored. If a non-printable key or (if the key is
  2813. * `GLFW_KEY_UNKNOWN`) a scancode that maps to a non-printable key is
  2814. * specified, this function returns `NULL`.
  2815. *
  2816. * This behavior allows you to pass in the arguments passed to the
  2817. * [key callback](@ref input_key) without modification.
  2818. *
  2819. * The printable keys are:
  2820. * - `GLFW_KEY_APOSTROPHE`
  2821. * - `GLFW_KEY_COMMA`
  2822. * - `GLFW_KEY_MINUS`
  2823. * - `GLFW_KEY_PERIOD`
  2824. * - `GLFW_KEY_SLASH`
  2825. * - `GLFW_KEY_SEMICOLON`
  2826. * - `GLFW_KEY_EQUAL`
  2827. * - `GLFW_KEY_LEFT_BRACKET`
  2828. * - `GLFW_KEY_RIGHT_BRACKET`
  2829. * - `GLFW_KEY_BACKSLASH`
  2830. * - `GLFW_KEY_WORLD_1`
  2831. * - `GLFW_KEY_WORLD_2`
  2832. * - `GLFW_KEY_0` to `GLFW_KEY_9`
  2833. * - `GLFW_KEY_A` to `GLFW_KEY_Z`
  2834. * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
  2835. * - `GLFW_KEY_KP_DECIMAL`
  2836. * - `GLFW_KEY_KP_DIVIDE`
  2837. * - `GLFW_KEY_KP_MULTIPLY`
  2838. * - `GLFW_KEY_KP_SUBTRACT`
  2839. * - `GLFW_KEY_KP_ADD`
  2840. * - `GLFW_KEY_KP_EQUAL`
  2841. *
  2842. * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
  2843. * @param[in] scancode The scancode of the key to query.
  2844. * @return The localized name of the key, or `NULL`.
  2845. *
  2846. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2847. * GLFW_PLATFORM_ERROR.
  2848. *
  2849. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  2850. * should not free it yourself. It is valid until the next call to @ref
  2851. * glfwGetKeyName, or until the library is terminated.
  2852. *
  2853. * @thread_safety This function must only be called from the main thread.
  2854. *
  2855. * @sa @ref input_key_name
  2856. *
  2857. * @since Added in version 3.2.
  2858. *
  2859. * @ingroup input
  2860. */
  2861. GLFWAPI const char* glfwGetKeyName(int key, int scancode);
  2862. /*! @brief Returns the last reported state of a keyboard key for the specified
  2863. * window.
  2864. *
  2865. * This function returns the last state reported for the specified key to the
  2866. * specified window. The returned state is one of `GLFW_PRESS` or
  2867. * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to
  2868. * the key callback.
  2869. *
  2870. * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
  2871. * `GLFW_PRESS` the first time you call it for a key that was pressed, even if
  2872. * that key has already been released.
  2873. *
  2874. * The key functions deal with physical keys, with [key tokens](@ref keys)
  2875. * named after their use on the standard US keyboard layout. If you want to
  2876. * input text, use the Unicode character callback instead.
  2877. *
  2878. * The [modifier key bit masks](@ref mods) are not key tokens and cannot be
  2879. * used with this function.
  2880. *
  2881. * __Do not use this function__ to implement [text input](@ref input_char).
  2882. *
  2883. * @param[in] window The desired window.
  2884. * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is
  2885. * not a valid key for this function.
  2886. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  2887. *
  2888. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2889. * GLFW_INVALID_ENUM.
  2890. *
  2891. * @thread_safety This function must only be called from the main thread.
  2892. *
  2893. * @sa @ref input_key
  2894. *
  2895. * @since Added in version 1.0.
  2896. * @glfw3 Added window handle parameter.
  2897. *
  2898. * @ingroup input
  2899. */
  2900. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  2901. /*! @brief Returns the last reported state of a mouse button for the specified
  2902. * window.
  2903. *
  2904. * This function returns the last state reported for the specified mouse button
  2905. * to the specified window. The returned state is one of `GLFW_PRESS` or
  2906. * `GLFW_RELEASE`.
  2907. *
  2908. * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
  2909. * `GLFW_PRESS` the first time you call it for a mouse button that was pressed,
  2910. * even if that mouse button has already been released.
  2911. *
  2912. * @param[in] window The desired window.
  2913. * @param[in] button The desired [mouse button](@ref buttons).
  2914. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  2915. *
  2916. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2917. * GLFW_INVALID_ENUM.
  2918. *
  2919. * @thread_safety This function must only be called from the main thread.
  2920. *
  2921. * @sa @ref input_mouse_button
  2922. *
  2923. * @since Added in version 1.0.
  2924. * @glfw3 Added window handle parameter.
  2925. *
  2926. * @ingroup input
  2927. */
  2928. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  2929. /*! @brief Retrieves the position of the cursor relative to the client area of
  2930. * the window.
  2931. *
  2932. * This function returns the position of the cursor, in screen coordinates,
  2933. * relative to the upper-left corner of the client area of the specified
  2934. * window.
  2935. *
  2936. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  2937. * position is unbounded and limited only by the minimum and maximum values of
  2938. * a `double`.
  2939. *
  2940. * The coordinate can be converted to their integer equivalents with the
  2941. * `floor` function. Casting directly to an integer type works for positive
  2942. * coordinates, but fails for negative ones.
  2943. *
  2944. * Any or all of the position arguments may be `NULL`. If an error occurs, all
  2945. * non-`NULL` position arguments will be set to zero.
  2946. *
  2947. * @param[in] window The desired window.
  2948. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  2949. * left edge of the client area, or `NULL`.
  2950. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  2951. * top edge of the client area, or `NULL`.
  2952. *
  2953. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2954. * GLFW_PLATFORM_ERROR.
  2955. *
  2956. * @thread_safety This function must only be called from the main thread.
  2957. *
  2958. * @sa @ref cursor_pos
  2959. * @sa glfwSetCursorPos
  2960. *
  2961. * @since Added in version 3.0. Replaces `glfwGetMousePos`.
  2962. *
  2963. * @ingroup input
  2964. */
  2965. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  2966. /*! @brief Sets the position of the cursor, relative to the client area of the
  2967. * window.
  2968. *
  2969. * This function sets the position, in screen coordinates, of the cursor
  2970. * relative to the upper-left corner of the client area of the specified
  2971. * window. The window must have input focus. If the window does not have
  2972. * input focus when this function is called, it fails silently.
  2973. *
  2974. * __Do not use this function__ to implement things like camera controls. GLFW
  2975. * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
  2976. * cursor, transparently re-centers it and provides unconstrained cursor
  2977. * motion. See @ref glfwSetInputMode for more information.
  2978. *
  2979. * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
  2980. * unconstrained and limited only by the minimum and maximum values of
  2981. * a `double`.
  2982. *
  2983. * @param[in] window The desired window.
  2984. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  2985. * client area.
  2986. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  2987. * client area.
  2988. *
  2989. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  2990. * GLFW_PLATFORM_ERROR.
  2991. *
  2992. * @thread_safety This function must only be called from the main thread.
  2993. *
  2994. * @sa @ref cursor_pos
  2995. * @sa glfwGetCursorPos
  2996. *
  2997. * @since Added in version 3.0. Replaces `glfwSetMousePos`.
  2998. *
  2999. * @ingroup input
  3000. */
  3001. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  3002. /*! @brief Creates a custom cursor.
  3003. *
  3004. * Creates a new custom cursor image that can be set for a window with @ref
  3005. * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor.
  3006. * Any remaining cursors are destroyed by @ref glfwTerminate.
  3007. *
  3008. * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
  3009. * bits per channel. They are arranged canonically as packed sequential rows,
  3010. * starting from the top-left corner.
  3011. *
  3012. * The cursor hotspot is specified in pixels, relative to the upper-left corner
  3013. * of the cursor image. Like all other coordinate systems in GLFW, the X-axis
  3014. * points to the right and the Y-axis points down.
  3015. *
  3016. * @param[in] image The desired cursor image.
  3017. * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
  3018. * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
  3019. * @return The handle of the created cursor, or `NULL` if an
  3020. * [error](@ref error_handling) occurred.
  3021. *
  3022. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3023. * GLFW_PLATFORM_ERROR.
  3024. *
  3025. * @pointer_lifetime The specified image data is copied before this function
  3026. * returns.
  3027. *
  3028. * @reentrancy This function must not be called from a callback.
  3029. *
  3030. * @thread_safety This function must only be called from the main thread.
  3031. *
  3032. * @sa @ref cursor_object
  3033. * @sa glfwDestroyCursor
  3034. * @sa glfwCreateStandardCursor
  3035. *
  3036. * @since Added in version 3.1.
  3037. *
  3038. * @ingroup input
  3039. */
  3040. GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
  3041. /*! @brief Creates a cursor with a standard shape.
  3042. *
  3043. * Returns a cursor with a [standard shape](@ref shapes), that can be set for
  3044. * a window with @ref glfwSetCursor.
  3045. *
  3046. * @param[in] shape One of the [standard shapes](@ref shapes).
  3047. * @return A new cursor ready to use or `NULL` if an
  3048. * [error](@ref error_handling) occurred.
  3049. *
  3050. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3051. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3052. *
  3053. * @reentrancy This function must not be called from a callback.
  3054. *
  3055. * @thread_safety This function must only be called from the main thread.
  3056. *
  3057. * @sa @ref cursor_object
  3058. * @sa glfwCreateCursor
  3059. *
  3060. * @since Added in version 3.1.
  3061. *
  3062. * @ingroup input
  3063. */
  3064. GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
  3065. /*! @brief Destroys a cursor.
  3066. *
  3067. * This function destroys a cursor previously created with @ref
  3068. * glfwCreateCursor. Any remaining cursors will be destroyed by @ref
  3069. * glfwTerminate.
  3070. *
  3071. * @param[in] cursor The cursor object to destroy.
  3072. *
  3073. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3074. * GLFW_PLATFORM_ERROR.
  3075. *
  3076. * @reentrancy This function must not be called from a callback.
  3077. *
  3078. * @thread_safety This function must only be called from the main thread.
  3079. *
  3080. * @sa @ref cursor_object
  3081. * @sa glfwCreateCursor
  3082. *
  3083. * @since Added in version 3.1.
  3084. *
  3085. * @ingroup input
  3086. */
  3087. GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
  3088. /*! @brief Sets the cursor for the window.
  3089. *
  3090. * This function sets the cursor image to be used when the cursor is over the
  3091. * client area of the specified window. The set cursor will only be visible
  3092. * when the [cursor mode](@ref cursor_mode) of the window is
  3093. * `GLFW_CURSOR_NORMAL`.
  3094. *
  3095. * On some platforms, the set cursor may not be visible unless the window also
  3096. * has input focus.
  3097. *
  3098. * @param[in] window The window to set the cursor for.
  3099. * @param[in] cursor The cursor to set, or `NULL` to switch back to the default
  3100. * arrow cursor.
  3101. *
  3102. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3103. * GLFW_PLATFORM_ERROR.
  3104. *
  3105. * @thread_safety This function must only be called from the main thread.
  3106. *
  3107. * @sa @ref cursor_object
  3108. *
  3109. * @since Added in version 3.1.
  3110. *
  3111. * @ingroup input
  3112. */
  3113. GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
  3114. /*! @brief Sets the key callback.
  3115. *
  3116. * This function sets the key callback of the specified window, which is called
  3117. * when a key is pressed, repeated or released.
  3118. *
  3119. * The key functions deal with physical keys, with layout independent
  3120. * [key tokens](@ref keys) named after their values in the standard US keyboard
  3121. * layout. If you want to input text, use the
  3122. * [character callback](@ref glfwSetCharCallback) instead.
  3123. *
  3124. * When a window loses input focus, it will generate synthetic key release
  3125. * events for all pressed keys. You can tell these events from user-generated
  3126. * events by the fact that the synthetic ones are generated after the focus
  3127. * loss event has been processed, i.e. after the
  3128. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  3129. *
  3130. * The scancode of a key is specific to that platform or sometimes even to that
  3131. * machine. Scancodes are intended to allow users to bind keys that don't have
  3132. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  3133. * state is not saved and so it cannot be queried with @ref glfwGetKey.
  3134. *
  3135. * Sometimes GLFW needs to generate synthetic key events, in which case the
  3136. * scancode may be zero.
  3137. *
  3138. * @param[in] window The window whose callback to set.
  3139. * @param[in] cbfun The new key callback, or `NULL` to remove the currently
  3140. * set callback.
  3141. * @return The previously set callback, or `NULL` if no callback was set or the
  3142. * library had not been [initialized](@ref intro_init).
  3143. *
  3144. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3145. *
  3146. * @thread_safety This function must only be called from the main thread.
  3147. *
  3148. * @sa @ref input_key
  3149. *
  3150. * @since Added in version 1.0.
  3151. * @glfw3 Added window handle parameter and return value.
  3152. *
  3153. * @ingroup input
  3154. */
  3155. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
  3156. /*! @brief Sets the Unicode character callback.
  3157. *
  3158. * This function sets the character callback of the specified window, which is
  3159. * called when a Unicode character is input.
  3160. *
  3161. * The character callback is intended for Unicode text input. As it deals with
  3162. * characters, it is keyboard layout dependent, whereas the
  3163. * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1
  3164. * to physical keys, as a key may produce zero, one or more characters. If you
  3165. * want to know whether a specific physical key was pressed or released, see
  3166. * the key callback instead.
  3167. *
  3168. * The character callback behaves as system text input normally does and will
  3169. * not be called if modifier keys are held down that would prevent normal text
  3170. * input on that platform, for example a Super (Command) key on OS X or Alt key
  3171. * on Windows. There is a
  3172. * [character with modifiers callback](@ref glfwSetCharModsCallback) that
  3173. * receives these events.
  3174. *
  3175. * @param[in] window The window whose callback to set.
  3176. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3177. * callback.
  3178. * @return The previously set callback, or `NULL` if no callback was set or the
  3179. * library had not been [initialized](@ref intro_init).
  3180. *
  3181. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3182. *
  3183. * @thread_safety This function must only be called from the main thread.
  3184. *
  3185. * @sa @ref input_char
  3186. *
  3187. * @since Added in version 2.4.
  3188. * @glfw3 Added window handle parameter and return value.
  3189. *
  3190. * @ingroup input
  3191. */
  3192. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
  3193. /*! @brief Sets the Unicode character with modifiers callback.
  3194. *
  3195. * This function sets the character with modifiers callback of the specified
  3196. * window, which is called when a Unicode character is input regardless of what
  3197. * modifier keys are used.
  3198. *
  3199. * The character with modifiers callback is intended for implementing custom
  3200. * Unicode character input. For regular Unicode text input, see the
  3201. * [character callback](@ref glfwSetCharCallback). Like the character
  3202. * callback, the character with modifiers callback deals with characters and is
  3203. * keyboard layout dependent. Characters do not map 1:1 to physical keys, as
  3204. * a key may produce zero, one or more characters. If you want to know whether
  3205. * a specific physical key was pressed or released, see the
  3206. * [key callback](@ref glfwSetKeyCallback) instead.
  3207. *
  3208. * @param[in] window The window whose callback to set.
  3209. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3210. * callback.
  3211. * @return The previously set callback, or `NULL` if no callback was set or an
  3212. * error occurred.
  3213. *
  3214. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3215. *
  3216. * @thread_safety This function must only be called from the main thread.
  3217. *
  3218. * @sa @ref input_char
  3219. *
  3220. * @since Added in version 3.1.
  3221. *
  3222. * @ingroup input
  3223. */
  3224. GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);
  3225. /*! @brief Sets the mouse button callback.
  3226. *
  3227. * This function sets the mouse button callback of the specified window, which
  3228. * is called when a mouse button is pressed or released.
  3229. *
  3230. * When a window loses input focus, it will generate synthetic mouse button
  3231. * release events for all pressed mouse buttons. You can tell these events
  3232. * from user-generated events by the fact that the synthetic ones are generated
  3233. * after the focus loss event has been processed, i.e. after the
  3234. * [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
  3235. *
  3236. * @param[in] window The window whose callback to set.
  3237. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3238. * callback.
  3239. * @return The previously set callback, or `NULL` if no callback was set or the
  3240. * library had not been [initialized](@ref intro_init).
  3241. *
  3242. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3243. *
  3244. * @thread_safety This function must only be called from the main thread.
  3245. *
  3246. * @sa @ref input_mouse_button
  3247. *
  3248. * @since Added in version 1.0.
  3249. * @glfw3 Added window handle parameter and return value.
  3250. *
  3251. * @ingroup input
  3252. */
  3253. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
  3254. /*! @brief Sets the cursor position callback.
  3255. *
  3256. * This function sets the cursor position callback of the specified window,
  3257. * which is called when the cursor is moved. The callback is provided with the
  3258. * position, in screen coordinates, relative to the upper-left corner of the
  3259. * client area of the window.
  3260. *
  3261. * @param[in] window The window whose callback to set.
  3262. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3263. * callback.
  3264. * @return The previously set callback, or `NULL` if no callback was set or the
  3265. * library had not been [initialized](@ref intro_init).
  3266. *
  3267. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3268. *
  3269. * @thread_safety This function must only be called from the main thread.
  3270. *
  3271. * @sa @ref cursor_pos
  3272. *
  3273. * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`.
  3274. *
  3275. * @ingroup input
  3276. */
  3277. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
  3278. /*! @brief Sets the cursor enter/exit callback.
  3279. *
  3280. * This function sets the cursor boundary crossing callback of the specified
  3281. * window, which is called when the cursor enters or leaves the client area of
  3282. * the window.
  3283. *
  3284. * @param[in] window The window whose callback to set.
  3285. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3286. * callback.
  3287. * @return The previously set callback, or `NULL` if no callback was set or the
  3288. * library had not been [initialized](@ref intro_init).
  3289. *
  3290. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3291. *
  3292. * @thread_safety This function must only be called from the main thread.
  3293. *
  3294. * @sa @ref cursor_enter
  3295. *
  3296. * @since Added in version 3.0.
  3297. *
  3298. * @ingroup input
  3299. */
  3300. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
  3301. /*! @brief Sets the scroll callback.
  3302. *
  3303. * This function sets the scroll callback of the specified window, which is
  3304. * called when a scrolling device is used, such as a mouse wheel or scrolling
  3305. * area of a touchpad.
  3306. *
  3307. * The scroll callback receives all scrolling input, like that from a mouse
  3308. * wheel or a touchpad scrolling area.
  3309. *
  3310. * @param[in] window The window whose callback to set.
  3311. * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
  3312. * set callback.
  3313. * @return The previously set callback, or `NULL` if no callback was set or the
  3314. * library had not been [initialized](@ref intro_init).
  3315. *
  3316. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3317. *
  3318. * @thread_safety This function must only be called from the main thread.
  3319. *
  3320. * @sa @ref scrolling
  3321. *
  3322. * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`.
  3323. *
  3324. * @ingroup input
  3325. */
  3326. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
  3327. /*! @brief Sets the file drop callback.
  3328. *
  3329. * This function sets the file drop callback of the specified window, which is
  3330. * called when one or more dragged files are dropped on the window.
  3331. *
  3332. * Because the path array and its strings may have been generated specifically
  3333. * for that event, they are not guaranteed to be valid after the callback has
  3334. * returned. If you wish to use them after the callback returns, you need to
  3335. * make a deep copy.
  3336. *
  3337. * @param[in] window The window whose callback to set.
  3338. * @param[in] cbfun The new file drop callback, or `NULL` to remove the
  3339. * currently set callback.
  3340. * @return The previously set callback, or `NULL` if no callback was set or the
  3341. * library had not been [initialized](@ref intro_init).
  3342. *
  3343. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3344. *
  3345. * @thread_safety This function must only be called from the main thread.
  3346. *
  3347. * @sa @ref path_drop
  3348. *
  3349. * @since Added in version 3.1.
  3350. *
  3351. * @ingroup input
  3352. */
  3353. GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);
  3354. /*! @brief Returns whether the specified joystick is present.
  3355. *
  3356. * This function returns whether the specified joystick is present.
  3357. *
  3358. * @param[in] joy The [joystick](@ref joysticks) to query.
  3359. * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
  3360. *
  3361. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3362. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3363. *
  3364. * @thread_safety This function must only be called from the main thread.
  3365. *
  3366. * @sa @ref joystick
  3367. *
  3368. * @since Added in version 3.0. Replaces `glfwGetJoystickParam`.
  3369. *
  3370. * @ingroup input
  3371. */
  3372. GLFWAPI int glfwJoystickPresent(int joy);
  3373. /*! @brief Returns the values of all axes of the specified joystick.
  3374. *
  3375. * This function returns the values of all axes of the specified joystick.
  3376. * Each element in the array is a value between -1.0 and 1.0.
  3377. *
  3378. * Querying a joystick slot with no device present is not an error, but will
  3379. * cause this function to return `NULL`. Call @ref glfwJoystickPresent to
  3380. * check device presence.
  3381. *
  3382. * @param[in] joy The [joystick](@ref joysticks) to query.
  3383. * @param[out] count Where to store the number of axis values in the returned
  3384. * array. This is set to zero if an error occurred.
  3385. * @return An array of axis values, or `NULL` if the joystick is not present.
  3386. *
  3387. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3388. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3389. *
  3390. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  3391. * should not free it yourself. It is valid until the specified joystick is
  3392. * disconnected, this function is called again for that joystick or the library
  3393. * is terminated.
  3394. *
  3395. * @thread_safety This function must only be called from the main thread.
  3396. *
  3397. * @sa @ref joystick_axis
  3398. *
  3399. * @since Added in version 3.0. Replaces `glfwGetJoystickPos`.
  3400. *
  3401. * @ingroup input
  3402. */
  3403. GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count);
  3404. /*! @brief Returns the state of all buttons of the specified joystick.
  3405. *
  3406. * This function returns the state of all buttons of the specified joystick.
  3407. * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
  3408. *
  3409. * Querying a joystick slot with no device present is not an error, but will
  3410. * cause this function to return `NULL`. Call @ref glfwJoystickPresent to
  3411. * check device presence.
  3412. *
  3413. * @param[in] joy The [joystick](@ref joysticks) to query.
  3414. * @param[out] count Where to store the number of button states in the returned
  3415. * array. This is set to zero if an error occurred.
  3416. * @return An array of button states, or `NULL` if the joystick is not present.
  3417. *
  3418. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3419. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3420. *
  3421. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  3422. * should not free it yourself. It is valid until the specified joystick is
  3423. * disconnected, this function is called again for that joystick or the library
  3424. * is terminated.
  3425. *
  3426. * @thread_safety This function must only be called from the main thread.
  3427. *
  3428. * @sa @ref joystick_button
  3429. *
  3430. * @since Added in version 2.2.
  3431. * @glfw3 Changed to return a dynamic array.
  3432. *
  3433. * @ingroup input
  3434. */
  3435. GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count);
  3436. /*! @brief Returns the name of the specified joystick.
  3437. *
  3438. * This function returns the name, encoded as UTF-8, of the specified joystick.
  3439. * The returned string is allocated and freed by GLFW. You should not free it
  3440. * yourself.
  3441. *
  3442. * Querying a joystick slot with no device present is not an error, but will
  3443. * cause this function to return `NULL`. Call @ref glfwJoystickPresent to
  3444. * check device presence.
  3445. *
  3446. * @param[in] joy The [joystick](@ref joysticks) to query.
  3447. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  3448. * is not present.
  3449. *
  3450. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3451. * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
  3452. *
  3453. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  3454. * should not free it yourself. It is valid until the specified joystick is
  3455. * disconnected, this function is called again for that joystick or the library
  3456. * is terminated.
  3457. *
  3458. * @thread_safety This function must only be called from the main thread.
  3459. *
  3460. * @sa @ref joystick_name
  3461. *
  3462. * @since Added in version 3.0.
  3463. *
  3464. * @ingroup input
  3465. */
  3466. GLFWAPI const char* glfwGetJoystickName(int joy);
  3467. /*! @brief Sets the joystick configuration callback.
  3468. *
  3469. * This function sets the joystick configuration callback, or removes the
  3470. * currently set callback. This is called when a joystick is connected to or
  3471. * disconnected from the system.
  3472. *
  3473. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  3474. * callback.
  3475. * @return The previously set callback, or `NULL` if no callback was set or the
  3476. * library had not been [initialized](@ref intro_init).
  3477. *
  3478. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3479. *
  3480. * @thread_safety This function must only be called from the main thread.
  3481. *
  3482. * @sa @ref joystick_event
  3483. *
  3484. * @since Added in version 3.2.
  3485. *
  3486. * @ingroup input
  3487. */
  3488. GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun);
  3489. /*! @brief Sets the clipboard to the specified string.
  3490. *
  3491. * This function sets the system clipboard to the specified, UTF-8 encoded
  3492. * string.
  3493. *
  3494. * @param[in] window The window that will own the clipboard contents.
  3495. * @param[in] string A UTF-8 encoded string.
  3496. *
  3497. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3498. * GLFW_PLATFORM_ERROR.
  3499. *
  3500. * @pointer_lifetime The specified string is copied before this function
  3501. * returns.
  3502. *
  3503. * @thread_safety This function must only be called from the main thread.
  3504. *
  3505. * @sa @ref clipboard
  3506. * @sa glfwGetClipboardString
  3507. *
  3508. * @since Added in version 3.0.
  3509. *
  3510. * @ingroup input
  3511. */
  3512. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  3513. /*! @brief Returns the contents of the clipboard as a string.
  3514. *
  3515. * This function returns the contents of the system clipboard, if it contains
  3516. * or is convertible to a UTF-8 encoded string. If the clipboard is empty or
  3517. * if its contents cannot be converted, `NULL` is returned and a @ref
  3518. * GLFW_FORMAT_UNAVAILABLE error is generated.
  3519. *
  3520. * @param[in] window The window that will request the clipboard contents.
  3521. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  3522. * if an [error](@ref error_handling) occurred.
  3523. *
  3524. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3525. * GLFW_PLATFORM_ERROR.
  3526. *
  3527. * @pointer_lifetime The returned string is allocated and freed by GLFW. You
  3528. * should not free it yourself. It is valid until the next call to @ref
  3529. * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
  3530. * is terminated.
  3531. *
  3532. * @thread_safety This function must only be called from the main thread.
  3533. *
  3534. * @sa @ref clipboard
  3535. * @sa glfwSetClipboardString
  3536. *
  3537. * @since Added in version 3.0.
  3538. *
  3539. * @ingroup input
  3540. */
  3541. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  3542. /*! @brief Returns the value of the GLFW timer.
  3543. *
  3544. * This function returns the value of the GLFW timer. Unless the timer has
  3545. * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
  3546. * was initialized.
  3547. *
  3548. * The resolution of the timer is system dependent, but is usually on the order
  3549. * of a few micro- or nanoseconds. It uses the highest-resolution monotonic
  3550. * time source on each supported platform.
  3551. *
  3552. * @return The current value, in seconds, or zero if an
  3553. * [error](@ref error_handling) occurred.
  3554. *
  3555. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3556. *
  3557. * @thread_safety This function may be called from any thread. Reading and
  3558. * writing of the internal timer offset is not atomic, so it needs to be
  3559. * externally synchronized with calls to @ref glfwSetTime.
  3560. *
  3561. * @sa @ref time
  3562. *
  3563. * @since Added in version 1.0.
  3564. *
  3565. * @ingroup input
  3566. */
  3567. GLFWAPI double glfwGetTime(void);
  3568. /*! @brief Sets the GLFW timer.
  3569. *
  3570. * This function sets the value of the GLFW timer. It then continues to count
  3571. * up from that value. The value must be a positive finite number less than
  3572. * or equal to 18446744073.0, which is approximately 584.5 years.
  3573. *
  3574. * @param[in] time The new value, in seconds.
  3575. *
  3576. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3577. * GLFW_INVALID_VALUE.
  3578. *
  3579. * @remark The upper limit of the timer is calculated as
  3580. * floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
  3581. * storing nanoseconds in 64 bits. The limit may be increased in the future.
  3582. *
  3583. * @thread_safety This function may be called from any thread. Reading and
  3584. * writing of the internal timer offset is not atomic, so it needs to be
  3585. * externally synchronized with calls to @ref glfwGetTime.
  3586. *
  3587. * @sa @ref time
  3588. *
  3589. * @since Added in version 2.2.
  3590. *
  3591. * @ingroup input
  3592. */
  3593. GLFWAPI void glfwSetTime(double time);
  3594. /*! @brief Returns the current value of the raw timer.
  3595. *
  3596. * This function returns the current value of the raw timer, measured in
  3597. * 1&nbsp;/&nbsp;frequency seconds. To get the frequency, call @ref
  3598. * glfwGetTimerFrequency.
  3599. *
  3600. * @return The value of the timer, or zero if an
  3601. * [error](@ref error_handling) occurred.
  3602. *
  3603. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3604. *
  3605. * @thread_safety This function may be called from any thread.
  3606. *
  3607. * @sa @ref time
  3608. * @sa glfwGetTimerFrequency
  3609. *
  3610. * @since Added in version 3.2.
  3611. *
  3612. * @ingroup input
  3613. */
  3614. GLFWAPI uint64_t glfwGetTimerValue(void);
  3615. /*! @brief Returns the frequency, in Hz, of the raw timer.
  3616. *
  3617. * This function returns the frequency, in Hz, of the raw timer.
  3618. *
  3619. * @return The frequency of the timer, in Hz, or zero if an
  3620. * [error](@ref error_handling) occurred.
  3621. *
  3622. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3623. *
  3624. * @thread_safety This function may be called from any thread.
  3625. *
  3626. * @sa @ref time
  3627. * @sa glfwGetTimerValue
  3628. *
  3629. * @since Added in version 3.2.
  3630. *
  3631. * @ingroup input
  3632. */
  3633. GLFWAPI uint64_t glfwGetTimerFrequency(void);
  3634. /*! @brief Makes the context of the specified window current for the calling
  3635. * thread.
  3636. *
  3637. * This function makes the OpenGL or OpenGL ES context of the specified window
  3638. * current on the calling thread. A context can only be made current on
  3639. * a single thread at a time and each thread can have only a single current
  3640. * context at a time.
  3641. *
  3642. * By default, making a context non-current implicitly forces a pipeline flush.
  3643. * On machines that support `GL_KHR_context_flush_control`, you can control
  3644. * whether a context performs this flush by setting the
  3645. * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint.
  3646. *
  3647. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  3648. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  3649. * error.
  3650. *
  3651. * @param[in] window The window whose context to make current, or `NULL` to
  3652. * detach the current context.
  3653. *
  3654. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3655. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3656. *
  3657. * @thread_safety This function may be called from any thread.
  3658. *
  3659. * @sa @ref context_current
  3660. * @sa glfwGetCurrentContext
  3661. *
  3662. * @since Added in version 3.0.
  3663. *
  3664. * @ingroup context
  3665. */
  3666. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  3667. /*! @brief Returns the window whose context is current on the calling thread.
  3668. *
  3669. * This function returns the window whose OpenGL or OpenGL ES context is
  3670. * current on the calling thread.
  3671. *
  3672. * @return The window whose context is current, or `NULL` if no window's
  3673. * context is current.
  3674. *
  3675. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3676. *
  3677. * @thread_safety This function may be called from any thread.
  3678. *
  3679. * @sa @ref context_current
  3680. * @sa glfwMakeContextCurrent
  3681. *
  3682. * @since Added in version 3.0.
  3683. *
  3684. * @ingroup context
  3685. */
  3686. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  3687. /*! @brief Swaps the front and back buffers of the specified window.
  3688. *
  3689. * This function swaps the front and back buffers of the specified window when
  3690. * rendering with OpenGL or OpenGL ES. If the swap interval is greater than
  3691. * zero, the GPU driver waits the specified number of screen updates before
  3692. * swapping the buffers.
  3693. *
  3694. * The specified window must have an OpenGL or OpenGL ES context. Specifying
  3695. * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
  3696. * error.
  3697. *
  3698. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  3699. * see `vkQueuePresentKHR` instead.
  3700. *
  3701. * @param[in] window The window whose buffers to swap.
  3702. *
  3703. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3704. * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3705. *
  3706. * @remark __EGL:__ The context of the specified window must be current on the
  3707. * calling thread.
  3708. *
  3709. * @thread_safety This function may be called from any thread.
  3710. *
  3711. * @sa @ref buffer_swap
  3712. * @sa glfwSwapInterval
  3713. *
  3714. * @since Added in version 1.0.
  3715. * @glfw3 Added window handle parameter.
  3716. *
  3717. * @ingroup window
  3718. */
  3719. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  3720. /*! @brief Sets the swap interval for the current context.
  3721. *
  3722. * This function sets the swap interval for the current OpenGL or OpenGL ES
  3723. * context, i.e. the number of screen updates to wait from the time @ref
  3724. * glfwSwapBuffers was called before swapping the buffers and returning. This
  3725. * is sometimes called _vertical synchronization_, _vertical retrace
  3726. * synchronization_ or just _vsync_.
  3727. *
  3728. * Contexts that support either of the `WGL_EXT_swap_control_tear` and
  3729. * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,
  3730. * which allow the driver to swap even if a frame arrives a little bit late.
  3731. * You can check for the presence of these extensions using @ref
  3732. * glfwExtensionSupported. For more information about swap tearing, see the
  3733. * extension specifications.
  3734. *
  3735. * A context must be current on the calling thread. Calling this function
  3736. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3737. *
  3738. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  3739. * see the present mode of your swapchain instead.
  3740. *
  3741. * @param[in] interval The minimum number of screen updates to wait for
  3742. * until the buffers are swapped by @ref glfwSwapBuffers.
  3743. *
  3744. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3745. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3746. *
  3747. * @remark This function is not called during context creation, leaving the
  3748. * swap interval set to whatever is the default on that platform. This is done
  3749. * because some swap interval extensions used by GLFW do not allow the swap
  3750. * interval to be reset to zero once it has been set to a non-zero value.
  3751. *
  3752. * @remark Some GPU drivers do not honor the requested swap interval, either
  3753. * because of a user setting that overrides the application's request or due to
  3754. * bugs in the driver.
  3755. *
  3756. * @thread_safety This function may be called from any thread.
  3757. *
  3758. * @sa @ref buffer_swap
  3759. * @sa glfwSwapBuffers
  3760. *
  3761. * @since Added in version 1.0.
  3762. *
  3763. * @ingroup context
  3764. */
  3765. GLFWAPI void glfwSwapInterval(int interval);
  3766. /*! @brief Returns whether the specified extension is available.
  3767. *
  3768. * This function returns whether the specified
  3769. * [API extension](@ref context_glext) is supported by the current OpenGL or
  3770. * OpenGL ES context. It searches both for client API extension and context
  3771. * creation API extensions.
  3772. *
  3773. * A context must be current on the calling thread. Calling this function
  3774. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3775. *
  3776. * As this functions retrieves and searches one or more extension strings each
  3777. * call, it is recommended that you cache its results if it is going to be used
  3778. * frequently. The extension strings will not change during the lifetime of
  3779. * a context, so there is no danger in doing this.
  3780. *
  3781. * This function does not apply to Vulkan. If you are using Vulkan, see @ref
  3782. * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
  3783. * and `vkEnumerateDeviceExtensionProperties` instead.
  3784. *
  3785. * @param[in] extension The ASCII encoded name of the extension.
  3786. * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
  3787. * otherwise.
  3788. *
  3789. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3790. * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
  3791. * GLFW_PLATFORM_ERROR.
  3792. *
  3793. * @thread_safety This function may be called from any thread.
  3794. *
  3795. * @sa @ref context_glext
  3796. * @sa glfwGetProcAddress
  3797. *
  3798. * @since Added in version 1.0.
  3799. *
  3800. * @ingroup context
  3801. */
  3802. GLFWAPI int glfwExtensionSupported(const char* extension);
  3803. /*! @brief Returns the address of the specified function for the current
  3804. * context.
  3805. *
  3806. * This function returns the address of the specified OpenGL or OpenGL ES
  3807. * [core or extension function](@ref context_glext), if it is supported
  3808. * by the current context.
  3809. *
  3810. * A context must be current on the calling thread. Calling this function
  3811. * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
  3812. *
  3813. * This function does not apply to Vulkan. If you are rendering with Vulkan,
  3814. * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
  3815. * `vkGetDeviceProcAddr` instead.
  3816. *
  3817. * @param[in] procname The ASCII encoded name of the function.
  3818. * @return The address of the function, or `NULL` if an
  3819. * [error](@ref error_handling) occurred.
  3820. *
  3821. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3822. * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
  3823. *
  3824. * @remark The address of a given function is not guaranteed to be the same
  3825. * between contexts.
  3826. *
  3827. * @remark This function may return a non-`NULL` address despite the
  3828. * associated version or extension not being available. Always check the
  3829. * context version or extension string first.
  3830. *
  3831. * @pointer_lifetime The returned function pointer is valid until the context
  3832. * is destroyed or the library is terminated.
  3833. *
  3834. * @thread_safety This function may be called from any thread.
  3835. *
  3836. * @sa @ref context_glext
  3837. * @sa glfwExtensionSupported
  3838. *
  3839. * @since Added in version 1.0.
  3840. *
  3841. * @ingroup context
  3842. */
  3843. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  3844. /*! @brief Returns whether the Vulkan loader has been found.
  3845. *
  3846. * This function returns whether the Vulkan loader has been found. This check
  3847. * is performed by @ref glfwInit.
  3848. *
  3849. * The availability of a Vulkan loader does not by itself guarantee that window
  3850. * surface creation or even device creation is possible. Call @ref
  3851. * glfwGetRequiredInstanceExtensions to check whether the extensions necessary
  3852. * for Vulkan surface creation are available and @ref
  3853. * glfwGetPhysicalDevicePresentationSupport to check whether a queue family of
  3854. * a physical device supports image presentation.
  3855. *
  3856. * @return `GLFW_TRUE` if Vulkan is available, or `GLFW_FALSE` otherwise.
  3857. *
  3858. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
  3859. *
  3860. * @thread_safety This function may be called from any thread.
  3861. *
  3862. * @sa @ref vulkan_support
  3863. *
  3864. * @since Added in version 3.2.
  3865. *
  3866. * @ingroup vulkan
  3867. */
  3868. GLFWAPI int glfwVulkanSupported(void);
  3869. /*! @brief Returns the Vulkan instance extensions required by GLFW.
  3870. *
  3871. * This function returns an array of names of Vulkan instance extensions required
  3872. * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the
  3873. * list will always contains `VK_KHR_surface`, so if you don't require any
  3874. * additional extensions you can pass this list directly to the
  3875. * `VkInstanceCreateInfo` struct.
  3876. *
  3877. * If Vulkan is not available on the machine, this function returns `NULL` and
  3878. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  3879. * to check whether Vulkan is available.
  3880. *
  3881. * If Vulkan is available but no set of extensions allowing window surface
  3882. * creation was found, this function returns `NULL`. You may still use Vulkan
  3883. * for off-screen rendering and compute work.
  3884. *
  3885. * @param[out] count Where to store the number of extensions in the returned
  3886. * array. This is set to zero if an error occurred.
  3887. * @return An array of ASCII encoded extension names, or `NULL` if an
  3888. * [error](@ref error_handling) occurred.
  3889. *
  3890. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3891. * GLFW_API_UNAVAILABLE.
  3892. *
  3893. * @remarks Additional extensions may be required by future versions of GLFW.
  3894. * You should check if any extensions you wish to enable are already in the
  3895. * returned array, as it is an error to specify an extension more than once in
  3896. * the `VkInstanceCreateInfo` struct.
  3897. *
  3898. * @pointer_lifetime The returned array is allocated and freed by GLFW. You
  3899. * should not free it yourself. It is guaranteed to be valid only until the
  3900. * library is terminated.
  3901. *
  3902. * @thread_safety This function may be called from any thread.
  3903. *
  3904. * @sa @ref vulkan_ext
  3905. * @sa glfwCreateWindowSurface
  3906. *
  3907. * @since Added in version 3.2.
  3908. *
  3909. * @ingroup vulkan
  3910. */
  3911. GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
  3912. #if defined(VK_VERSION_1_0)
  3913. /*! @brief Returns the address of the specified Vulkan instance function.
  3914. *
  3915. * This function returns the address of the specified Vulkan core or extension
  3916. * function for the specified instance. If instance is set to `NULL` it can
  3917. * return any function exported from the Vulkan loader, including at least the
  3918. * following functions:
  3919. *
  3920. * - `vkEnumerateInstanceExtensionProperties`
  3921. * - `vkEnumerateInstanceLayerProperties`
  3922. * - `vkCreateInstance`
  3923. * - `vkGetInstanceProcAddr`
  3924. *
  3925. * If Vulkan is not available on the machine, this function returns `NULL` and
  3926. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  3927. * to check whether Vulkan is available.
  3928. *
  3929. * This function is equivalent to calling `vkGetInstanceProcAddr` with
  3930. * a platform-specific query of the Vulkan loader as a fallback.
  3931. *
  3932. * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
  3933. * functions related to instance creation.
  3934. * @param[in] procname The ASCII encoded name of the function.
  3935. * @return The address of the function, or `NULL` if an
  3936. * [error](@ref error_handling) occurred.
  3937. *
  3938. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
  3939. * GLFW_API_UNAVAILABLE.
  3940. *
  3941. * @pointer_lifetime The returned function pointer is valid until the library
  3942. * is terminated.
  3943. *
  3944. * @thread_safety This function may be called from any thread.
  3945. *
  3946. * @sa @ref vulkan_proc
  3947. *
  3948. * @since Added in version 3.2.
  3949. *
  3950. * @ingroup vulkan
  3951. */
  3952. GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
  3953. /*! @brief Returns whether the specified queue family can present images.
  3954. *
  3955. * This function returns whether the specified queue family of the specified
  3956. * physical device supports presentation to the platform GLFW was built for.
  3957. *
  3958. * If Vulkan or the required window surface creation instance extensions are
  3959. * not available on the machine, or if the specified instance was not created
  3960. * with the required extensions, this function returns `GLFW_FALSE` and
  3961. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported
  3962. * to check whether Vulkan is available and @ref
  3963. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  3964. * required.
  3965. *
  3966. * @param[in] instance The instance that the physical device belongs to.
  3967. * @param[in] device The physical device that the queue family belongs to.
  3968. * @param[in] queuefamily The index of the queue family to query.
  3969. * @return `GLFW_TRUE` if the queue family supports presentation, or
  3970. * `GLFW_FALSE` otherwise.
  3971. *
  3972. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  3973. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  3974. *
  3975. * @thread_safety This function may be called from any thread. For
  3976. * synchronization details of Vulkan objects, see the Vulkan specification.
  3977. *
  3978. * @sa @ref vulkan_present
  3979. *
  3980. * @since Added in version 3.2.
  3981. *
  3982. * @ingroup vulkan
  3983. */
  3984. GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
  3985. /*! @brief Creates a Vulkan surface for the specified window.
  3986. *
  3987. * This function creates a Vulkan surface for the specified window.
  3988. *
  3989. * If the Vulkan loader was not found at initialization, this function returns
  3990. * `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref GLFW_API_UNAVAILABLE
  3991. * error. Call @ref glfwVulkanSupported to check whether the Vulkan loader was
  3992. * found.
  3993. *
  3994. * If the required window surface creation instance extensions are not
  3995. * available or if the specified instance was not created with these extensions
  3996. * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
  3997. * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref
  3998. * glfwGetRequiredInstanceExtensions to check what instance extensions are
  3999. * required.
  4000. *
  4001. * The window surface must be destroyed before the specified Vulkan instance.
  4002. * It is the responsibility of the caller to destroy the window surface. GLFW
  4003. * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the
  4004. * surface.
  4005. *
  4006. * @param[in] instance The Vulkan instance to create the surface in.
  4007. * @param[in] window The window to create the surface for.
  4008. * @param[in] allocator The allocator to use, or `NULL` to use the default
  4009. * allocator.
  4010. * @param[out] surface Where to store the handle of the surface. This is set
  4011. * to `VK_NULL_HANDLE` if an error occurred.
  4012. * @return `VK_SUCCESS` if successful, or a Vulkan error code if an
  4013. * [error](@ref error_handling) occurred.
  4014. *
  4015. * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
  4016. * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
  4017. *
  4018. * @remarks If an error occurs before the creation call is made, GLFW returns
  4019. * the Vulkan error code most appropriate for the error. Appropriate use of
  4020. * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
  4021. * eliminate almost all occurrences of these errors.
  4022. *
  4023. * @thread_safety This function may be called from any thread. For
  4024. * synchronization details of Vulkan objects, see the Vulkan specification.
  4025. *
  4026. * @sa @ref vulkan_surface
  4027. * @sa glfwGetRequiredInstanceExtensions
  4028. *
  4029. * @since Added in version 3.2.
  4030. *
  4031. * @ingroup vulkan
  4032. */
  4033. GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
  4034. #endif /*VK_VERSION_1_0*/
  4035. /*************************************************************************
  4036. * Global definition cleanup
  4037. *************************************************************************/
  4038. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  4039. #ifdef GLFW_WINGDIAPI_DEFINED
  4040. #undef WINGDIAPI
  4041. #undef GLFW_WINGDIAPI_DEFINED
  4042. #endif
  4043. #ifdef GLFW_CALLBACK_DEFINED
  4044. #undef CALLBACK
  4045. #undef GLFW_CALLBACK_DEFINED
  4046. #endif
  4047. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  4048. #ifdef __cplusplus
  4049. }
  4050. #endif
  4051. #endif /* _glfw3_h_ */