Skip to main content

STRUCT

ArdkBuffer

public struct ArdkBuffer

A buffer containing binary data for ARDK operations.

ArdkBuffer provides a safe wrapper around binary data buffers used by various ARDK features. It handles memory management and provides convenient access to buffer data.

Overview

ARDK buffers are used for:

  • Image data transfer
  • Mesh data storage
  • Configuration data
  • Any binary data that needs to be passed between Swift and the native ARDK layer

Example Usage

// Create buffer from Swift Data
let imageData = UIImage(named: "texture")?.pngData()
let buffer = ArdkBuffer(data: imageData!)

// Access buffer data
print("Buffer size: \(buffer.dataSize) bytes")

// Use buffer with ARDK APIs
let status = someArdkFunction(buffer: buffer)

Memory Management

ArdkBuffer automatically manages memory allocation and deallocation. When created from Swift Data, it maintains a reference to prevent premature deallocation.

Properties

data

public let data: UnsafePointer\<UInt8\>

Pointer to the buffer's binary data.

This provides direct access to the buffer's contents. The data remains valid as long as the ArdkBuffer instance exists.

dataSize

public let dataSize: UInt32

Size of the buffer data in bytes.

This indicates the total number of bytes available in the buffer.

owner

public let owner: ResourceOwner?

Resource owner for memory management.

This ensures the buffer's memory is properly managed and deallocated when the buffer is no longer needed.

Methods

init(data:dataSize:)

public init(data: UnsafePointer\<UInt8\>, dataSize: UInt32)

init(data:)

public init(data: Data)