Moved inputs inside update section of game loop.

This commit is contained in:
Harrison Deng 2020-07-03 18:16:16 -05:00
parent ad77fec3a2
commit 3ecd32520c
3 changed files with 58 additions and 57 deletions

View File

@ -99,6 +99,13 @@ namespace SlatedGameToolkit.Framework {
}
deltaChanged = false;
}
DateTime frameStart = DateTime.Now;
TimeSpan difference = frameStart - currentTime;
currentTime = frameStart;
timePassedFromLastUpdate += difference;
while (timePassedFromLastUpdate > updateDeltaTime) {
//Updates.
//Events
SDL.SDL_Event SDL_Event;
while (SDL.SDL_PollEvent(out SDL_Event) != 0) {
@ -153,13 +160,7 @@ namespace SlatedGameToolkit.Framework {
break;
}
}
DateTime frameStart = DateTime.Now;
TimeSpan difference = frameStart - currentTime;
currentTime = frameStart;
timePassedFromLastUpdate += difference;
while (timePassedFromLastUpdate > updateDeltaTime) {
//Updates.
manager.update(updateDeltaTime.TotalSeconds <= 0 ? timePassedFromLastUpdate.TotalSeconds : updateDeltaTime.TotalSeconds);
timePassedFromLastUpdate -= updateDeltaTime;
if (updateDeltaTime.TotalSeconds <= 0) {

View File

@ -162,8 +162,8 @@ namespace SlatedGameToolkit.Framework.Graphics.Text
context.BindTexture(TextureTarget.Texture2D, Handle);
context.TexImage2D(TextureTarget.Texture2D, 0, InternalFormat.Red, length, length, 0, PixelFormat.Red, PixelType.UnsignedByte, IntPtr.Zero);
context.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
context.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
context.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
context.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
context.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
context.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

View File

@ -88,7 +88,7 @@ namespace SlatedGameToolkit.Tools.Utilities.Playground
renderer.Draw(logo);
renderer.Draw(textureTester);
renderer.Draw(untextured);
font.Draw(renderer, 0.25f, -0.35f, "ABCDEFHIJKLMNOPQRSTUVWXYZ1234567890", Color.White);
font.Draw(renderer, 0.25f, -0.35f, "Hello World.", Color.White);
renderer.Draw(new RectangleMesh(new RectangleF(-1, -1, 0.5f, 0.5f), new RectangleF(0, 1, 1, -1), font.GetTextureBacking(0), Color.White));
renderer.End();
}