Bare Docs
ReferenceBareModules

bare-sdl

Reference overview for bare-sdl: SDL bindings for Bare—windows, GPU-accelerated rendering, textures, input events, and audio devices.

bare-sdl provides SDL bindings for Bare—native windowing, GPU-accelerated 2D rendering, input, and audio. It's a native addon and requires Bare >=1.14.0. This page is an overview of the main classes; see the repository README for constructors, enums, and the full surface.

npm i bare-sdl

API overview

Windowing and rendering

  • Window— a native window. window.destroy() tears it down.
  • Renderer— a GPU-accelerated 2D renderer for a window: renderer.clear(), renderer.texture(texture), renderer.present(), renderer.destroy().
  • Texture— a renderable image: texture.update(buffer, pitch), texture.destroy().
  • Rect / Rect.F— an integer or float rectangle (x, y, w, h, plus set(x, y, w, h) to update in place), used for the optional sub-regions passed to renderer.texture() and texture.update().

Input

  • Event— an input event with a type and, for keyboard events, event.key (including event.key.scancode).
  • Poller— pumps the event queue: poller.poll(event) fills an Event with the next pending event.

Audio

  • AudioDevice— a playback or recording device. Instance members include name, format, isPlaybackDevice, isPhysicalDevice, isPaused, and gain, plus bindStream(stream), unbindStream(stream), pause(), resume(), and close(). Static helpers enumerate devices and formats: AudioDevice.playbackDevices(), AudioDevice.recordingDevices(), AudioDevice.defaultPlaybackDevice([spec]), AudioDevice.defaultRecordingDevice([spec]), AudioDevice.playbackDeviceFormats(), and AudioDevice.recordingDeviceFormats().
  • AudioStream— an audio stream you bind to an AudioDevice with bindStream(stream). Instance members include available and device, plus put(buffer) and get(buffer) to write and read audio data, and flush(), clear(), and destroy().

Video

See also

On this page