{"id":13800856,"url":"https://github.com/littledivy/deno_sdl2","last_synced_at":"2025-04-06T09:07:52.193Z","repository":{"id":40988672,"uuid":"391610017","full_name":"littledivy/deno_sdl2","owner":"littledivy","description":"SDL2 module for Deno","archived":false,"fork":false,"pushed_at":"2024-03-03T13:25:41.000Z","size":2195,"stargazers_count":126,"open_issues_count":8,"forks_count":16,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T16:22:26.722Z","etag":null,"topics":["canvas","deno","gfx","gui","sdl2","typescript","webgpu"],"latest_commit_sha":null,"homepage":"https://jsr.io/@divy/sdl2","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/littledivy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-01T11:34:22.000Z","updated_at":"2024-07-14T06:35:29.734Z","dependencies_parsed_at":"2024-01-20T14:22:51.435Z","dependency_job_id":"fde97bd4-6022-455c-a38f-a964f0b7c6ba","html_url":"https://github.com/littledivy/deno_sdl2","commit_stats":{"total_commits":112,"total_committers":10,"mean_commits":11.2,"dds":0.2142857142857143,"last_synced_commit":"b0381ee18f3033915f65e44f4d4bbf0da17d5797"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fdeno_sdl2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fdeno_sdl2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fdeno_sdl2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littledivy%2Fdeno_sdl2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/littledivy","download_url":"https://codeload.github.com/littledivy/deno_sdl2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457801,"owners_count":20941906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["canvas","deno","gfx","gui","sdl2","typescript","webgpu"],"created_at":"2024-08-04T00:01:16.998Z","updated_at":"2025-04-06T09:07:52.177Z","avatar_url":"https://github.com/littledivy.png","language":"TypeScript","funding_links":[],"categories":["Modules"],"sub_categories":["Game engine"],"readme":"### Deno SDL2\n\ndeno_sdl2 provides bindings to sdl2, sdl2_ttf and sdl2_image.\n\nhttps://user-images.githubusercontent.com/34997667/160436698-9045ba0c-3fc8-45f9-8038-4194e5d3dcc8.mov\n\nMinimum supported Deno version: 2.0.0-rc.7\n\n### get started\n\n```typescript\nimport { EventType, WindowBuilder } from \"jsr:@divy/sdl2@0.14\";\n\nconst window = new WindowBuilder(\"Hello, Deno!\", 640, 480).build();\nconst canvas = window.canvas();\n\nfor await (const event of window.events()) {\n  if (event.type == EventType.Quit) {\n    break;\n  } else if (event.type == EventType.Draw) {\n    // Rainbow effect\n    const r = Math.sin(Date.now() / 1000) * 127 + 128;\n    const g = Math.sin(Date.now() / 1000 + 2) * 127 + 128;\n    const b = Math.sin(Date.now() / 1000 + 4) * 127 + 128;\n    canvas.setDrawColor(Math.floor(r), Math.floor(g), Math.floor(b), 255);\n    canvas.clear();\n    canvas.present();\n  }\n}\n```\n\n```shell\ndeno run --allow-env --allow-ffi https://jsr.io/@divy/sdl2/0.14.0/examples/hello.ts\n```\n\n### installing sdl2\n\nFollow https://wiki.libsdl.org/SDL2/Installation to install the dynamic library.\n\nTL;DR\n\nMacOS (arm64/x64):\n\n```shell\nbrew install sdl2 sdl2_image sdl2_ttf\n```\n\nMake sure the libraries is in your system's library search paths, if not\nalready:\n\n```shell\nsudo ln -s /opt/homebrew/lib/libSDL2.dylib /usr/local/lib/\nsudo ln -s /opt/homebrew/lib/libSDL2_image.dylib /usr/local/lib/\nsudo ln -s /opt/homebrew/lib/libSDL2_ttf.dylib /usr/local/lib/\n```\n\nAdditionally, you can set `DENO_SDL2_PATH` to point to the directory where these\nthree libraries are located.\n\nWindows (x64):\n\nGrab prebuilt libraries from:\n\n- https://github.com/libsdl-org/SDL/releases/tag/release-2.28.5\n- https://github.com/libsdl-org/SDL_image/releases/tag/release-2.8.1\n- https://github.com/libsdl-org/SDL_ttf/releases/tag/release-2.0.18\n\nTake `SDL2.dll`, `SDL2_image.dll` and `SDL2_ttf.dll` from each respectively and\nput them into cwd or `C:\\Windows\\System32\\`.\n\nLinux (x64):\n\n```shell\nsudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev\n```\n\n### security\n\nyou need `--allow-ffi` to use SDL2. `deno_sdl2` needs access to system's SDL2\nlibrary. Deno's permission model does not work well with FFI libraries, use at\nyour own risk.\n\n### projects using `deno_sdl2`\n\n- https://github.com/dhairy-online/dino-deno\n- https://github.com/dhairy-online/flappybird\n- https://github.com/load1n9/caviar\n- ...insert your project here\n\n### license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittledivy%2Fdeno_sdl2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittledivy%2Fdeno_sdl2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittledivy%2Fdeno_sdl2/lists"}