Compare commits

...

8 Commits

Author SHA1 Message Date
Ian Burgmyer 60247572c3 Retargeted samples for .NET 5, normalized C# ver. 3 years ago
Ian Burgmyer 97e4d8c29e Bumped assembly version to 0.0.2. 5 years ago
Ian Burgmyer 86571340c7 Marked NuGet package as pre-release. 5 years ago
Ian Burgmyer a77ea261eb Preparing solution for NuGet packaging. 5 years ago
Ian Burgmyer 07d473c51c Updated README.md. 5 years ago
Ian Burgmyer 1253e3017b Unified the drawing routines. 5 years ago
Ian Burgmyer 76b3e292fe Merge branch 'improved_timing' 5 years ago
Ian Burgmyer aa9f02f8e7 Greatly improved the timing routine. 5 years ago
  1. 12
      DotSDL/DotSDL.csproj
  2. 2
      DotSDL/Graphics/Background.cs
  3. 11
      DotSDL/Graphics/Canvas.cs
  4. 250
      DotSDL/Graphics/SdlWindow.cs
  5. 11
      DotSDL/Graphics/Sprite.cs
  6. 13
      DotSDL/Platform/BasePlatform.cs
  7. 14
      DotSDL/Platform/IPlatform.cs
  8. 29
      DotSDL/Platform/Interop/Fallback/Timing.cs
  9. 36
      DotSDL/Platform/Interop/Posix/Timing.cs
  10. 18
      DotSDL/Platform/PlatformFactory.cs
  11. 10
      DotSDL/Platform/PosixPlatform.cs
  12. 6
      README.md
  13. 2
      Samples/Sample.Audio/Program.cs
  14. 5
      Samples/Sample.Audio/Sample.Audio.csproj
  15. 4
      Samples/Sample.Audio/Window.cs
  16. 2
      Samples/Sample.BasicPixels/Program.cs
  17. 5
      Samples/Sample.BasicPixels/Sample.BasicPixels.csproj
  18. 2
      Samples/Sample.Layers/Program.cs
  19. 5
      Samples/Sample.Layers/Sample.Layers.csproj
  20. 2
      Samples/Sample.Layers/Window.cs
  21. 2
      Samples/Sample.Power/Program.cs
  22. 5
      Samples/Sample.Power/Sample.Power.csproj
  23. 2
      Samples/Sample.Sprites/Program.cs
  24. 5
      Samples/Sample.Sprites/Sample.Sprites.csproj
  25. 2
      Samples/Sample.Sprites/Window.cs

12
DotSDL/DotSDL.csproj

@ -1,17 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.0.1.0</Version>
<AssemblyVersion>0.0.1.0</AssemblyVersion>
<FileVersion>0.0.1.0</FileVersion>
<Version>0.0.2.0</Version>
<AssemblyVersion>0.0.2.0</AssemblyVersion>
<FileVersion>0.0.2.0</FileVersion>
<Description>A framework for .NET designed to interoperate with SDL2.</Description>
<Copyright>(c) 2019 Ian Burgmyer</Copyright>
<Authors>Ian Burgmyer</Authors>
<Company>The DotSDL Team</Company>
<LangVersion>7.2</LangVersion>
<LangVersion>7.3</LangVersion>
<Title>DotSDL</Title>
<PackageProjectUrl>https://github.com/Spectere/DotSDL</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/Spectere/DotSDL/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageLicenseExpression>Zlib</PackageLicenseExpression>
<PackageTags>SDL; graphics; audio; input</PackageTags>
<PackageVersion>0.0.2-alpha</PackageVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>

2
DotSDL/Graphics/Background.cs

@ -30,7 +30,7 @@ namespace DotSDL.Graphics {
// TODO: Might be able to make this faster by leveraging memcpy(). Need to benchmark it.
unsafe {
var copySize = Width * Height * 4; // Width x Height at 4 bytes per pixel.
Render.LockTexture(Texture, IntPtr.Zero, out var pixels, out var _);
Render.LockTexture(Texture, IntPtr.Zero, out var pixels, out _);
Buffer.MemoryCopy(GetCanvasPointer().ToPointer(), pixels, copySize, copySize);
Render.UnlockTexture(Texture);
}

11
DotSDL/Graphics/Canvas.cs

@ -153,6 +153,17 @@ namespace DotSDL.Graphics {
}
}
/// <summary>
/// <c>true</c> if the <see cref="Canvas"/> should be drawn to the screen, otherwise <c>false</c>.
/// </summary>
public bool Shown { get; set; } = true;
/// <summary>
/// The order in which the canvas is drawn. Lower numbered <see cref="Canvas"/> instances are drawn first
/// and will appear on the bottom. This number can be negative.
/// </summary>
public int ZOrder { get; set; }
/// <summary>
/// Sets the section of the <see cref="Canvas"/> that should be drawn. If the size values are set to 0, the
/// <see cref="Canvas"/> will fill as much of its containing object as possible.

