Varjo SDK Examples

Note: you are currently viewing documentation for a beta or an older version of Varjo

Benchmark Example

The Benchmark example could be downloaded with Native SDK package. The example can be found under \varjo-sdk\examples \Benchmark\src and you can open the project by running \varjo-sdk\examples\vs2017-x64\VarjoExamples.sln.

This application renders several donuts and a background grid to stress test the Varjo API.

Use main.cpp as a starting point. It contains the main rendering loop and all the frame logic that is not related to graphics.

To learn about the renderer, check the IRenderer.cpp file. Implementation can be found from D3D11Renderer.cpp and GLRenderer.cpp depending on the rendering engine.

Gaze tracking implementation can be found in the GazeTracking.cpp file. Examples include:

  • Checking that gaze tracking is allowed
  • Initializing gaze tracking
  • Requesting gaze calibration
  • Calculating relative gaze vector
  • Positioning gaze in relation to user pose
  • Calculating gaze position in world coordinates

MIXED REALITY EXAMPLE

The mixed reality example could be found in the examples folder which is downloaded with Native SDK package. Open the MRExample folder and see DataStreamer.cpp file for the basic video stream reading implementation.

Begin with obtaining available streams.

configs.resize(varjo_GetDataStreamConfigCount(m_session));
varjo_GetDataStreamConfigs(m_session, configs.data(), static_cast<int32_t>(configs.size()));

Proceed with starting the stream

varjo_StartDataStream(m_session, conf.streamId, varjo_ChannelFlag_Left | varjo_ChannelFlag_Right, dataStreamFrameCallback, this);

Process the frames in the callback functions. Callback contains both left and right frames as a batch.

varjo_Matrix extrinsics = varjo_GetCameraExtrinsics(session, frame->id, frame->frameNumber, channel);

varjo_CameraIntrinsics intrinsics = varjo_GetCameraIntrinsics(session, frame->id, frame->frameNumber, channel);

bufferId = varjo_GetBufferId(session, frame->id, frame->frameNumber, channel);

varjo_BufferMetadata meta = varjo_GetBufferMetadata(m_session, bufferId);
void* cpuData = varjo_GetBufferCPUData(m_session, bufferId);

Close the stream.