internal static unsafe void InitSubsystems()
        {
            MyRwTextures.Init();
            MyHwBuffers.Init();
            MyPipelineStates.Init();
            ResetShadows(MyRenderProxy.Settings.ShadowCascadeCount, RenderSettings.ShadowQuality.ShadowCascadeResolution());
            MyRender11.Init();
            MyCommon.Init();
            SamplerStates.Init();
            MyDepthStencilState.Init();
            MyTextures.Init();
            MyVertexLayouts.Init();
            MyShaders.Init();
            MyMeshes.Init();
            MyMeshTableSRV.Init();
            MyLightRendering.Init();
            MyLinesRenderer.Init();
            MySpritesRenderer.Init();
            MyPrimitivesRenderer.Init();
            MyOutline.Init();
            MyBlur.Init();
            MyTransparentRendering.Init();

            MyFoliageComponents.Init();

            MyBillboardRenderer.Init(); // hardcoded limits
            MyDebugRenderer.Init();

            MyScreenDecals.Init();
            MyEnvProbeProcessing.Init();
            MyAtmosphereRenderer.Init();
            MyCloudRenderer.Init();
            MyAAEdgeMarking.Init();
            MyScreenPass.Init();
            MyCopyToRT.Init();
            MyBlendTargets.Init();
            MyFXAA.Init();
            MyDepthResolve.Init();
            MyBloom.Init();
            MyLuminanceAverage.Init();
            MyToneMapping.Init();
            MySSAO.Init();
            MyPlanetBlur.Init();
            MyHdrDebugTools.Init();

            MySceneMaterials.Init();
            MyMaterials1.Init();
            MyVoxelMaterials1.Init();
            MyMeshMaterials1.Init();

            try
            {
                if (m_settings.UseStereoRendering)
                {
                    var openVR = new MyOpenVR();
                    MyStereoStencilMask.InitUsingOpenVR();
                }
            }
            catch (System.Exception e)
            {
                if (!VRage.MyCompilationSymbols.DX11ForceStereo)
                    throw;
                MyStereoStencilMask.InitUsingUndefinedMask();
            }
        }
Ejemplo n.º 2
0
        public MyOpenVR()
        {
            if (true)
            {
                m_viewHMD     = Matrix.Identity;
                m_headsetPosD = MatrixD.Identity;
                m_c1pos       = Matrix.Identity;
                m_c2pos       = Matrix.Identity;

                //IntPtr Handle = MyRender11.LoadLibrary(@"D:\KeenSWH.VR\Sandbox\Sources\SpaceEngineers\bin\x64\Debug\Bin64\openvr_api.dll");
                //IntPtr Handle = LoadLibrary(@"C:\Program Files (x86)\Steam\SteamApps\common\SteamVR\bin\win64\openvr_api.dll");
                IntPtr Handle = LoadLibrary(@"openvr_api.dll");
                //IntPtr Handle = MyRender11.LoadLibrary(@"c:\Program Files (x86)\Steam\bin\openvr_api.dll");//err code 193 -  not a valid Win32 application
                //Assembly.LoadFile(@"D:\KeenSWH\Sandbox\Sources\SpaceEngineers\bin\x64\Debug\Bin64\openvr_api.dll");
                if (Handle == IntPtr.Zero)
                {
                    int errorCode = Marshal.GetLastWin32Error();
                    throw new Exception(string.Format("Failed to load library (ErrorCode: {0})", errorCode));
                }

                EVRInitError error = EVRInitError.None;
                IntPtr       ptr   = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Scene);
                if (error == EVRInitError.None)
                {
                    m_vrSystem = new CVRSystem(ptr);

                    uint sizeX = 0, sizeY = 0;
                    m_vrSystem.GetRecommendedRenderTargetSize(ref sizeX, ref sizeY);

                    m_vrSystem.SetDisplayVisibility(true);

                    ETrackedPropertyError pError = 0;
                    m_ipd_2 = 0.5f * m_vrSystem.GetFloatTrackedDeviceProperty(0, ETrackedDeviceProperty.Prop_UserIpdMeters_Float, ref pError);
                    SetIPD(m_ipd_2 * 2);

                    IntPtr pointer = OpenVR.GetGenericInterface(OpenVR.IVRCompositor_Version, ref error);
                    if (error == EVRInitError.None)
                    {
                        m_vrCompositor = new CVRCompositor(pointer);
                        m_vrCompositor.CompositorBringToFront();
                        m_vrCompositor.ShowMirrorWindow();
                        m_openVR = this;
                    }
                    else
                    {
                        var errString = OpenVR.GetStringForHmdError(error);
                        Log.WriteLineAndConsole(errString);
                        Debug.Fail("No compositor interface");
                        throw new Exception(errString);
                    }
                }
                else
                {
                    var errString = OpenVR.GetStringForHmdError(error);
                    Log.WriteLineAndConsole(errString);
                    //Debug.Fail("OpenVR init failed");
                    throw new Exception(errString);
                }
                InitOverlays();
            }
        }
