feat: derive atlas tile size from loaded texture dimensions
This commit is contained in:
@@ -7,6 +7,9 @@ public sealed class Texture : IDisposable
|
||||
{
|
||||
private readonly int _handle;
|
||||
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
|
||||
public Texture(string path)
|
||||
{
|
||||
this._handle = GL.GenTexture();
|
||||
@@ -15,6 +18,8 @@ public sealed class Texture : IDisposable
|
||||
StbImage.stbi_set_flip_vertically_on_load(1);
|
||||
using FileStream stream = File.OpenRead(path);
|
||||
ImageResult image = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);
|
||||
this.Width = image.Width;
|
||||
this.Height = image.Height;
|
||||
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
|
||||
image.Width, image.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Data);
|
||||
|
||||
Reference in New Issue
Block a user