Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hazyvt/bunglfw
Typescript bindings of GLFW made for bun
https://github.com/hazyvt/bunglfw
bun bunsh glfw glfw-bindings glfw3 typescript
Last synced: 7 days ago
JSON representation
Typescript bindings of GLFW made for bun
- Host: GitHub
- URL: https://github.com/hazyvt/bunglfw
- Owner: HazyVT
- License: mit
- Created: 2024-01-30T06:25:09.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-08T08:57:58.000Z (about 1 year ago)
- Last Synced: 2024-02-08T09:51:56.401Z (about 1 year ago)
- Topics: bun, bunsh, glfw, glfw-bindings, glfw3, typescript
- Language: TypeScript
- Homepage:
- Size: 172 KB
- Stars: 16
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BunGLFW
Typescript bindings for bun. No installation needed.
To install please use
```node
bun install bunglfw
```Here is an example of some code
```ts
import {
glfwSetKeyCallback,
GLFW_FALSE,
GLFW_MAXIMIZED,
GLFW_RESIZABLE,
GLFW_TRUE,
GLFW_VISIBLE,
glfwCreateWindow,
glfwInit,
glfwMakeContextCurrent,
glfwPollEvents,
glfwSetErrorCallback,
glfwShowWindow,
glfwSwapBuffers,
glfwSwapInterval,
glfwWindowHint,
glfwWindowShouldClose,
GLFW_PRESS,
GLFW_KEY_ESCAPE,
glfwSetWindowShouldClose,
glfw_error_codes,
glfwDefaultWindowHints,
type GLFWkeyfun, type glfwWindow,
} from "bunglfw";if (!glfwInit()) {
throw new Error("GLFW Failed to initialize");
}const error_call = (error_code: number, description: string) => {
[...glfw_error_codes.keys()].forEach((key) => {
if (glfw_error_codes.get(key) == error_code) {
console.error(key);
}
})
}let controls: GLFWkeyfun = (window: glfwWindow, key: number, scancode: number, action: number, mods: number) => {
if (action == GLFW_PRESS) {
if (key == GLFW_KEY_ESCAPE) {
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
}
}glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);const window = glfwCreateWindow(640, 480, "Hello World", null, null);
glfwSetKeyCallback(window, controls)
glfwSetErrorCallback(error_call);glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwShowWindow(window);while (!glfwWindowShouldClose(window)) {
glfwPollEvents();glfwSwapBuffers(window);
}
```