Skip to content

Commit

Permalink
创建Instance
Browse files Browse the repository at this point in the history
  • Loading branch information
TangChen160186 committed Jun 29, 2024
1 parent cac8e80 commit 0d08372
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 2-Instance/2_Instance.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>_2_Instance</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Comman\Comman.csproj" />
</ItemGroup>

</Project>
56 changes: 56 additions & 0 deletions 2-Instance/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Silk.NET.WebGPU;
using Silk.NET.Windowing;

namespace _2_Instance
{
internal unsafe class Program
{
private static IWindow _window;


private static WebGPU _wgpu;
private static Instance* _instance;
static void Main(string[] args)
{
_window = Window.Create(WindowOptions.Default with{
API = GraphicsAPI.None,
WindowBorder = WindowBorder.Fixed
});

_window.Initialize();
_window.Center();
_window.Load += WindowLoad;
_window.Render += WindowRender;
_window.Update += WindowOnUpdate;
_window.Closing += WindowClosing;

_window.Run();
}
private static void WindowLoad()
{
_wgpu = WebGPU.GetApi();
_instance = _wgpu.CreateInstance(new InstanceDescriptor());
if (_instance is null)
throw new Exception("instance init failure");


}

private static void WindowOnUpdate(double obj)
{
Console.WriteLine("WindowOnUpdate");
}



private static void WindowRender(double obj)
{
Console.WriteLine("window_Render");
}

private static void WindowClosing()
{
_wgpu.InstanceRelease(_instance);
}
}
}
6 changes: 6 additions & 0 deletions LearnWebGPU.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Comman", "Comman\Comman.csp
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{11628A3B-EA07-4423-9DBF-E5C3DE0C515F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2_Instance", "2-Instance\2_Instance.csproj", "{808C9C28-3305-4503-9C1F-F806C4DDA50D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -23,6 +25,10 @@ Global
{61D9994E-1236-4A0D-9761-A5E5FFFACA19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61D9994E-1236-4A0D-9761-A5E5FFFACA19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{61D9994E-1236-4A0D-9761-A5E5FFFACA19}.Release|Any CPU.Build.0 = Release|Any CPU
{808C9C28-3305-4503-9C1F-F806C4DDA50D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{808C9C28-3305-4503-9C1F-F806C4DDA50D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{808C9C28-3305-4503-9C1F-F806C4DDA50D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{808C9C28-3305-4503-9C1F-F806C4DDA50D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 0d08372

Please sign in to comment.