diff --git a/SMCode/SM.Base/Controls/Keyboard.cs b/SMCode/SM.Base/Controls/Keyboard.cs index 5411d89..bb69948 100644 --- a/SMCode/SM.Base/Controls/Keyboard.cs +++ b/SMCode/SM.Base/Controls/Keyboard.cs @@ -13,8 +13,8 @@ namespace SM.Base.Controls /// public static class Keyboard { - internal static KeyboardState? _keyboardState; - internal static List _lastPressedKeys = new List(); + private static KeyboardState? _keyboardState; + private static List _lastPressedKeys = new List(); /// /// True, when ANY key pressed. diff --git a/SMCode/SM.Base/Controls/Mouse.cs b/SMCode/SM.Base/Controls/Mouse.cs index e3cfece..1309818 100644 --- a/SMCode/SM.Base/Controls/Mouse.cs +++ b/SMCode/SM.Base/Controls/Mouse.cs @@ -15,8 +15,8 @@ namespace SM.Base.Controls /// public class Mouse { - internal static MouseState? _mouseState; - internal static List _lastButtonsPressed = new List(); + private static MouseState? _mouseState; + private static List _lastButtonsPressed = new List(); /// /// The current position of the mouse in the screen. diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs index 29219f4..36f18f6 100644 --- a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs +++ b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs @@ -31,7 +31,7 @@ namespace SM.Base.Drawing.Particles /// /// The maximum speed of the particles /// - public float MaxSpeed = 1; + public float MaxSpeed = 50; /// /// This contains all important information for each particle. @@ -67,13 +67,14 @@ namespace SM.Base.Drawing.Particles public abstract Func MovementCalculation { get; set; } /// - public bool UpdateActive { get; set; } + public bool UpdateActive { + get => timer.Active; + set { return; } + } /// public void Update(UpdateContext context) { - if (!timer.Running) return; - ParticleContext particleContext = new ParticleContext { Timer = timer diff --git a/SMCode/SM.Base/Textures/Texture.cs b/SMCode/SM.Base/Textures/Texture.cs index 0e140f0..caa3efb 100644 --- a/SMCode/SM.Base/Textures/Texture.cs +++ b/SMCode/SM.Base/Textures/Texture.cs @@ -15,6 +15,21 @@ namespace SM.Base.Textures /// public class Texture : TextureBase { + static HintMode _hintMode; + /// + /// Defines the texture quailty. + /// It won't change already compiled textures! + /// + public static HintMode TextureQuality + { + get => _hintMode; + set + { + _hintMode = value; + GL.Hint(HintTarget.TextureCompressionHint, value); + } + } + private int? _height; private int? _width; @@ -116,7 +131,7 @@ namespace SM.Base.Textures var transparenz = map.PixelFormat == PixelFormat.Format32bppArgb; GL.TexImage2D(TextureTarget.Texture2D, 0, - transparenz ? PixelInternalFormat.Rgba : PixelInternalFormat.Rgb, + transparenz ? PixelInternalFormat.CompressedRgba : PixelInternalFormat.CompressedRgb, data.Width, data.Height, 0, transparenz ? OpenTK.Graphics.OpenGL4.PixelFormat.Bgra : OpenTK.Graphics.OpenGL4.PixelFormat.Bgr, PixelType.UnsignedByte, data.Scan0); diff --git a/SMCode/SM.OGL/GLDebugging.cs b/SMCode/SM.OGL/GLDebugging.cs index d333be3..e67c1e0 100644 --- a/SMCode/SM.OGL/GLDebugging.cs +++ b/SMCode/SM.OGL/GLDebugging.cs @@ -66,7 +66,7 @@ namespace SM.OGL /// /// Checks for OpenGL errors, while allowing to put stuff before and behind it. /// - /// + /// To decided where to put the error code into, just enter "%code%" to that specific place. /// public static bool CheckGLErrors(string formating) { diff --git a/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs b/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs index 51e2c84..0b6f2a7 100644 --- a/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs +++ b/SMCode/SM.OGL/Shaders/ShaderFileCollection.cs @@ -97,7 +97,7 @@ namespace SM.OGL.Shaders foreach (ShaderFile file in Fragment) GL.DetachShader(shader, file); - GLDebugging.CheckGLErrors($"Error at detaching '{shader.GetType()}'"); + GLDebugging.CheckGLErrors($"Error at detaching '{shader.GetType()}': %code%"); } } } \ No newline at end of file diff --git a/SMCode/SM2D/Drawing/DrawParticles.cs b/SMCode/SM2D/Drawing/DrawParticles.cs index 4adb988..0998e8d 100644 --- a/SMCode/SM2D/Drawing/DrawParticles.cs +++ b/SMCode/SM2D/Drawing/DrawParticles.cs @@ -14,6 +14,11 @@ namespace SM2D.Drawing /// public override Func MovementCalculation { get; set; } = ParticleMovement.Default2D; + /// + /// The direction the particles should travel. + /// + public Vector2? Direction; + /// public DrawParticles(TimeSpan duration) : base(duration) { @@ -25,7 +30,7 @@ namespace SM2D.Drawing return new ParticleStruct() { Matrix = Matrix4.CreateScale(1), - Direction = new Vector2(Randomize.GetFloat(-1, 1), Randomize.GetFloat(-1, 1)), + Direction = Direction.GetValueOrDefault(new Vector2(Randomize.GetFloat(-1, 1), Randomize.GetFloat(-1, 1))), Speed = Randomize.GetFloat(MaxSpeed) }; } diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs index 24c5c53..b3a325e 100644 --- a/SM_TEST/Program.cs +++ b/SM_TEST/Program.cs @@ -1,19 +1,13 @@ using System; using System.Diagnostics; using OpenTK; -using OpenTK.Graphics; -using OpenTK.Input; -using SM.Base; +using SM.Base.Controls; using SM.Base.Time; using SM.Base.Window; using SM2D; -using SM2D.Controls; using SM2D.Drawing; using SM2D.Object; -using SM2D.Pipelines; using SM2D.Scene; -using Font = SM.Base.Drawing.Text.Font; -using Vector2 = OpenTK.Vector2; namespace SM_TEST { @@ -22,6 +16,7 @@ namespace SM_TEST static Scene scene; private static GLWindow window; private static PolyLine line; + private static DrawParticles particles; static void Main(string[] args) { window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off); @@ -30,14 +25,13 @@ namespace SM_TEST window.SetScene(scene = new Scene()); - line = new PolyLine(new Vector2[] { Vector2.Zero, Vector2.One }, PolyLineType.Connected); - var display = new DrawObject2D() + particles = new DrawParticles(TimeSpan.FromSeconds(5)) { - Mesh = line + MaxSpeed = 50, }; - display.Transform.Size.Set(1); - scene.Objects.Add(display); - + particles.Transform.Size.Set(20); + scene.Objects.Add(particles); + window.UpdateFrame += WindowOnUpdateFrame; window.RenderFrame += Window_RenderFrame; window.Run(); @@ -52,13 +46,8 @@ namespace SM_TEST private static void WindowOnUpdateFrame(object sender, FrameEventArgs e) { - if (SM.Base.Controls.Mouse.LeftClick) - line.Vertex.Add(Vector3.Zero); - - line.Vertex[1] = new Vector3(Mouse2D.InWorld(window.ViewportCamera as Camera)); - line.Update(); - - + if (Mouse.LeftClick) + particles.Trigger(); } } } \ No newline at end of file