RTCSETNEWGEOMETRYBUFFER(3embree4)

✨ rtcSetNewGeometryBuffer ✨

okay bestie, welcome to the Embree Ray Tracing Kernels 4 manual, page rtcSetNewGeometryBuffer(3) β€” yes it's a long name, yes it's iconic, let's go πŸ’…

🌸 NAME 🌸

rtcSetNewGeometryBuffer β€” creates and assigns a new data buffer to the geometry πŸŽ€


✨ SYNOPSIS ✨

#include <embree4/rtcore.h>

void* rtcSetNewGeometryBuffer(
  RTCGeometry geometry,
  enum RTCBufferType type,
  unsigned int slot,
  enum RTCFormat format,
  size_t byteStride,
  size_t itemCount
);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the way this works is: rtcSetNewGeometryBuffer makes you a brand new data buffer and hands it straight to a geometry. it's giving personal assistant energy fr fr πŸ’–

you tell it the format (that's the format argument), the byte stride (that's byteStride), and how many items you want in there (that's itemCount). then it assigns that buffer to a geometry buffer slot β€” you pick which one with type and slot β€” on the geometry you passed in with geometry. no cap. 🫢

the best part?? the buffer data is managed internally and gets automatically freed when the geometry is destroyed. not me being obsessed with automatic cleanup 😭✨ no memory leaks, only vibes.

⚠️ okay but listen β€” the byte stride (byteStride argument) must be aligned to 4 bytes. if it isn't, rtcSetNewGeometryBuffer will straight up fail. periodt. πŸ’€

and one more lil detail bestie, don't skip this: when the buffer is used as a vertex buffer, the allocated buffer gets automatically over-allocated slightly. why? because the requirement is that each buffer element should be readable using 16-byte SSE load instructions. slay for alignment, honestly 🌈


πŸ’€ EXIT STATUS πŸ’€

if something goes wrong, an error code gets set β€” and you can go query it with rtcGetDeviceError. so if it's not working, that's where you look. iykyk πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

  • rtcSetGeometryBuffer
  • rtcSetSharedGeometryBuffer

okay that's the whole page bestie, you ate it, go build something gorgeous πŸ§šπŸ’œ

this was rtcSetNewGeometryBuffer(3) from the Embree Ray Tracing Kernels 4 manual set β€” mwah, bye πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from