glfw3.h 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282
  1. /*************************************************************************
  2. * GLFW 3.0 - www.glfw.org
  3. * A library for OpenGL, window and input
  4. *------------------------------------------------------------------------
  5. * Copyright (c) 2002-2006 Marcus Geelnard
  6. * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.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. /*! @defgroup clipboard Clipboard support
  37. */
  38. /*! @defgroup context Context handling
  39. */
  40. /*! @defgroup error Error handling
  41. */
  42. /*! @defgroup init Initialization and version information
  43. */
  44. /*! @defgroup input Input handling
  45. */
  46. /*! @defgroup monitor Monitor handling
  47. *
  48. * This is the reference documentation for monitor related functions and types.
  49. * For more information, see the @ref monitor.
  50. */
  51. /*! @defgroup time Time input
  52. */
  53. /*! @defgroup window Window handling
  54. *
  55. * This is the reference documentation for window related functions and types,
  56. * including creation, deletion and event polling. For more information, see
  57. * the @ref window.
  58. */
  59. /*************************************************************************
  60. * Global definitions
  61. *************************************************************************/
  62. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  63. /* Please report any problems that you find with your compiler, which may
  64. * be solved in this section! There are several compilers that I have not
  65. * been able to test this file with yet.
  66. *
  67. * First: If we are we on Windows, we want a single define for it (_WIN32)
  68. * (Note: For Cygwin the compiler flag -mwin32 should be used, but to
  69. * make sure that things run smoothly for Cygwin users, we add __CYGWIN__
  70. * to the list of "valid Win32 identifiers", which removes the need for
  71. * -mwin32)
  72. */
  73. #if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
  74. #define _WIN32
  75. #endif /* _WIN32 */
  76. /* In order for extension support to be portable, we need to define an
  77. * OpenGL function call method. We use the keyword APIENTRY, which is
  78. * defined for Win32. (Note: Windows also needs this for <GL/gl.h>)
  79. */
  80. #ifndef APIENTRY
  81. #ifdef _WIN32
  82. #define APIENTRY __stdcall
  83. #else
  84. #define APIENTRY
  85. #endif
  86. #endif /* APIENTRY */
  87. /* The following three defines are here solely to make some Windows-based
  88. * <GL/gl.h> files happy. Theoretically we could include <windows.h>, but
  89. * it has the major drawback of severely polluting our namespace.
  90. */
  91. /* Under Windows, we need WINGDIAPI defined */
  92. #if !defined(WINGDIAPI) && defined(_WIN32)
  93. #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
  94. /* Microsoft Visual C++, Borland C++ Builder and Pelles C */
  95. #define WINGDIAPI __declspec(dllimport)
  96. #elif defined(__LCC__)
  97. /* LCC-Win32 */
  98. #define WINGDIAPI __stdcall
  99. #else
  100. /* Others (e.g. MinGW, Cygwin) */
  101. #define WINGDIAPI extern
  102. #endif
  103. #define GLFW_WINGDIAPI_DEFINED
  104. #endif /* WINGDIAPI */
  105. /* Some <GL/glu.h> files also need CALLBACK defined */
  106. #if !defined(CALLBACK) && defined(_WIN32)
  107. #if defined(_MSC_VER)
  108. /* Microsoft Visual C++ */
  109. #if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
  110. #define CALLBACK __stdcall
  111. #else
  112. #define CALLBACK
  113. #endif
  114. #else
  115. /* Other Windows compilers */
  116. #define CALLBACK __stdcall
  117. #endif
  118. #define GLFW_CALLBACK_DEFINED
  119. #endif /* CALLBACK */
  120. /* Most GL/glu.h variants on Windows need wchar_t
  121. * OpenGL/gl.h blocks the definition of ptrdiff_t by glext.h on OS X */
  122. #include <stddef.h>
  123. /* ---------------- GLFW related system specific defines ----------------- */
  124. #if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
  125. /* GLFW_DLL is defined by users of GLFW when compiling programs that will link
  126. * to the DLL version of the GLFW library. _GLFW_BUILD_DLL is defined by the
  127. * GLFW configuration header when compiling the DLL version of the library.
  128. */
  129. #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
  130. #endif
  131. #if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
  132. /* We are building a Win32 DLL */
  133. #define GLFWAPI __declspec(dllexport)
  134. #elif defined(_WIN32) && defined(GLFW_DLL)
  135. /* We are calling a Win32 DLL */
  136. #if defined(__LCC__)
  137. #define GLFWAPI extern
  138. #else
  139. #define GLFWAPI __declspec(dllimport)
  140. #endif
  141. #elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
  142. #define GLFWAPI __attribute__((visibility("default")))
  143. #else
  144. /* We are either building/calling a static lib or we are non-win32 */
  145. #define GLFWAPI
  146. #endif
  147. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  148. /* Include the chosen client API headers.
  149. */
  150. #if defined(__APPLE_CC__)
  151. #if defined(GLFW_INCLUDE_GLCOREARB)
  152. #include <OpenGL/gl3.h>
  153. #elif !defined(GLFW_INCLUDE_NONE)
  154. #define GL_GLEXT_LEGACY
  155. #include <OpenGL/gl.h>
  156. #endif
  157. #if defined(GLFW_INCLUDE_GLU)
  158. #include <OpenGL/glu.h>
  159. #endif
  160. #else
  161. #if defined(GLFW_INCLUDE_GLCOREARB)
  162. #include <GL/glcorearb.h>
  163. #elif defined(GLFW_INCLUDE_ES1)
  164. #include <GLES/gl.h>
  165. #elif defined(GLFW_INCLUDE_ES2)
  166. #include <GLES2/gl2.h>
  167. #elif defined(GLFW_INCLUDE_ES3)
  168. #include <GLES3/gl3.h>
  169. #elif !defined(GLFW_INCLUDE_NONE)
  170. #include <GL/gl.h>
  171. #endif
  172. #if defined(GLFW_INCLUDE_GLU)
  173. #include <GL/glu.h>
  174. #endif
  175. #endif
  176. /*************************************************************************
  177. * GLFW API tokens
  178. *************************************************************************/
  179. /*! @name GLFW version macros
  180. * @{ */
  181. /*! @brief The major version number of the GLFW library.
  182. *
  183. * This is incremented when the API is changed in non-compatible ways.
  184. * @ingroup init
  185. */
  186. #define GLFW_VERSION_MAJOR 3
  187. /*! @brief The minor version number of the GLFW library.
  188. *
  189. * This is incremented when features are added to the API but it remains
  190. * backward-compatible.
  191. * @ingroup init
  192. */
  193. #define GLFW_VERSION_MINOR 0
  194. /*! @brief The revision number of the GLFW library.
  195. *
  196. * This is incremented when a bug fix release is made that does not contain any
  197. * API changes.
  198. * @ingroup init
  199. */
  200. #define GLFW_VERSION_REVISION 2
  201. /*! @} */
  202. /*! @name Key and button actions
  203. * @{ */
  204. /*! @brief The key or button was released.
  205. * @ingroup input
  206. */
  207. #define GLFW_RELEASE 0
  208. /*! @brief The key or button was pressed.
  209. * @ingroup input
  210. */
  211. #define GLFW_PRESS 1
  212. /*! @brief The key was held down until it repeated.
  213. * @ingroup input
  214. */
  215. #define GLFW_REPEAT 2
  216. /*! @} */
  217. /*! @defgroup keys Keyboard keys
  218. *
  219. * These key codes are inspired by the *USB HID Usage Tables v1.12* (p. 53-60),
  220. * but re-arranged to map to 7-bit ASCII for printable keys (function keys are
  221. * put in the 256+ range).
  222. *
  223. * The naming of the key codes follow these rules:
  224. * - The US keyboard layout is used
  225. * - Names of printable alpha-numeric characters are used (e.g. "A", "R",
  226. * "3", etc.)
  227. * - For non-alphanumeric characters, Unicode:ish names are used (e.g.
  228. * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
  229. * correspond to the Unicode standard (usually for brevity)
  230. * - Keys that lack a clear US mapping are named "WORLD_x"
  231. * - For non-printable keys, custom names are used (e.g. "F4",
  232. * "BACKSPACE", etc.)
  233. *
  234. * @ingroup input
  235. * @{
  236. */
  237. /* The unknown key */
  238. #define GLFW_KEY_UNKNOWN -1
  239. /* Printable keys */
  240. #define GLFW_KEY_SPACE 32
  241. #define GLFW_KEY_APOSTROPHE 39 /* ' */
  242. #define GLFW_KEY_COMMA 44 /* , */
  243. #define GLFW_KEY_MINUS 45 /* - */
  244. #define GLFW_KEY_PERIOD 46 /* . */
  245. #define GLFW_KEY_SLASH 47 /* / */
  246. #define GLFW_KEY_0 48
  247. #define GLFW_KEY_1 49
  248. #define GLFW_KEY_2 50
  249. #define GLFW_KEY_3 51
  250. #define GLFW_KEY_4 52
  251. #define GLFW_KEY_5 53
  252. #define GLFW_KEY_6 54
  253. #define GLFW_KEY_7 55
  254. #define GLFW_KEY_8 56
  255. #define GLFW_KEY_9 57
  256. #define GLFW_KEY_SEMICOLON 59 /* ; */
  257. #define GLFW_KEY_EQUAL 61 /* = */
  258. #define GLFW_KEY_A 65
  259. #define GLFW_KEY_B 66
  260. #define GLFW_KEY_C 67
  261. #define GLFW_KEY_D 68
  262. #define GLFW_KEY_E 69
  263. #define GLFW_KEY_F 70
  264. #define GLFW_KEY_G 71
  265. #define GLFW_KEY_H 72
  266. #define GLFW_KEY_I 73
  267. #define GLFW_KEY_J 74
  268. #define GLFW_KEY_K 75
  269. #define GLFW_KEY_L 76
  270. #define GLFW_KEY_M 77
  271. #define GLFW_KEY_N 78
  272. #define GLFW_KEY_O 79
  273. #define GLFW_KEY_P 80
  274. #define GLFW_KEY_Q 81
  275. #define GLFW_KEY_R 82
  276. #define GLFW_KEY_S 83
  277. #define GLFW_KEY_T 84
  278. #define GLFW_KEY_U 85
  279. #define GLFW_KEY_V 86
  280. #define GLFW_KEY_W 87
  281. #define GLFW_KEY_X 88
  282. #define GLFW_KEY_Y 89
  283. #define GLFW_KEY_Z 90
  284. #define GLFW_KEY_LEFT_BRACKET 91 /* [ */
  285. #define GLFW_KEY_BACKSLASH 92 /* \ */
  286. #define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
  287. #define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
  288. #define GLFW_KEY_WORLD_1 161 /* non-US #1 */
  289. #define GLFW_KEY_WORLD_2 162 /* non-US #2 */
  290. /* Function keys */
  291. #define GLFW_KEY_ESCAPE 256
  292. #define GLFW_KEY_ENTER 257
  293. #define GLFW_KEY_TAB 258
  294. #define GLFW_KEY_BACKSPACE 259
  295. #define GLFW_KEY_INSERT 260
  296. #define GLFW_KEY_DELETE 261
  297. #define GLFW_KEY_RIGHT 262
  298. #define GLFW_KEY_LEFT 263
  299. #define GLFW_KEY_DOWN 264
  300. #define GLFW_KEY_UP 265
  301. #define GLFW_KEY_PAGE_UP 266
  302. #define GLFW_KEY_PAGE_DOWN 267
  303. #define GLFW_KEY_HOME 268
  304. #define GLFW_KEY_END 269
  305. #define GLFW_KEY_CAPS_LOCK 280
  306. #define GLFW_KEY_SCROLL_LOCK 281
  307. #define GLFW_KEY_NUM_LOCK 282
  308. #define GLFW_KEY_PRINT_SCREEN 283
  309. #define GLFW_KEY_PAUSE 284
  310. #define GLFW_KEY_F1 290
  311. #define GLFW_KEY_F2 291
  312. #define GLFW_KEY_F3 292
  313. #define GLFW_KEY_F4 293
  314. #define GLFW_KEY_F5 294
  315. #define GLFW_KEY_F6 295
  316. #define GLFW_KEY_F7 296
  317. #define GLFW_KEY_F8 297
  318. #define GLFW_KEY_F9 298
  319. #define GLFW_KEY_F10 299
  320. #define GLFW_KEY_F11 300
  321. #define GLFW_KEY_F12 301
  322. #define GLFW_KEY_F13 302
  323. #define GLFW_KEY_F14 303
  324. #define GLFW_KEY_F15 304
  325. #define GLFW_KEY_F16 305
  326. #define GLFW_KEY_F17 306
  327. #define GLFW_KEY_F18 307
  328. #define GLFW_KEY_F19 308
  329. #define GLFW_KEY_F20 309
  330. #define GLFW_KEY_F21 310
  331. #define GLFW_KEY_F22 311
  332. #define GLFW_KEY_F23 312
  333. #define GLFW_KEY_F24 313
  334. #define GLFW_KEY_F25 314
  335. #define GLFW_KEY_KP_0 320
  336. #define GLFW_KEY_KP_1 321
  337. #define GLFW_KEY_KP_2 322
  338. #define GLFW_KEY_KP_3 323
  339. #define GLFW_KEY_KP_4 324
  340. #define GLFW_KEY_KP_5 325
  341. #define GLFW_KEY_KP_6 326
  342. #define GLFW_KEY_KP_7 327
  343. #define GLFW_KEY_KP_8 328
  344. #define GLFW_KEY_KP_9 329
  345. #define GLFW_KEY_KP_DECIMAL 330
  346. #define GLFW_KEY_KP_DIVIDE 331
  347. #define GLFW_KEY_KP_MULTIPLY 332
  348. #define GLFW_KEY_KP_SUBTRACT 333
  349. #define GLFW_KEY_KP_ADD 334
  350. #define GLFW_KEY_KP_ENTER 335
  351. #define GLFW_KEY_KP_EQUAL 336
  352. #define GLFW_KEY_LEFT_SHIFT 340
  353. #define GLFW_KEY_LEFT_CONTROL 341
  354. #define GLFW_KEY_LEFT_ALT 342
  355. #define GLFW_KEY_LEFT_SUPER 343
  356. #define GLFW_KEY_RIGHT_SHIFT 344
  357. #define GLFW_KEY_RIGHT_CONTROL 345
  358. #define GLFW_KEY_RIGHT_ALT 346
  359. #define GLFW_KEY_RIGHT_SUPER 347
  360. #define GLFW_KEY_MENU 348
  361. #define GLFW_KEY_LAST GLFW_KEY_MENU
  362. /*! @} */
  363. /*! @defgroup mods Modifier key flags
  364. * @ingroup input
  365. * @{ */
  366. /*! @brief If this bit is set one or more Shift keys were held down.
  367. */
  368. #define GLFW_MOD_SHIFT 0x0001
  369. /*! @brief If this bit is set one or more Control keys were held down.
  370. */
  371. #define GLFW_MOD_CONTROL 0x0002
  372. /*! @brief If this bit is set one or more Alt keys were held down.
  373. */
  374. #define GLFW_MOD_ALT 0x0004
  375. /*! @brief If this bit is set one or more Super keys were held down.
  376. */
  377. #define GLFW_MOD_SUPER 0x0008
  378. /*! @} */
  379. /*! @defgroup buttons Mouse buttons
  380. * @ingroup input
  381. * @{ */
  382. #define GLFW_MOUSE_BUTTON_1 0
  383. #define GLFW_MOUSE_BUTTON_2 1
  384. #define GLFW_MOUSE_BUTTON_3 2
  385. #define GLFW_MOUSE_BUTTON_4 3
  386. #define GLFW_MOUSE_BUTTON_5 4
  387. #define GLFW_MOUSE_BUTTON_6 5
  388. #define GLFW_MOUSE_BUTTON_7 6
  389. #define GLFW_MOUSE_BUTTON_8 7
  390. #define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8
  391. #define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1
  392. #define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2
  393. #define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3
  394. /*! @} */
  395. /*! @defgroup joysticks Joysticks
  396. * @ingroup input
  397. * @{ */
  398. #define GLFW_JOYSTICK_1 0
  399. #define GLFW_JOYSTICK_2 1
  400. #define GLFW_JOYSTICK_3 2
  401. #define GLFW_JOYSTICK_4 3
  402. #define GLFW_JOYSTICK_5 4
  403. #define GLFW_JOYSTICK_6 5
  404. #define GLFW_JOYSTICK_7 6
  405. #define GLFW_JOYSTICK_8 7
  406. #define GLFW_JOYSTICK_9 8
  407. #define GLFW_JOYSTICK_10 9
  408. #define GLFW_JOYSTICK_11 10
  409. #define GLFW_JOYSTICK_12 11
  410. #define GLFW_JOYSTICK_13 12
  411. #define GLFW_JOYSTICK_14 13
  412. #define GLFW_JOYSTICK_15 14
  413. #define GLFW_JOYSTICK_16 15
  414. #define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16
  415. /*! @} */
  416. /*! @defgroup errors Error codes
  417. * @ingroup error
  418. * @{ */
  419. /*! @brief GLFW has not been initialized.
  420. */
  421. #define GLFW_NOT_INITIALIZED 0x00010001
  422. /*! @brief No context is current for this thread.
  423. */
  424. #define GLFW_NO_CURRENT_CONTEXT 0x00010002
  425. /*! @brief One of the enum parameters for the function was given an invalid
  426. * enum.
  427. */
  428. #define GLFW_INVALID_ENUM 0x00010003
  429. /*! @brief One of the parameters for the function was given an invalid value.
  430. */
  431. #define GLFW_INVALID_VALUE 0x00010004
  432. /*! @brief A memory allocation failed.
  433. */
  434. #define GLFW_OUT_OF_MEMORY 0x00010005
  435. /*! @brief GLFW could not find support for the requested client API on the
  436. * system.
  437. */
  438. #define GLFW_API_UNAVAILABLE 0x00010006
  439. /*! @brief The requested client API version is not available.
  440. */
  441. #define GLFW_VERSION_UNAVAILABLE 0x00010007
  442. /*! @brief A platform-specific error occurred that does not match any of the
  443. * more specific categories.
  444. */
  445. #define GLFW_PLATFORM_ERROR 0x00010008
  446. /*! @brief The clipboard did not contain data in the requested format.
  447. */
  448. #define GLFW_FORMAT_UNAVAILABLE 0x00010009
  449. /*! @} */
  450. #define GLFW_FOCUSED 0x00020001
  451. #define GLFW_ICONIFIED 0x00020002
  452. #define GLFW_RESIZABLE 0x00020003
  453. #define GLFW_VISIBLE 0x00020004
  454. #define GLFW_DECORATED 0x00020005
  455. #define GLFW_RED_BITS 0x00021001
  456. #define GLFW_GREEN_BITS 0x00021002
  457. #define GLFW_BLUE_BITS 0x00021003
  458. #define GLFW_ALPHA_BITS 0x00021004
  459. #define GLFW_DEPTH_BITS 0x00021005
  460. #define GLFW_STENCIL_BITS 0x00021006
  461. #define GLFW_ACCUM_RED_BITS 0x00021007
  462. #define GLFW_ACCUM_GREEN_BITS 0x00021008
  463. #define GLFW_ACCUM_BLUE_BITS 0x00021009
  464. #define GLFW_ACCUM_ALPHA_BITS 0x0002100A
  465. #define GLFW_AUX_BUFFERS 0x0002100B
  466. #define GLFW_STEREO 0x0002100C
  467. #define GLFW_SAMPLES 0x0002100D
  468. #define GLFW_SRGB_CAPABLE 0x0002100E
  469. #define GLFW_REFRESH_RATE 0x0002100F
  470. #define GLFW_CLIENT_API 0x00022001
  471. #define GLFW_CONTEXT_VERSION_MAJOR 0x00022002
  472. #define GLFW_CONTEXT_VERSION_MINOR 0x00022003
  473. #define GLFW_CONTEXT_REVISION 0x00022004
  474. #define GLFW_CONTEXT_ROBUSTNESS 0x00022005
  475. #define GLFW_OPENGL_FORWARD_COMPAT 0x00022006
  476. #define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
  477. #define GLFW_OPENGL_PROFILE 0x00022008
  478. #define GLFW_OPENGL_API 0x00030001
  479. #define GLFW_OPENGL_ES_API 0x00030002
  480. #define GLFW_NO_ROBUSTNESS 0
  481. #define GLFW_NO_RESET_NOTIFICATION 0x00031001
  482. #define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002
  483. #define GLFW_OPENGL_ANY_PROFILE 0
  484. #define GLFW_OPENGL_CORE_PROFILE 0x00032001
  485. #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002
  486. #define GLFW_CURSOR 0x00033001
  487. #define GLFW_STICKY_KEYS 0x00033002
  488. #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
  489. #define GLFW_CURSOR_NORMAL 0x00034001
  490. #define GLFW_CURSOR_HIDDEN 0x00034002
  491. #define GLFW_CURSOR_DISABLED 0x00034003
  492. #define GLFW_CONNECTED 0x00040001
  493. #define GLFW_DISCONNECTED 0x00040002
  494. /*************************************************************************
  495. * GLFW API types
  496. *************************************************************************/
  497. /*! @brief Client API function pointer type.
  498. *
  499. * Generic function pointer used for returning client API function pointers
  500. * without forcing a cast from a regular pointer.
  501. *
  502. * @ingroup context
  503. */
  504. typedef void (*GLFWglproc)(void);
  505. /*! @brief Opaque monitor object.
  506. *
  507. * Opaque monitor object.
  508. *
  509. * @ingroup monitor
  510. */
  511. typedef struct GLFWmonitor GLFWmonitor;
  512. /*! @brief Opaque window object.
  513. *
  514. * Opaque window object.
  515. *
  516. * @ingroup window
  517. */
  518. typedef struct GLFWwindow GLFWwindow;
  519. /*! @brief The function signature for error callbacks.
  520. *
  521. * This is the function signature for error callback functions.
  522. *
  523. * @param[in] error An [error code](@ref errors).
  524. * @param[in] description A UTF-8 encoded string describing the error.
  525. *
  526. * @sa glfwSetErrorCallback
  527. *
  528. * @ingroup error
  529. */
  530. typedef void (* GLFWerrorfun)(int,const char*);
  531. /*! @brief The function signature for window position callbacks.
  532. *
  533. * This is the function signature for window position callback functions.
  534. *
  535. * @param[in] window The window that the user moved.
  536. * @param[in] xpos The new x-coordinate, in screen coordinates, of the
  537. * upper-left corner of the client area of the window.
  538. * @param[in] ypos The new y-coordinate, in screen coordinates, of the
  539. * upper-left corner of the client area of the window.
  540. *
  541. * @sa glfwSetWindowPosCallback
  542. *
  543. * @ingroup window
  544. */
  545. typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
  546. /*! @brief The function signature for window resize callbacks.
  547. *
  548. * This is the function signature for window size callback functions.
  549. *
  550. * @param[in] window The window that the user resized.
  551. * @param[in] width The new width, in screen coordinates, of the window.
  552. * @param[in] height The new height, in screen coordinates, of the window.
  553. *
  554. * @sa glfwSetWindowSizeCallback
  555. *
  556. * @ingroup window
  557. */
  558. typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
  559. /*! @brief The function signature for window close callbacks.
  560. *
  561. * This is the function signature for window close callback functions.
  562. *
  563. * @param[in] window The window that the user attempted to close.
  564. *
  565. * @sa glfwSetWindowCloseCallback
  566. *
  567. * @ingroup window
  568. */
  569. typedef void (* GLFWwindowclosefun)(GLFWwindow*);
  570. /*! @brief The function signature for window content refresh callbacks.
  571. *
  572. * This is the function signature for window refresh callback functions.
  573. *
  574. * @param[in] window The window whose content needs to be refreshed.
  575. *
  576. * @sa glfwSetWindowRefreshCallback
  577. *
  578. * @ingroup window
  579. */
  580. typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
  581. /*! @brief The function signature for window focus/defocus callbacks.
  582. *
  583. * This is the function signature for window focus callback functions.
  584. *
  585. * @param[in] window The window that was focused or defocused.
  586. * @param[in] focused `GL_TRUE` if the window was focused, or `GL_FALSE` if
  587. * it was defocused.
  588. *
  589. * @sa glfwSetWindowFocusCallback
  590. *
  591. * @ingroup window
  592. */
  593. typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
  594. /*! @brief The function signature for window iconify/restore callbacks.
  595. *
  596. * This is the function signature for window iconify/restore callback
  597. * functions.
  598. *
  599. * @param[in] window The window that was iconified or restored.
  600. * @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`
  601. * if it was restored.
  602. *
  603. * @sa glfwSetWindowIconifyCallback
  604. *
  605. * @ingroup window
  606. */
  607. typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
  608. /*! @brief The function signature for framebuffer resize callbacks.
  609. *
  610. * This is the function signature for framebuffer resize callback
  611. * functions.
  612. *
  613. * @param[in] window The window whose framebuffer was resized.
  614. * @param[in] width The new width, in pixels, of the framebuffer.
  615. * @param[in] height The new height, in pixels, of the framebuffer.
  616. *
  617. * @sa glfwSetFramebufferSizeCallback
  618. *
  619. * @ingroup window
  620. */
  621. typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
  622. /*! @brief The function signature for mouse button callbacks.
  623. *
  624. * This is the function signature for mouse button callback functions.
  625. *
  626. * @param[in] window The window that received the event.
  627. * @param[in] button The [mouse button](@ref buttons) that was pressed or
  628. * released.
  629. * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.
  630. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  631. * held down.
  632. *
  633. * @sa glfwSetMouseButtonCallback
  634. *
  635. * @ingroup input
  636. */
  637. typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
  638. /*! @brief The function signature for cursor position callbacks.
  639. *
  640. * This is the function signature for cursor position callback functions.
  641. *
  642. * @param[in] window The window that received the event.
  643. * @param[in] xpos The new x-coordinate of the cursor.
  644. * @param[in] ypos The new y-coordinate of the cursor.
  645. *
  646. * @sa glfwSetCursorPosCallback
  647. *
  648. * @ingroup input
  649. */
  650. typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
  651. /*! @brief The function signature for cursor enter/leave callbacks.
  652. *
  653. * This is the function signature for cursor enter/leave callback functions.
  654. *
  655. * @param[in] window The window that received the event.
  656. * @param[in] entered `GL_TRUE` if the cursor entered the window's client
  657. * area, or `GL_FALSE` if it left it.
  658. *
  659. * @sa glfwSetCursorEnterCallback
  660. *
  661. * @ingroup input
  662. */
  663. typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
  664. /*! @brief The function signature for scroll callbacks.
  665. *
  666. * This is the function signature for scroll callback functions.
  667. *
  668. * @param[in] window The window that received the event.
  669. * @param[in] xoffset The scroll offset along the x-axis.
  670. * @param[in] yoffset The scroll offset along the y-axis.
  671. *
  672. * @sa glfwSetScrollCallback
  673. *
  674. * @ingroup input
  675. */
  676. typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
  677. /*! @brief The function signature for keyboard key callbacks.
  678. *
  679. * This is the function signature for keyboard key callback functions.
  680. *
  681. * @param[in] window The window that received the event.
  682. * @param[in] key The [keyboard key](@ref keys) that was pressed or released.
  683. * @param[in] scancode The system-specific scancode of the key.
  684. * @param[in] action @ref GLFW_PRESS, @ref GLFW_RELEASE or @ref GLFW_REPEAT.
  685. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were
  686. * held down.
  687. *
  688. * @sa glfwSetKeyCallback
  689. *
  690. * @ingroup input
  691. */
  692. typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
  693. /*! @brief The function signature for Unicode character callbacks.
  694. *
  695. * This is the function signature for Unicode character callback functions.
  696. *
  697. * @param[in] window The window that received the event.
  698. * @param[in] character The Unicode code point of the character.
  699. *
  700. * @sa glfwSetCharCallback
  701. *
  702. * @ingroup input
  703. */
  704. typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
  705. /*! @brief The function signature for monitor configuration callbacks.
  706. *
  707. * This is the function signature for monitor configuration callback functions.
  708. *
  709. * @param[in] monitor The monitor that was connected or disconnected.
  710. * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.
  711. *
  712. * @sa glfwSetMonitorCallback
  713. *
  714. * @ingroup monitor
  715. */
  716. typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
  717. /*! @brief Video mode type.
  718. *
  719. * This describes a single video mode.
  720. *
  721. * @ingroup monitor
  722. */
  723. typedef struct
  724. {
  725. /*! The width, in screen coordinates, of the video mode.
  726. */
  727. int width;
  728. /*! The height, in screen coordinates, of the video mode.
  729. */
  730. int height;
  731. /*! The bit depth of the red channel of the video mode.
  732. */
  733. int redBits;
  734. /*! The bit depth of the green channel of the video mode.
  735. */
  736. int greenBits;
  737. /*! The bit depth of the blue channel of the video mode.
  738. */
  739. int blueBits;
  740. /*! The refresh rate, in Hz, of the video mode.
  741. */
  742. int refreshRate;
  743. } GLFWvidmode;
  744. /*! @brief Gamma ramp.
  745. *
  746. * This describes the gamma ramp for a monitor.
  747. *
  748. * @sa glfwGetGammaRamp glfwSetGammaRamp
  749. *
  750. * @ingroup monitor
  751. */
  752. typedef struct
  753. {
  754. /*! An array of value describing the response of the red channel.
  755. */
  756. unsigned short* red;
  757. /*! An array of value describing the response of the green channel.
  758. */
  759. unsigned short* green;
  760. /*! An array of value describing the response of the blue channel.
  761. */
  762. unsigned short* blue;
  763. /*! The number of elements in each array.
  764. */
  765. unsigned int size;
  766. } GLFWgammaramp;
  767. /*************************************************************************
  768. * GLFW API functions
  769. *************************************************************************/
  770. /*! @brief Initializes the GLFW library.
  771. *
  772. * This function initializes the GLFW library. Before most GLFW functions can
  773. * be used, GLFW must be initialized, and before a program terminates GLFW
  774. * should be terminated in order to free any resources allocated during or
  775. * after initialization.
  776. *
  777. * If this function fails, it calls @ref glfwTerminate before returning. If it
  778. * succeeds, you should call @ref glfwTerminate before the program exits.
  779. *
  780. * Additional calls to this function after successful initialization but before
  781. * termination will succeed but will do nothing.
  782. *
  783. * @return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred.
  784. *
  785. * @par New in GLFW 3
  786. * This function no longer registers @ref glfwTerminate with `atexit`.
  787. *
  788. * @note This function may only be called from the main thread.
  789. *
  790. * @note This function may take several seconds to complete on some systems,
  791. * while on other systems it may take only a fraction of a second to complete.
  792. *
  793. * @note **Mac OS X:** This function will change the current directory of the
  794. * application to the `Contents/Resources` subdirectory of the application's
  795. * bundle, if present.
  796. *
  797. * @sa glfwTerminate
  798. *
  799. * @ingroup init
  800. */
  801. GLFWAPI int glfwInit(void);
  802. /*! @brief Terminates the GLFW library.
  803. *
  804. * This function destroys all remaining windows, frees any allocated resources
  805. * and sets the library to an uninitialized state. Once this is called, you
  806. * must again call @ref glfwInit successfully before you will be able to use
  807. * most GLFW functions.
  808. *
  809. * If GLFW has been successfully initialized, this function should be called
  810. * before the program exits. If initialization fails, there is no need to call
  811. * this function, as it is called by @ref glfwInit before it returns failure.
  812. *
  813. * @remarks This function may be called before @ref glfwInit.
  814. *
  815. * @note This function may only be called from the main thread.
  816. *
  817. * @warning No window's context may be current on another thread when this
  818. * function is called.
  819. *
  820. * @sa glfwInit
  821. *
  822. * @ingroup init
  823. */
  824. GLFWAPI void glfwTerminate(void);
  825. /*! @brief Retrieves the version of the GLFW library.
  826. *
  827. * This function retrieves the major, minor and revision numbers of the GLFW
  828. * library. It is intended for when you are using GLFW as a shared library and
  829. * want to ensure that you are using the minimum required version.
  830. *
  831. * @param[out] major Where to store the major version number, or `NULL`.
  832. * @param[out] minor Where to store the minor version number, or `NULL`.
  833. * @param[out] rev Where to store the revision number, or `NULL`.
  834. *
  835. * @remarks This function may be called before @ref glfwInit.
  836. *
  837. * @remarks This function may be called from any thread.
  838. *
  839. * @sa glfwGetVersionString
  840. *
  841. * @ingroup init
  842. */
  843. GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
  844. /*! @brief Returns a string describing the compile-time configuration.
  845. *
  846. * This function returns a static string generated at compile-time according to
  847. * which configuration macros were defined. This is intended for use when
  848. * submitting bug reports, to allow developers to see which code paths are
  849. * enabled in a binary.
  850. *
  851. * The format of the string is as follows:
  852. * - The version of GLFW
  853. * - The name of the window system API
  854. * - The name of the context creation API
  855. * - Any additional options or APIs
  856. *
  857. * For example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL
  858. * back ends, the version string may look something like this:
  859. *
  860. * 3.0.0 Win32 WGL MinGW
  861. *
  862. * @return The GLFW version string.
  863. *
  864. * @remarks This function may be called before @ref glfwInit.
  865. *
  866. * @remarks This function may be called from any thread.
  867. *
  868. * @sa glfwGetVersion
  869. *
  870. * @ingroup init
  871. */
  872. GLFWAPI const char* glfwGetVersionString(void);
  873. /*! @brief Sets the error callback.
  874. *
  875. * This function sets the error callback, which is called with an error code
  876. * and a human-readable description each time a GLFW error occurs.
  877. *
  878. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  879. * callback.
  880. * @return The previously set callback, or `NULL` if no callback was set or an
  881. * error occurred.
  882. *
  883. * @remarks This function may be called before @ref glfwInit.
  884. *
  885. * @note The error callback is called by the thread where the error was
  886. * generated. If you are using GLFW from multiple threads, your error callback
  887. * needs to be written accordingly.
  888. *
  889. * @note Because the description string provided to the callback may have been
  890. * generated specifically for that error, it is not guaranteed to be valid
  891. * after the callback has returned. If you wish to use it after that, you need
  892. * to make your own copy of it before returning.
  893. *
  894. * @ingroup error
  895. */
  896. GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);
  897. /*! @brief Returns the currently connected monitors.
  898. *
  899. * This function returns an array of handles for all currently connected
  900. * monitors.
  901. *
  902. * @param[out] count Where to store the size of the returned array. This is
  903. * set to zero if an error occurred.
  904. * @return An array of monitor handles, or `NULL` if an error occurred.
  905. *
  906. * @note The returned array is allocated and freed by GLFW. You should not
  907. * free it yourself.
  908. *
  909. * @note The returned array is valid only until the monitor configuration
  910. * changes. See @ref glfwSetMonitorCallback to receive notifications of
  911. * configuration changes.
  912. *
  913. * @sa glfwGetPrimaryMonitor
  914. *
  915. * @ingroup monitor
  916. */
  917. GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
  918. /*! @brief Returns the primary monitor.
  919. *
  920. * This function returns the primary monitor. This is usually the monitor
  921. * where elements like the Windows task bar or the OS X menu bar is located.
  922. *
  923. * @return The primary monitor, or `NULL` if an error occurred.
  924. *
  925. * @sa glfwGetMonitors
  926. *
  927. * @ingroup monitor
  928. */
  929. GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
  930. /*! @brief Returns the position of the monitor's viewport on the virtual screen.
  931. *
  932. * This function returns the position, in screen coordinates, of the upper-left
  933. * corner of the specified monitor.
  934. *
  935. * @param[in] monitor The monitor to query.
  936. * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
  937. * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
  938. *
  939. * @ingroup monitor
  940. */
  941. GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
  942. /*! @brief Returns the physical size of the monitor.
  943. *
  944. * This function returns the size, in millimetres, of the display area of the
  945. * specified monitor.
  946. *
  947. * @param[in] monitor The monitor to query.
  948. * @param[out] width Where to store the width, in mm, of the monitor's display
  949. * area, or `NULL`.
  950. * @param[out] height Where to store the height, in mm, of the monitor's
  951. * display area, or `NULL`.
  952. *
  953. * @note Some operating systems do not provide accurate information, either
  954. * because the monitor's EDID data is incorrect, or because the driver does not
  955. * report it accurately.
  956. *
  957. * @ingroup monitor
  958. */
  959. GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* width, int* height);
  960. /*! @brief Returns the name of the specified monitor.
  961. *
  962. * This function returns a human-readable name, encoded as UTF-8, of the
  963. * specified monitor.
  964. *
  965. * @param[in] monitor The monitor to query.
  966. * @return The UTF-8 encoded name of the monitor, or `NULL` if an error
  967. * occurred.
  968. *
  969. * @note The returned string is allocated and freed by GLFW. You should not
  970. * free it yourself.
  971. *
  972. * @ingroup monitor
  973. */
  974. GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
  975. /*! @brief Sets the monitor configuration callback.
  976. *
  977. * This function sets the monitor configuration callback, or removes the
  978. * currently set callback. This is called when a monitor is connected to or
  979. * disconnected from the system.
  980. *
  981. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  982. * callback.
  983. * @return The previously set callback, or `NULL` if no callback was set or an
  984. * error occurred.
  985. *
  986. * @bug **X11:** This callback is not yet called on monitor configuration
  987. * changes.
  988. *
  989. * @ingroup monitor
  990. */
  991. GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);
  992. /*! @brief Returns the available video modes for the specified monitor.
  993. *
  994. * This function returns an array of all video modes supported by the specified
  995. * monitor. The returned array is sorted in ascending order, first by color
  996. * bit depth (the sum of all channel depths) and then by resolution area (the
  997. * product of width and height).
  998. *
  999. * @param[in] monitor The monitor to query.
  1000. * @param[out] count Where to store the number of video modes in the returned
  1001. * array. This is set to zero if an error occurred.
  1002. * @return An array of video modes, or `NULL` if an error occurred.
  1003. *
  1004. * @note The returned array is allocated and freed by GLFW. You should not
  1005. * free it yourself.
  1006. *
  1007. * @note The returned array is valid only until this function is called again
  1008. * for the specified monitor.
  1009. *
  1010. * @sa glfwGetVideoMode
  1011. *
  1012. * @ingroup monitor
  1013. */
  1014. GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
  1015. /*! @brief Returns the current mode of the specified monitor.
  1016. *
  1017. * This function returns the current video mode of the specified monitor. If
  1018. * you are using a full screen window, the return value will therefore depend
  1019. * on whether it is focused.
  1020. *
  1021. * @param[in] monitor The monitor to query.
  1022. * @return The current mode of the monitor, or `NULL` if an error occurred.
  1023. *
  1024. * @note The returned struct is allocated and freed by GLFW. You should not
  1025. * free it yourself.
  1026. *
  1027. * @sa glfwGetVideoModes
  1028. *
  1029. * @ingroup monitor
  1030. */
  1031. GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
  1032. /*! @brief Generates a gamma ramp and sets it for the specified monitor.
  1033. *
  1034. * This function generates a 256-element gamma ramp from the specified exponent
  1035. * and then calls @ref glfwSetGammaRamp with it.
  1036. *
  1037. * @param[in] monitor The monitor whose gamma ramp to set.
  1038. * @param[in] gamma The desired exponent.
  1039. *
  1040. * @ingroup monitor
  1041. */
  1042. GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
  1043. /*! @brief Retrieves the current gamma ramp for the specified monitor.
  1044. *
  1045. * This function retrieves the current gamma ramp of the specified monitor.
  1046. *
  1047. * @param[in] monitor The monitor to query.
  1048. * @return The current gamma ramp, or `NULL` if an error occurred.
  1049. *
  1050. * @note The value arrays of the returned ramp are allocated and freed by GLFW.
  1051. * You should not free them yourself.
  1052. *
  1053. * @ingroup monitor
  1054. */
  1055. GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
  1056. /*! @brief Sets the current gamma ramp for the specified monitor.
  1057. *
  1058. * This function sets the current gamma ramp for the specified monitor.
  1059. *
  1060. * @param[in] monitor The monitor whose gamma ramp to set.
  1061. * @param[in] ramp The gamma ramp to use.
  1062. *
  1063. * @note Gamma ramp sizes other than 256 are not supported by all hardware.
  1064. *
  1065. * @ingroup monitor
  1066. */
  1067. GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
  1068. /*! @brief Resets all window hints to their default values.
  1069. *
  1070. * This function resets all window hints to their
  1071. * [default values](@ref window_hints_values).
  1072. *
  1073. * @note This function may only be called from the main thread.
  1074. *
  1075. * @sa glfwWindowHint
  1076. *
  1077. * @ingroup window
  1078. */
  1079. GLFWAPI void glfwDefaultWindowHints(void);
  1080. /*! @brief Sets the specified window hint to the desired value.
  1081. *
  1082. * This function sets hints for the next call to @ref glfwCreateWindow. The
  1083. * hints, once set, retain their values until changed by a call to @ref
  1084. * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
  1085. * terminated with @ref glfwTerminate.
  1086. *
  1087. * @param[in] target The [window hint](@ref window_hints) to set.
  1088. * @param[in] hint The new value of the window hint.
  1089. *
  1090. * @par New in GLFW 3
  1091. * Hints are no longer reset to their default values on window creation. To
  1092. * set default hint values, use @ref glfwDefaultWindowHints.
  1093. *
  1094. * @note This function may only be called from the main thread.
  1095. *
  1096. * @sa glfwDefaultWindowHints
  1097. *
  1098. * @ingroup window
  1099. */
  1100. GLFWAPI void glfwWindowHint(int target, int hint);
  1101. /*! @brief Creates a window and its associated context.
  1102. *
  1103. * This function creates a window and its associated context. Most of the
  1104. * options controlling how the window and its context should be created are
  1105. * specified through @ref glfwWindowHint.
  1106. *
  1107. * Successful creation does not change which context is current. Before you
  1108. * can use the newly created context, you need to make it current using @ref
  1109. * glfwMakeContextCurrent.
  1110. *
  1111. * Note that the created window and context may differ from what you requested,
  1112. * as not all parameters and hints are
  1113. * [hard constraints](@ref window_hints_hard). This includes the size of the
  1114. * window, especially for full screen windows. To retrieve the actual
  1115. * attributes of the created window and context, use queries like @ref
  1116. * glfwGetWindowAttrib and @ref glfwGetWindowSize.
  1117. *
  1118. * To create a full screen window, you need to specify the monitor to use. If
  1119. * no monitor is specified, windowed mode will be used. Unless you have a way
  1120. * for the user to choose a specific monitor, it is recommended that you pick
  1121. * the primary monitor. For more information on how to retrieve monitors, see
  1122. * @ref monitor_monitors.
  1123. *
  1124. * To create the window at a specific position, make it initially invisible
  1125. * using the `GLFW_VISIBLE` window hint, set its position and then show it.
  1126. *
  1127. * If a full screen window is active, the screensaver is prohibited from
  1128. * starting.
  1129. *
  1130. * @param[in] width The desired width, in screen coordinates, of the window.
  1131. * This must be greater than zero.
  1132. * @param[in] height The desired height, in screen coordinates, of the window.
  1133. * This must be greater than zero.
  1134. * @param[in] title The initial, UTF-8 encoded window title.
  1135. * @param[in] monitor The monitor to use for full screen mode, or `NULL` to use
  1136. * windowed mode.
  1137. * @param[in] share The window whose context to share resources with, or `NULL`
  1138. * to not share resources.
  1139. * @return The handle of the created window, or `NULL` if an error occurred.
  1140. *
  1141. * @remarks **Windows:** If the executable has an icon resource named
  1142. * `GLFW_ICON,` it will be set as the icon for the window. If no such icon is
  1143. * present, the `IDI_WINLOGO` icon will be used instead.
  1144. *
  1145. * @remarks **Mac OS X:** The GLFW window has no icon, as it is not a document
  1146. * window, but the dock icon will be the same as the application bundle's icon.
  1147. * Also, the first time a window is opened the menu bar is populated with
  1148. * common commands like Hide, Quit and About. The (minimal) about dialog uses
  1149. * information from the application's bundle. For more information on bundles,
  1150. * see the Bundle Programming Guide provided by Apple.
  1151. *
  1152. * @note This function may only be called from the main thread.
  1153. *
  1154. * @sa glfwDestroyWindow
  1155. *
  1156. * @ingroup window
  1157. */
  1158. GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
  1159. /*! @brief Destroys the specified window and its context.
  1160. *
  1161. * This function destroys the specified window and its context. On calling
  1162. * this function, no further callbacks will be called for that window.
  1163. *
  1164. * @param[in] window The window to destroy.
  1165. *
  1166. * @note This function may only be called from the main thread.
  1167. *
  1168. * @note This function may not be called from a callback.
  1169. *
  1170. * @note If the window's context is current on the main thread, it is
  1171. * detached before being destroyed.
  1172. *
  1173. * @warning The window's context must not be current on any other thread.
  1174. *
  1175. * @sa glfwCreateWindow
  1176. *
  1177. * @ingroup window
  1178. */
  1179. GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
  1180. /*! @brief Checks the close flag of the specified window.
  1181. *
  1182. * This function returns the value of the close flag of the specified window.
  1183. *
  1184. * @param[in] window The window to query.
  1185. * @return The value of the close flag.
  1186. *
  1187. * @remarks This function may be called from secondary threads.
  1188. *
  1189. * @ingroup window
  1190. */
  1191. GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
  1192. /*! @brief Sets the close flag of the specified window.
  1193. *
  1194. * This function sets the value of the close flag of the specified window.
  1195. * This can be used to override the user's attempt to close the window, or
  1196. * to signal that it should be closed.
  1197. *
  1198. * @param[in] window The window whose flag to change.
  1199. * @param[in] value The new value.
  1200. *
  1201. * @remarks This function may be called from secondary threads.
  1202. *
  1203. * @ingroup window
  1204. */
  1205. GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
  1206. /*! @brief Sets the title of the specified window.
  1207. *
  1208. * This function sets the window title, encoded as UTF-8, of the specified
  1209. * window.
  1210. *
  1211. * @param[in] window The window whose title to change.
  1212. * @param[in] title The UTF-8 encoded window title.
  1213. *
  1214. * @note This function may only be called from the main thread.
  1215. *
  1216. * @ingroup window
  1217. */
  1218. GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
  1219. /*! @brief Retrieves the position of the client area of the specified window.
  1220. *
  1221. * This function retrieves the position, in screen coordinates, of the
  1222. * upper-left corner of the client area of the specified window.
  1223. *
  1224. * @param[in] window The window to query.
  1225. * @param[out] xpos Where to store the x-coordinate of the upper-left corner of
  1226. * the client area, or `NULL`.
  1227. * @param[out] ypos Where to store the y-coordinate of the upper-left corner of
  1228. * the client area, or `NULL`.
  1229. *
  1230. * @sa glfwSetWindowPos
  1231. *
  1232. * @ingroup window
  1233. */
  1234. GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
  1235. /*! @brief Sets the position of the client area of the specified window.
  1236. *
  1237. * This function sets the position, in screen coordinates, of the upper-left
  1238. * corner of the client area of the window.
  1239. *
  1240. * If the specified window is a full screen window, this function does nothing.
  1241. *
  1242. * If you wish to set an initial window position you should create a hidden
  1243. * window (using @ref glfwWindowHint and `GLFW_VISIBLE`), set its position and
  1244. * then show it.
  1245. *
  1246. * @param[in] window The window to query.
  1247. * @param[in] xpos The x-coordinate of the upper-left corner of the client area.
  1248. * @param[in] ypos The y-coordinate of the upper-left corner of the client area.
  1249. *
  1250. * @note It is very rarely a good idea to move an already visible window, as it
  1251. * will confuse and annoy the user.
  1252. *
  1253. * @note This function may only be called from the main thread.
  1254. *
  1255. * @note The window manager may put limits on what positions are allowed.
  1256. *
  1257. * @bug **X11:** Some window managers ignore the set position of hidden (i.e.
  1258. * unmapped) windows, instead placing them where it thinks is appropriate once
  1259. * they are shown.
  1260. *
  1261. * @sa glfwGetWindowPos
  1262. *
  1263. * @ingroup window
  1264. */
  1265. GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
  1266. /*! @brief Retrieves the size of the client area of the specified window.
  1267. *
  1268. * This function retrieves the size, in screen coordinates, of the client area
  1269. * of the specified window.
  1270. *
  1271. * @param[in] window The window whose size to retrieve.
  1272. * @param[out] width Where to store the width, in screen coordinates, of the
  1273. * client area, or `NULL`.
  1274. * @param[out] height Where to store the height, in screen coordinates, of the
  1275. * client area, or `NULL`.
  1276. *
  1277. * @sa glfwSetWindowSize
  1278. *
  1279. * @ingroup window
  1280. */
  1281. GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
  1282. /*! @brief Sets the size of the client area of the specified window.
  1283. *
  1284. * This function sets the size, in screen coordinates, of the client area of
  1285. * the specified window.
  1286. *
  1287. * For full screen windows, this function selects and switches to the resolution
  1288. * closest to the specified size, without affecting the window's context. As
  1289. * the context is unaffected, the bit depths of the framebuffer remain
  1290. * unchanged.
  1291. *
  1292. * @param[in] window The window to resize.
  1293. * @param[in] width The desired width of the specified window.
  1294. * @param[in] height The desired height of the specified window.
  1295. *
  1296. * @note This function may only be called from the main thread.
  1297. *
  1298. * @note The window manager may put limits on what window sizes are allowed.
  1299. *
  1300. * @sa glfwGetWindowSize
  1301. *
  1302. * @ingroup window
  1303. */
  1304. GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
  1305. /*! @brief Retrieves the size of the framebuffer of the specified window.
  1306. *
  1307. * This function retrieves the size, in pixels, of the framebuffer of the
  1308. * specified window.
  1309. *
  1310. * @param[in] window The window whose framebuffer to query.
  1311. * @param[out] width Where to store the width, in pixels, of the framebuffer,
  1312. * or `NULL`.
  1313. * @param[out] height Where to store the height, in pixels, of the framebuffer,
  1314. * or `NULL`.
  1315. *
  1316. * @sa glfwSetFramebufferSizeCallback
  1317. *
  1318. * @ingroup window
  1319. */
  1320. GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
  1321. /*! @brief Iconifies the specified window.
  1322. *
  1323. * This function iconifies/minimizes the specified window, if it was previously
  1324. * restored. If it is a full screen window, the original monitor resolution is
  1325. * restored until the window is restored. If the window is already iconified,
  1326. * this function does nothing.
  1327. *
  1328. * @param[in] window The window to iconify.
  1329. *
  1330. * @note This function may only be called from the main thread.
  1331. *
  1332. * @sa glfwRestoreWindow
  1333. *
  1334. * @ingroup window
  1335. */
  1336. GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
  1337. /*! @brief Restores the specified window.
  1338. *
  1339. * This function restores the specified window, if it was previously
  1340. * iconified/minimized. If it is a full screen window, the resolution chosen
  1341. * for the window is restored on the selected monitor. If the window is
  1342. * already restored, this function does nothing.
  1343. *
  1344. * @param[in] window The window to restore.
  1345. *
  1346. * @note This function may only be called from the main thread.
  1347. *
  1348. * @sa glfwIconifyWindow
  1349. *
  1350. * @ingroup window
  1351. */
  1352. GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
  1353. /*! @brief Makes the specified window visible.
  1354. *
  1355. * This function makes the specified window visible, if it was previously
  1356. * hidden. If the window is already visible or is in full screen mode, this
  1357. * function does nothing.
  1358. *
  1359. * @param[in] window The window to make visible.
  1360. *
  1361. * @note This function may only be called from the main thread.
  1362. *
  1363. * @sa glfwHideWindow
  1364. *
  1365. * @ingroup window
  1366. */
  1367. GLFWAPI void glfwShowWindow(GLFWwindow* window);
  1368. /*! @brief Hides the specified window.
  1369. *
  1370. * This function hides the specified window, if it was previously visible. If
  1371. * the window is already hidden or is in full screen mode, this function does
  1372. * nothing.
  1373. *
  1374. * @param[in] window The window to hide.
  1375. *
  1376. * @note This function may only be called from the main thread.
  1377. *
  1378. * @sa glfwShowWindow
  1379. *
  1380. * @ingroup window
  1381. */
  1382. GLFWAPI void glfwHideWindow(GLFWwindow* window);
  1383. /*! @brief Returns the monitor that the window uses for full screen mode.
  1384. *
  1385. * This function returns the handle of the monitor that the specified window is
  1386. * in full screen on.
  1387. *
  1388. * @param[in] window The window to query.
  1389. * @return The monitor, or `NULL` if the window is in windowed mode.
  1390. *
  1391. * @ingroup window
  1392. */
  1393. GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
  1394. /*! @brief Returns an attribute of the specified window.
  1395. *
  1396. * This function returns an attribute of the specified window. There are many
  1397. * attributes, some related to the window and others to its context.
  1398. *
  1399. * @param[in] window The window to query.
  1400. * @param[in] attrib The [window attribute](@ref window_attribs) whose value to
  1401. * return.
  1402. * @return The value of the attribute, or zero if an error occurred.
  1403. *
  1404. * @ingroup window
  1405. */
  1406. GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
  1407. /*! @brief Sets the user pointer of the specified window.
  1408. *
  1409. * This function sets the user-defined pointer of the specified window. The
  1410. * current value is retained until the window is destroyed. The initial value
  1411. * is `NULL`.
  1412. *
  1413. * @param[in] window The window whose pointer to set.
  1414. * @param[in] pointer The new value.
  1415. *
  1416. * @sa glfwGetWindowUserPointer
  1417. *
  1418. * @ingroup window
  1419. */
  1420. GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
  1421. /*! @brief Returns the user pointer of the specified window.
  1422. *
  1423. * This function returns the current value of the user-defined pointer of the
  1424. * specified window. The initial value is `NULL`.
  1425. *
  1426. * @param[in] window The window whose pointer to return.
  1427. *
  1428. * @sa glfwSetWindowUserPointer
  1429. *
  1430. * @ingroup window
  1431. */
  1432. GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
  1433. /*! @brief Sets the position callback for the specified window.
  1434. *
  1435. * This function sets the position callback of the specified window, which is
  1436. * called when the window is moved. The callback is provided with the screen
  1437. * position of the upper-left corner of the client area of the window.
  1438. *
  1439. * @param[in] window The window whose callback to set.
  1440. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1441. * callback.
  1442. * @return The previously set callback, or `NULL` if no callback was set or an
  1443. * error occurred.
  1444. *
  1445. * @ingroup window
  1446. */
  1447. GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);
  1448. /*! @brief Sets the size callback for the specified window.
  1449. *
  1450. * This function sets the size callback of the specified window, which is
  1451. * called when the window is resized. The callback is provided with the size,
  1452. * in screen coordinates, of the client area of the window.
  1453. *
  1454. * @param[in] window The window whose callback to set.
  1455. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1456. * callback.
  1457. * @return The previously set callback, or `NULL` if no callback was set or an
  1458. * error occurred.
  1459. *
  1460. * @ingroup window
  1461. */
  1462. GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);
  1463. /*! @brief Sets the close callback for the specified window.
  1464. *
  1465. * This function sets the close callback of the specified window, which is
  1466. * called when the user attempts to close the window, for example by clicking
  1467. * the close widget in the title bar.
  1468. *
  1469. * The close flag is set before this callback is called, but you can modify it
  1470. * at any time with @ref glfwSetWindowShouldClose.
  1471. *
  1472. * The close callback is not triggered by @ref glfwDestroyWindow.
  1473. *
  1474. * @param[in] window The window whose callback to set.
  1475. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1476. * callback.
  1477. * @return The previously set callback, or `NULL` if no callback was set or an
  1478. * error occurred.
  1479. *
  1480. * @remarks **Mac OS X:** Selecting Quit from the application menu will
  1481. * trigger the close callback for all windows.
  1482. *
  1483. * @ingroup window
  1484. */
  1485. GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);
  1486. /*! @brief Sets the refresh callback for the specified window.
  1487. *
  1488. * This function sets the refresh callback of the specified window, which is
  1489. * called when the client area of the window needs to be redrawn, for example
  1490. * if the window has been exposed after having been covered by another window.
  1491. *
  1492. * On compositing window systems such as Aero, Compiz or Aqua, where the window
  1493. * contents are saved off-screen, this callback may be called only very
  1494. * infrequently or never at all.
  1495. *
  1496. * @param[in] window The window whose callback to set.
  1497. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1498. * callback.
  1499. * @return The previously set callback, or `NULL` if no callback was set or an
  1500. * error occurred.
  1501. *
  1502. * @note On compositing window systems such as Aero, Compiz or Aqua, where the
  1503. * window contents are saved off-screen, this callback may be called only very
  1504. * infrequently or never at all.
  1505. *
  1506. * @ingroup window
  1507. */
  1508. GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);
  1509. /*! @brief Sets the focus callback for the specified window.
  1510. *
  1511. * This function sets the focus callback of the specified window, which is
  1512. * called when the window gains or loses focus.
  1513. *
  1514. * After the focus callback is called for a window that lost focus, synthetic
  1515. * key and mouse button release events will be generated for all such that had
  1516. * been pressed. For more information, see @ref glfwSetKeyCallback and @ref
  1517. * glfwSetMouseButtonCallback.
  1518. *
  1519. * @param[in] window The window whose callback to set.
  1520. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1521. * callback.
  1522. * @return The previously set callback, or `NULL` if no callback was set or an
  1523. * error occurred.
  1524. *
  1525. * @ingroup window
  1526. */
  1527. GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);
  1528. /*! @brief Sets the iconify callback for the specified window.
  1529. *
  1530. * This function sets the iconification callback of the specified window, which
  1531. * is called when the window is iconified or restored.
  1532. *
  1533. * @param[in] window The window whose callback to set.
  1534. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1535. * callback.
  1536. * @return The previously set callback, or `NULL` if no callback was set or an
  1537. * error occurred.
  1538. *
  1539. * @ingroup window
  1540. */
  1541. GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);
  1542. /*! @brief Sets the framebuffer resize callback for the specified window.
  1543. *
  1544. * This function sets the framebuffer resize callback of the specified window,
  1545. * which is called when the framebuffer of the specified window is resized.
  1546. *
  1547. * @param[in] window The window whose callback to set.
  1548. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1549. * callback.
  1550. * @return The previously set callback, or `NULL` if no callback was set or an
  1551. * error occurred.
  1552. *
  1553. * @ingroup window
  1554. */
  1555. GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
  1556. /*! @brief Processes all pending events.
  1557. *
  1558. * This function processes only those events that have already been received
  1559. * and then returns immediately. Processing events will cause the window and
  1560. * input callbacks associated with those events to be called.
  1561. *
  1562. * This function is not required for joystick input to work.
  1563. *
  1564. * @par New in GLFW 3
  1565. * This function is no longer called by @ref glfwSwapBuffers. You need to call
  1566. * it or @ref glfwWaitEvents yourself.
  1567. *
  1568. * @note This function may only be called from the main thread.
  1569. *
  1570. * @note This function may not be called from a callback.
  1571. *
  1572. * @note On some platforms, certain callbacks may be called outside of a call
  1573. * to one of the event processing functions.
  1574. *
  1575. * @sa glfwWaitEvents
  1576. *
  1577. * @ingroup window
  1578. */
  1579. GLFWAPI void glfwPollEvents(void);
  1580. /*! @brief Waits until events are pending and processes them.
  1581. *
  1582. * This function puts the calling thread to sleep until at least one event has
  1583. * been received. Once one or more events have been received, it behaves as if
  1584. * @ref glfwPollEvents was called, i.e. the events are processed and the
  1585. * function then returns immediately. Processing events will cause the window
  1586. * and input callbacks associated with those events to be called.
  1587. *
  1588. * Since not all events are associated with callbacks, this function may return
  1589. * without a callback having been called even if you are monitoring all
  1590. * callbacks.
  1591. *
  1592. * This function is not required for joystick input to work.
  1593. *
  1594. * @note This function may only be called from the main thread.
  1595. *
  1596. * @note This function may not be called from a callback.
  1597. *
  1598. * @note On some platforms, certain callbacks may be called outside of a call
  1599. * to one of the event processing functions.
  1600. *
  1601. * @sa glfwPollEvents
  1602. *
  1603. * @ingroup window
  1604. */
  1605. GLFWAPI void glfwWaitEvents(void);
  1606. /*! @brief Returns the value of an input option for the specified window.
  1607. *
  1608. * @param[in] window The window to query.
  1609. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  1610. * `GLFW_STICKY_MOUSE_BUTTONS`.
  1611. *
  1612. * @sa glfwSetInputMode
  1613. *
  1614. * @ingroup input
  1615. */
  1616. GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
  1617. /*! @brief Sets an input option for the specified window.
  1618. * @param[in] window The window whose input mode to set.
  1619. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
  1620. * `GLFW_STICKY_MOUSE_BUTTONS`.
  1621. * @param[in] value The new value of the specified input mode.
  1622. *
  1623. * If `mode` is `GLFW_CURSOR`, the value must be one of the supported input
  1624. * modes:
  1625. * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
  1626. * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client
  1627. * area of the window.
  1628. * - `GLFW_CURSOR_DISABLED` disables the cursor and removes any limitations on
  1629. * cursor movement.
  1630. *
  1631. * If `mode` is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to
  1632. * enable sticky keys, or `GL_FALSE` to disable it. If sticky keys are
  1633. * enabled, a key press will ensure that @ref glfwGetKey returns @ref
  1634. * GLFW_PRESS the next time it is called even if the key had been released
  1635. * before the call. This is useful when you are only interested in whether
  1636. * keys have been pressed but not when or in which order.
  1637. *
  1638. * If `mode` is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either `GL_TRUE`
  1639. * to enable sticky mouse buttons, or `GL_FALSE` to disable it. If sticky
  1640. * mouse buttons are enabled, a mouse button press will ensure that @ref
  1641. * glfwGetMouseButton returns @ref GLFW_PRESS the next time it is called even
  1642. * if the mouse button had been released before the call. This is useful when
  1643. * you are only interested in whether mouse buttons have been pressed but not
  1644. * when or in which order.
  1645. *
  1646. * @sa glfwGetInputMode
  1647. *
  1648. * @ingroup input
  1649. */
  1650. GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
  1651. /*! @brief Returns the last reported state of a keyboard key for the specified
  1652. * window.
  1653. *
  1654. * This function returns the last state reported for the specified key to the
  1655. * specified window. The returned state is one of `GLFW_PRESS` or
  1656. * `GLFW_RELEASE`. The higher-level state `GLFW_REPEAT` is only reported to
  1657. * the key callback.
  1658. *
  1659. * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns
  1660. * `GLFW_PRESS` the first time you call this function after a key has been
  1661. * pressed, even if the key has already been released.
  1662. *
  1663. * The key functions deal with physical keys, with [key tokens](@ref keys)
  1664. * named after their use on the standard US keyboard layout. If you want to
  1665. * input text, use the Unicode character callback instead.
  1666. *
  1667. * @param[in] window The desired window.
  1668. * @param[in] key The desired [keyboard key](@ref keys).
  1669. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  1670. *
  1671. * @note `GLFW_KEY_UNKNOWN` is not a valid key for this function.
  1672. *
  1673. * @ingroup input
  1674. */
  1675. GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
  1676. /*! @brief Returns the last reported state of a mouse button for the specified
  1677. * window.
  1678. *
  1679. * This function returns the last state reported for the specified mouse button
  1680. * to the specified window.
  1681. *
  1682. * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function
  1683. * returns `GLFW_PRESS` the first time you call this function after a mouse
  1684. * button has been pressed, even if the mouse button has already been released.
  1685. *
  1686. * @param[in] window The desired window.
  1687. * @param[in] button The desired [mouse button](@ref buttons).
  1688. * @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
  1689. *
  1690. * @ingroup input
  1691. */
  1692. GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
  1693. /*! @brief Retrieves the last reported cursor position, relative to the client
  1694. * area of the window.
  1695. *
  1696. * This function returns the last reported position of the cursor to the
  1697. * specified window.
  1698. *
  1699. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  1700. * position is unbounded and limited only by the minimum and maximum values of
  1701. * a `double`.
  1702. *
  1703. * The coordinate can be converted to their integer equivalents with the
  1704. * `floor` function. Casting directly to an integer type works for positive
  1705. * coordinates, but fails for negative ones.
  1706. *
  1707. * @param[in] window The desired window.
  1708. * @param[out] xpos Where to store the cursor x-coordinate, relative to the
  1709. * left edge of the client area, or `NULL`.
  1710. * @param[out] ypos Where to store the cursor y-coordinate, relative to the to
  1711. * top edge of the client area, or `NULL`.
  1712. *
  1713. * @sa glfwSetCursorPos
  1714. *
  1715. * @ingroup input
  1716. */
  1717. GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
  1718. /*! @brief Sets the position of the cursor, relative to the client area of the window.
  1719. *
  1720. * This function sets the position of the cursor. The specified window must be
  1721. * focused. If the window does not have focus when this function is called, it
  1722. * fails silently.
  1723. *
  1724. * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
  1725. * position is unbounded and limited only by the minimum and maximum values of
  1726. * a `double`.
  1727. *
  1728. * @param[in] window The desired window.
  1729. * @param[in] xpos The desired x-coordinate, relative to the left edge of the
  1730. * client area, or `NULL`.
  1731. * @param[in] ypos The desired y-coordinate, relative to the top edge of the
  1732. * client area, or `NULL`.
  1733. *
  1734. * @sa glfwGetCursorPos
  1735. *
  1736. * @ingroup input
  1737. */
  1738. GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
  1739. /*! @brief Sets the key callback.
  1740. *
  1741. * This function sets the key callback of the specific window, which is called
  1742. * when a key is pressed, repeated or released.
  1743. *
  1744. * The key functions deal with physical keys, with layout independent
  1745. * [key tokens](@ref keys) named after their values in the standard US keyboard
  1746. * layout. If you want to input text, use the
  1747. * [character callback](@ref glfwSetCharCallback) instead.
  1748. *
  1749. * When a window loses focus, it will generate synthetic key release events
  1750. * for all pressed keys. You can tell these events from user-generated events
  1751. * by the fact that the synthetic ones are generated after the window has lost
  1752. * focus, i.e. `GLFW_FOCUSED` will be false and the focus callback will have
  1753. * already been called.
  1754. *
  1755. * The scancode of a key is specific to that platform or sometimes even to that
  1756. * machine. Scancodes are intended to allow users to bind keys that don't have
  1757. * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
  1758. * state is not saved and so it cannot be retrieved with @ref glfwGetKey.
  1759. *
  1760. * Sometimes GLFW needs to generate synthetic key events, in which case the
  1761. * scancode may be zero.
  1762. *
  1763. * @param[in] window The window whose callback to set.
  1764. * @param[in] cbfun The new key callback, or `NULL` to remove the currently
  1765. * set callback.
  1766. * @return The previously set callback, or `NULL` if no callback was set or an
  1767. * error occurred.
  1768. *
  1769. * @ingroup input
  1770. */
  1771. GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);
  1772. /*! @brief Sets the Unicode character callback.
  1773. *
  1774. * This function sets the character callback of the specific window, which is
  1775. * called when a Unicode character is input.
  1776. *
  1777. * The character callback is intended for text input. If you want to know
  1778. * whether a specific key was pressed or released, use the
  1779. * [key callback](@ref glfwSetKeyCallback) instead.
  1780. *
  1781. * @param[in] window The window whose callback to set.
  1782. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1783. * callback.
  1784. * @return The previously set callback, or `NULL` if no callback was set or an
  1785. * error occurred.
  1786. *
  1787. * @ingroup input
  1788. */
  1789. GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);
  1790. /*! @brief Sets the mouse button callback.
  1791. *
  1792. * This function sets the mouse button callback of the specified window, which
  1793. * is called when a mouse button is pressed or released.
  1794. *
  1795. * When a window loses focus, it will generate synthetic mouse button release
  1796. * events for all pressed mouse buttons. You can tell these events from
  1797. * user-generated events by the fact that the synthetic ones are generated
  1798. * after the window has lost focus, i.e. `GLFW_FOCUSED` will be false and the
  1799. * focus callback will have already been called.
  1800. *
  1801. * @param[in] window The window whose callback to set.
  1802. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1803. * callback.
  1804. * @return The previously set callback, or `NULL` if no callback was set or an
  1805. * error occurred.
  1806. *
  1807. * @ingroup input
  1808. */
  1809. GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);
  1810. /*! @brief Sets the cursor position callback.
  1811. *
  1812. * This function sets the cursor position callback of the specified window,
  1813. * which is called when the cursor is moved. The callback is provided with the
  1814. * position relative to the upper-left corner of the client area of the window.
  1815. *
  1816. * @param[in] window The window whose callback to set.
  1817. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1818. * callback.
  1819. * @return The previously set callback, or `NULL` if no callback was set or an
  1820. * error occurred.
  1821. *
  1822. * @ingroup input
  1823. */
  1824. GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);
  1825. /*! @brief Sets the cursor enter/exit callback.
  1826. *
  1827. * This function sets the cursor boundary crossing callback of the specified
  1828. * window, which is called when the cursor enters or leaves the client area of
  1829. * the window.
  1830. *
  1831. * @param[in] window The window whose callback to set.
  1832. * @param[in] cbfun The new callback, or `NULL` to remove the currently set
  1833. * callback.
  1834. * @return The previously set callback, or `NULL` if no callback was set or an
  1835. * error occurred.
  1836. *
  1837. * @ingroup input
  1838. */
  1839. GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);
  1840. /*! @brief Sets the scroll callback.
  1841. *
  1842. * This function sets the scroll callback of the specified window, which is
  1843. * called when a scrolling device is used, such as a mouse wheel or scrolling
  1844. * area of a touchpad.
  1845. *
  1846. * The scroll callback receives all scrolling input, like that from a mouse
  1847. * wheel or a touchpad scrolling area.
  1848. *
  1849. * @param[in] window The window whose callback to set.
  1850. * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently
  1851. * set callback.
  1852. * @return The previously set callback, or `NULL` if no callback was set or an
  1853. * error occurred.
  1854. *
  1855. * @ingroup input
  1856. */
  1857. GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);
  1858. /*! @brief Returns whether the specified joystick is present.
  1859. *
  1860. * This function returns whether the specified joystick is present.
  1861. *
  1862. * @param[in] joy The joystick to query.
  1863. * @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise.
  1864. *
  1865. * @ingroup input
  1866. */
  1867. GLFWAPI int glfwJoystickPresent(int joy);
  1868. /*! @brief Returns the values of all axes of the specified joystick.
  1869. *
  1870. * This function returns the values of all axes of the specified joystick.
  1871. *
  1872. * @param[in] joy The joystick to query.
  1873. * @param[out] count Where to store the size of the returned array. This is
  1874. * set to zero if an error occurred.
  1875. * @return An array of axis values, or `NULL` if the joystick is not present.
  1876. *
  1877. * @note The returned array is allocated and freed by GLFW. You should not
  1878. * free it yourself.
  1879. *
  1880. * @note The returned array is valid only until the next call to @ref
  1881. * glfwGetJoystickAxes for that joystick.
  1882. *
  1883. * @ingroup input
  1884. */
  1885. GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count);
  1886. /*! @brief Returns the state of all buttons of the specified joystick.
  1887. *
  1888. * This function returns the state of all buttons of the specified joystick.
  1889. *
  1890. * @param[in] joy The joystick to query.
  1891. * @param[out] count Where to store the size of the returned array. This is
  1892. * set to zero if an error occurred.
  1893. * @return An array of button states, or `NULL` if the joystick is not present.
  1894. *
  1895. * @note The returned array is allocated and freed by GLFW. You should not
  1896. * free it yourself.
  1897. *
  1898. * @note The returned array is valid only until the next call to @ref
  1899. * glfwGetJoystickButtons for that joystick.
  1900. *
  1901. * @ingroup input
  1902. */
  1903. GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count);
  1904. /*! @brief Returns the name of the specified joystick.
  1905. *
  1906. * This function returns the name, encoded as UTF-8, of the specified joystick.
  1907. *
  1908. * @param[in] joy The joystick to query.
  1909. * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
  1910. * is not present.
  1911. *
  1912. * @note The returned string is allocated and freed by GLFW. You should not
  1913. * free it yourself.
  1914. *
  1915. * @note The returned string is valid only until the next call to @ref
  1916. * glfwGetJoystickName for that joystick.
  1917. *
  1918. * @ingroup input
  1919. */
  1920. GLFWAPI const char* glfwGetJoystickName(int joy);
  1921. /*! @brief Sets the clipboard to the specified string.
  1922. *
  1923. * This function sets the system clipboard to the specified, UTF-8 encoded
  1924. * string. The string is copied before returning, so you don't have to retain
  1925. * it afterwards.
  1926. *
  1927. * @param[in] window The window that will own the clipboard contents.
  1928. * @param[in] string A UTF-8 encoded string.
  1929. *
  1930. * @note This function may only be called from the main thread.
  1931. *
  1932. * @sa glfwGetClipboardString
  1933. *
  1934. * @ingroup clipboard
  1935. */
  1936. GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
  1937. /*! @brief Retrieves the contents of the clipboard as a string.
  1938. *
  1939. * This function returns the contents of the system clipboard, if it contains
  1940. * or is convertible to a UTF-8 encoded string.
  1941. *
  1942. * @param[in] window The window that will request the clipboard contents.
  1943. * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
  1944. * if an error occurred.
  1945. *
  1946. * @note This function may only be called from the main thread.
  1947. *
  1948. * @note The returned string is allocated and freed by GLFW. You should not
  1949. * free it yourself.
  1950. *
  1951. * @note The returned string is valid only until the next call to @ref
  1952. * glfwGetClipboardString or @ref glfwSetClipboardString.
  1953. *
  1954. * @sa glfwSetClipboardString
  1955. *
  1956. * @ingroup clipboard
  1957. */
  1958. GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
  1959. /*! @brief Returns the value of the GLFW timer.
  1960. *
  1961. * This function returns the value of the GLFW timer. Unless the timer has
  1962. * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW
  1963. * was initialized.
  1964. *
  1965. * @return The current value, in seconds, or zero if an error occurred.
  1966. *
  1967. * @remarks This function may be called from secondary threads.
  1968. *
  1969. * @note The resolution of the timer is system dependent, but is usually on the
  1970. * order of a few micro- or nanoseconds. It uses the highest-resolution
  1971. * monotonic time source on each supported platform.
  1972. *
  1973. * @ingroup time
  1974. */
  1975. GLFWAPI double glfwGetTime(void);
  1976. /*! @brief Sets the GLFW timer.
  1977. *
  1978. * This function sets the value of the GLFW timer. It then continues to count
  1979. * up from that value.
  1980. *
  1981. * @param[in] time The new value, in seconds.
  1982. *
  1983. * @note The resolution of the timer is system dependent, but is usually on the
  1984. * order of a few micro- or nanoseconds. It uses the highest-resolution
  1985. * monotonic time source on each supported platform.
  1986. *
  1987. * @ingroup time
  1988. */
  1989. GLFWAPI void glfwSetTime(double time);
  1990. /*! @brief Makes the context of the specified window current for the calling
  1991. * thread.
  1992. *
  1993. * This function makes the context of the specified window current on the
  1994. * calling thread. A context can only be made current on a single thread at
  1995. * a time and each thread can have only a single current context at a time.
  1996. *
  1997. * @param[in] window The window whose context to make current, or `NULL` to
  1998. * detach the current context.
  1999. *
  2000. * @remarks This function may be called from secondary threads.
  2001. *
  2002. * @sa glfwGetCurrentContext
  2003. *
  2004. * @ingroup context
  2005. */
  2006. GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
  2007. /*! @brief Returns the window whose context is current on the calling thread.
  2008. *
  2009. * This function returns the window whose context is current on the calling
  2010. * thread.
  2011. *
  2012. * @return The window whose context is current, or `NULL` if no window's
  2013. * context is current.
  2014. *
  2015. * @remarks This function may be called from secondary threads.
  2016. *
  2017. * @sa glfwMakeContextCurrent
  2018. *
  2019. * @ingroup context
  2020. */
  2021. GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
  2022. /*! @brief Swaps the front and back buffers of the specified window.
  2023. *
  2024. * This function swaps the front and back buffers of the specified window. If
  2025. * the swap interval is greater than zero, the GPU driver waits the specified
  2026. * number of screen updates before swapping the buffers.
  2027. *
  2028. * @param[in] window The window whose buffers to swap.
  2029. *
  2030. * @remarks This function may be called from secondary threads.
  2031. *
  2032. * @par New in GLFW 3
  2033. * This function no longer calls @ref glfwPollEvents. You need to call it or
  2034. * @ref glfwWaitEvents yourself.
  2035. *
  2036. * @sa glfwSwapInterval
  2037. *
  2038. * @ingroup context
  2039. */
  2040. GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
  2041. /*! @brief Sets the swap interval for the current context.
  2042. *
  2043. * This function sets the swap interval for the current context, i.e. the
  2044. * number of screen updates to wait before swapping the buffers of a window and
  2045. * returning from @ref glfwSwapBuffers. This is sometimes called 'vertical
  2046. * synchronization', 'vertical retrace synchronization' or 'vsync'.
  2047. *
  2048. * Contexts that support either of the `WGL_EXT_swap_control_tear` and
  2049. * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,
  2050. * which allow the driver to swap even if a frame arrives a little bit late.
  2051. * You can check for the presence of these extensions using @ref
  2052. * glfwExtensionSupported. For more information about swap tearing, see the
  2053. * extension specifications.
  2054. *
  2055. * @param[in] interval The minimum number of screen updates to wait for
  2056. * until the buffers are swapped by @ref glfwSwapBuffers.
  2057. *
  2058. * @remarks This function may be called from secondary threads.
  2059. *
  2060. * @note Some GPU drivers do not honor the requested swap interval, either
  2061. * because of user settings that override the request or due to bugs in the
  2062. * driver.
  2063. *
  2064. * @sa glfwSwapBuffers
  2065. *
  2066. * @ingroup context
  2067. */
  2068. GLFWAPI void glfwSwapInterval(int interval);
  2069. /*! @brief Returns whether the specified extension is available.
  2070. *
  2071. * This function returns whether the specified
  2072. * [OpenGL or context creation API extension](@ref context_glext) is supported
  2073. * by the current context. For example, on Windows both the OpenGL and WGL
  2074. * extension strings are checked.
  2075. *
  2076. * @param[in] extension The ASCII encoded name of the extension.
  2077. * @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise.
  2078. *
  2079. * @remarks This function may be called from secondary threads.
  2080. *
  2081. * @note As this functions searches one or more extension strings on each call,
  2082. * it is recommended that you cache its results if it's going to be used
  2083. * frequently. The extension strings will not change during the lifetime of
  2084. * a context, so there is no danger in doing this.
  2085. *
  2086. * @ingroup context
  2087. */
  2088. GLFWAPI int glfwExtensionSupported(const char* extension);
  2089. /*! @brief Returns the address of the specified function for the current
  2090. * context.
  2091. *
  2092. * This function returns the address of the specified
  2093. * [client API or extension function](@ref context_glext), if it is supported
  2094. * by the current context.
  2095. *
  2096. * @param[in] procname The ASCII encoded name of the function.
  2097. * @return The address of the function, or `NULL` if the function is
  2098. * unavailable.
  2099. *
  2100. * @remarks This function may be called from secondary threads.
  2101. *
  2102. * @note The addresses of these functions are not guaranteed to be the same for
  2103. * all contexts, especially if they use different client APIs or even different
  2104. * context creation hints.
  2105. *
  2106. * @ingroup context
  2107. */
  2108. GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
  2109. /*************************************************************************
  2110. * Global definition cleanup
  2111. *************************************************************************/
  2112. /* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
  2113. #ifdef GLFW_WINGDIAPI_DEFINED
  2114. #undef WINGDIAPI
  2115. #undef GLFW_WINGDIAPI_DEFINED
  2116. #endif
  2117. #ifdef GLFW_CALLBACK_DEFINED
  2118. #undef CALLBACK
  2119. #undef GLFW_CALLBACK_DEFINED
  2120. #endif
  2121. /* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
  2122. #ifdef __cplusplus
  2123. }
  2124. #endif
  2125. #endif /* _glfw3_h_ */