JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q41234F
  • License MIT

SDL2 bindings for Node

Package Exports

  • sdl2-link

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sdl2-link) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sdl2-link

A node module that exposes the SDL2 C API to Javascript through the Foreign Function Interface (FFI).

Installation

npm install sdl2-link

Usage

Load SDL2.

// Import FFI modules.
const ref = require('ref-napi');
const ffi = require('ffi-napi');

// Load the SDL2 library, including constants, structs, unions and functions.
const SDL2 = require('sdl2-link')({ ffi: ffi, ref: ref })

// Start making calls to SDL2.
SDL2.SDL_Init(SDL2.SDL_INIT_VIDEO);

Load SDL2 with extensions. SDL_ttf, SDL_image and SDL_mixer are supported extensions.

// Import FFI modules.
const ref = require('ref-napi');
const ffi = require('ffi-napi');

// Load the SDL2 library with the SDL_ttf extension.
const SDL2 = require('sdl2-link')({ ffi: ffi, ref: ref, extensions: [ 'SDL_ttf' ] });

// Start making calls to SDL2.
SDL2.TTF_Init();
SDL2.SDL_Init(SDL2.SDL_INIT_VIDEO);

SDL2 Documentation

The namespace (object) sdl2-link returns contains constants, structs and functions exactly as they appear in the SDL2 API. Use the official SDL2 documentation for reference.

Notes

  • fastcall has a compatible FFI API, but it does not currently support some SDL function signatures (structs by value).