diff --git a/SMCode/SM.Base/Textures/Texture.cs b/SMCode/SM.Base/Textures/Texture.cs
index 8908308..135e31b 100644
--- a/SMCode/SM.Base/Textures/Texture.cs
+++ b/SMCode/SM.Base/Textures/Texture.cs
@@ -25,6 +25,22 @@ namespace SM.Base.Textures
///
public Bitmap Map;
+ ///
+ public override int Width
+ {
+ get => Map.Width;
+ protected set
+ { }
+ }
+
+ ///
+ public override int Height
+ {
+ get => Map.Height;
+ protected set {}
+ }
+ public float Aspect { get; private set; }
+
///
/// Empty constructor
///
@@ -50,6 +66,9 @@ namespace SM.Base.Textures
public Texture(Bitmap map, TextureMinFilter filter, TextureWrapMode wrapMode)
{
Map = map;
+
+ Aspect = (float)map.Width / map.Height;
+
Filter = filter;
WrapMode = wrapMode;
}
diff --git a/SMCode/SM.OGL/Texture/TextureBase.cs b/SMCode/SM.OGL/Texture/TextureBase.cs
index fd1966e..cc8630d 100644
--- a/SMCode/SM.OGL/Texture/TextureBase.cs
+++ b/SMCode/SM.OGL/Texture/TextureBase.cs
@@ -32,12 +32,12 @@ namespace SM.OGL.Texture
///
/// The Width of the texture
///
- public int Width { get; protected set; }
+ public virtual int Width { get; protected set; }
///
/// The height of the texture
///
- public int Height { get; protected set; }
+ public virtual int Height { get; protected set; }
public override void Dispose()
{
diff --git a/SMCode/SM2D/Types/Transformation.cs b/SMCode/SM2D/Types/Transformation.cs
index 811e4f1..a603073 100644
--- a/SMCode/SM2D/Types/Transformation.cs
+++ b/SMCode/SM2D/Types/Transformation.cs
@@ -1,8 +1,10 @@
#region usings
+using System;
using OpenTK;
using SM.Base.Drawing;
using SM.Base.Scene;
+using SM.Base.Textures;
using SM.Base.Types;
using SM.Utility;
@@ -38,5 +40,15 @@ namespace SM2D.Types
vec.Normalize();
return vec.Xy;
}
+
+ public void ApplyTextureSize(Texture texture)
+ {
+ Size.Set(texture.Width, texture.Height);
+ }
+
+ public void ApplyTextureSize(Texture texture, float width)
+ {
+ Size.Set(width, width / texture.Aspect);
+ }
}
}
\ No newline at end of file
diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs
index 5d81f97..be18419 100644
--- a/SM_TEST/Program.cs
+++ b/SM_TEST/Program.cs
@@ -55,9 +55,8 @@ namespace SM_TEST
scene.ShowAxisHelper = true;
DrawObject2D kasten = new DrawObject2D();
- kasten.Transform.Size.Set(500,500);
- kasten.ApplyCircle();
kasten.Texture = new Texture(new Bitmap("herosword.png"));
+ kasten.Transform.ApplyTextureSize(kasten.Texture, 500);
scene.Objects.Add(kasten);
//particles.Trigger();