├── .DS_Store ├── .gitattributes ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── bun.lockb ├── glfw.ts ├── index.ts ├── lib ├── glfw3.dll └── libglfw.3.dylib ├── package.json └── tsconfig.json /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HazyVT/BunGLFW/d977d3fdaca573f91658f220b78651811ede64e3/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Serverless directories 108 | .serverless/ 109 | 110 | # FuseBox cache 111 | .fusebox/ 112 | 113 | # DynamoDB Local files 114 | .dynamodb/ 115 | 116 | # TernJS port file 117 | .tern-port 118 | 119 | # Stores VSCode versions used for testing VSCode extensions 120 | .vscode-test 121 | 122 | # yarn v2 123 | .yarn/cache 124 | .yarn/unplugged 125 | .yarn/build-state.yml 126 | .yarn/install-state.gz 127 | .pnp.* 128 | 129 | main.ts 130 | 131 | /dist 132 | 133 | .vscode -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "disabled" 3 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Mohammed Salim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BunGLFW 2 | 3 | Typescript bindings for bun. No installation needed. 4 | 5 | To install please use 6 | ```node 7 | bun install bunglfw 8 | ``` 9 | 10 | Here is an example of some code 11 | 12 | ```ts 13 | import { 14 | glfwSetKeyCallback, 15 | GLFW_FALSE, 16 | GLFW_MAXIMIZED, 17 | GLFW_RESIZABLE, 18 | GLFW_TRUE, 19 | GLFW_VISIBLE, 20 | glfwCreateWindow, 21 | glfwInit, 22 | glfwMakeContextCurrent, 23 | glfwPollEvents, 24 | glfwSetErrorCallback, 25 | glfwShowWindow, 26 | glfwSwapBuffers, 27 | glfwSwapInterval, 28 | glfwWindowHint, 29 | glfwWindowShouldClose, 30 | GLFW_PRESS, 31 | GLFW_KEY_ESCAPE, 32 | glfwSetWindowShouldClose, 33 | glfw_error_codes, 34 | glfwDefaultWindowHints, 35 | type GLFWkeyfun, type glfwWindow, 36 | } from "bunglfw"; 37 | 38 | if (!glfwInit()) { 39 | throw new Error("GLFW Failed to initialize"); 40 | } 41 | 42 | const error_call = (error_code: number, description: string) => { 43 | [...glfw_error_codes.keys()].forEach((key) => { 44 | if (glfw_error_codes.get(key) == error_code) { 45 | console.error(key); 46 | } 47 | }) 48 | } 49 | 50 | let controls: GLFWkeyfun = (window: glfwWindow, key: number, scancode: number, action: number, mods: number) => { 51 | if (action == GLFW_PRESS) { 52 | if (key == GLFW_KEY_ESCAPE) { 53 | glfwSetWindowShouldClose(window, GLFW_TRUE); 54 | } 55 | } 56 | } 57 | 58 | glfwDefaultWindowHints(); 59 | glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); 60 | glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); 61 | glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); 62 | 63 | const window = glfwCreateWindow(640, 480, "Hello World", null, null); 64 | 65 | 66 | glfwSetKeyCallback(window, controls) 67 | glfwSetErrorCallback(error_call); 68 | 69 | glfwMakeContextCurrent(window); 70 | 71 | glfwSwapInterval(1); 72 | glfwShowWindow(window); 73 | 74 | while (!glfwWindowShouldClose(window)) { 75 | glfwPollEvents(); 76 | 77 | glfwSwapBuffers(window); 78 | } 79 | ``` -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HazyVT/BunGLFW/d977d3fdaca573f91658f220b78651811ede64e3/bun.lockb -------------------------------------------------------------------------------- /glfw.ts: -------------------------------------------------------------------------------- 1 | import { dlopen, suffix, FFIType } from "bun:ffi"; 2 | 3 | const platform = process.platform; 4 | let path: string = ""; 5 | 6 | if (platform == "darwin") { 7 | path = import.meta.dir + `/lib/libglfw.3.${suffix}`; 8 | } else if (platform == "win32") { 9 | path = import.meta.dir + `/lib/glfw3.${suffix}`; 10 | } 11 | 12 | export const lib = dlopen(path, { 13 | glfwInit: { 14 | returns: "bool" 15 | }, 16 | glfwSetErrorCallback: { 17 | args: [FFIType.function], 18 | returns: "ptr" 19 | }, 20 | glfwCreateWindow: { 21 | args: ["int", "int", "cstring", "ptr", "ptr"], 22 | returns: ["ptr"] 23 | }, 24 | glfwMakeContextCurrent: { 25 | args: ["ptr"], 26 | returns: "void" 27 | }, 28 | glfwShowWindow: { 29 | args: ["ptr"], 30 | returns: "void" 31 | }, 32 | glfwWindowShouldClose: { 33 | args: ["ptr"], 34 | returns: "bool" 35 | }, 36 | glfwPollEvents: { 37 | returns: "void" 38 | }, 39 | glfwSwapBuffers: { 40 | args: ["ptr"], 41 | returns: "void" 42 | }, 43 | glfwSwapInterval: { 44 | args: ["int"], 45 | returns: "void" 46 | }, 47 | glfwGetProcAddress: { 48 | args: ["cstring"], 49 | returns: "ptr" 50 | }, 51 | glfwGetWindowAttrib: { 52 | args: ["ptr", "int"], 53 | returns: "bool" 54 | }, 55 | glfwDestroyWindow: { 56 | args: ["ptr"], 57 | returns: "void" 58 | }, 59 | glfwTerminate: { 60 | returns: "void" 61 | }, 62 | glfwDefaultWindowHints: { 63 | args: [], 64 | returns: "void" 65 | }, 66 | glfwWindowHint: { 67 | args: ["int", "int"], 68 | returns: "void" 69 | }, 70 | glfwInitHint: { 71 | args: ["int", "int"], 72 | returns: "void" 73 | }, 74 | glfwGetError: { 75 | args: ["cstring"], 76 | returns: "int" 77 | }, 78 | glfwWindowHintString: { 79 | args: ["int", "cstring"], 80 | returns: "void" 81 | }, 82 | glfwSetWindowShouldClose: { 83 | args: ["ptr", "int"], 84 | returns: "void" 85 | }, 86 | glfwSetWindowTitle: { 87 | args: ["ptr", "cstring"], 88 | returns: "void" 89 | }, 90 | glfwSetWindowPos: { 91 | args: ["ptr", "int", "int"], 92 | returns: "void" 93 | }, 94 | glfwSetWindowSize: { 95 | args: ["ptr", "int", "int"], 96 | returns: "void" 97 | }, 98 | glfwSetWindowSizeLimits: { 99 | args: ["ptr", "int", "int", "int", "int"], 100 | returns: "void" 101 | }, 102 | glfwSetWindowAspectRatio: { 103 | args: ["ptr", "int", "int"], 104 | returns: "void" 105 | }, 106 | glfwGetWindowOpacity: { 107 | args: ["ptr"], 108 | returns: "float" 109 | }, 110 | glfwSetWindowOpacity: { 111 | args: ["ptr"], 112 | returns: "void" 113 | }, 114 | glfwIconifyWindow: { 115 | args: ["ptr"], 116 | returns: "void" 117 | }, 118 | glfwRestoreWindow: { 119 | args: ["ptr"], 120 | returns: "void" 121 | }, 122 | glfwMaximizeWindow: { 123 | args: ["ptr"], 124 | returns: "void" 125 | }, 126 | glfwHideWindow: { 127 | args: ["ptr"], 128 | returns: "void" 129 | }, 130 | glfwFocusWindow: { 131 | args: ["ptr"], 132 | returns: "void" 133 | }, 134 | glfwRequestWindowAttention: { 135 | args: ["ptr"], 136 | returns: "void" 137 | }, 138 | glfwGetWindowMonitor: { 139 | args: ["ptr"], 140 | returns: "ptr" 141 | }, 142 | glfwSetWindowMonitor: { 143 | args: ["ptr", "ptr", "int", "int", "int", "int", "int"], 144 | returns: "void" 145 | }, 146 | glfwSetWindowAttrib: { 147 | args: ["ptr", "int", "int"], 148 | returns: "void" 149 | }, 150 | glfwWaitEvents: { 151 | args: [], 152 | returns: "void" 153 | }, 154 | glfwWaitEventsTimeout: { 155 | args: ["double"], 156 | returns: "void" 157 | }, 158 | glfwPostEmptyEvent: { 159 | args: [], 160 | returns: "void" 161 | }, 162 | glfwSetWindowPosCallback: { 163 | args: ["ptr", FFIType.function], 164 | returns: "ptr" 165 | }, 166 | glfwSetWindowSizeCallback: { 167 | args: ["ptr", FFIType.function], 168 | returns: "ptr" 169 | }, 170 | glfwSetWindowCloseCallback: { 171 | args: ["ptr", FFIType.function], 172 | returns: "ptr" 173 | }, 174 | glfwSetWindowRefreshCallback: { 175 | args: ["ptr", FFIType.function], 176 | returns: "ptr" 177 | }, 178 | glfwSetWindowFocusCallback: { 179 | args: ["ptr", FFIType.function], 180 | returns: "ptr" 181 | }, 182 | glfwSetWindowIconifyCallback: { 183 | args: ["ptr", FFIType.function], 184 | returns: "ptr" 185 | }, 186 | glfwSetWindowMaximizeCallback: { 187 | args: ["ptr", FFIType.function], 188 | returns: "ptr" 189 | }, 190 | glfwSetFramebufferSizeCallback: { 191 | args: ["ptr", FFIType.function], 192 | returns: "ptr" 193 | }, 194 | glfwSetWindowContentScaleCallback: { 195 | args: ["ptr", FFIType.function], 196 | returns: "ptr" 197 | }, 198 | glfwSetKeyCallback: { 199 | args: ['ptr', FFIType.function], 200 | returns: "ptr" 201 | }, 202 | glfwSetCharCallback: { 203 | args: ['ptr', FFIType.function], 204 | returns: "ptr" 205 | }, 206 | glfwSetCharModsCallback: { 207 | args: ['ptr', FFIType.function], 208 | returns: "ptr" 209 | }, 210 | glfwSetMouseButtonCallback: { 211 | args: ['ptr', FFIType.function], 212 | returns: "ptr" 213 | }, 214 | glfwSetScrollCallback: { 215 | args: ['ptr', FFIType.function], 216 | returns: "ptr" 217 | }, 218 | glfwSetJoystickCallback: { 219 | args: ['ptr', FFIType.function], 220 | returns: "ptr" 221 | }, 222 | glfwSetCursorPosCallback: { 223 | args: ['ptr', FFIType.function], 224 | returns: "ptr" 225 | }, 226 | glfwSetCursorEnterCallback: { 227 | args: ["ptr", FFIType.function], 228 | returns: "ptr" 229 | }, 230 | glfwGetInputMode: { 231 | args: ["ptr", "int"], 232 | returns: "int" 233 | }, 234 | glfwSetInputMode: { 235 | args: ["ptr", "int", "int"], 236 | returns: "void" 237 | }, 238 | glfwRawMouseMotionSupported: { 239 | returns: "int" 240 | }, 241 | glfwGetKeyName: { 242 | args: ["int", "int"], 243 | returns: "cstring" 244 | }, 245 | glfwGetKeyScancode: { 246 | args: ["int"], 247 | returns: "int" 248 | }, 249 | glfwGetKey: { 250 | args: ["ptr", "int"], 251 | returns: "int" 252 | }, 253 | glfwGetMouseButton: { 254 | args: ["ptr", "int"], 255 | returns: 'int' 256 | }, 257 | glfwSetCursorPos: { 258 | args: ["ptr", "int", "int"], 259 | returns: "void" 260 | }, 261 | glfwJoystickPresent: { 262 | args: ["int"], 263 | returns: "int" 264 | }, 265 | glfwGetJoystickName: { 266 | args: ["int"], 267 | returns: "cstring" 268 | }, 269 | glfwJoystickIsGamepad: { 270 | args: ["int"], 271 | returns: "bool" 272 | }, 273 | glfwGetTime: { 274 | args: [], 275 | returns: "double" 276 | }, 277 | glfwSetTime: { 278 | args: ["double"], 279 | returns: "void" 280 | }, 281 | glfwGetTimerValue: { 282 | args: [], 283 | returns: "uint64_t" 284 | }, 285 | glfwGetTimerFrequency: { 286 | args: [], 287 | returns: "uint64_t" 288 | }, 289 | glfwGetCursorPos: { 290 | args: ["ptr", "ptr", "ptr"], 291 | returns: "int" 292 | }, 293 | 294 | 295 | 296 | 297 | }) -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | import { ptr, JSCallback, CFunction, FFIType, type Pointer } from 'bun:ffi' 2 | import { lib } from "./glfw" 3 | 4 | // GLFW window vairables 5 | export const GLFW_FOCUSED = 0x00020001 6 | export const GLFW_ICONIFIED = 0x00020002 7 | export const GLFW_RESIZABLE = 0x00020003 8 | export const GLFW_VISIBLE = 0x00020004 9 | export const GLFW_DECORATED = 0x00020005 10 | export const GLFW_AUTO_ICONIFY = 0x00020006 11 | export const GLFW_FLOATING = 0x00020007 12 | export const GLFW_MAXIMIZED = 0x00020008 13 | export const GLFW_CENTER_CURSOR = 0x00020009 14 | export const GLFW_TRANSPARENT_FRAMEBUFFER = 0x0002000A 15 | export const GLFW_HOVERED = 0x0002000B 16 | export const GLFW_FOCUS_ON_SHOW = 0x0002000C 17 | export const GLFW_RED_BITS = 0x00021001 18 | export const GLFW_GREEN_BITS = 0x00021002 19 | export const GLFW_BLUE_BITS = 0x00021003 20 | export const GLFW_ALPHA_BITS = 0x00021004 21 | export const GLFW_DEPTH_BITS = 0x00021005 22 | export const GLFW_STENCIL_BITS = 0x00021006 23 | export const GLFW_ACCUM_RED_BITS = 0x00021007 24 | export const GLFW_ACCUM_GREEN_BITS = 0x00021008 25 | export const GLFW_ACCUM_BLUE_BITS = 0x00021009 26 | export const GLFW_ACCUM_ALPHA_BITS = 0x0002100A 27 | export const GLFW_AUX_BUFFERS = 0x0002100B 28 | export const GLFW_STEREO = 0x0002100C 29 | export const GLFW_SAMPLES = 0x0002100D 30 | export const GLFW_SRGB_CAPABLE = 0x0002100E 31 | export const GLFW_REFRESH_RATE = 0x0002100F 32 | export const GLFW_DOUBLEBUFFER = 0x00021010 33 | export const GLFW_CLIENT_API = 0x00022001 34 | export const GLFW_CONTEXT_VERSION_MAJOR = 0x00022002 35 | export const GLFW_CONTEXT_VERSION_MINOR = 0x00022003 36 | export const GLFW_CONTEXT_REVISION = 0x00022004 37 | export const GLFW_CONTEXT_ROBUSTNESS = 0x00022005 38 | export const GLFW_OPENGL_FORWARD_COMPAT = 0x00022006 39 | export const GLFW_OPENGL_DEBUG_CONTEXT = 0x00022007 40 | export const GLFW_OPENGL_PROFILE = 0x00022008 41 | export const GLFW_CONTEXT_RELEASE_BEHAVIOR = 0x00022009 42 | export const GLFW_CONTEXT_NO_ERROR = 0x0002200A 43 | export const GLFW_CONTEXT_CREATION_API = 0x0002200B 44 | export const GLFW_SCALE_TO_MONITOR = 0x0002200C 45 | export const GLFW_COCOA_RETINA_FRAMEBUFFER = 0x00023001 46 | export const GLFW_COCOA_FRAME_NAME = 0x00023002 47 | export const GLFW_COCOA_GRAPHICS_SWITCHING = 0x00023003 48 | export const GLFW_X11_CLASS_NAME = 0x00024001 49 | export const GLFW_X11_INSTANCE_NAME = 0x00024002 50 | 51 | // GLFW global variables 52 | export const GLFW_TRUE = 1; 53 | export const GLFW_FALSE = 0; 54 | export const GLFW_RELEASE = 0; 55 | export const GLFW_PRESS = 1; 56 | export const GLFW_REPEAT = 2; 57 | 58 | // GLFW joystick hat states 59 | export const GLFW_HAT_CENTERED = 0; 60 | export const GLFW_HAT_UP = 1; 61 | export const GLFW_HAT_RIGHT = 2; 62 | export const GLFW_HAT_DOWN = 4; 63 | export const GLFW_HAT_LEFT = 8; 64 | export const GLFW_HAT_RIGHT_UP = (GLFW_HAT_RIGHT | GLFW_HAT_UP); 65 | export const GLFW_HAT_RIGHT_DOWN = (GLFW_HAT_RIGHT | GLFW_HAT_DOWN); 66 | export const GLFW_HAT_LEFT_UP = (GLFW_HAT_LEFT | GLFW_HAT_UP); 67 | export const GLFW_HAT_LEFT_DOWN = (GLFW_HAT_LEFT | GLFW_HAT_DOWN); 68 | 69 | /* Printable keys */ 70 | export const GLFW_KEY_UNKNOWN = -1; 71 | export const GLFW_KEY_SPACE = 32 72 | export const GLFW_KEY_APOSTROPHE = 39 /* ' */ 73 | export const GLFW_KEY_COMMA = 44 /* , */ 74 | export const GLFW_KEY_MINUS = 45 /* - */ 75 | export const GLFW_KEY_PERIOD = 46 /* . */ 76 | export const GLFW_KEY_SLASH = 47 /* / */ 77 | export const GLFW_KEY_0 = 48 78 | export const GLFW_KEY_1 = 49 79 | export const GLFW_KEY_2 = 50 80 | export const GLFW_KEY_3 = 51 81 | export const GLFW_KEY_4 = 52 82 | export const GLFW_KEY_5 = 53 83 | export const GLFW_KEY_6 = 54 84 | export const GLFW_KEY_7 = 55 85 | export const GLFW_KEY_8 = 56 86 | export const GLFW_KEY_9 = 57 87 | export const GLFW_KEY_SEMICOLON = 59 /* ; */ 88 | export const GLFW_KEY_EQUAL = 61 /* = */ 89 | export const GLFW_KEY_A = 65 90 | export const GLFW_KEY_B = 66 91 | export const GLFW_KEY_C = 67 92 | export const GLFW_KEY_D = 68 93 | export const GLFW_KEY_E = 69 94 | export const GLFW_KEY_F = 70 95 | export const GLFW_KEY_G = 71 96 | export const GLFW_KEY_H = 72 97 | export const GLFW_KEY_I = 73 98 | export const GLFW_KEY_J = 74 99 | export const GLFW_KEY_K = 75 100 | export const GLFW_KEY_L = 76 101 | export const GLFW_KEY_M = 77 102 | export const GLFW_KEY_N = 78 103 | export const GLFW_KEY_O = 79 104 | export const GLFW_KEY_P = 80 105 | export const GLFW_KEY_Q = 81 106 | export const GLFW_KEY_R = 82 107 | export const GLFW_KEY_S = 83 108 | export const GLFW_KEY_T = 84 109 | export const GLFW_KEY_U = 85 110 | export const GLFW_KEY_V = 86 111 | export const GLFW_KEY_W = 87 112 | export const GLFW_KEY_X = 88 113 | export const GLFW_KEY_Y = 89 114 | export const GLFW_KEY_Z = 90 115 | export const GLFW_KEY_LEFT_BRACKET = 91 /* [ */ 116 | export const GLFW_KEY_BACKSLASH = 92 /* \ */ 117 | export const GLFW_KEY_RIGHT_BRACKET = 93 /* ] */ 118 | export const GLFW_KEY_GRAVE_ACCENT = 96 /* ` */ 119 | export const GLFW_KEY_WORLD_1 = 161 /* non-US #1 */ 120 | export const GLFW_KEY_WORLD_2 = 162 /* non-US #2 */ 121 | 122 | /* Function keys */ 123 | export const GLFW_KEY_ESCAPE = 256 124 | export const GLFW_KEY_ENTER = 257 125 | export const GLFW_KEY_TAB = 258 126 | export const GLFW_KEY_BACKSPACE = 259 127 | export const GLFW_KEY_INSERT = 260 128 | export const GLFW_KEY_DELETE = 261 129 | export const GLFW_KEY_RIGHT = 262 130 | export const GLFW_KEY_LEFT = 263 131 | export const GLFW_KEY_DOWN = 264 132 | export const GLFW_KEY_UP = 265 133 | export const GLFW_KEY_PAGE_UP = 266 134 | export const GLFW_KEY_PAGE_DOWN = 267 135 | export const GLFW_KEY_HOME = 268 136 | export const GLFW_KEY_END = 269 137 | export const GLFW_KEY_CAPS_LOCK = 280 138 | export const GLFW_KEY_SCROLL_LOCK = 281 139 | export const GLFW_KEY_NUM_LOCK = 282 140 | export const GLFW_KEY_PRINT_SCREEN = 283 141 | export const GLFW_KEY_PAUSE = 284 142 | export const GLFW_KEY_F1 = 290 143 | export const GLFW_KEY_F2 = 291 144 | export const GLFW_KEY_F3 = 292 145 | export const GLFW_KEY_F4 = 293 146 | export const GLFW_KEY_F5 = 294 147 | export const GLFW_KEY_F6 = 295 148 | export const GLFW_KEY_F7 = 296 149 | export const GLFW_KEY_F8 = 297 150 | export const GLFW_KEY_F9 = 298 151 | export const GLFW_KEY_F10 = 299 152 | export const GLFW_KEY_F11 = 300 153 | export const GLFW_KEY_F12 = 301 154 | export const GLFW_KEY_F13 = 302 155 | export const GLFW_KEY_F14 = 303 156 | export const GLFW_KEY_F15 = 304 157 | export const GLFW_KEY_F16 = 305 158 | export const GLFW_KEY_F17 = 306 159 | export const GLFW_KEY_F18 = 307 160 | export const GLFW_KEY_F19 = 308 161 | export const GLFW_KEY_F20 = 309 162 | export const GLFW_KEY_F21 = 310 163 | export const GLFW_KEY_F22 = 311 164 | export const GLFW_KEY_F23 = 312 165 | export const GLFW_KEY_F24 = 313 166 | export const GLFW_KEY_F25 = 314 167 | export const GLFW_KEY_KP_0 = 320 168 | export const GLFW_KEY_KP_1 = 321 169 | export const GLFW_KEY_KP_2 = 322 170 | export const GLFW_KEY_KP_3 = 323 171 | export const GLFW_KEY_KP_4 = 324 172 | export const GLFW_KEY_KP_5 = 325 173 | export const GLFW_KEY_KP_6 = 326 174 | export const GLFW_KEY_KP_7 = 327 175 | export const GLFW_KEY_KP_8 = 328 176 | export const GLFW_KEY_KP_9 = 329 177 | export const GLFW_KEY_KP_DECIMAL = 330 178 | export const GLFW_KEY_KP_DIVIDE = 331 179 | export const GLFW_KEY_KP_MULTIPLY = 332 180 | export const GLFW_KEY_KP_SUBTRACT = 333 181 | export const GLFW_KEY_KP_ADD = 334 182 | export const GLFW_KEY_KP_ENTER = 335 183 | export const GLFW_KEY_KP_EQUAL = 336 184 | export const GLFW_KEY_LEFT_SHIFT = 340 185 | export const GLFW_KEY_LEFT_CONTROL = 341 186 | export const GLFW_KEY_LEFT_ALT = 342 187 | export const GLFW_KEY_LEFT_SUPER = 343 188 | export const GLFW_KEY_RIGHT_SHIFT = 344 189 | export const GLFW_KEY_RIGHT_CONTROL = 345 190 | export const GLFW_KEY_RIGHT_ALT = 346 191 | export const GLFW_KEY_RIGHT_SUPER = 347 192 | 193 | export const GLFW_KEY_MENU = 348; 194 | 195 | /* Mod keys */ 196 | export const GLFW_MOD_SHIFT = 0x0001 197 | export const GLFW_MOD_CONTROL = 0x0002 198 | export const GLFW_MOD_ALT = 0x0004 199 | export const GLFW_MOD_SUPER = 0x0008 200 | export const GLFW_MOD_CAPS_LOCK = 0x0010 201 | export const GLFW_MOD_NUM_LOCK = 0x0020 202 | 203 | /* Mouse Buttons */ 204 | export const GLFW_MOUSE_BUTTON_1 = 0 205 | export const GLFW_MOUSE_BUTTON_2 = 1 206 | export const GLFW_MOUSE_BUTTON_3 = 2 207 | export const GLFW_MOUSE_BUTTON_4 = 3 208 | export const GLFW_MOUSE_BUTTON_5 = 4 209 | export const GLFW_MOUSE_BUTTON_6 = 5 210 | export const GLFW_MOUSE_BUTTON_7 = 6 211 | export const GLFW_MOUSE_BUTTON_8 = 7 212 | export const GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8 213 | export const GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1 214 | export const GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2 215 | export const GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3 216 | 217 | /* Joysticks */ 218 | export const GLFW_JOYSTICK_1 = 0 219 | export const GLFW_JOYSTICK_2 = 1 220 | export const GLFW_JOYSTICK_3 = 2 221 | export const GLFW_JOYSTICK_4 = 3 222 | export const GLFW_JOYSTICK_5 = 4 223 | export const GLFW_JOYSTICK_6 = 5 224 | export const GLFW_JOYSTICK_7 = 6 225 | export const GLFW_JOYSTICK_8 = 7 226 | export const GLFW_JOYSTICK_9 = 8 227 | export const GLFW_JOYSTICK_10 = 9 228 | export const GLFW_JOYSTICK_11 = 10 229 | export const GLFW_JOYSTICK_12 = 11 230 | export const GLFW_JOYSTICK_13 = 12 231 | export const GLFW_JOYSTICK_14 = 13 232 | export const GLFW_JOYSTICK_15 = 14 233 | export const GLFW_JOYSTICK_16 = 15 234 | export const GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16 235 | 236 | /* Gamepad */ 237 | export const GLFW_GAMEPAD_BUTTON_A = 0 238 | export const GLFW_GAMEPAD_BUTTON_B = 1 239 | export const GLFW_GAMEPAD_BUTTON_X = 2 240 | export const GLFW_GAMEPAD_BUTTON_Y = 3 241 | export const GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4 242 | export const GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5 243 | export const GLFW_GAMEPAD_BUTTON_BACK = 6 244 | export const GLFW_GAMEPAD_BUTTON_START = 7 245 | export const GLFW_GAMEPAD_BUTTON_GUIDE = 8 246 | export const GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9 247 | export const GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10 248 | export const GLFW_GAMEPAD_BUTTON_DPAD_UP = 11 249 | export const GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12 250 | export const GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13 251 | export const GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14 252 | export const GLFW_GAMEPAD_BUTTON_LAST = GLFW_GAMEPAD_BUTTON_DPAD_LEFT 253 | 254 | export const GLFW_GAMEPAD_BUTTON_CROSS = GLFW_GAMEPAD_BUTTON_A 255 | export const GLFW_GAMEPAD_BUTTON_CIRCLE = GLFW_GAMEPAD_BUTTON_B 256 | export const GLFW_GAMEPAD_BUTTON_SQUARE = GLFW_GAMEPAD_BUTTON_X 257 | export const GLFW_GAMEPAD_BUTTON_TRIANGLE = GLFW_GAMEPAD_BUTTON_Y 258 | 259 | /* Gamepad Axis */ 260 | export const GLFW_GAMEPAD_AXIS_LEFT_X = 0 261 | export const GLFW_GAMEPAD_AXIS_LEFT_Y = 1 262 | export const GLFW_GAMEPAD_AXIS_RIGHT_X = 2 263 | export const GLFW_GAMEPAD_AXIS_RIGHT_Y = 3 264 | export const GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4 265 | export const GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5 266 | export const GLFW_GAMEPAD_AXIS_LAST = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 267 | 268 | /* Error codes */ 269 | export const GLFW_NO_ERROR = 0 270 | export const GLFW_NOT_INITIALIZED = 0x00010001 271 | export const GLFW_NO_CURRENT_CONTEXT = 0x00010002 272 | export const GLFW_INVALID_ENUM = 0x00010003 273 | export const GLFW_INVALID_VALUE = 0x00010004 274 | export const GLFW_OUT_OF_MEMORY = 0x00010005 275 | export const GLFW_API_UNAVAILABLE = 0x00010006 276 | export const GLFW_VERSION_UNAVAILABLE = 0x00010007 277 | export const GLFW_PLATFORM_ERROR = 0x00010008 278 | export const GLFW_FORMAT_UNAVAILABLE = 0x00010009 279 | export const GLFW_NO_WINDOW_CONTEXT = 0x0001000A 280 | export const GLFW_CURSOR_UNAVAILABLE = 0x0001000B 281 | export const GLFW_FEATURE_UNAVAILABLE = 0x0001000C 282 | export const GLFW_FEATURE_UNIMPLEMENTED = 0x0001000D 283 | export const GLFW_PLATFORM_UNAVAILABLE = 0x0001000E 284 | 285 | export const glfw_error_codes = new Map([ 286 | ['GLFW_NOT_INITIALIZED', 0x00010001], 287 | ['GLFW_NO_CURRENT_CONTEXT', 0x00010002], 288 | ['GLFW_INVALID_ENUM', 0x00010003], 289 | ['GLFW_INVALID_VALUE', 0x00010004], 290 | ['GLFW_OUT_OF_MEMORY', 0x00010005], 291 | ['GLFW_API_UNAVAILABLE', 0x00010006], 292 | ['GLFW_VERSION_UNAVAILABLE', 0x00010007], 293 | ['GLFW_PLATFORM_ERROR', 0x00010008], 294 | ['GLFW_FORMAT_UNAVAILABLE', 0x00010009] 295 | ]) 296 | 297 | 298 | /* Types */ 299 | export type glfwMonitor = Pointer | null; 300 | export type glfwWindow = Pointer | null; 301 | export type glfwAllocator = Pointer | null; 302 | export type glfwCursor = Pointer | null; 303 | 304 | /* Function Types */ 305 | export type GLFWwindowposfun = (window: glfwWindow, xpos: number, ypos: number) => void; 306 | export type GLFWwindowsizefun = (window: glfwWindow, width: number, height: number) => void; 307 | export type GLFWwindowclosefun = (window: glfwWindow) => void; 308 | export type GLFWwindowrefreshfun = (window: glfwWindow) => void; 309 | export type GLFWwindowfocusfun = (window: glfwWindow, focused: number) => void; 310 | export type GLFWwindowiconifyfun = (window: glfwWindow, iconified: number) => void; 311 | export type GLFWwindowmaximizefun = (window: glfwWindow, maximized: number) => void; 312 | export type GLFWframebuffersizefun = (window: glfwWindow, width: number, height: number) => void; 313 | export type GLFWwindowcontentscalefun = (window: glfwWindow, x_scale: number, y_scale: number) => void; 314 | export type GLFWcursorenterfun = (window: glfwWindow, entered: number) => void; 315 | export type GLFWscrollfun = (window: glfwWindow, x_offset: number, y_offset: number) => void; 316 | export type GLFWkeyfun = (window: glfwWindow, key: number, scancode: number, action: number, mods: number) => void; 317 | export type GLFWcharfun = (window: glfwWindow, codepoint: number) => void; 318 | export type GLFWcharmodsfun = (window: glfwWindow, codepoint: number, mods: number) => void; 319 | export type GLFWmonitorfun = (window: glfwWindow, event: number) => void; 320 | export type GLFWjoystickfun = (joystick_id: number, event: number) => void; 321 | export type GLFWmousebuttonfun = (window: glfwWindow, button: number, action: number, mods: number) => void; 322 | export type GLFWcursorposfun = (window: glfwWindow, xpos: number, ypos: number) => void; 323 | export type GLFWerrorfun = (error_code: number, description: string) => void; 324 | 325 | // Void argument functions 326 | export const glfwInit = lib.symbols.glfwInit; 327 | export const glfwPollEvents = lib.symbols.glfwPollEvents; 328 | export const glfwTerminate = lib.symbols.glfwTerminate; 329 | export const glfwDefaultWindowHints = lib.symbols.glfwDefaultWindowHints; 330 | export const glfwWaitEvents = lib.symbols.glfwWaitEvents; 331 | export const glfwPostEmptyEvent = lib.symbols.glfwPostEmptyEvent; 332 | export const glfwRawMouseMotionSupported = lib.symbols.glfwRawMouseMotionSupported; 333 | export const glfwGetTime = lib.symbols.glfwGetTime; 334 | export const glfwGetTimerValue = () => lib.symbols.glfwGetTimerValue().toString(); 335 | export const glfwGetTimerFrequency = () => lib.symbols.glfwGetTimerFrequency().toString(); 336 | 337 | // Window 338 | export const glfwCreateWindow = (width: number, height: number, title: string, monitor: glfwMonitor, share: glfwWindow) : glfwWindow => lib.symbols.glfwCreateWindow(width, height, Buffer.from(title), monitor, share); 339 | export const glfwMakeContextCurrent = (window: glfwWindow) : void => lib.symbols.glfwMakeContextCurrent(window); 340 | export const glfwSwapInterval = (interval: number) : void => lib.symbols.glfwSwapInterval(interval); 341 | export const glfwShowWindow = (window: glfwWindow) : void => lib.symbols.glfwShowWindow(window); 342 | export const glfwWindowShouldClose = (window: glfwWindow) : boolean => lib.symbols.glfwWindowShouldClose(window); 343 | export const glfwSwapBuffers = (window: glfwWindow) : void => lib.symbols.glfwSwapBuffers(window); 344 | export const glfwGetWindowAttrib = (window: glfwWindow, attribute: number) : boolean => lib.symbols.glfwGetWindowAttrib(window, attribute); 345 | export const glfwDestroyWindow = (window: glfwWindow) : void => lib.symbols.glfwDestroyWindow(window); 346 | export const glfwWindowHint = (hint: number, state: number) : void => lib.symbols.glfwWindowHint(hint, state); 347 | export const glfwInitHint = (hint: number, state: number) : void => lib.symbols.glfwInitHint(hint, state); 348 | export const glfwGetError = (description: string) : number => lib.symbols.glfwGetError(Buffer.from(description)); 349 | export const glfwWindowHintString = (hint: number, value: string) : void => lib.symbols.glfwWindowHintString(hint, Buffer.from(value)); 350 | export const glfwSetWindowShouldClose = (window: glfwWindow, value: number) : void => lib.symbols.glfwSetWindowShouldClose(window, value); 351 | export const glfwSetWindowTitle = (window: glfwWindow, title: string) : void => lib.symbols.glfwSetWindowTitle(window, Buffer.from(title)); 352 | export const glfwSetWindowPos = (window: glfwWindow, x: number, y: number) : void => lib.symbols.glfwSetWindowPos(window, x, y); 353 | export const glfwSetWindowSize = (window: glfwWindow, width: number, height: number) : void => lib.symbols.glfwSetWindowSize(window, width, height); 354 | export const glfwSetWindowSizeLimits = (window: glfwWindow, minWidth: number, minHeight: number, maxWidth: number, maxHeight: number) : void => lib.symbols.glfwSetWindowSizeLimits(window, minWidth, minHeight, maxWidth, maxHeight); 355 | export const glfwSetWindowAspectRatio = (window: glfwWindow, numer: number, denom: number) : void => lib.symbols.glfwSetWindowAspectRatio(window, numer, denom); 356 | export const glfwGetWindowOpacity = (window: glfwWindow) : number => lib.symbols.glfwGetWindowOpacity(window); 357 | export const glfwSetWindowMonitor = (window: glfwWindow, monitor: glfwMonitor, x: number, y: number, width: number, height: number, refresh_rate: number) : void => lib.symbols.glfwSetWindowMonitor(window, monitor, x, y, width, height, refresh_rate); 358 | export const glfwIconifyWindow = (window: glfwWindow) : void => lib.symbols.glfwIconifyWindow(window); 359 | export const glfwRestoreWindow = (window: glfwWindow) : void => lib.symbols.glfwRestoreWindow(window); 360 | export const glfwMaximizeWindow = (window: glfwWindow) : void => lib.symbols.glfwMaximizeWindow(window); 361 | export const glfwHideWindow = (window: glfwWindow) : void => lib.symbols.glfwHideWindow(window); 362 | export const glfwFocusWindow = (window: glfwWindow) : void => lib.symbols.glfwFocusWindow(window); 363 | export const glfwRequestWindowAttention = (window: glfwWindow) : void => lib.symbols.glfwRequestWindowAttention(window); 364 | export const glfwGetWindowMonitor = (window: glfwWindow) : glfwMonitor => lib.symbols.glfwGetWindowMonitor(window); 365 | export const glfwSetWindowAttrib = (window: glfwWindow, attribute: number, value: number) : void => lib.symbols.glfwSetWindowAttrib(window, attribute, value); 366 | export const glfwWaitEventsTimeout = (timeout: number) : void => lib.symbols.glfwWaitEventsTimeout(timeout); 367 | export const glfwGetInputMode = (window: glfwWindow, mode: number) : number => lib.symbols.glfwGetInputMode(window, mode); 368 | export const glfwSetInputMode = (window: glfwWindow, mode: number, value: number) : void => lib.symbols.glfwSetInputMode(window, mode, value); 369 | export const glfwGetKeyName = (key: number, scancode: number) : string => lib.symbols.glfwGetKeyName(key, scancode).toString(); 370 | export const glfwGetKeyScancode = (key: number) : number => lib.symbols.glfwGetKeyScancode(key); 371 | export const glfwGetKey = (window: glfwWindow, key: number) : number => lib.symbols.glfwGetKey(window, key); 372 | export const glfwGetMouseButton = (window: glfwWindow, button: number) : number => lib.symbols.glfwGetMouseButton(window, button); 373 | export const glfwSetCursorPos = (window: glfwWindow, x_pos: number, y_pos: number) : void => lib.symbols.glfwSetCursorPos(window, x_pos, y_pos); 374 | export const glfwJoystickPresent = (joystick_id: number) : number => lib.symbols.glfwJoystickPresent(joystick_id); 375 | export const glfwGetJoystickName = (joystick_id: number) : string => lib.symbols.glfwGetJoystickName(joystick_id).toString(); 376 | export const glfwJoystickIsGamepad = (joystick_id: number) : boolean => lib.symbols.glfwJoystickIsGamepad(joystick_id); 377 | export const glfwSetTime = (time: number) : void => lib.symbols.glfwSetTime(time); 378 | export const glfwGetCursorPos = (window: glfwWindow, xpos: number, ypos: number) : number => lib.symbols.glfwGetCursorPos(window, xpos , ypos); 379 | 380 | 381 | 382 | // Setters 383 | export const glfwSetWindowPosCallback = (window: glfwWindow, callback: GLFWwindowposfun) : void => { 384 | const clb = new JSCallback(callback, { 385 | args: ["ptr", "int", "int"], 386 | returns: "void" 387 | }) 388 | lib.symbols.glfwSetWindowPosCallback(window, clb); 389 | } 390 | 391 | export const glfwSetWindowSizeCallback = (window: glfwWindow, callback: GLFWwindowsizefun) : void => { 392 | const clb = new JSCallback(callback, { 393 | args: ["ptr", "int", "int"], 394 | returns: "void" 395 | }) 396 | lib.symbols.glfwSetWindowSizeCallback(window, clb); 397 | } 398 | 399 | export const glfwSetWindowCloseCallback = (window: glfwWindow, callback: GLFWwindowclosefun) : void => { 400 | const clb = new JSCallback(callback, { 401 | args: ["ptr"], 402 | returns: "void" 403 | }) 404 | lib.symbols.glfwSetWindowCloseCallback(window, clb); 405 | } 406 | 407 | export const glfwSetWindowRefreshCallback = (window: glfwWindow, callback: GLFWwindowrefreshfun) : void => { 408 | const clb = new JSCallback(callback, { 409 | args: ["ptr"], 410 | returns: "void" 411 | }) 412 | lib.symbols.glfwSetWindowRefreshCallback(window, clb); 413 | } 414 | 415 | export const glfwSetWindowFocusCallback = (window: glfwWindow, callback: GLFWwindowfocusfun) : void => { 416 | const clb = new JSCallback(callback, { 417 | args: ["ptr", "int"], 418 | returns: "void" 419 | }) 420 | lib.symbols.glfwSetWindowFocusCallback(window, clb); 421 | } 422 | 423 | export const glfwSetWindowIconifyCallback = (window: glfwWindow, callback: GLFWwindowiconifyfun) : void => { 424 | const clb = new JSCallback(callback, { 425 | args: ["ptr", "int"], 426 | returns: "void" 427 | }) 428 | lib.symbols.glfwSetWindowIconifyCallback(window, clb); 429 | } 430 | 431 | export const glfwSetWindowMaximizeCallback = (window: glfwWindow, callback: GLFWwindowmaximizefun) : void => { 432 | const clb = new JSCallback(callback, { 433 | args: ["ptr", "int"], 434 | returns: "void" 435 | }) 436 | lib.symbols.glfwSetWindowMaximizeCallback(window, clb); 437 | } 438 | 439 | export const glfwSetFramebufferSizeCallback = (window: glfwWindow, callback: GLFWframebuffersizefun) : void => { 440 | const clb = new JSCallback(callback, { 441 | args: ["ptr", "int", "int"], 442 | returns: "void" 443 | }) 444 | lib.symbols.glfwSetFramebufferSizeCallback(window, clb); 445 | } 446 | 447 | export const glfwSetKeyCallback = (window: glfwWindow, callback: GLFWkeyfun) : void => { 448 | const clb = new JSCallback(callback, { 449 | args: ["ptr", "int", "int", "int", "int"], 450 | returns: "void" 451 | }) 452 | lib.symbols.glfwSetKeyCallback(window, clb); 453 | } 454 | 455 | export const glfwSetCharCallback = (window: glfwWindow, callback: GLFWcharfun) : void => { 456 | const clb = new JSCallback(callback, { 457 | args: ["ptr", "int"], 458 | returns: "void" 459 | }) 460 | lib.symbols.glfwSetCharCallback(window, clb); 461 | } 462 | 463 | export const glfwSetCharModsCallback = (window: glfwWindow, callback: GLFWcharmodsfun) : void => { 464 | const clb = new JSCallback(callback, { 465 | args: ["ptr", "int", "int"], 466 | returns: "void" 467 | }) 468 | lib.symbols.glfwSetCharModsCallback(window, clb); 469 | } 470 | 471 | export const glfwSetMouseButtonCallback = (window: glfwWindow, callback: GLFWmousebuttonfun) : void => { 472 | const clb = new JSCallback(callback, { 473 | args: ["ptr", "int", "int", "int"], 474 | returns: "void" 475 | }) 476 | lib.symbols.glfwSetMouseButtonCallback(window, clb); 477 | } 478 | 479 | export const glfwSetScrollCallback = (window: glfwWindow, callback: GLFWscrollfun) : void => { 480 | const clb = new JSCallback(callback, { 481 | args: ["ptr", "int", "int"], 482 | returns: "void" 483 | }) 484 | lib.symbols.glfwSetScrollCallback(window, clb); 485 | } 486 | 487 | export const glfwSetJoystickCallback = (window: glfwWindow, callback: GLFWjoystickfun) : void => { 488 | const clb = new JSCallback(callback, { 489 | args: ["int", "int"], 490 | returns: "void" 491 | }) 492 | lib.symbols.glfwSetScrollCallback(window, clb); 493 | } 494 | 495 | export const glfwSetCursorPosCallback = (window: glfwWindow, callback: GLFWcursorposfun) : void => { 496 | const clb = new JSCallback(callback, { 497 | args: ["ptr", "int", "int"], 498 | returns: "void" 499 | }) 500 | lib.symbols.glfwSetScrollCallback(window, clb); 501 | } 502 | 503 | export const glfwSetCursorEnterCallback = (window: glfwWindow, callback: GLFWcursorenterfun) : void => { 504 | const clb = new JSCallback(callback, { 505 | args: ["ptr", "int"], 506 | returns: "void" 507 | }) 508 | lib.symbols.glfwSetScrollCallback(window, clb); 509 | } 510 | 511 | export const glfwSetErrorCallback = (callback: GLFWerrorfun) : void => { 512 | const clb = new JSCallback(callback, { 513 | args: ["int", "cstring"], 514 | returns: "void" 515 | }) 516 | lib.symbols.glfwSetErrorCallback(clb); 517 | } -------------------------------------------------------------------------------- /lib/glfw3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HazyVT/BunGLFW/d977d3fdaca573f91658f220b78651811ede64e3/lib/glfw3.dll -------------------------------------------------------------------------------- /lib/libglfw.3.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HazyVT/BunGLFW/d977d3fdaca573f91658f220b78651811ede64e3/lib/libglfw.3.dylib -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bunglfw", 3 | "module": "index.ts", 4 | "version": "1.0.3", 5 | "description": "Typescript bindings for GLFW all for bun", 6 | "devDependencies": { 7 | "@types/bun": "latest" 8 | }, 9 | "peerDependencies": { 10 | "typescript": "^5.0.0" 11 | }, 12 | "scripts": { 13 | "dev": "bun run main.ts" 14 | }, 15 | "type": "module", 16 | "dependencies": { 17 | "typescript": "^5.3.3" 18 | } 19 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["ESNext"], 4 | "target": "ESNext", 5 | "module": "ESNext", 6 | "moduleDetection": "force", 7 | "jsx": "react-jsx", 8 | "allowJs": true, 9 | 10 | /* Bundler mode */ 11 | "moduleResolution": "bundler", 12 | "allowImportingTsExtensions": true, 13 | "verbatimModuleSyntax": true, 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "skipLibCheck": true, 18 | "strict": true, 19 | "noFallthroughCasesInSwitch": true, 20 | "forceConsistentCasingInFileNames": true 21 | } 22 | } 23 | --------------------------------------------------------------------------------