OSVR_ReturnCode UNITY_INTERFACE_API ConstructRenderBuffers() { if (!s_deviceType) { DebugLog("Device type not supported."); return OSVR_RETURN_FAILURE; } UpdateRenderInfo(); // construct buffers const int n = static_cast<int>(s_renderInfo.size()); switch (s_deviceType.getDeviceTypeEnum()) { #if SUPPORT_D3D11 case OSVRSupportedRenderers::D3D11: return applyRenderBufferConstructor(n, ConstructBuffersD3D11, CleanupBufferD3D11); break; #endif #if SUPPORT_OPENGL case OSVRSupportedRenderers::OpenGL: return applyRenderBufferConstructor(n, ConstructBuffersOpenGL, CleanupBufferOpenGL); break; #endif case OSVRSupportedRenderers::EmptyRenderer: default: DebugLog("Device type not supported."); return OSVR_RETURN_FAILURE; } }
// -------------------------------------------------------------------------- // UnityRenderEvent // This will be called for GL.IssuePluginEvent script calls; eventID will // be the integer passed to IssuePluginEvent. /// @todo does this actually need to be exported? It seems like /// GetRenderEventFunc returning it would be sufficient... void UNITY_INTERFACE_API OnRenderEvent(int eventID) { // Unknown graphics device type? Do nothing. if (!s_deviceType) { return; } switch (eventID) { // Call the Render loop case kOsvrEventID_Render: DoRender(); break; case kOsvrEventID_Shutdown: break; case kOsvrEventID_Update: UpdateRenderInfo(); break; case kOsvrEventID_SetRoomRotationUsingHead: SetRoomRotationUsingHead(); break; case kOsvrEventID_ClearRoomToWorldTransform: ClearRoomToWorldTransform(); break; default: break; } }
void CGameClient::CClientData::Reset() { m_aName[0] = 0; m_aClan[0] = 0; m_Country = -1; m_SkinID = 0; m_Team = 0; m_Angle = 0; m_Emoticon = 0; m_EmoticonStart = -1; m_Active = false; m_ChatIgnore = false; m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(0)->m_ColorTexture; m_SkinInfo.m_ColorBody = vec4(1,1,1,1); m_SkinInfo.m_ColorFeet = vec4(1,1,1,1); UpdateRenderInfo(); }
void CGameClient::CClientData::Reset() { m_aName[0] = 0; m_aClan[0] = 0; m_Country = -1; m_Team = 0; m_Angle = 0; m_Emoticon = 0; m_EmoticonStart = -1; m_Active = false; m_ChatIgnore = false; for(int p = 0; p < NUM_SKINPARTS; p++) { m_SkinPartIDs[p] = 0; m_SkinInfo.m_aTextures[p] = g_GameClient.m_pSkins->GetSkinPart(p, 0)->m_ColorTexture; m_SkinInfo.m_aColors[p] = vec4(1.0f, 1.0f, 1.0f , 1.0f); } UpdateRenderInfo(); }
// Called from Unity to create a RenderManager, passing in a ClientContext OSVR_ReturnCode UNITY_INTERFACE_API CreateRenderManagerFromUnity(OSVR_ClientContext context) { /// See if we're already created/running - shouldn't happen, but might. if (s_render != nullptr) { if (s_render->doingOkay()) { DebugLog("[OSVR Rendering Plugin] RenderManager already created " "and doing OK - will just return success without trying " "to re-initialize."); return OSVR_RETURN_SUCCESS; } DebugLog("[OSVR Rendering Plugin] RenderManager already created, " "but not doing OK. Will shut down before creating again."); ShutdownRenderManager(); } if (s_clientContext != nullptr) { DebugLog( "[OSVR Rendering Plugin] Client context already set! Replacing..."); } s_clientContext = context; if (!s_deviceType) { // @todo pass the platform from Unity // This is a patch to workaround a bug in Unity where the renderer type // is not being set on Windows x86 builds. Until the OpenGL path is // working, it's safe to assume we're using D3D11, but we'd rather get // the platform from Unity than assume it's D3D11. s_deviceType = kUnityGfxRendererD3D11; /* DebugLog("[OSVR Rendering Plugin] Attempted to create render manager, " "but device type wasn't set (to a supported type) by the " "plugin load/init routine. Order issue?"); return OSVR_RETURN_FAILURE;*/ } bool setLibraryFromOpenDisplayReturn = false; /// @todo We should always have a legit value in /// s_deviceType.getDeviceTypeEnum() at this point, right? switch (s_deviceType.getDeviceTypeEnum()) { #if SUPPORT_D3D11 case OSVRSupportedRenderers::D3D11: s_render = osvr::renderkit::createRenderManager(context, "Direct3D11", s_library); #ifdef ATTEMPT_D3D_SHARING setLibraryFromOpenDisplayReturn = true; #endif // ATTEMPT_D3D_SHARING break; #endif // SUPPORT_D3D11 #if SUPPORT_OPENGL case OSVRSupportedRenderers::OpenGL: s_render = osvr::renderkit::createRenderManager(context, "OpenGL"); setLibraryFromOpenDisplayReturn = true; break; #endif // SUPPORT_OPENGL } if ((s_render == nullptr) || (!s_render->doingOkay())) { DebugLog("[OSVR Rendering Plugin] Could not create RenderManager"); ShutdownRenderManager(); return OSVR_RETURN_FAILURE; } // Open the display and make sure this worked. osvr::renderkit::RenderManager::OpenResults ret = s_render->OpenDisplay(); if (ret.status == osvr::renderkit::RenderManager::OpenStatus::FAILURE) { DebugLog("[OSVR Rendering Plugin] Could not open display"); ShutdownRenderManager(); return OSVR_RETURN_FAILURE; } if (setLibraryFromOpenDisplayReturn) { // Set our library from the one RenderManager created. s_library = ret.library; } // create a new set of RenderParams for passing to GetRenderInfo() s_renderParams = osvr::renderkit::RenderManager::RenderParams(); UpdateRenderInfo(); DebugLog("[OSVR Rendering Plugin] CreateRenderManagerFromUnity Success!"); return OSVR_RETURN_SUCCESS; }