Open topic with navigation

# Initializing Tracking

Initializing tracking overlaps quite a bit with initializing stereo. Although we cover stereo and tracking as separate topics, usually you combine stereo and tracking initialization. To initialize tracking, you will:

- Initialize the SDK.
- Get the handle for the stylus for later use.

The following partial code example illustrates these steps. Error handling is omitted for brevity.

      // Initialize the zSpace SDK. This MUST be called before
      // calling any other zSpace API.
      ZSContext zSpaceContext = NULL;
      zsInitialize(&zSpaceContext);

      // Grab a handle to the stylus target.
      ZSHandle stylusHandle = NULL;
      zsFindTargetByType(zSpaceContext, ZS_TARGET_TYPE_PRIMARY, 0, &stylusHandle);

For a more complete example, refer to the Basic Stereo sample application in the Samples\Render subdirectory. The examples in this manual are based on the OpenGL sample, but the SDK also includes examples for D3D9, D3D10, D3D11, and D3D11_1. Read the following paragraphs for further explanation of the above functions.

Call zsInitialize() once per zSpace session. zsInitialize() loads the zSpace DLL, detects connected peripherals, and creates the handles for the tracked targets. You can see zsInitialize() used for setting up stereo as well. Refer to Stereo Basics for another example.

Call zsFindTargetByType() to get the stylus handle, which will be used during updates.

Note: Although you can use the Tracker Target API for the polarized glasses, it is not necessary. The zSpace Core SDK automatically passes the head pose from the glasses to the stereo frustum.

Open topic with navigation