aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore353
-rw-r--r--Unicity.RenderTest/App.config6
-rw-r--r--Unicity.RenderTest/Program.cs43
-rw-r--r--Unicity.RenderTest/Properties/AssemblyInfo.cs36
-rw-r--r--Unicity.RenderTest/Unicity.RenderTest.csproj59
-rw-r--r--Unicity.Renderer/GraphicsRenderer.cs63
-rw-r--r--Unicity.Renderer/Properties/AssemblyInfo.cs36
-rw-r--r--Unicity.Renderer/RenderWindow.cs120
-rw-r--r--Unicity.Renderer/Shapes/Shape.cs17
-rw-r--r--Unicity.Renderer/Shapes/Triangle.cs43
-rw-r--r--Unicity.Renderer/Unicity.Renderer.csproj72
-rw-r--r--Unicity.Renderer/WindowCreationFailedException.cs10
-rw-r--r--Unicity.Renderer/glfw.dllbin0 -> 206848 bytes
-rw-r--r--Unicity.Renderer/packages.config5
-rw-r--r--Unicity.sln31
15 files changed, 894 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..663f9df
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,353 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/ \ No newline at end of file
diff --git a/Unicity.RenderTest/App.config b/Unicity.RenderTest/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/Unicity.RenderTest/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <startup>
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+ </startup>
+</configuration> \ No newline at end of file
diff --git a/Unicity.RenderTest/Program.cs b/Unicity.RenderTest/Program.cs
new file mode 100644
index 0000000..0de65c1
--- /dev/null
+++ b/Unicity.RenderTest/Program.cs
@@ -0,0 +1,43 @@
+using Unicity.Renderer;
+using Unicity.Renderer.Shapes;
+
+namespace Unicity.RenderTest
+{
+ class Program
+ {
+ static RenderWindow window = null;
+ static GraphicsRenderer renderer = null;
+
+ static Triangle triangle;
+
+ static void Main(string[] args)
+ {
+ using (window = new RenderWindow(400, 400, "Test123"))
+ using (renderer = new GraphicsRenderer(window))
+ {
+ window.Init += Window_Init;
+ window.Update += Window_Update;
+ window.Render += Window_Render;
+
+ window.StartUpdateLoop();
+ }
+ }
+
+ private static void Window_Init(object sender, System.EventArgs e)
+ {
+ renderer.SetClearColor(0, 1, 0, 1);
+ triangle = new Triangle(0.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f);
+ }
+
+ private static void Window_Update(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private static void Window_Render(object sender, System.EventArgs e)
+ {
+ renderer.ClearScreen();
+ renderer.RenderShape(triangle);
+ }
+ }
+}
diff --git a/Unicity.RenderTest/Properties/AssemblyInfo.cs b/Unicity.RenderTest/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d5a6093
--- /dev/null
+++ b/Unicity.RenderTest/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("Unicity Render Test")]
+[assembly: AssemblyDescription("Test for the Unicity renderer")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Alee Productions")]
+[assembly: AssemblyProduct("Unicity Renderer Test")]
+[assembly: AssemblyCopyright("Copyright © 2019 Alee Productions")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("0155c998-9189-4c19-8dcc-13499797c7ea")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// indem Sie "*" wie unten gezeigt eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Unicity.RenderTest/Unicity.RenderTest.csproj b/Unicity.RenderTest/Unicity.RenderTest.csproj
new file mode 100644
index 0000000..3bbc39e
--- /dev/null
+++ b/Unicity.RenderTest/Unicity.RenderTest.csproj
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{0155C998-9189-4C19-8DCC-13499797C7EA}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Unicity.RenderTest</RootNamespace>
+ <AssemblyName>Unicity.RenderTest</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Unicity.Renderer\Unicity.Renderer.csproj">
+ <Project>{f6ebb1f8-fca9-4a8d-a807-e877cd047908}</Project>
+ <Name>Unicity.Renderer</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/Unicity.Renderer/GraphicsRenderer.cs b/Unicity.Renderer/GraphicsRenderer.cs
new file mode 100644
index 0000000..f417e14
--- /dev/null
+++ b/Unicity.Renderer/GraphicsRenderer.cs
@@ -0,0 +1,63 @@
+using GLFW;
+using SharpGL;
+using System;
+using Unicity.Renderer.Shapes;
+using static SharpGL.OpenGL;
+
+namespace Unicity.Renderer
+{
+ public class GraphicsRenderer : IDisposable
+ {
+ internal static OpenGL GL = new OpenGL();
+
+ public RenderWindow window { get; }
+
+ public GraphicsRenderer(RenderWindow window)
+ {
+ this.window = window;
+ }
+
+ public void SetClearColor(float red, float green, float blue, float alpha)
+ {
+ GL.ClearColor(red, green, blue, alpha);
+ }
+
+ public void ClearScreen()
+ {
+ Glfw.MakeContextCurrent(window.window);
+ GL.Clear(GL_COLOR_BUFFER_BIT);
+ }
+
+ public void RenderShape(Shape shape)
+ {
+ shape.Render();
+ }
+
+ bool disposed = false;
+ protected virtual void Dispose(bool disposing)
+ {
+ // Return of already disposed
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ // Free managed objects here
+ }
+
+ // Dispose of any unmanaged resources
+ window?.Dispose();
+
+ // Set disposed flag to true
+ disposed = true;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
diff --git a/Unicity.Renderer/Properties/AssemblyInfo.cs b/Unicity.Renderer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..b86f96f
--- /dev/null
+++ b/Unicity.Renderer/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die einer Assembly zugeordnet sind.
+[assembly: AssemblyTitle("Unicity Renderer")]
+[assembly: AssemblyDescription("Renderer for the Unicity game")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Alee Productions")]
+[assembly: AssemblyProduct("Unicity Renderer")]
+[assembly: AssemblyCopyright("Copyright © 2019 Alee Productions")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly
+// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
+// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("f6ebb1f8-fca9-4a8d-a807-e877cd047908")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+// indem Sie "*" wie unten gezeigt eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Unicity.Renderer/RenderWindow.cs b/Unicity.Renderer/RenderWindow.cs
new file mode 100644
index 0000000..840d4fb
--- /dev/null
+++ b/Unicity.Renderer/RenderWindow.cs
@@ -0,0 +1,120 @@
+using System;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using GLFW;
+
+namespace Unicity.Renderer
+{
+ public class RenderWindow : IDisposable
+ {
+ const int FPS = 60;
+
+ internal NativeWindow window = null;
+
+ Stopwatch loopTimer = new Stopwatch();
+
+ public event EventHandler Init;
+ public event EventHandler Update;
+ public event EventHandler Render;
+
+ public int Width
+ {
+ get => window.ClientSize.Width;
+ set => window.ClientSize = new Size(value, window.ClientSize.Height);
+ }
+
+ public int Height
+ {
+ get => window.ClientSize.Height;
+ set => window.ClientSize = new Size(window.ClientSize.Width, value);
+ }
+
+ public string Title
+ {
+ get => window.Title;
+ set => window.Title = value;
+ }
+
+ public RenderWindow(int width, int height, string title)
+ {
+ if (!File.Exists(Glfw.LIBRARY + ".dll"))
+ {
+ throw new WindowCreationFailedException("A required library file is missing and operation cannot continue.");
+ }
+
+ if (!Glfw.Init())
+ {
+ throw new WindowCreationFailedException("Failed to initialize GLFW.");
+ }
+
+ window = new NativeWindow(width, height, title);
+ window.SizeChanged += Window_SizeChanged;
+ }
+
+ private void Window_SizeChanged(object sender, SizeChangeEventArgs e)
+ {
+ GraphicsRenderer.GL.Viewport(0, 0, Width, Height);
+ UpdateWindow();
+ }
+
+ public void StartUpdateLoop()
+ {
+ if (loopTimer.IsRunning) return;
+
+ loopTimer.Start();
+
+ Init?.Invoke(this, EventArgs.Empty);
+
+ while (!window.IsClosed)
+ {
+ Glfw.PollEvents();
+
+ if (!window.IsClosing) UpdateWindow();
+ }
+
+ loopTimer.Stop();
+ }
+
+ private void UpdateWindow()
+ {
+ if (loopTimer.Elapsed.TotalMilliseconds >= 1000 / FPS)
+ {
+ loopTimer.Restart();
+
+ Update?.Invoke(this, EventArgs.Empty);
+ Render?.Invoke(this, EventArgs.Empty);
+
+ window.SwapBuffers();
+ }
+ }
+
+ bool disposed = false;
+ protected virtual void Dispose(bool disposing)
+ {
+ // Return of already disposed
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ // Free managed objects here
+ }
+
+ // Dispose of any unmanaged resources
+ window?.Dispose();
+ Glfw.Terminate();
+
+ // Set disposed flag to true
+ disposed = true;
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
diff --git a/Unicity.Renderer/Shapes/Shape.cs b/Unicity.Renderer/Shapes/Shape.cs
new file mode 100644
index 0000000..b051a89
--- /dev/null
+++ b/Unicity.Renderer/Shapes/Shape.cs
@@ -0,0 +1,17 @@
+using System;
+using static Unicity.Renderer.GraphicsRenderer;
+
+namespace Unicity.Renderer.Shapes
+{
+ public class Shape : IDisposable
+ {
+ protected uint[] buffers = new uint[1];
+
+ public void Dispose()
+ {
+ GL.DeleteBuffers(1, buffers);
+ }
+
+ internal virtual void Render() { }
+ }
+}
diff --git a/Unicity.Renderer/Shapes/Triangle.cs b/Unicity.Renderer/Shapes/Triangle.cs
new file mode 100644
index 0000000..2aec109
--- /dev/null
+++ b/Unicity.Renderer/Shapes/Triangle.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Drawing;
+using static Unicity.Renderer.GraphicsRenderer;
+using static SharpGL.OpenGL;
+
+namespace Unicity.Renderer.Shapes
+{
+ public class Triangle : Shape
+ {
+ public Triangle(PointF pos1, PointF pos2, PointF pos3)
+ {
+ Init(pos1.X, pos1.Y, pos2.X, pos2.Y, pos3.X, pos3.Y);
+ }
+
+ public Triangle(float x1, float y1, float x2, float y2, float x3, float y3)
+ {
+ Init(x1, y1, x2, y2, x3, y3);
+ }
+
+ private void Init(float x1, float y1, float x2, float y2, float x3, float y3)
+ {
+ float[] data =
+ {
+ x1, y1,
+ x2, y2,
+ x3, y3
+ };
+
+ GL.GenBuffers(1, buffers);
+ GL.BindBuffer(GL_ARRAY_BUFFER, buffers[0]);
+ GL.BufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW);
+ }
+
+ internal override void Render()
+ {
+ GL.EnableVertexAttribArray(0);
+ GL.BindBuffer(GL_ARRAY_BUFFER, buffers[0]);
+ GL.VertexAttribPointer(0, 2, GL_FLOAT, false, 0, IntPtr.Zero);
+ GL.DrawArrays(GL_TRIANGLES, 0, 3);
+ GL.DisableVertexAttribArray(0);
+ }
+ }
+}
diff --git a/Unicity.Renderer/Unicity.Renderer.csproj b/Unicity.Renderer/Unicity.Renderer.csproj
new file mode 100644
index 0000000..4be8ec2
--- /dev/null
+++ b/Unicity.Renderer/Unicity.Renderer.csproj
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{F6EBB1F8-FCA9-4A8D-A807-E877CD047908}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Unicity.Renderer</RootNamespace>
+ <AssemblyName>Unicity.Renderer</AssemblyName>
+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <Deterministic>true</Deterministic>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="GLFW.NET, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
+ <HintPath>..\packages\glfw-net.3.3.1\lib\netstandard2.0\GLFW.NET.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpGL, Version=2.4.1.2, Culture=neutral, PublicKeyToken=27fc851303210b27, processorArchitecture=MSIL">
+ <HintPath>..\packages\SharpGL.2.4.1.2\lib\net40-client\SharpGL.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="GraphicsRenderer.cs" />
+ <Compile Include="RenderWindow.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Shapes\Shape.cs" />
+ <Compile Include="Shapes\Triangle.cs" />
+ <Compile Include="WindowCreationFailedException.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="glfw.dll">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project> \ No newline at end of file
diff --git a/Unicity.Renderer/WindowCreationFailedException.cs b/Unicity.Renderer/WindowCreationFailedException.cs
new file mode 100644
index 0000000..380ffb6
--- /dev/null
+++ b/Unicity.Renderer/WindowCreationFailedException.cs
@@ -0,0 +1,10 @@
+namespace Unicity.Renderer
+{
+ class WindowCreationFailedException : System.Exception
+ {
+ public WindowCreationFailedException(string message) : base(message)
+ {
+
+ }
+ }
+}
diff --git a/Unicity.Renderer/glfw.dll b/Unicity.Renderer/glfw.dll
new file mode 100644
index 0000000..f9747a3
--- /dev/null
+++ b/Unicity.Renderer/glfw.dll
Binary files differ
diff --git a/Unicity.Renderer/packages.config b/Unicity.Renderer/packages.config
new file mode 100644
index 0000000..a52cd52
--- /dev/null
+++ b/Unicity.Renderer/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="glfw-net" version="3.3.1" targetFramework="net472" />
+ <package id="SharpGL" version="2.4.1.2" targetFramework="net472" />
+</packages> \ No newline at end of file
diff --git a/Unicity.sln b/Unicity.sln
new file mode 100644
index 0000000..a423de1
--- /dev/null
+++ b/Unicity.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29418.71
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unicity.Renderer", "Unicity.Renderer\Unicity.Renderer.csproj", "{F6EBB1F8-FCA9-4A8D-A807-E877CD047908}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unicity.RenderTest", "Unicity.RenderTest\Unicity.RenderTest.csproj", "{0155C998-9189-4C19-8DCC-13499797C7EA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F6EBB1F8-FCA9-4A8D-A807-E877CD047908}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F6EBB1F8-FCA9-4A8D-A807-E877CD047908}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F6EBB1F8-FCA9-4A8D-A807-E877CD047908}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F6EBB1F8-FCA9-4A8D-A807-E877CD047908}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0155C998-9189-4C19-8DCC-13499797C7EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0155C998-9189-4C19-8DCC-13499797C7EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0155C998-9189-4C19-8DCC-13499797C7EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0155C998-9189-4C19-8DCC-13499797C7EA}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1452E7DC-0F6D-41A6-9FD4-4E8219DB282D}
+ EndGlobalSection
+EndGlobal