rtcSetGeometryBuffer(3)

πŸ’– rtcSetGeometryBuffer β€” bestie edition πŸ’–

okay so we're deep in the Embree Ray Tracing Kernels 4 era and this page is rtcSetGeometryBuffer(3). it's giving buffer-binding, it's giving geometry glow-up, and yes it's a (3) library call so put your C hat on πŸŽ€


✨ NAME ✨

rtcSetGeometryBuffer β€” assigns a view of a buffer to the geometry 🫢


✨ SYNOPSIS ✨

#include <embree4/rtcore.h>

void rtcSetGeometryBuffer(
  RTCGeometry geometry,
  enum RTCBufferType type,
  unsigned int slot,
  enum RTCFormat format,
  RTCBuffer buffer,
  size_t byteOffset,
  size_t byteStride,
  size_t itemCount
);

✨ DESCRIPTION ✨

so what this function does, bestie, is it takes a buffer object (that's the buffer argument 🌸) and binds a whole view of it onto a geometry buffer type and slot (the type and slot arguments, respectively) of the geometry you picked (the geometry argument πŸ‘‘).

and like, you get to be picky about the details, which is the fun part:

  • the start of the first buffer element, in bytes β€” that's the byteOffset argument πŸ“
  • the byte stride between individual buffer elements β€” that's the byteStride argument
  • the format of the buffer elements β€” that's the format argument ✨
  • how many elements you're actually binding β€” that's the itemCount πŸ’…
⚠️ okay important thing, no cap: the start address (byteOffset argument) and the stride (byteStride argument) must both be aligned to 4 bytes, otherwise rtcSetGeometryBuffer will straight up fail. like, it's not gonna warn you and vibe, it's gonna fail. so align your stuff. periodt πŸ’€

and once this function completes successfully, the geometry will hold a reference to the buffer object πŸ”₯ (yes, a real reference, it's committed, main character energy).


✨ EXIT STATUS ✨

if it fails, an error code gets set that you can go query with rtcGetDeviceError 😭 (go check it, don't just sit there wondering).


✨ SEE ALSO ✨

  • rtcSetSharedGeometryBuffer
  • rtcSetNewGeometryBuffer

and that's the whole page, bestie πŸ¦‹ this was rtcSetGeometryBuffer(3) from the Embree Ray Tracing Kernels 4 era β€” go bind some buffers, align your bytes, and slay πŸ’…βœ¨

πŸ“¦ where this page comes from