Skip to content

Instantly share code, notes, and snippets.

View jherico's full-sized avatar
🖖
Peace and long life

Tano🏳️‍⚧️ jherico

🖖
Peace and long life
View GitHub Profile
#include <OVR.h>
#undef new
#undef min
#undef max
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/noise.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtx/norm.hpp>
template <typename Function>
void for_each_eye(Function f){
for (Eye eye = LEFT; eye <= RIGHT; eye = static_cast<Eye>(eye + 1)) {
f(eye);
}
}
...
void renderScene() {
// do all your normal rendering here
...
// Render the latency test color if required
renderLatencyTestSquare();
}
void renderLatencyTestSquare() {
// In your class
OVR::Quatf currentOrientation;
OVR::SensorFusion sensorFusion;
// In my per-frame update code
...
currentOrientation = sensorFusion.GetPredictedOrientation();
ovrLatencyTest.ProcessInputs();
...
// In your class
OVR::Ptr<OVR::LatencyTestDevice> ovrLatencyTester;
OVR::Util::LatencyTest ovrLatencyTest;
// In your constructor
ovrLatencyTester = *ovrManager->EnumerateDevices<OVR::LatencyTestDevice>().CreateDevice();
if (ovrLatencyTester) {
ovrLatencyTest.SetDevice(ovrLatencyTester);
}
void renderLatencyTestSquare() {
OVR::Color colorToDisplay;
// If this returns a non-0 value, we're performing a latency
// test and must render a colored square underneath the tester
// (On the lens axis)
if (ovrLatencyTest.DisplayScreenColor(colorToDisplay)) {
latencyTestProgram->use();
latencyTestProgram->setUniform("Color", Rift::fromOvr(colorToDisplay));