public ArrayTexture ToTexture() { var texture = new ArrayTexture(); PopulateTexture(texture); return(texture); }
public void PopulateTexture(ArrayTexture texture) { using var target = texture.Bind(); target.Resize(Width, Height, LayerCount, PixelInternalFormat.Rgba); for (var i = 0; i < LayerCount; i++) { textureData[i].FillArrayTextureLayer(texture, i); } }
public static ArrayTexture Empty( int width, int height, int layerCount, PixelInternalFormat pixelFormat = PixelInternalFormat.Rgba) { var arrayTexture = new ArrayTexture(); using var target = arrayTexture.Bind(); target.Resize(width, height, layerCount, pixelFormat); target.SetFilterMode(TextureMinFilter.LinearMipmapLinear, TextureMagFilter.Linear); target.SetWrapMode(TextureWrapMode.Repeat, TextureWrapMode.Repeat); return(arrayTexture); }
public void FillArrayTextureLayer(ArrayTexture texture, int layer) { if (texture.Width != Width || texture.Height != Height) { throw new ArgumentException("Texture data does not have same dimensions as array texture."); } if (layer < 0 || layer >= texture.LayerCount) { throw new ArgumentOutOfRangeException(nameof(layer)); } using var target = texture.Bind(); Visit(ptr => { // ReSharper disable once AccessToDisposedClosure // we trust the implementation to behave target.UploadLayer(ptr, PixelFormat.Bgra, PixelType.UnsignedByte, layer); }); }
internal Target(ArrayTexture arrayTexture, TextureTarget target) { this.arrayTexture = arrayTexture; this.target = target; GL.BindTexture(target, arrayTexture.Handle); }