Make frame time in Renderer a property, update TestGame.
This commit is contained in:
@@ -100,7 +100,7 @@ namespace DaggerFramework.Rendering
|
|||||||
Raylib.ClearBackground(DaggerColorToRaylibColor(color));
|
Raylib.ClearBackground(DaggerColorToRaylibColor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override double GetFrameTime()
|
protected override double GetFrameTime()
|
||||||
{
|
{
|
||||||
return (double)Raylib.GetFrameTime();
|
return (double)Raylib.GetFrameTime();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace DaggerFramework.Rendering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract int TargetFps { get; set; }
|
public abstract int TargetFps { get; set; }
|
||||||
public abstract bool VSync { get; set; }
|
public abstract bool VSync { get; set; }
|
||||||
|
public double FrameTime => GetFrameTime();
|
||||||
|
|
||||||
// WINDOW
|
// WINDOW
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -52,6 +53,7 @@ namespace DaggerFramework.Rendering
|
|||||||
protected abstract void SetWindowTitle(string title);
|
protected abstract void SetWindowTitle(string title);
|
||||||
protected abstract void SetWindowVSync(bool value);
|
protected abstract void SetWindowVSync(bool value);
|
||||||
protected abstract void SetTargetFps(int fps);
|
protected abstract void SetTargetFps(int fps);
|
||||||
|
protected abstract double GetFrameTime();
|
||||||
protected abstract int GetMonitorWidth(int monitorId);
|
protected abstract int GetMonitorWidth(int monitorId);
|
||||||
protected abstract int GetMonitorHeight(int monitorId);
|
protected abstract int GetMonitorHeight(int monitorId);
|
||||||
protected abstract int GetCurrentMonitor();
|
protected abstract int GetCurrentMonitor();
|
||||||
@@ -76,7 +78,6 @@ namespace DaggerFramework.Rendering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="color">Background color.</param>
|
/// <param name="color">Background color.</param>
|
||||||
public abstract void ClearBackground(Color color);
|
public abstract void ClearBackground(Color color);
|
||||||
public abstract double GetFrameTime();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads the texture onto the GPU for later use in DrawTexture or other Texture related methods.
|
/// Loads the texture onto the GPU for later use in DrawTexture or other Texture related methods.
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace DaggerFramework.Rendering
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override double GetFrameTime()
|
protected override double GetFrameTime()
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace DaggerFramework.SceneGraph
|
|||||||
public AudioBackend Audio => _audioBackend;
|
public AudioBackend Audio => _audioBackend;
|
||||||
public ResourceManager ResourceManager => _resourceManager;
|
public ResourceManager ResourceManager => _resourceManager;
|
||||||
|
|
||||||
public double DeltaTime => Renderer.GetFrameTime();
|
public double DeltaTime => _renderer.FrameTime;
|
||||||
public bool ShouldRun => Renderer.ShouldRun;
|
public bool ShouldRun => Renderer.ShouldRun;
|
||||||
|
|
||||||
public Scene(Renderer renderer, InputHandler input, AudioBackend audioBackend, ResourceManager resourceManager)
|
public Scene(Renderer renderer, InputHandler input, AudioBackend audioBackend, ResourceManager resourceManager)
|
||||||
|
|||||||
@@ -74,8 +74,12 @@ public class TestGame : Game
|
|||||||
{
|
{
|
||||||
while (_scene.ShouldRun)
|
while (_scene.ShouldRun)
|
||||||
{
|
{
|
||||||
// _renderer.SetWindowTitle($"Test Game ({_renderer.GetFrameTime()} ms)");
|
|
||||||
_scene.Update();
|
_scene.Update();
|
||||||
|
|
||||||
|
double frameTimeMs = _renderer.FrameTime * 1000f;
|
||||||
|
|
||||||
|
_renderer.SetTransform(Vector2.One * 32f, Vector2.Zero, 0f);
|
||||||
|
_renderer.DrawText(_fontHandle, $"{frameTimeMs:0.0} ms", 20, new Color(1f, 1f, 1f, 0.5f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user