Skip to content

Commit 2b67545

Browse files
committed
Fix OpenAL loading on Windows and make the examples run out-of-the-box
1 parent bf101dc commit 2b67545

5 files changed

Lines changed: 28 additions & 2 deletions

File tree

Silk.NET.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDL.Tutorial001.HelloWindow
122122
EndProject
123123
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SDL", "SDL", "{96567E92-4A89-4AC8-9F20-C2A3FE644D10}"
124124
EndProject
125+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenAL.Soft.Native", "sources\OpenAL\Soft.Native\Silk.NET.OpenAL.Soft.Native.csproj", "{72256365-2C76-4E60-9CF0-A4FFF6F3843F}"
126+
EndProject
125127
Global
126128
GlobalSection(SolutionConfigurationPlatforms) = preSolution
127129
Debug|Any CPU = Debug|Any CPU
@@ -204,6 +206,10 @@ Global
204206
{3444151F-2DE3-41BC-B5E0-EFBF0091C087}.Debug|Any CPU.Build.0 = Debug|Any CPU
205207
{3444151F-2DE3-41BC-B5E0-EFBF0091C087}.Release|Any CPU.ActiveCfg = Release|Any CPU
206208
{3444151F-2DE3-41BC-B5E0-EFBF0091C087}.Release|Any CPU.Build.0 = Release|Any CPU
209+
{72256365-2C76-4E60-9CF0-A4FFF6F3843F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
210+
{72256365-2C76-4E60-9CF0-A4FFF6F3843F}.Debug|Any CPU.Build.0 = Debug|Any CPU
211+
{72256365-2C76-4E60-9CF0-A4FFF6F3843F}.Release|Any CPU.ActiveCfg = Release|Any CPU
212+
{72256365-2C76-4E60-9CF0-A4FFF6F3843F}.Release|Any CPU.Build.0 = Release|Any CPU
207213
EndGlobalSection
208214
GlobalSection(SolutionProperties) = preSolution
209215
HideSolutionNode = FALSE
@@ -245,6 +251,7 @@ Global
245251
{E5E8FFBF-1319-4D33-B084-E732656E8A04} = {5E20252F-E2A0-46C9-BBEF-4CE5C96D0E07}
246252
{96567E92-4A89-4AC8-9F20-C2A3FE644D10} = {12B4D1CB-8938-4EC4-8895-79C4E6ABD1E8}
247253
{3444151F-2DE3-41BC-B5E0-EFBF0091C087} = {96567E92-4A89-4AC8-9F20-C2A3FE644D10}
254+
{72256365-2C76-4E60-9CF0-A4FFF6F3843F} = {AF13F7C9-4EE2-403E-B3D2-C4C2E45D9EF3}
248255
EndGlobalSection
249256
GlobalSection(ExtensibilityGlobals) = postSolution
250257
SolutionGuid = {78D2CF6A-60A1-43E3-837B-00B73C9DA384}

examples/CSharp/OpenAL/Tutorial001.HelloSound/OpenAL.Tutorial001.HelloSound.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
<TargetFramework>net10.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
9+
<!-- Ensure native binaries are copied when referencing Silk by ProjectReference -->
10+
<!-- See: https://dotnet.github.io/Silk.NET/docs/v3/for-contributors/build-system#native-packaging -->
11+
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
812
</PropertyGroup>
913

1014
<ItemGroup>
1115
<ProjectReference Include="..\..\..\..\sources\OpenAL\OpenAL\Silk.NET.OpenAL.csproj" />
16+
<ProjectReference Include="..\..\..\..\sources\OpenAL\Soft.Native\Silk.NET.OpenAL.Soft.Native.csproj" />
1217
</ItemGroup>
1318

1419
<ItemGroup>

examples/CSharp/SDL/Tutorial001.HelloWindow/SDL.Tutorial001.HelloWindow.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>net10.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8+
9+
<!-- Ensure native binaries are copied when referencing Silk by ProjectReference -->
10+
<!-- See: https://dotnet.github.io/Silk.NET/docs/v3/for-contributors/build-system#native-packaging -->
11+
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
812
</PropertyGroup>
913

1014
<ItemGroup>

sources/OpenAL/OpenAL/AL.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ namespace Silk.NET.OpenAL;
77

88
public partial class AL
99
{
10-
static AL() =>
10+
static AL()
11+
{
1112
LoaderInterface.RegisterAlternativeName(
1213
"openal",
1314
"/System/Library/Frameworks/OpenAL.framework/OpenAL"
1415
);
1516

17+
LoaderInterface.RegisterAlternativeName("openal", "OpenAL32");
18+
LoaderInterface.RegisterAlternativeName("openal", "soft_oal");
19+
}
20+
1621
public partial class ThisThread
1722
{
1823
private static partial IAL ContextFactory() =>

sources/OpenAL/OpenAL/ALContext.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ public partial class ALContext
1313
"CurrentDevice cannot be changed once set, use another API object for additional devices. For more "
1414
+ "info, see https://dotnet.github.io/Silk.NET/docs/v3/silk.net/static-vs-instance-bindings";
1515

16-
static ALContext() =>
16+
static ALContext()
17+
{
1718
LoaderInterface.RegisterAlternativeName(
1819
"openal",
1920
"/System/Library/Frameworks/OpenAL.framework/OpenAL"
2021
);
2122

23+
LoaderInterface.RegisterAlternativeName("openal", "OpenAL32");
24+
LoaderInterface.RegisterAlternativeName("openal", "soft_oal");
25+
}
26+
2227
public unsafe partial class DllImport
2328
{
2429
[UnmanagedCallersOnly]

0 commit comments

Comments
 (0)