void VRController::OnDisplayChanged(device::blink::VRDisplayPtr display) { VRDisplay* vrDisplay = getDisplayForIndex(display->index); if (!vrDisplay) return; vrDisplay->update(display); }
glm::ivec2 getHmdRenderSize() { VRSystem* pVrSystem = VRSystem::instance(); VRDisplay* pDisplay = pVrSystem->getHMD().get(); glm::ivec2 renderSize = pDisplay->getRecommendedRenderSize(); return renderSize; }
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")); }
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; }
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; }
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; }
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); } }
void VRController::OnExitPresent(unsigned index) { VRDisplay* vrDisplay = getDisplayForIndex(index); if (vrDisplay) vrDisplay->forceExitPresent(); }