gbm

Nim bindings to Mesa's Generic Buffer Management API

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 0.1.0
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:27

Authors

  • xTrayambak

Installation

nimble install gbm
choosenim install gbm
git clone https://github.com/xTrayambak/gbm-nim

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
gbm - - - - - - -

Dependencies

Package Version Optional
nim >= 2.2.0 No

Source

Repository https://github.com/xTrayambak/gbm-nim
Homepage https://github.com/xTrayambak/gbm-nim
Registry Source nimble_official

README

gbm

This library provides full Nim bindings to Mesa's gbm subsystem alongside a work-in-progress idiomatic Nim wrapper that uses Nim's ARC/ORC move semantics alongside sanity checks to make working with gbm a hassle-free experience.

basic example

import pkg/gbm

proc main() {.inline.} =
  var device = openDevice("/dev/dri/card1")
  echo "using gpu: " & device.path
  echo "backend: " & device.backend

  echo "allocating 1920x1080 buffer"
  var buffer = device.allocateBuffer(
    1920,
    1080,
    BufferObjectFormat.XRGB8888,
    {BufferFlags.UseScanout, BufferFlags.UseRendering},
  )
  echo "buffer format: " & $buffer.format
  echo "buffer fd: " & $buffer.getFd
  echo "plane count: " & $buffer.planeCount

  for p in 0 ..< buffer.planeCount:
    echo "plane fd: " & $buffer.getFdForPlane(p)

when isMainModule:
  main()

This code opens the first GPU device on your system and allocates a 1920x1080 buffer in its memory (VRAM). Notice how you don't need to manually free up the buffers afterwards like in C examples, as this library provides destructors that automatically do this as soon as the GBM buffer or device goes out of scope and is no longer needed.