250
DotSDL/Graphics/SdlWindow.cs

@ -1,8 +1,10 @@
using DotSDL.Events;
using DotSDL.Input;
using DotSDL.Interop.Core;
using DotSDL.Platform;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace DotSDL.Graphics {
@ -19,13 +21,26 @@ namespace DotSDL.Graphics {
private IntPtr _texture;
private bool _hasTexture;
private float _videoUpdateRate, _gameUpdateRate;
private float _videoUpdateMs, _gameUpdateMs;
private bool _videoUpdateUncapped, _gameUpdateUncapped;
private bool _running;
private uint _nextVideoUpdate;
private uint _nextGameUpdate;
private float _nextVideoUpdate;
private float _nextGameUpdate;
private float _updateDelta;
private List<Canvas> _drawList = new List<Canvas>();
private ScalingQuality _scalingQuality = ScalingQuality.Nearest;
/// <summary>
/// An <see cref="IPlatform"/> that contains native functions appropriate to
/// the platform that this application is running on.
/// </summary>
protected IPlatform Platform { get; } = PlatformFactory.GetPlatform();
/// <summary>Gets the background layer of this window. This is equivalent to accessing Layers[0].</summary>
public Canvas Background => Layers[0];
@ -66,11 +81,35 @@ namespace DotSDL.Graphics {
public int RenderHeight { 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; }
public float MillisecondsElapsed { get; private set; } = 0.0f;
/// <summary>Gets or sets the rate, in hertz, between video updates.</summary>
public float VideoUpdateRate {
get => _videoUpdateUncapped ? 0 : _videoUpdateRate;
set {
_videoUpdateRate = value;
if(System.Math.Abs(_videoUpdateRate) < 1.0f) {
_videoUpdateUncapped = true;
} else {
_videoUpdateUncapped = false;
_videoUpdateMs = 1000 / _videoUpdateRate;
}
}
}
/// <summary>Gets or sets the rate, in hertz, between game (logic) updates.</summary>
public float GameUpdateRate {
get => _gameUpdateUncapped ? 0 : _gameUpdateRate;
set {
_gameUpdateRate = value;
if(System.Math.Abs(_gameUpdateRate) < 1.0f) {
_gameUpdateUncapped = true;
} else {
_gameUpdateUncapped = false;
_gameUpdateMs = 1000 / _gameUpdateRate;
}
}
}
/// <summary>Gets a <see cref="Rectangle"/> that can be manipulated to modify how much of the scene is displayed.</summary>
public Rectangle CameraView { get; }
@ -191,6 +230,7 @@ namespace DotSDL.Graphics {
BlendMode = BlendMode.None
}
};
Background.ZOrder = int.MinValue;
Background.CreateTexture();
CameraView = new Rectangle(
@ -240,20 +280,29 @@ namespace DotSDL.Graphics {
Render.SetRenderTarget(_renderer, _texture);
// Blit the background canvases to the target texture.
foreach(var canvas in Layers) {
canvas.Clipping.Position = CameraView.Position;
canvas.Clipping.Size = CameraView.Size;
canvas.UpdateTexture();
unsafe {
var canvasClippingRect = canvas.Clipping.SdlRect;
Render.RenderCopy(_renderer, canvas.Texture, new IntPtr(&canvasClippingRect), IntPtr.Zero);
// Sort all of the canvases, then draw them.
_drawList.Clear();
_drawList.AddRange(Layers.Where(l => l.Shown).ToArray());
_drawList.AddRange(Sprites.Where(s => s.Shown).ToArray());
foreach(var canvas in _drawList.OrderBy(layer => layer.ZOrder)) {
switch(canvas) {
case Sprite sprite:
DrawSprite(sprite);
break;
default:
canvas.Clipping.Position = CameraView.Position;
canvas.Clipping.Size = CameraView.Size;
canvas.UpdateTexture();
unsafe {
var canvasClippingRect = canvas.Clipping.SdlRect;
Render.RenderCopy(_renderer, canvas.Texture, new IntPtr(&canvasClippingRect), IntPtr.Zero);
}
break;
}
}
// Plot sprites on top of the background layer.
if(Sprites.Count > 0) DrawSprites();
Render.SetRenderTarget(_renderer, IntPtr.Zero);
Render.RenderCopy(_renderer, _texture, IntPtr.Zero, IntPtr.Zero);
@ -270,11 +319,11 @@ namespace DotSDL.Graphics {
/// <summary>
/// Handles updating the application logic for the <see cref="SdlWindow"/>.
/// </summary>
private void BaseUpdate() {
private void BaseUpdate(float delta) {
if(IsDestroyed) return;
Events.EventHandler.ProcessEvents();
OnUpdate(); // Call the overridden Update function.
OnUpdate(delta); // Call the overridden Update function.
}
/// <summary>
@ -306,61 +355,58 @@ namespace DotSDL.Graphics {
}
/// <summary>
/// Plots the sprites stored in <see cref="Sprites"/> to the screen. Please note that this method is called by
/// DotSDL's drawing routines and does not need to be called manually. Additionally, this method will not be
/// called if there are no sprites defined. You usually do not need to override this method.
/// </summary>
public virtual void DrawSprites() {
Render.SetRenderTarget(_renderer, _texture);
foreach(var sprite in Sprites.Where(e => e.Shown).OrderBy(e => e.ZOrder)) {
var srcRect = sprite.Clipping.SdlRect;
var drawSize = sprite.DrawSize;
Rectangle dest;
Point rotationCenter;
if(sprite.CoordinateSystem == CoordinateSystem.ScreenSpace) {
dest = new Rectangle(sprite.Position, drawSize);
rotationCenter = sprite.RotationCenter;
} else {
// Create a set of world coordinates based on the position of the camera
// and this sprite.
var relPosition = new Point(sprite.Position - CameraView.Position);
var screenPosition = new Point(
(int)((float)relPosition.X / CameraView.Size.X * RenderWidth),
(int)((float)relPosition.Y / CameraView.Size.Y * RenderHeight)
);
var scaleFactorX = (float)RenderWidth / CameraView.Size.X;
var scaleFactorY = (float)RenderHeight / CameraView.Size.Y;
var size = new Point(
(int)(drawSize.X * scaleFactorX),
(int)(drawSize.Y * scaleFactorY)
);
dest = new Rectangle(screenPosition, size);
rotationCenter = new Point(
(int)(sprite.RotationCenter.X * scaleFactorX),
(int)(sprite.RotationCenter.Y * scaleFactorY)
);
}
/// Plots a sprite to the screen. Please note that this method is called by DotSDL's drawing
/// routines and does not need to be called manually. Additionally, this method will never be
/// called if there are no active sprites. You usually do not need to override this method.
/// </summary>
public virtual void DrawSprite(Sprite sprite) {
var srcRect = sprite.Clipping.SdlRect;
var drawSize = sprite.DrawSize;
Rectangle dest;
Point rotationCenter;
if(sprite.CoordinateSystem == CoordinateSystem.ScreenSpace) {
dest = new Rectangle(sprite.Position, drawSize);
rotationCenter = sprite.RotationCenter;
} else {
// Create a set of world coordinates based on the position of the camera
// and this sprite.
var relPosition = new Point(sprite.Position - CameraView.Position);
var screenPosition = new Point(
(int)((float)relPosition.X / CameraView.Size.X * RenderWidth),
(int)((float)relPosition.Y / CameraView.Size.Y * RenderHeight)
);
var scaleFactorX = (float)RenderWidth / CameraView.Size.X;
var scaleFactorY = (float)RenderHeight / CameraView.Size.Y;
var size = new Point(
(int)(drawSize.X * scaleFactorX),
(int)(drawSize.Y * scaleFactorY)
);
dest = new Rectangle(screenPosition, size);
rotationCenter = new Point(
(int)(sprite.RotationCenter.X * scaleFactorX),
(int)(sprite.RotationCenter.Y * scaleFactorY)
);
}
var destRect = dest.SdlRect;
var rotationCenterPoint = rotationCenter.SdlPoint;
unsafe {
var srcRectPtr = new IntPtr(&srcRect);
var destRectPtr = new IntPtr(&destRect);
var rotationCenterPtr = new IntPtr(&rotationCenterPoint);
Render.RenderCopyEx(
renderer: _renderer,
texture: sprite.Texture,
srcRect: srcRectPtr,
dstRect: destRectPtr,
angle: sprite.Rotation,
center: rotationCenterPtr,
flip: sprite.Flip
);
}
var destRect = dest.SdlRect;
var rotationCenterPoint = rotationCenter.SdlPoint;
unsafe {
var srcRectPtr = new IntPtr(&srcRect);
var destRectPtr = new IntPtr(&destRect);
var rotationCenterPtr = new IntPtr(&rotationCenterPoint);
Render.RenderCopyEx(
renderer: _renderer,
texture: sprite.Texture,
srcRect: srcRectPtr,
dstRect: destRectPtr,
angle: sprite.Rotation,
center: rotationCenterPtr,
flip: sprite.Flip
);
}
}
@ -409,26 +455,40 @@ namespace DotSDL.Graphics {
/// A game loop that calls the <see cref="SdlWindow"/> update and draw functions.
/// </summary>
private void Loop() {
long MsToNs(float ms) => (long)(ms * 1000000);
var sw = new Stopwatch();
_running = true;
while(_running) {
var ticks = TicksElapsed;
sw.Restart();
if(ticks > _nextGameUpdate || GameUpdateTicks == 0) {
_nextGameUpdate = ticks + GameUpdateTicks;
BaseUpdate();
if(_nextGameUpdate <= 0 || _gameUpdateUncapped) {
BaseUpdate(_updateDelta);
_updateDelta = 0;
_nextGameUpdate += _gameUpdateMs;
}
if(ticks > _nextVideoUpdate || VideoUpdateTicks == 0) {
_nextVideoUpdate = ticks + VideoUpdateTicks;
if(_nextVideoUpdate <= 0 || _videoUpdateUncapped) {
BaseDraw();
_nextVideoUpdate += _videoUpdateMs;
}
if(VideoUpdateTicks <= 0 && GameUpdateTicks <= 0) continue; // Cook the CPU!
var cycleElapsed = (float)sw.Elapsed.TotalMilliseconds;
MillisecondsElapsed += cycleElapsed;
_nextGameUpdate -= cycleElapsed;
_nextVideoUpdate -= cycleElapsed;
_updateDelta += cycleElapsed;
if(!_videoUpdateUncapped && !_gameUpdateUncapped) {
var waitMs = _nextGameUpdate > _nextVideoUpdate ? _nextVideoUpdate : _nextGameUpdate;
if(waitMs > 0)
Platform.Nanosleep(MsToNs(waitMs));
var updateTicks = (long)(_nextGameUpdate > _nextVideoUpdate ? _nextVideoUpdate : _nextGameUpdate) - TicksElapsed;
if(updateTicks > 0)
Timer.Delay((uint)updateTicks);
_updateDelta += waitMs;
_nextGameUpdate -= waitMs;
_nextVideoUpdate -= waitMs;
}
}
}
@ -469,7 +529,7 @@ namespace DotSDL.Graphics {
/// <summary>
/// Called every time the application logic update runs.
/// </summary>
protected virtual void OnUpdate() { }
protected virtual void OnUpdate(float delta) { }
/// <summary>
/// Removes a layer from the layer stack.
@ -486,26 +546,22 @@ namespace DotSDL.Graphics {
/// <summary>
/// Displays the window and begins executing code that's associated with it.
/// </summary>
public void Start() {
Start(0, 0);
}
public void Start() => Start(0, 0);
/// <summary>
/// Displays the window and begins executing code that's associated with it.
/// </summary>
/// <param name="updateRate">The desired number of milliseconds between frames and game logic updates. 0 causes the display and game to be continuously updated.</param>
public void Start(uint updateRate) {
Start(updateRate, updateRate);
}
/// <param name="updateRate">The desired number of video and game logic updates per second. 0 causes the display and game to be updated as quickly as possible.</param>
public void Start(float updateRate) => Start(updateRate, updateRate);
/// <summary>
/// Displays the window and begins executing code that's associated with it.
/// </summary>
/// <param name="drawRate">The desired number of milliseconds between draw calls. 0 causes the display to be continuously updated.</param>
/// <param name="updateRate">The desired number of milliseconds between game logic updates. 0 causes the game to be continuously updated.</param>
public void Start(uint drawRate, uint updateRate) {
VideoUpdateTicks = drawRate;
GameUpdateTicks = updateRate;
/// <param name="drawRate">The desired number of draw calls per second. 0 causes the display to be updated as quickly as possible.</param>
/// <param name="updateRate">The desired number of game logic updates per second. 0 causes the game to be updated as quickly as possible.</param>
public void Start(float drawRate, float updateRate) {
VideoUpdateRate = drawRate;
GameUpdateRate = updateRate;
BaseLoad();
Video.ShowWindow(_window);

11
DotSDL/Graphics/Sprite.cs

@ -83,17 +83,6 @@ namespace DotSDL.Graphics {
/// </summary>
public CoordinateSystem CoordinateSystem { get; set; } = CoordinateSystem.WorldSpace;
/// <summary>
/// <c>true</c> if the sprite should be drawn to the screen, otherwise <c>false</c>.
/// </summary>
public bool Shown { get; set; }
/// <summary>
/// The order in which the sprite is drawn. Lower numbered <see cref="Sprite"/> instances are drawn first
/// and will appear on the bottom.
/// </summary>
public int ZOrder { get; set; }
/// <summary>
/// Initializes a new <see cref="Sprite"/>.
/// </summary>

13
DotSDL/Platform/BasePlatform.cs

@ -0,0 +1,13 @@
using System;
using DotSDL.Platform.Interop.Fallback;
namespace DotSDL.Platform {
/// <summary>
/// Implements the
/// </summary>
public class BasePlatform : IPlatform {
private readonly Timing _fallbackTiming = new Timing();
public virtual Action<long> Nanosleep => _fallbackTiming.Nanosleep;
}
}

14
DotSDL/Platform/IPlatform.cs

@ -0,0 +1,14 @@
using System;
namespace DotSDL.Platform {
/// <summary>
/// Defines a set of function pointers for platform-specific native calls.
/// </summary>
public interface IPlatform {
/// <summary>
/// A high-resolution sleep timer that attempts to rest for a given
/// number of nanoseconds.
/// </summary>
Action<long> Nanosleep { get; }
}
}

29
DotSDL/Platform/Interop/Fallback/Timing.cs

@ -0,0 +1,29 @@
using DotSDL.Interop.Core;
namespace DotSDL.Platform.Interop.Fallback {
public class Timing {
private float _sleepSkew = 0.0f;
/// <summary>
/// Sleeps for a given number of nanoseconds.
/// </summary>
/// <param name="ns">The number of nanoseconds to sleep.</param>
/// <remarks>This implementation uses the SDL_Delay function and should work
/// with all platforms. It attempts to skirt around the resolution issues using
/// the number of fractional milliseconds.</remarks>
public void Nanosleep(long ns) {
var waitTime = ns / 1000000;
_sleepSkew += (float)ns / 1000000 - waitTime;
if(_sleepSkew >= 1) {
// Take the whole part of the skew and add it to the sleep time.
var skewAdd = (long)_sleepSkew;
waitTime += skewAdd;
_sleepSkew -= skewAdd;
}
if(waitTime > 0)
Timer.Delay((uint)waitTime);
}
}
}

36
DotSDL/Platform/Interop/Posix/Timing.cs

@ -0,0 +1,36 @@
using System;
using System.Runtime.InteropServices;
namespace DotSDL.Platform.Interop.Posix {
public class Timing {
private struct Timespec {
/// <summary>
/// A number of seconds.
/// </summary>
public int tvSec;
/// <summary>
/// A number of nanoseconds. This field must be in the range of 0 to 999999999.
/// </summary>
public long tvNsec;
}
/// <summary>
/// Suspends a thread until at least the time given in <paramref name="req"/> has
/// elapsed.
/// </summary>
/// <param name="req">The requested amount of time to sleep.</param>
/// <param name="rem">The remaining sleep time, or NULL if this isn't necessary.</param>
[DllImport("c", EntryPoint = "nanosleep", CallingConvention = CallingConvention.Cdecl)]
private static extern void PosixNanosleep(in Timespec req, out Timespec rem);
/// <summary>
/// Sleeps for a given number of nanoseconds.
/// </summary>
/// <param name="ns">The number of nanoseconds to sleep.</param>
/// <remarks>This implementation uses the nanosleep function introduced
/// with POSIX.1.</remarks>
public void Nanosleep(long ns) =>
PosixNanosleep(new Timespec { tvSec = 0, tvNsec = ns}, out _);
}
}

18
DotSDL/Platform/PlatformFactory.cs

@ -0,0 +1,18 @@
using System;
namespace DotSDL.Platform {
/// <summary>
/// Senses the user's platform and returns a new instance of the most
/// appropriate <see cref="IPlatform"/> implementation.
/// </summary>
public static class PlatformFactory {
public static IPlatform GetPlatform() {
switch(Environment.OSVersion.Platform) {
case PlatformID.Unix:
return new PosixPlatform();
default:
return new BasePlatform();
}
}
}
}

10
DotSDL/Platform/PosixPlatform.cs

@ -0,0 +1,10 @@
using System;
using DotSDL.Platform.Interop.Posix;
namespace DotSDL.Platform {
public class PosixPlatform : BasePlatform {
private readonly Timing _posixTiming = new Timing();
public override Action<long> Nanosleep => _posixTiming.Nanosleep;
}
}

6
README.md

@ -19,9 +19,11 @@ At this time, DotSDL supports the following features:
* Keyboard input.
* Window events.
* Graphics
* A single 32-bit ARGB background canvas (useful for pixel plotting).
* An arbitrary number of 32-bit ARGB background canvases (useful for pixel
plotting and backgrounds).
* Sprite drawing, with support for alpha blending, world and screen space
rendering, and scaling.
rendering, rotation, flipping, and scaling.
* Configurable Z-order for all sprites and background layers.
* Power
* Battery state.

2
Samples/Sample.Audio/Program.cs

@ -2,7 +2,7 @@
internal class Program {
internal static void Main(string[] args) {
var window = new Window(720, 180);
window.Start(16);
window.Start(60);
}
}
}

5
Samples/Sample.Audio/Sample.Audio.csproj

@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\DotSDL\DotSDL.csproj" />

4
Samples/Sample.Audio/Window.cs

@ -107,7 +107,7 @@ namespace Sample.Audio {
base.OnDraw();
}
protected override void OnUpdate() {
protected override void OnUpdate(float _) {
var delta = Fast ? 10 : 1;
if(UpPressed)
_freq += delta;
@ -117,7 +117,7 @@ namespace Sample.Audio {
if(_freq > _maxFreq) _freq = _maxFreq;
if(_freq < _minFreq) _freq = _minFreq;
base.OnUpdate();
base.OnUpdate(delta);
}
private void Window_KeyPressed(object sender, DotSDL.Events.KeyboardEvent e) {

2
Samples/Sample.BasicPixels/Program.cs

@ -2,7 +2,7 @@
internal class Program {
private static void Main(string[] args) {
var window = new Window(512, 256);
window.Start(100, 16); // 10fps, 62.5ups
window.Start(10, 60); // 10 fps, 60hz updates
}
}
}

5
Samples/Sample.BasicPixels/Sample.BasicPixels.csproj

@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\DotSDL\DotSDL.csproj" />

2
Samples/Sample.Layers/Program.cs

@ -2,7 +2,7 @@
internal class Program {
private static void Main(string[] args) {
var window = new Window(4);
window.Start(16);
window.Start(60);
}
}
}

5
Samples/Sample.Layers/Sample.Layers.csproj

@ -2,8 +2,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>

2
Samples/Sample.Layers/Window.cs

@ -82,7 +82,7 @@ namespace Sample.Layers {
Stop();
}
protected override void OnUpdate() {
protected override void OnUpdate(float delta) {
_redPhase += RedSpeed;
_greenPhase += GreenSpeed;
_bluePhase += BlueSpeed;

2
Samples/Sample.Power/Program.cs

@ -4,7 +4,7 @@ namespace Sample.Power {
class Program {
static void Main(string[] args) {
var window = new Window(256, 128);
window.Start(100, 16);
window.Start(10, 60);
}
}
}

5
Samples/Sample.Power/Sample.Power.csproj

@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\DotSDL\DotSDL.csproj" />

2
Samples/Sample.Sprites/Program.cs

@ -2,7 +2,7 @@
internal static class Program {
private static void Main(string[] args) {
var window = new Window(4);
window.Start(16);
window.Start(60);
}
}
}

5
Samples/Sample.Sprites/Sample.Sprites.csproj

@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\DotSDL\DotSDL.csproj" />

2
Samples/Sample.Sprites/Window.cs

@ -152,7 +152,7 @@ namespace Sample.Sprites {
_player2Rotation = 0;
}
protected override void OnUpdate() {
protected override void OnUpdate(float delta) {
_player1.Move(_player1Delta);
_player1.Rotate(_player1Rotation);

Loading…
Cancel
Save