LogoPear Docs
ReferencesBareModules

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[, src[, dst]]), renderer.present(), renderer.destroy().
  • Texture— a renderable image: texture.update(buffer, pitch[, rect]), texture.destroy().
  • Rect— a rectangle with x, y, w, h and rect.set(x, y, w, h), used for source/destination regions.

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.playbackDeviceFormats(), and AudioDevice.recordingDeviceFormats().

See also

On this page