} // WhiteTexture #endregion #endregion #region Constructor /// <summary> /// Create cube map from given filename. /// </summary> /// <param name="filename">Set filename, must be relative and be a valid file in the textures cube directory.</param> public TextureCube(string filename) { Name = filename; IsRgbm = false; RgbmMaxRange = 50; Filename = AssetContentManager.GameDataDirectory + "Textures\\CubeTextures\\" + filename; if (File.Exists(Filename + ".xnb") == false) { throw new ArgumentException("Failed to load cube map: File " + Filename + " does not exists!"); } try { xnaTextureCube = AssetContentManager.CurrentContentManager.XnaContentManager.Load <Microsoft.Xna.Framework.Graphics.TextureCube>(Filename); Size = xnaTextureCube.Size; Resource.Name = filename; } catch (ObjectDisposedException) { throw new InvalidOperationException("Content Manager: Content manager disposed"); } catch (Exception e) { throw new InvalidOperationException("Failed to load cube map: " + filename, e); } } // TextureCube
} // TextureCube #endregion #region Recreate Resource /// <summary> /// Useful when the XNA device is disposed. /// </summary> internal override void RecreateResource() { xnaTextureCube = AssetContentManager.CurrentContentManager.XnaContentManager.Load <Microsoft.Xna.Framework.Graphics.TextureCube>(Filename); } // RecreateResource
/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/> protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext) { // if the device changed, call Warm() if ((state.DeviceUniqueIndex != BackgroundFill.gd)) { this.WarmShader(state); ic = true; } // Force updating if the instance has changed this.vreg_change = (this.vreg_change | ic); this.preg_change = (this.preg_change | ic); this.vbreg_change = (this.vbreg_change | ic); this.vireg_change = (this.vireg_change | ic); // Set the value for attribute 'worldViewProj' this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc0)); // Set the value for global 'RgbmImageRenderScale' this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[0], BackgroundFill.gid0, ref this.gc0)); // Assign global textures this.CubeRgbmTexture = state.GetGlobalTextureCube(BackgroundFill.tid0); // Assign pixel shader textures and samplers if ((ic | this.ptc)) { state.SetPixelShaderSamplers(this.ptx, this.pts); this.ptc = false; } if ((this.vreg_change == true)) { BackgroundFill.fx.vs_c.SetValue(this.vreg); this.vreg_change = false; ic = true; } if ((this.preg_change == true)) { BackgroundFill.fx.ps_c.SetValue(this.preg); this.preg_change = false; ic = true; } if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending)) { ic = (ic | state.SetBlendMatricesDirect(BackgroundFill.fx.vsb_c, ref this.sc1)); } if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing)) { this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc2)); if ((this.vireg_change == true)) { BackgroundFill.fx.vsi_c.SetValue(this.vireg); this.vireg_change = false; ic = true; } } // Finally, bind the effect if ((ic | ec)) { state.SetEffect(this, ref BackgroundFill.fx, ext); } }