示例#1
0
 /// <summary>
 /// Copies all properties of the given style to the current instance (or a subset, if the
 /// classes don't match). Must be overridden by all subclasses!
 /// </summary>
 public virtual void CopyFrom(MeshStyle meshStyle)
 {
     _texture          = meshStyle._texture;
     _textureBase      = meshStyle._textureBase;
     TextureRepeat     = meshStyle.TextureRepeat;
     _textureSmoothing = meshStyle._textureSmoothing;
 }
示例#2
0
        public static void SetSamplerStateAt(uint name, bool hasMipMaps,
                                             TextureSmoothing smoothing = TextureSmoothing.Bilinear,
                                             bool repeat = false)
        {
            // set repeat
            Gl.BindTexture(TextureTarget.Texture2d, name);
            Gl.TexParameter(TextureTarget.Texture2d, TextureParameterName.TextureWrapS, repeat ? Gl.REPEAT : Gl.CLAMP_TO_EDGE);
            Gl.TexParameter(TextureTarget.Texture2d, TextureParameterName.TextureWrapT, repeat ? Gl.REPEAT : Gl.CLAMP_TO_EDGE);

            // set smoothing
            TextureMagFilter magFilter;
            TextureMinFilter minFilter;

            if (smoothing == TextureSmoothing.None)
            {
                magFilter = TextureMagFilter.Nearest;
                minFilter = hasMipMaps ? TextureMinFilter.NearestMipmapNearest : TextureMinFilter.Nearest;
            }
            else if (smoothing == TextureSmoothing.Bilinear)
            {
                magFilter = TextureMagFilter.Linear;
                minFilter = hasMipMaps ? TextureMinFilter.LinearMipmapNearest : TextureMinFilter.Linear;
            }
            else
            {
                magFilter = TextureMagFilter.Linear;
                minFilter = hasMipMaps ? TextureMinFilter.LinearMipmapLinear : TextureMinFilter.Linear;
            }
            Gl.TexParameter(TextureTarget.Texture2d, TextureParameterName.TextureMagFilter, (int)magFilter);
            Gl.TexParameter(TextureTarget.Texture2d, TextureParameterName.TextureMinFilter, (int)minFilter);
        }
示例#3
0
        private void Init(uint name, float width, float height, bool hasMipMaps, float scale, bool premultipliedAlpha)
        {
            if (width <= 0.0f)
            {
                throw new InvalidOperationException("invalid width");
            }
            if (height <= 0.0f)
            {
                throw new InvalidOperationException("invalid height");
            }
            if (scale <= 0.0f)
            {
                throw new InvalidOperationException("invalid scale");
            }

            _name               = name;
            _width              = width;
            _height             = height;
            _mipmaps            = hasMipMaps;
            _scale              = scale;
            _premultipliedAlpha = premultipliedAlpha;

            _repeat    = true;                      // force first update
            Repeat     = false;
            _smoothing = (TextureSmoothing)9999999; // force first update
            Smoothing  = TextureSmoothing.Bilinear;
        }
示例#4
0
 /// <summary>
 /// Creates a new effect.
 /// </summary>
 public Effect()
 {
     _mvpMatrix3D                 = Matrix3D.Create();
     ProgramBaseName              = GetType().Name;
     SparrowSharp.ContextCreated += OnContextCreated;
     TextureSmoothing             = TextureSmoothing.Bilinear;
 }
示例#5
0
        /// <summary>
        /// Creates a new instance. The base class' implementation just draws the unmodified
        /// input texture.
        /// </summary>
        protected FragmentFilter()
        {
            _resolution       = 1.0f;
            _textureFormat    = TextureFormat.Rgba4444;
            _textureSmoothing = TextureSmoothing.Bilinear;

            SetRequiresRedraw();
        }
示例#6
0
        public FilterQuad(TextureSmoothing smoothing) : base(new VertexData(4), new IndexData())
        {
            IndexData.AddQuad(0, 1, 2, 3);
            VertexData.Colorize(0xFFFFFF, 1.0f);

            TextureSmoothing = smoothing;
            PixelSnapping    = false;
        }
示例#7
0
        private void ParseAndLoadInfo(XmlDocument xml)
        {
            XmlNodeList infoNodes = xml.GetElementsByTagName("info");

            if (infoNodes.Count > 0)
            {
                XmlAttributeCollection attributes = infoNodes[0].Attributes;

                _name = attributes["face"].Value;
                _size = Convert.ToSingle(attributes["size"].Value);

                if (attributes["smooth"].Value == "0")
                {
                    Smoothing = TextureSmoothing.None;
                }
            }
        }
 protected bool IsStateChange(uint texture,
                              TextureSmoothing smoothing, string blendMode, FragmentFilter filter,
                              bool premultiplyAlpha, int numParticles)
 {
     if (_mNumParticles == 0)
     {
         return(false);
     }
     if (_mNumParticles + numParticles > MaxPossibleParticles)
     {
         return(true);
     }
     if (_mTexture != null && texture != 0)
     {
         return(_mTexture.Base != texture || TexSmoothing != smoothing || BlendMode != blendMode ||
                _mFilter != filter || PremultiplyAlpha != premultiplyAlpha);
     }
     return(true);
 }
示例#9
0
        private IndexData _indexData;     // just a reference to the target's index data

        /// <summary>
        /// Creates a new MeshStyle instance.
        /// Subclasses must provide a constructor that can be called without any arguments.
        /// </summary>
        public MeshStyle()
        {
            _textureSmoothing = TextureSmoothing.Bilinear;
            _type             = GetType();
        }
示例#10
0
        private void Init(uint name, float width, float height, bool hasMipMaps, float scale, bool premultipliedAlpha)
        {
            if (width <= 0.0f)
                throw new InvalidOperationException("invalid width");
            if (height <= 0.0f)
                throw new InvalidOperationException("invalid height");
            if (scale <= 0.0f)
                throw new InvalidOperationException("invalid scale");

            _name = name;
            _width = width;
            _height = height;
            _mipmaps = hasMipMaps;
            _scale = scale;
            _premultipliedAlpha = premultipliedAlpha;

            _repeat = true; // force first update
            Repeat = false;
            _smoothing = (TextureSmoothing)9999999; // force first update
            Smoothing = TextureSmoothing.Bilinear;
        }
示例#11
0
        private void ParseAndLoadInfo(XmlDocument xml)
        {
            XmlNodeList infoNodes = xml.GetElementsByTagName("info");
            if (infoNodes.Count > 0)
            {
                XmlAttributeCollection attributes = infoNodes[0].Attributes;

                _name = attributes["face"].Value;
                _size = Convert.ToSingle(attributes["size"].Value);

                if (attributes["smooth"].Value == "0")
                {
                    Smoothing = TextureSmoothing.None;
                }
            }
        }