feat: derive atlas tile size from loaded texture dimensions

This commit is contained in:
MDietermann
2026-05-31 21:43:53 +02:00
parent 50f2bc4221
commit c81cd3c561
4 changed files with 46 additions and 13 deletions

View File

@@ -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);