//--------------------------------------------------------------- #endregion //--------------------------------------------------------------- //--------------------------------------------------------------- #region Initialisation //--------------------------------------------------------------- /// <summary> /// Creates a new state object. /// </summary> /// <param name="stage">TextureStage to set filters for.</param> /// <param name="u">Address type for the first texture coordinate.</param> /// <param name="v">Address type for the second texture coordinate.</param> /// <param name="w">Address type for the third texture coordinate.</param> public TextureAddressState(int stage, TextureAddress u, TextureAddress v, TextureAddress w) { Stage = stage; this.U = u; this.V = v; this.W = w; }
public override void Render(Device dxDevice, TextureFilter texFilter, TextureAddress texAddressMode) { dxDevice.RenderState.AlphaBlendEnable = true; dxDevice.RenderState.SourceBlend = Blend.SourceAlpha; dxDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha; dxDevice.RenderState.BlendOperation = BlendOperation.Add; base.Render(dxDevice, texFilter, texAddressMode); }
internal TextureSamplerState(TextureAddress uv, TextureFilter min, TextureFilter mag, TextureFilter mip, int maxAni) { Mode = 0; this.AddressUV = uv; this.MinFilter = min; this.MagFilter = mag; this.MipFilter = mip; this.MaxAnisotropy = maxAni; }
XmlElement writeAddress(XmlDocument doc, string coord, TextureAddress mode) { if (mode != TextureAddress.CLAMP) { XmlElement elem = doc.CreateElement("address"); elem.SetAttribute("coord", coord); elem.SetAttribute("mode", mode.ToString().ToLower()); } return(null); }
public virtual void Render(Device dxDevice, TextureFilter texFilter, TextureAddress texAddressMode) { dxDevice.VertexFormat = CustomVertex.TransformedTextured.Format; dxDevice.SetStreamSource(0, vertices, 0); dxDevice.SamplerState[0].MinFilter = texFilter; dxDevice.SamplerState[0].MagFilter = texFilter; dxDevice.SamplerState[0].AddressU = texAddressMode; dxDevice.SamplerState[0].AddressV = texAddressMode; dxDevice.SetTexture(0, texture); dxDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); }
public void TextureOptions(Matrix matrix, bool filter, TextureAddress textureaddress) { // TextureOptions device.Transform.Texture0 = matrix; if (filter) { device.SamplerState[0].MinFilter = device.SamplerState[0].MagFilter = TextureFilter.Linear; } else { device.SamplerState[0].MinFilter = device.SamplerState[0].MagFilter = TextureFilter.None; } device.SamplerState[0].AddressU = textureaddress; device.SamplerState[0].AddressV = textureaddress; }
public static Result Hook06000035(BaseMesh obj, int subset) { TextureAddress addr_u = 0.0f <= mat_last.Specular.Red && mat_last.Specular.Green <= 1.0f ? TextureAddress.Clamp : TextureAddress.Wrap; if (addr_u != last_u) { obj.Device.SetSamplerState(0, SamplerState.AddressU, addr_u); last_u = addr_u; } TextureAddress addr_v = 0.0f <= mat_last.Specular.Blue && mat_last.Specular.Alpha <= 1.0f ? TextureAddress.Clamp : TextureAddress.Wrap; if (addr_v != last_v) { obj.Device.SetSamplerState(0, SamplerState.AddressV, addr_v); last_v = addr_v; } return(obj.DrawSubset(subset)); }
public static void Hook06000037(Device device, List <AttributeRange> attrs, int i) { TextureAddress addr_u = 0.0f <= mat_last.Specular.Red && mat_last.Specular.Green <= 1.0f ? TextureAddress.Clamp : TextureAddress.Wrap; if (addr_u != last_u) { device.SetSamplerState(0, SamplerState.AddressU, addr_u); last_u = addr_u; } TextureAddress addr_v = 0.0f <= mat_last.Specular.Blue && mat_last.Specular.Alpha <= 1.0f ? TextureAddress.Clamp : TextureAddress.Wrap; if (addr_v != last_v) { device.SetSamplerState(0, SamplerState.AddressV, addr_v); last_v = addr_v; } device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, attrs[i].VertexStart, attrs[i].VertexCount, attrs[i].FaceStart * 3, attrs[i].FaceCount); }
public void SetSamplerState(int sampler, SamplerState state, TextureAddress value) { device.SetSamplerState(sampler, state, value); }
public void SetSamplerState(TextureAddress address) { RenderDevice_SetSamplerState(Handle, address); }
static extern void RenderDevice_SetSamplerState(IntPtr handle, TextureAddress address);
public void SetSamplerState(int sampler, SamplerState state, TextureAddress value) { SetSamplerState(sampler, state, (int)value); }
public Texture(string fromFile) { //Check for XML file //load xml file //Else create a default xml file Name = fromFile; fileName_ = fromFile; string path = System.IO.Path.ChangeExtension(fromFile, "xml"); try { if (System.IO.File.Exists(path)) { XmlDocument doc = new XmlDocument(); doc.Load(path); XmlElement root = doc.DocumentElement; foreach (XmlElement elem in root.ChildNodes) { if (elem.Name.ToLower().Equals("address")) { string coord = elem.GetAttribute("coord"); string mode = elem.GetAttribute("mode"); TextureAddress addr = TextureAddress.CLAMP; if (mode.Equals("wrap")) { addr = TextureAddress.WRAP; } else if (mode.Equals("repeat")) { addr = TextureAddress.REPEAT; } else if (mode.Equals("clamp")) { addr = TextureAddress.CLAMP; } else if (mode.Equals("border")) { addr = TextureAddress.BORDER; } else if (mode.Equals("mirror")) { addr = TextureAddress.MIRROR; } if (coord.Equals("u")) { this.UAddress = addr; } else if (coord.Equals("v")) { this.VAddress = addr; } else if (coord.Equals("w")) { this.WAddress = addr; } } else if (elem.Name.ToLower().Equals("border")) { if (elem.HasAttribute("color")) { BorderColor = UColor.FromString(elem.GetAttribute("color")); } } else if (elem.Name.ToLower().Equals("filter")) { if (elem.HasAttribute("mode")) { string str = elem.GetAttribute("mode").ToLower(); if (str.Equals("nearest")) { FilteringMode = FilteringMode.NEAREST; } else if (str.Equals("bilinear")) { FilteringMode = FilteringMode.BILINEAR; } else if (str.Equals("trilinear")) { FilteringMode = FilteringMode.TRILINEAR; } else if (str.Equals("anisotropic")) { FilteringMode = FilteringMode.ANISOTROPIC; } else { FilteringMode = FilteringMode.DEFAULT; } } } else if (elem.Name.ToLower().Equals("mipmap")) { if (elem.HasAttribute("enable")) { Mipmapping = elem.GetAttribute("enable").Equals("true"); } } else if (elem.Name.ToLower().Equals("quality")) { if (elem.HasAttribute("low")) { LowQualityMIP = int.Parse(elem.GetAttribute("low")); } if (elem.HasAttribute("medium")) { MedQualityMIP = int.Parse(elem.GetAttribute("medium")); } if (elem.HasAttribute("high")) { HighQualityMIP = int.Parse(elem.GetAttribute("high")); } } else if (elem.Name.ToLower().Equals("srgb")) { if (elem.HasAttribute("enable")) { SRGBEnabled = elem.GetAttribute("enable").Equals("true"); } } } } } catch (Exception ex) { } }
private static void ApplyTextureAddress(List <VariableSave> gumVariables, FlatRedBall.Glue.SaveClasses.NamedObjectSave namedObject, TextureAddress textureAddress) { VariableSave variableSave = new VariableSave(); variableSave.Name = $"{namedObject.InstanceName}.Texture Address"; variableSave.Type = nameof(Gum.Managers.TextureAddress); variableSave.Value = textureAddress; gumVariables.Add(variableSave); }
public Result SetSamplerState(int sampler, SamplerState type, TextureAddress textureAddress) { return(_device.SetSamplerState(sampler, type, textureAddress)); }
//--------------------------------------------------------------- #endregion //--------------------------------------------------------------- //--------------------------------------------------------------- #region Methods //--------------------------------------------------------------- /// <summary> /// Saves the current state into the current <see cref="IRenderState"/> object. /// </summary> public void Save() { U = Device.Instance.SamplerStates[Stage].AddressU; V = Device.Instance.SamplerStates[Stage].AddressV; W = Device.Instance.SamplerStates[Stage].AddressW; }
/// <summary> /// Applies the render state. /// </summary> /// <remarks> /// Use this static method if you don't want to allocate a renderState object. /// </remarks> /// <param name="stage">TextureStage to set address mode for.</param> /// <param name="mode">Address mode for all texture coordinates.</param> public static void Apply(int stage, TextureAddress mode) { Device.Instance.SamplerStates[stage].AddressU = mode; Device.Instance.SamplerStates[stage].AddressV = mode; Device.Instance.SamplerStates[stage].AddressW = mode; }
/// <summary> /// Applies the render state. /// </summary> /// <remarks> /// Use this static method if you don't want to allocate a renderState object. /// </remarks> /// <param name="stage">TextureStage to set address mode for.</param> /// <param name="u">Address type for the first texture coordinate.</param> /// <param name="v">Address type for the second texture coordinate.</param> /// <param name="w">Address type for the third texture coordinate.</param> public static void Apply(int stage, TextureAddress u, TextureAddress v, TextureAddress w) { Device.Instance.SamplerStates[stage].AddressU = u; Device.Instance.SamplerStates[stage].AddressV = v; Device.Instance.SamplerStates[stage].AddressW = w; }