<!--
{
  "availability" : [
    "macOS: 26.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CompositorServices",
  "identifier" : "/documentation/CompositorServices/cp_drawable_set_device_anchor",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Compositor Services"
    ],
    "preciseIdentifier" : "c:@F@cp_drawable_set_device_anchor"
  },
  "title" : "cp_drawable_set_device_anchor"
}
-->

# cp_drawable_set_device_anchor

Specifies the world position and orientation to apply to the current frame.

```
void cp_drawable_set_device_anchor(cp_drawable_t drawable, ar_device_anchor_t device_anchor);
```

## Parameters

`drawable`

The drawable for a frame.

`device_anchor`

The anchor that specifies the 3D rotation, translation,
and scaling factors you applied to your content when you rendered the frame.
If you specify `nil`, Compositor Services doesn’t adjust your content to match
the actual display-time position and orientation of the device.

## Discussion

During rendering, match the camera position in your scene to the device anchor
to create a better experience.
In a visionOS app, the device anchor corresponds to the movements of someone’s head.
If your camera movements aren’t synchronized to the device movements,
the person might experience discomfort while viewing your content.

Because you encode your drawing commands before the final rendered frame appears,
you must predict the device anchor in advance.
ARKit provides the
<doc://com.apple.documentation/documentation/ARKit/ar_world_tracking_provider_query_device_anchor_at_timestamp>
function to help you determine this information.
Use the value from the [`cp_frame_timing_get_presentation_time`](/documentation/CompositorServices/cp_frame_timing_get_presentation_time)
function as the time for the request.
Start the prediction process at some point after the time the
[`cp_frame_timing_get_optimal_input_time`](/documentation/CompositorServices/cp_frame_timing_get_optimal_input_time) function returns.

At display time, Compositor Services compares your predicted device anchor with
the actual position and orientation of the device at that time.
If the two values don’t match, Compositor Services adjusts the pixels
of your frame to align it with the hardware.
If you don’t want it to make this adjustment,
specify `nil` for the `device_anchor` parameter or don’t call this function.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)