Exemple #1
0
void VRController::OnDisplayChanged(device::blink::VRDisplayPtr display) {
  VRDisplay* vrDisplay = getDisplayForIndex(display->index);
  if (!vrDisplay)
    return;

  vrDisplay->update(display);
}
Exemple #2
0
 glm::ivec2 getHmdRenderSize()
 {
     VRSystem* pVrSystem = VRSystem::instance();
     VRDisplay* pDisplay = pVrSystem->getHMD().get();
     glm::ivec2 renderSize = pDisplay->getRecommendedRenderSize();
     return renderSize;
 }
Exemple #3
0
void VRController::OnDisplayDisconnected(unsigned index) {
  VRDisplay* vrDisplay = getDisplayForIndex(index);
  if (!vrDisplay)
    return;

  vrDisplay->disconnected();

  m_navigatorVR->fireVREvent(
      VRDisplayEvent::create(EventTypeNames::vrdisplaydisconnect, true, false,
                             vrDisplay, "disconnect"));
}
Exemple #4
0
VRDisplay* VRController::getDisplayForIndex(unsigned index) {
  VRDisplay* display;
  for (size_t i = 0; i < m_displays.size(); ++i) {
    display = m_displays[i];
    if (display->displayId() == index) {
      return display;
    }
  }

  return 0;
}
Exemple #5
0
VRDisplay* VRController::createOrUpdateDisplay(
    const device::blink::VRDisplayPtr& display) {
  VRDisplay* vrDisplay = getDisplayForIndex(display->index);
  if (!vrDisplay) {
    vrDisplay = new VRDisplay(m_navigatorVR);
    m_displays.append(vrDisplay);
  }

  vrDisplay->update(display);
  return vrDisplay;
}
Exemple #6
0
VRDisplayVector VRDisplayCollection::updateDisplays(mojo::WTFArray<mojom::blink::VRDeviceInfoPtr> devices)
{
    VRDisplayVector vrDevices;

    for (const auto& device : devices.PassStorage()) {
        VRDisplay* display = getDisplayForIndex(device->index);
        if (!display) {
            display = new VRDisplay(m_navigatorVR);
            m_displays.append(display);
        }

        display->update(device);
        vrDevices.append(display);
    }

    return vrDevices;
}
Exemple #7
0
void VRController::onPresentComplete(ScriptPromiseResolver* resolver,
                                     unsigned index,
                                     bool success) {
  VRDisplay* vrDisplay = getDisplayForIndex(index);
  if (!vrDisplay) {
    DOMException* exception =
        DOMException::create(InvalidStateError, "VRDisplay not found.");
    resolver->reject(exception);
    ReportPresentationResult(PresentationResult::VRDisplayNotFound);
    return;
  }

  if (success) {
    vrDisplay->beginPresent(resolver);
  } else {
    vrDisplay->forceExitPresent();
    DOMException* exception = DOMException::create(
        NotAllowedError, "Presentation request was denied.");
    ReportPresentationResult(PresentationResult::RequestDenied);
    resolver->reject(exception);
  }
}
Exemple #8
0
void VRController::OnExitPresent(unsigned index) {
  VRDisplay* vrDisplay = getDisplayForIndex(index);
  if (vrDisplay)
    vrDisplay->forceExitPresent();
}