/// <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; }
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); }
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; }
/// <summary> /// Creates a new effect. /// </summary> public Effect() { _mvpMatrix3D = Matrix3D.Create(); ProgramBaseName = GetType().Name; SparrowSharp.ContextCreated += OnContextCreated; TextureSmoothing = TextureSmoothing.Bilinear; }
/// <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(); }
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; }
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); }
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(); }
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; }