コード例 #1
0
        //---------------------------------------------------------------
        #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;
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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);
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 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;
 }
コード例 #8
0
        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));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 public void SetSamplerState(int sampler, SamplerState state, TextureAddress value)
 {
     device.SetSamplerState(sampler, state, value);
 }
コード例 #11
0
 public void SetSamplerState(TextureAddress address)
 {
     RenderDevice_SetSamplerState(Handle, address);
 }
コード例 #12
0
 static extern void RenderDevice_SetSamplerState(IntPtr handle, TextureAddress address);
コード例 #13
0
 public void SetSamplerState(int sampler, SamplerState state, TextureAddress value)
 {
     SetSamplerState(sampler, state, (int)value);
 }
コード例 #14
0
        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) { }
        }
コード例 #15
0
        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);
        }
コード例 #16
0
 public void SetSamplerState(int sampler, SamplerState state, TextureAddress value)
 {
     SetSamplerState(sampler, state, (int)value);
 }
コード例 #17
0
 public Result SetSamplerState(int sampler, SamplerState type, TextureAddress textureAddress)
 {
     return(_device.SetSamplerState(sampler, type, textureAddress));
 }
コード例 #18
0
 public void SetSamplerState(int sampler, SamplerState state, TextureAddress value)
 {
     device.SetSamplerState(sampler, state, value);
 }
コード例 #19
0
        //---------------------------------------------------------------
        #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;
        }
コード例 #20
0
 /// <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;
 }
コード例 #21
0
 /// <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;
 }