rename Window to OSWindow for namespacing + add alpha timing to draw

pull/14/head
cosmonaut 2021-01-25 13:02:35 -08:00
parent 9f2cddb4ae
commit 0dcb103994
4 changed files with 12 additions and 9 deletions

View File

@ -3,6 +3,7 @@ using SDL2;
using MoonWorks.Audio; using MoonWorks.Audio;
using MoonWorks.Graphics; using MoonWorks.Graphics;
using MoonWorks.Input; using MoonWorks.Input;
using MoonWorks.Window;
namespace MoonWorks namespace MoonWorks
{ {
@ -16,7 +17,7 @@ namespace MoonWorks
double accumulator = 0; double accumulator = 0;
bool debugMode; bool debugMode;
public Window Window { get; } public OSWindow Window { get; }
public GraphicsDevice GraphicsDevice { get; } public GraphicsDevice GraphicsDevice { get; }
public AudioDevice AudioDevice { get; } public AudioDevice AudioDevice { get; }
public Inputs Inputs { get; } public Inputs Inputs { get; }
@ -47,7 +48,7 @@ namespace MoonWorks
Inputs = new Inputs(); Inputs = new Inputs();
Window = new Window(windowCreateInfo); Window = new OSWindow(windowCreateInfo);
GraphicsDevice = new GraphicsDevice( GraphicsDevice = new GraphicsDevice(
Window.Handle, Window.Handle,
@ -92,9 +93,11 @@ namespace MoonWorks
accumulator -= timestep; accumulator -= timestep;
} }
double alpha = accumulator / timestep;
if (updateThisLoop) if (updateThisLoop)
{ {
Draw(); Draw(timestep, alpha);
} }
} }
} }
@ -115,6 +118,6 @@ namespace MoonWorks
protected abstract void Update(double dt); protected abstract void Update(double dt);
protected abstract void Draw(); protected abstract void Draw(double dt, double alpha);
} }
} }

View File

@ -1,14 +1,14 @@
using System; using System;
using SDL2; using SDL2;
namespace MoonWorks namespace MoonWorks.Window
{ {
public class Window public class OSWindow
{ {
internal IntPtr Handle { get; } internal IntPtr Handle { get; }
public ScreenMode ScreenMode { get; } public ScreenMode ScreenMode { get; }
public Window(WindowCreateInfo windowCreateInfo) public OSWindow(WindowCreateInfo windowCreateInfo)
{ {
var windowFlags = SDL.SDL_WindowFlags.SDL_WINDOW_VULKAN; var windowFlags = SDL.SDL_WindowFlags.SDL_WINDOW_VULKAN;

View File

@ -1,4 +1,4 @@
namespace MoonWorks namespace MoonWorks.Window
{ {
public enum ScreenMode public enum ScreenMode
{ {

View File

@ -1,4 +1,4 @@
namespace MoonWorks namespace MoonWorks.Window
{ {
public struct WindowCreateInfo public struct WindowCreateInfo
{ {