Browse Source

Began adding in Timer features.

improved_timing
Ian Burgmyer 7 years ago
parent
commit
bbfedc247f
  1. 10
      DotSDL/Graphics/SdlWindow.cs
  2. 15
      DotSDL/Sdl/Timer.cs

10
DotSDL/Graphics/SdlWindow.cs

@ -15,6 +15,9 @@ namespace DotSDL.Graphics {
private Canvas _canvas;
private bool _running;
private uint _nextVideoUpdate;
private uint _nextGameUpdate;
/// <summary>The width of the user window.</summary>
public int WindowWidth { get; }
/// <summary>The height of the user window.</summary>
@ -25,6 +28,13 @@ namespace DotSDL.Graphics {
/// <summary>The height of the internal texture used by this <see cref="SdlWindow"/>.</summary>
public int TextureHeight { get; }
/// <summary>The amount of time, in milliseconds, from when the application was started.</summary>
public uint TicksElapsed => Timer.GetTicks();
/// <summary>Gets or sets the amount of time, in milliseconds, between video updates.</summary>
public uint VideoUpdateTicks { get; set; }
/// <summary>Gets or sets the amount of time, in milliseconds, between game (logic) updates.</summary>
public uint GameUpdateTicks { get; set; }
/// <summary>
/// Indicates that the window manager should position the window. To place the window on a specific display, use the <see cref="WindowPosCenteredDisplay"/> function.
/// </summary>

15
DotSDL/Sdl/Timer.cs

@ -0,0 +1,15 @@
using System.Runtime.InteropServices;
namespace DotSDL.Sdl {
/// <summary>
/// Contains the necessary constants and function imports from SDL_timer.h.
/// </summary>
internal static class Timer {
/// <summary>
/// Retrieves the number of milliseconds since the SDL library was initialized.
/// </summary>
/// <returns>The number of milliseconds since the SDL library was initialized.</returns>
[DllImport(Meta.DllName, EntryPoint = "SDL_GetTicks", CallingConvention = CallingConvention.Cdecl)]
internal static extern uint GetTicks();
}
}
Loading…
Cancel
Save