public ITexture GetTexture(string path) { lock (textures) { if (path == null) { path = string.Empty; } if (path.StartsWith("#")) // It's supposed render target texture { path = path.ToLower(); } ITexture texture; if (textures.TryGetValue(path, out var weakReference)) { texture = weakReference.Target as ITexture; if (texture != null && !texture.IsDisposed) { return(texture); } } texture = CreateTexture(path); textures[path] = new WeakReference(texture); TextureCreated?.Invoke(path, texture); return(texture); } }
public TextureGLAtlas(int width, int height, bool manualMipmaps, All filteringMode = All.Linear) : base(width, height, manualMipmaps, filteringMode) { all_atlases.Add(this); TextureCreated?.Invoke(this); }
public TextureGLAtlas(int width, int height, bool manualMipmaps, All filteringMode = All.Linear, int padding = 0) : base(width, height, manualMipmaps, filteringMode) { this.padding = padding; atlasBounds = new RectangleI(0, 0, Width, Height); all_atlases.Add(this); TextureCreated?.Invoke(this); }
/// <summary> /// Creates a new <see cref="TextureGLSingle"/>. /// </summary> /// <param name="width">The width of the texture.</param> /// <param name="height">The height of the texture.</param> /// <param name="manualMipmaps">Whether manual mipmaps will be uploaded to the texture. If false, the texture will compute mipmaps automatically.</param> /// <param name="filteringMode">The filtering mode.</param> /// <param name="wrapModeS">The texture wrap mode in horizontal direction.</param> /// <param name="wrapModeT">The texture wrap mode in vertical direction.</param> public TextureGLSingle(int width, int height, bool manualMipmaps = false, All filteringMode = All.Linear, WrapMode wrapModeS = WrapMode.None, WrapMode wrapModeT = WrapMode.None) : base(wrapModeS, wrapModeT) { Width = width; Height = height; this.manualMipmaps = manualMipmaps; this.filteringMode = filteringMode; all_textures.Add(this); TextureCreated?.Invoke(this); }
protected void OnTextureCreated(int id, int width, int height) => TextureCreated?.Invoke(this, new TextureCreatedEventArgs(id, width, height));