public override void LoadContent() { if (m_glare == null) { m_glare = new MyLightGlare(this); } m_glare.LoadContent(); SpotQuery = MyOcclusionQueries.Get(); SpotQueryState = QueryState.IssueOcc; base.LoadContent(); }
public override void LoadContent() { base.LoadContent(); 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; System.Diagnostics.Debug.Assert(m_queries[i].OcclusionQuery == null); m_queries[i].OcclusionQuery = occlusionQuery; } }
// IMPORTANT: This load content can be called only once in application - at the application start. Not for every game-play screen start. // Reason is that OcclusionQuery will stop work if two or more instances are created, even if previous was Disposed. I don't know if // it's error or feature... I will just follow above rule. public override void LoadContent() { MyRender.Log.WriteLine("MySunGlare.LoadContent() - START"); MyRender.Log.IncreaseIndent(); // Load the glow, ray and flare textures. m_glareSprite = MyTextureManager.GetTexture <MyTexture2D>("Textures\\SunGlare\\SunGlare.dds"); m_glowSprite = MyTextureManager.GetTexture <MyTexture2D>("Textures\\SunGlare\\sun_glow_main.dds"); m_glowSprite2 = MyTextureManager.GetTexture <MyTexture2D>("Textures\\SunGlare\\sun_glow_ray.dds"); m_flares = new[] { new MyFlare(-0.5f, 0.7f, new Color(30, 40, 50), "Textures\\SunGlare\\flare1.dds"), new MyFlare(0.3f, 0.4f, new Color(155, 165, 180), "Textures\\SunGlare\\flare1.dds"), new MyFlare(1.2f, 1.0f, new Color(40, 50, 50), "Textures\\SunGlare\\flare1.dds"), new MyFlare(1.5f, 1.5f, new Color(80, 90, 100), "Textures\\SunGlare\\flare1.dds"), new MyFlare(-0.3f, 0.7f, new Color(140, 150, 160), "Textures\\SunGlare\\flare2.dds"), new MyFlare(0.6f, 0.9f, new Color(85, 95, 100), "Textures\\SunGlare\\flare2.dds"), new MyFlare(0.7f, 0.4f, new Color(130, 150, 170), "Textures\\SunGlare\\flare2.dds"), new MyFlare(-0.7f, 0.7f, new Color(60, 60, 80), "Textures\\SunGlare\\flare3.dds"), new MyFlare(0.0f, 0.6f, new Color(20, 25, 30), "Textures\\SunGlare\\flare3.dds"), new MyFlare(2.0f, 1.4f, new Color(70, 85, 110), "Textures\\SunGlare\\flare3.dds"), }; // Create a SpriteBatch for drawing the glow and flare sprites. m_spriteBatch = new SpriteBatch(MyRender.GraphicsDevice, "SunGlare"); // Create the occlusion query object. But only first time! Then just reuse it. for (int i = 0; i < m_occlusionQueries.Length; i++) { m_occlusionQueries[i] = MyOcclusionQueries.Get(); m_occlusionStates[i] = QueryState.IssueMeasure; } for (int i = 0; i < m_measurementOcclusionQueries.Length; i++) { m_measurementOcclusionQueries[i] = MyOcclusionQueries.Get(); } MyRender.Log.DecreaseIndent(); MyRender.Log.WriteLine("MySunGlare.LoadContent() - END"); }