Ejemplo n.º 3
0
        public MyOpenVR()
        {
            if (true)
            {
                m_viewHMD = Matrix.Identity;
                m_headsetPosD = MatrixD.Identity;
                m_c1pos = Matrix.Identity;
                m_c2pos = Matrix.Identity;

                //IntPtr Handle = MyRender11.LoadLibrary(@"D:\KeenSWH.VR\Sandbox\Sources\SpaceEngineers\bin\x64\Debug\Bin64\openvr_api.dll");
                //IntPtr Handle = LoadLibrary(@"C:\Program Files (x86)\Steam\SteamApps\common\SteamVR\bin\win64\openvr_api.dll");
                IntPtr Handle = LoadLibrary(@"openvr_api.dll");
                //IntPtr Handle = MyRender11.LoadLibrary(@"c:\Program Files (x86)\Steam\bin\openvr_api.dll");//err code 193 -  not a valid Win32 application
                //Assembly.LoadFile(@"D:\KeenSWH\Sandbox\Sources\SpaceEngineers\bin\x64\Debug\Bin64\openvr_api.dll");
                if (Handle == IntPtr.Zero)
                {
                    int errorCode = Marshal.GetLastWin32Error();
                    throw new Exception(string.Format("Failed to load library (ErrorCode: {0})", errorCode));
                }

                EVRInitError error = EVRInitError.None;
                IntPtr ptr = OpenVR.Init(ref error, EVRApplicationType.VRApplication_Scene);
                if (error == EVRInitError.None)
                {
                    m_vrSystem = new CVRSystem(ptr);
                    
                    uint sizeX=0,sizeY=0;
                    m_vrSystem.GetRecommendedRenderTargetSize(ref sizeX, ref sizeY);
                    
                    m_vrSystem.SetDisplayVisibility(true);

                    ETrackedPropertyError pError=0;
                    m_ipd_2=0.5f*m_vrSystem.GetFloatTrackedDeviceProperty(0,ETrackedDeviceProperty.Prop_UserIpdMeters_Float,ref pError);
                    SetIPD(m_ipd_2*2);

                    IntPtr pointer = OpenVR.GetGenericInterface(OpenVR.IVRCompositor_Version, ref error);
                    if (error == EVRInitError.None)
                    {
                        m_vrCompositor = new CVRCompositor(pointer);
                        m_vrCompositor.CompositorBringToFront();
                        m_vrCompositor.ShowMirrorWindow();
                        m_openVR = this;
                    }
                    else
                    {
                        var errString = OpenVR.GetStringForHmdError(error);
                        Log.WriteLineAndConsole(errString);
                        Debug.Fail("No compositor interface");
                        throw new Exception(errString);
                    }
                }
                else
                {
                    var errString = OpenVR.GetStringForHmdError(error);
                    Log.WriteLineAndConsole(errString);
                    //Debug.Fail("OpenVR init failed");
                    throw new Exception(errString);
                }
                InitOverlays();
            }
        }