-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebd6ed9
commit 26b3179
Showing
21 changed files
with
1,525 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Peridot", "src\Peridot\Peridot.csproj", "{25280CCF-69F0-4997-83BD-8921182BDCBE}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Peridot.Veldrid", "src\Peridot.Veldrid\Peridot.Veldrid.csproj", "{06D982B2-97D8-4C38-9837-50D2EA5E050D}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Peridot.Demo", "src\Peridot.Demo\Peridot.Demo.csproj", "{2B5DA501-2051-4045-A3C7-B5E9C74DE7ED}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F5D6FEB2-6E90-4034-83E4-78BCA8EDDA25}" | ||
ProjectSection(SolutionItems) = preProject | ||
src\build\common.props.csproj = src\build\common.props.csproj | ||
src\build\peridot.png = src\build\peridot.png | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{25280CCF-69F0-4997-83BD-8921182BDCBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{25280CCF-69F0-4997-83BD-8921182BDCBE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{25280CCF-69F0-4997-83BD-8921182BDCBE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{25280CCF-69F0-4997-83BD-8921182BDCBE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{06D982B2-97D8-4C38-9837-50D2EA5E050D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{06D982B2-97D8-4C38-9837-50D2EA5E050D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{06D982B2-97D8-4C38-9837-50D2EA5E050D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{06D982B2-97D8-4C38-9837-50D2EA5E050D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{2B5DA501-2051-4045-A3C7-B5E9C74DE7ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2B5DA501-2051-4045-A3C7-B5E9C74DE7ED}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2B5DA501-2051-4045-A3C7-B5E9C74DE7ED}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2B5DA501-2051-4045-A3C7-B5E9C74DE7ED}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {283E4FA4-87D7-4804-B948-D717D1157195} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Ez.Numerics" Version="0.2.0-alpha" /> | ||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" /> | ||
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" /> | ||
<PackageReference Include="Veldrid.StartupUtilities" Version="4.8.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Peridot.Veldrid\Peridot.Veldrid.csproj" /> | ||
<ProjectReference Include="..\Peridot\Peridot.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="Resource.Designer.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resource.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Update="Resource.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resource.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright (c) 2021 ezequias2d <[email protected]> and the Peridot contributors | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
using Peridot.Veldrid; | ||
using System.Drawing; | ||
using System.Drawing.Imaging; | ||
using Veldrid; | ||
using Veldrid.StartupUtilities; | ||
using System.Numerics; | ||
using Peridot.Demo; | ||
using Ez.Numerics; | ||
|
||
var title = "Peridot.Demo"; | ||
var wci = new WindowCreateInfo(100, 100, 640, 480, WindowState.Normal, title); | ||
VeldridStartup.CreateWindowAndGraphicsDevice(wci, out var window, out var gd); | ||
|
||
window.Resized += () => | ||
{ | ||
gd.MainSwapchain.Resize((uint)window.Width, (uint)window.Height); | ||
}; | ||
|
||
var shaders = VeldridSpriteBatch.LoadDefaultShaders(gd); | ||
var sb = new VeldridSpriteBatch(gd, gd.MainSwapchain.Framebuffer.OutputDescription, shaders); | ||
var cl = gd.ResourceFactory.CreateCommandList(); | ||
var fence = gd.ResourceFactory.CreateFence(false); | ||
var texture = LoadTexture(Resource._4_2_07); | ||
var count = 0; | ||
|
||
var time = DateTime.Now; | ||
while (window.Exists) | ||
{ | ||
count++; | ||
|
||
var now = DateTime.Now; | ||
var delta = now - time; | ||
var deltaTime = delta.TotalSeconds; | ||
time = now; | ||
|
||
if((count % 1000) == 0) | ||
{ | ||
window.Title = title + " " + (1f / deltaTime); | ||
} | ||
|
||
window.PumpEvents(); | ||
|
||
sb.Begin(); | ||
sb.ViewMatrix = Matrix4x4.CreateOrthographic(window.Width, window.Height, 0.01f, 1000f); | ||
//ref var item = ref sb.Draw(texture); | ||
var size = new Vector2(texture.Width, texture.Height); | ||
var pos = size * -0.5f; | ||
var source = new System.Drawing.Rectangle(0, 0, (int)texture.Width, (int)texture.Height); | ||
|
||
//item = new(pos, size, source, Color.White, 0f, Vector2.Zero, Vector2.One, 1); | ||
sb.Draw(texture, default, source, Color.White, EzMath.Deg2Rad * count / 1000, size * 0.5f, Vector2.One, 1); | ||
sb.End(); | ||
|
||
cl.Begin(); | ||
cl.SetFramebuffer(gd.SwapchainFramebuffer); | ||
cl.ClearColorTarget(0, RgbaFloat.CornflowerBlue); | ||
sb.DrawBatch(cl); | ||
cl.End(); | ||
|
||
fence.Reset(); | ||
gd.SubmitCommands(cl, fence); | ||
gd.WaitForFence(fence); | ||
gd.SwapBuffers(); | ||
} | ||
|
||
Texture LoadTexture(Bitmap image) | ||
{ | ||
|
||
var texture = gd.ResourceFactory.CreateTexture(new() | ||
{ | ||
Format = Veldrid.PixelFormat.B8_G8_R8_A8_UNorm, | ||
Height = (uint)image.Height, | ||
Width = (uint)image.Width, | ||
Depth = 1, | ||
ArrayLayers = 1, | ||
MipLevels = 1, | ||
SampleCount = TextureSampleCount.Count1, | ||
Type = TextureType.Texture2D, | ||
Usage = TextureUsage.Sampled, | ||
}); | ||
image.RotateFlip(RotateFlipType.RotateNoneFlipY); | ||
image = image.Clone(new(0, 0, image.Width, image.Height), System.Drawing.Imaging.PixelFormat.Format32bppArgb); | ||
|
||
var data = image.LockBits(new(default, new(image.Width, image.Height)), ImageLockMode.ReadOnly, image.PixelFormat); | ||
var size = (uint)(data.Stride * data.Height); | ||
gd.UpdateTexture(texture, data.Scan0, size, 0, 0, 0, (uint)image.Width, (uint)image.Height, 1, 0, 0); | ||
|
||
image.UnlockBits(data); | ||
|
||
return texture; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<!-- | ||
Microsoft ResX Schema | ||
Version 2.0 | ||
The primary goals of this format is to allow a simple XML format | ||
that is mostly human readable. The generation and parsing of the | ||
various data types are done through the TypeConverter classes | ||
associated with the data types. | ||
Example: | ||
... ado.net/XML headers & schema ... | ||
<resheader name="resmimetype">text/microsoft-resx</resheader> | ||
<resheader name="version">2.0</resheader> | ||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | ||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | ||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | ||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | ||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | ||
<value>[base64 mime encoded serialized .NET Framework object]</value> | ||
</data> | ||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | ||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | ||
<comment>This is a comment</comment> | ||
</data> | ||
There are any number of "resheader" rows that contain simple | ||
name/value pairs. | ||
Each data row contains a name, and value. The row also contains a | ||
type or mimetype. Type corresponds to a .NET class that support | ||
text/value conversion through the TypeConverter architecture. | ||
Classes that don't support this are serialized and stored with the | ||
mimetype set. | ||
The mimetype is used for serialized objects, and tells the | ||
ResXResourceReader how to depersist the object. This is currently not | ||
extensible. For a given mimetype the value must be set accordingly: | ||
Note - application/x-microsoft.net.object.binary.base64 is the format | ||
that the ResXResourceWriter will generate, however the reader can | ||
read any of the formats listed below. | ||
mimetype: application/x-microsoft.net.object.binary.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.soap.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
value : The object must be serialized into a byte array | ||
: using a System.ComponentModel.TypeConverter | ||
: and then encoded with base64 encoding. | ||
--> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" use="required" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
<xsd:attribute ref="xml:space" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | ||
<data name="_4_2_07" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||
<value>Resources\4.2.07.tiff;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> | ||
</data> | ||
</root> |
Binary file not shown.
Oops, something went wrong.