Exemple #1
0
        public static void UnloadContent(bool removeObjects = true)
        {
            MyMwcLog.WriteLine("MyRender.UnloadContent - START");
            MyMwcLog.IncreaseIndent();

            MyShadowRendererBase.UnloadContent();

            for (int i = 0; i < m_renderTargets.GetLength(0); i++)
            {
                DisposeRenderTarget((MyRenderTargets)i);
            }

            DisposeSpotShadowRT();

            if (m_randomTexture != null)
            {
                m_randomTexture.Dispose();
                m_randomTexture = null;
            }

            MyOcclusionQueries.UnloadContent();

            UnloadEffects();

            Clear();

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyRender.UnloadContent - END");
        }
Exemple #2
0
        public static void LoadContent()
        {
            MyMwcLog.WriteLine("MyRender.LoadContent - START");
            MyMwcLog.IncreaseIndent();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyRender::LoadContent");
            UnloadContent(false); //Because XNA does not do this automatically

            m_device = MyMinerGame.Static.GraphicsDevice;

            CreateRenderTargets();
            CreateEnvironmentMapsRT(MyRenderConstants.ENVIRONMENT_MAP_SIZE);

            MyMwcLog.WriteLine("CreateRandomTexture");

            m_randomTexture = CreateRandomTexture();

            MyShadowRendererBase.LoadContent();

            MyOcclusionQueries.LoadContent(m_device);

            LoadEffects();

            MyMwcLog.WriteLine("MyShadowRenderer");

            if (m_shadowRenderer == null)
            {
#if RENDER_PROFILING
                //m_shadowRenderer = new MyShadowRenderer(GetShadowCascadeSize(), MyRenderTargets.ShadowMap, false);
                m_shadowRenderer = new MyShadowRenderer(GetShadowCascadeSize(), MyRenderTargets.ShadowMap, MyRenderTargets.ShadowMapZBuffer, true);
#else
                m_shadowRenderer = new MyShadowRenderer(GetShadowCascadeSize(), MyRenderTargets.ShadowMap, MyRenderTargets.ShadowMapZBuffer, true);
#endif
            }

            MyMwcLog.WriteLine("SpotShadowRenderer");

            if (m_spotShadowRenderer == null)
            {
                m_spotShadowRenderer = new MySpotShadowRenderer();
            }

            MyMwcLog.WriteLine("InitQueries");

            List <MyElement> list = new List <MyElement>();
            BoundingBox      aabb = new BoundingBox(new Vector3(float.MinValue), new Vector3(float.MaxValue));
            m_cullingStructure.OverlapAllBoundingBox(ref aabb, list);
            foreach (MyCullableRenderObject element in list)
            {
                element.InitQueries();
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyRender.LoadContent - END");
        }
        public void InitQueries()
        {
            for (int i = 0; i < Enum.GetValues(typeof(MyOcclusionQueryID)).Length; i++)
            {
                MyOcclusionQuery occlusionQuery = MyOcclusionQueries.Get();

                m_queries[i].OcclusionQueryIssued  = false;
                m_queries[i].OcclusionQueryVisible = true;

                m_queries[i].OcclusionQuery = occlusionQuery;
            }
        }
        public void DestroyQueries()
        {
            for (int i = 0; i < Enum.GetValues(typeof(MyOcclusionQueryID)).Length; i++)
            {
                m_queries[i].OcclusionQueryIssued = false;
                if (m_queries[i].OcclusionQuery != null)
                {
                    MyOcclusionQueries.Return(m_queries[i].OcclusionQuery);
                    m_queries[i].OcclusionQuery = null;
                }
            }

            if (CulledObjects != null)
            {
                CulledObjects.Clear();
            }
        }