aboutsummaryrefslogtreecommitdiff
path: root/Unicity.Engine/GameWindow.cs
diff options
context:
space:
mode:
authorAdrian Ulbrich <adrian.ulbrich.2003@gmail.com>2019-11-08 23:56:17 +0100
committerAdrian Ulbrich <adrian.ulbrich.2003@gmail.com>2019-11-08 23:56:17 +0100
commit3b214e75effaca1ba67daaf29d0a94e5b0129386 (patch)
treeee0ccd43f193f2bdaedd36dcdc944f01a75e37e3 /Unicity.Engine/GameWindow.cs
parente63155370c817a1d9c16ef798b0a55e6fe328941 (diff)
downloadUnicity-3b214e75effaca1ba67daaf29d0a94e5b0129386.tar.gz
Unicity-3b214e75effaca1ba67daaf29d0a94e5b0129386.tar.bz2
Unicity-3b214e75effaca1ba67daaf29d0a94e5b0129386.zip
Started work on actual engine
Diffstat (limited to 'Unicity.Engine/GameWindow.cs')
-rw-r--r--Unicity.Engine/GameWindow.cs63
1 files changed, 63 insertions, 0 deletions
diff --git a/Unicity.Engine/GameWindow.cs b/Unicity.Engine/GameWindow.cs
new file mode 100644
index 0000000..cb44eb8
--- /dev/null
+++ b/Unicity.Engine/GameWindow.cs
@@ -0,0 +1,63 @@
+using System;
+using Unicity.Renderer;
+
+namespace Unicity.Engine
+{
+ public class GameWindow : IDisposable
+ {
+ RenderWindow window = null;
+ GraphicsRenderer renderer = null;
+
+ public int Width { get => window.Width; set => window.Width = value; }
+ public int Height { get => window.Height; set => window.Height = value; }
+
+ public string Title { get => window.Title; set => window.Title = value; }
+
+ bool disposed = false;
+
+ public GameWindow(int width = 800, int height = 800, string title = "Unicity Renderer written by Adrian Ulbrich")
+ {
+ window = new RenderWindow(width, height, title);
+ renderer = new GraphicsRenderer(window);
+
+ window.Render += Window_Render;
+
+ renderer.TestInit();
+ }
+
+ private void Window_Render(object sender, EventArgs e)
+ {
+ renderer.TestLoop();
+ }
+
+ public void Open(double ups = 60.0, double fps = 60.0)
+ {
+ window.Open(ups, fps);
+ renderer.TestInit();
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ // Dispose of managed resources
+ }
+
+ // Dispose of unmanaged resources
+ window?.Dispose();
+
+ disposed = true;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}