Watch
2
0
Fork
You've already forked raylib-cs
0

fix: centralized version data in Directory.build.props, and fixed various interop details that had incorrect function signatures

This commit is contained in:
tiger tiger tiger 2026-06-30 17:12:15 +02:00
commit 3b305013a1
11 changed files with 169 additions and 105 deletions

1
.gitignore vendored
View file

@ -177,6 +177,7 @@ PublishScripts/
# NuGet Packages # NuGet Packages
*.nupkg *.nupkg
nuget
# The packages folder can be ignored because of Package Restore # The packages folder can be ignored because of Package Restore
**/packages/* **/packages/*
# except build/, which is used as an MSBuild target. # except build/, which is used as an MSBuild target.

6
Directory.Build.props Normal file
View file

@ -0,0 +1,6 @@
<Project>
<!-- Auto-imported by every project in the repo; referenced via $(RaylibCsVersion). -->
<PropertyGroup>
<RaylibCsVersion>8.1.0</RaylibCsVersion>
</PropertyGroup>
</Project>

17
Directory.Build.targets Normal file
View file

@ -0,0 +1,17 @@
<Project>
<!-- Raylib-cs 8.1.0 is not on nuget.org yet; pack locally so Examples and tests resolve the package with native runtimes. -->
<Target Name="_EnsureLocalRaylibCsPackage"
BeforeTargets="Restore"
Condition="'$(MSBuildProjectName)' != 'Raylib-cs' And Exists('$(MSBuildThisFileDirectory)Raylib-cs/Raylib-cs.csproj')">
<PropertyGroup>
<_LocalNuGetDir>$(MSBuildThisFileDirectory)nuget</_LocalNuGetDir>
<_LocalRaylibCsNupkg>$(_LocalNuGetDir)/Raylib-cs.$(RaylibCsVersion).nupkg</_LocalRaylibCsNupkg>
</PropertyGroup>
<MakeDir Directories="$(_LocalNuGetDir)" Condition="!Exists('$(_LocalNuGetDir)')"/>
<MSBuild Projects="$(MSBuildThisFileDirectory)Raylib-cs/Raylib-cs.csproj"
Targets="Restore;Pack"
Properties="Configuration=Release;PackageOutputPath=$(_LocalNuGetDir)"
RemoveProperties="RuntimeIdentifier;RuntimeIdentifiers;SelfContained;_IsPublishing"
Condition="!Exists('$(_LocalRaylibCsNupkg)') Or '$(ForceRaylibCsPack)' == 'true'"/>
</Target>
</Project>

View file

@ -16,6 +16,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Raylib-cs" Version="8.0.0"/> <PackageReference Include="Raylib-cs" Version="$(RaylibCsVersion)"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -1,7 +1,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<TargetRaylibTag>6.0</TargetRaylibTag> <TargetRaylibTag>6.0</TargetRaylibTag>
<Version>8.0.0</Version> <Version>$(RaylibCsVersion)</Version>
<PackageVersion>8.0.0</PackageVersion> <PackageVersion>$(RaylibCsVersion)</PackageVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View file

@ -5,7 +5,6 @@
<RootNamespace>Raylib_cs</RootNamespace> <RootNamespace>Raylib_cs</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>12</LangVersion> <LangVersion>12</LangVersion>
<PackageRids>win-x64;win-x86;linux-x64;osx-x64;osx-arm64;browser-wasm</PackageRids>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@ -14,7 +13,6 @@
<PropertyGroup> <PropertyGroup>
<PackageId>Raylib-cs</PackageId> <PackageId>Raylib-cs</PackageId>
<Version>8.0.0</Version>
<Description>C# bindings for raylib</Description> <Description>C# bindings for raylib</Description>
<RepositoryUrl>https://github.com/raylib-cs/raylib-cs/</RepositoryUrl> <RepositoryUrl>https://github.com/raylib-cs/raylib-cs/</RepositoryUrl>
<Authors>raylib-cs</Authors> <Authors>raylib-cs</Authors>
@ -49,93 +47,51 @@
<NativesRoot>$(BaseIntermediateOutputPath)natives/</NativesRoot> <NativesRoot>$(BaseIntermediateOutputPath)natives/</NativesRoot>
</PropertyGroup> </PropertyGroup>
<Choose> <!-- Single source of truth: RID -> raylib release archive + library file.
<When Condition="'$(RuntimeIdentifier)' == 'win-x64'"> Pkg/Ext name the upstream release asset; Lib is the download-time copy glob
<PropertyGroup> (libraylib.so* catches the versioned .so); Pack is the exact file name packed
<RaylibPackageName>raylib-$(TargetRaylibTag)_win64_msvc16</RaylibPackageName> into the nupkg; PackAs renames it inside the package (wasm: libraylib.web.a -> raylib.a).
<ArchiveExt>.zip</ArchiveExt> Drives PackageRids, the per-RID resolve below, and the pack file list. -->
<LibPattern>raylib.dll</LibPattern> <ItemGroup>
</PropertyGroup> <RaylibRid Include="win-x64" Pkg="raylib-$(TargetRaylibTag)_win64_msvc16" Ext=".zip" Lib="raylib.dll" Pack="raylib.dll"/>
</When> <RaylibRid Include="win-x86" Pkg="raylib-$(TargetRaylibTag)_win32_msvc16" Ext=".zip" Lib="raylib.dll" Pack="raylib.dll"/>
<When Condition="'$(RuntimeIdentifier)' == 'win-x86'"> <RaylibRid Include="linux-x64" Pkg="raylib-$(TargetRaylibTag)_linux_amd64" Ext=".tar.gz" Lib="libraylib.so*" Pack="libraylib.so"/>
<PropertyGroup> <RaylibRid Include="osx-x64" Pkg="raylib-$(TargetRaylibTag)_macos" Ext=".tar.gz" Lib="libraylib.dylib" Pack="libraylib.dylib"/>
<RaylibPackageName>raylib-$(TargetRaylibTag)_win32_msvc16</RaylibPackageName> <RaylibRid Include="osx-arm64" Pkg="raylib-$(TargetRaylibTag)_macos" Ext=".tar.gz" Lib="libraylib.dylib" Pack="libraylib.dylib"/>
<ArchiveExt>.zip</ArchiveExt> <RaylibRid Include="browser-wasm" Pkg="raylib-$(TargetRaylibTag)_webassembly" Ext=".zip" Lib="libraylib.web.a" Pack="libraylib.web.a" PackAs="raylib.a"/>
<LibPattern>raylib.dll</LibPattern> </ItemGroup>
</PropertyGroup>
</When> <!-- Resolve the active RID's archive metadata from the table. Runs as a dependency
<When Condition="'$(RuntimeIdentifier)' == 'linux-x64'"> (execution phase) because properties can't read items during evaluation. -->
<PropertyGroup> <Target Name="_ResolveRaylibNative">
<RaylibPackageName>raylib-$(TargetRaylibTag)_linux_amd64</RaylibPackageName> <PropertyGroup>
<ArchiveExt>.tar.gz</ArchiveExt> <RaylibPackageName>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Pkg)')</RaylibPackageName>
<LibPattern>libraylib.so*</LibPattern> <ArchiveExt>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Ext)')</ArchiveExt>
</PropertyGroup> <LibPattern>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Lib)')</LibPattern>
</When> </PropertyGroup>
<When Condition="'$(RuntimeIdentifier)' == 'osx-x64'"> </Target>
<PropertyGroup>
<RaylibPackageName>raylib-$(TargetRaylibTag)_macos</RaylibPackageName>
<ArchiveExt>.tar.gz</ArchiveExt>
<LibPattern>libraylib.dylib</LibPattern>
</PropertyGroup>
</When>
<When Condition="'$(RuntimeIdentifier)' == 'osx-arm64'">
<PropertyGroup>
<RaylibPackageName>raylib-$(TargetRaylibTag)_macos</RaylibPackageName>
<ArchiveExt>.tar.gz</ArchiveExt>
<LibPattern>libraylib.dylib</LibPattern>
</PropertyGroup>
</When>
<When Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
<PropertyGroup>
<RaylibPackageName>raylib-$(TargetRaylibTag)_webassembly</RaylibPackageName>
<ArchiveExt>.zip</ArchiveExt>
<LibPattern>libraylib.web.a</LibPattern>
</PropertyGroup>
</When>
</Choose>
<!-- ================================================================== --> <!-- ================================================================== -->
<!-- TARGET: PACKING --> <!-- TARGET: PACKING -->
<!-- ================================================================== --> <!-- ================================================================== -->
<Target Name="PrepareNativesForPack" BeforeTargets="_GetPackageFiles"> <Target Name="PrepareNativesForPack" BeforeTargets="_GetPackageFiles">
<ItemGroup>
<_TargetRids Include="$(PackageRids)"/>
</ItemGroup>
<MSBuild Projects="$(MSBuildThisFileFullPath)" <MSBuild Projects="$(MSBuildThisFileFullPath)"
Targets="_DownloadAndExtractInternal" Targets="_DownloadAndExtractInternal"
Properties="RuntimeIdentifier=%(_TargetRids.Identity);TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)" Properties="RuntimeIdentifier=%(RaylibRid.Identity);TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)"
BuildInParallel="false"/> BuildInParallel="false"/>
<!-- Direct injection into _PackageFiles --> <!-- Direct injection into _PackageFiles, derived from the RID table.
RIDs without PackAs keep their file name in runtimes/<rid>/native/;
RIDs with PackAs (wasm) are renamed via an explicit file path. -->
<ItemGroup> <ItemGroup>
<_PackageFiles Include="$(NativesRoot)win-x64/raylib-$(TargetRaylibTag)_win64_msvc16/lib/raylib.dll"> <_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')"
<PackagePath>runtimes/win-x64/native/</PackagePath> Condition="'%(RaylibRid.PackAs)' == ''">
<PackagePath>runtimes/%(RaylibRid.Identity)/native/</PackagePath>
<BuildAction>None</BuildAction> <BuildAction>None</BuildAction>
</_PackageFiles> </_PackageFiles>
<_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')"
<_PackageFiles Include="$(NativesRoot)win-x86/raylib-$(TargetRaylibTag)_win32_msvc16/lib/raylib.dll"> Condition="'%(RaylibRid.PackAs)' != ''">
<PackagePath>runtimes/win-x86/native/</PackagePath> <PackagePath>runtimes/%(RaylibRid.Identity)/native/%(RaylibRid.PackAs)</PackagePath>
<BuildAction>None</BuildAction>
</_PackageFiles>
<_PackageFiles Include="$(NativesRoot)linux-x64/raylib-$(TargetRaylibTag)_linux_amd64/lib/libraylib.so">
<PackagePath>runtimes/linux-x64/native/</PackagePath>
<BuildAction>None</BuildAction>
</_PackageFiles>
<_PackageFiles Include="$(NativesRoot)osx-x64/raylib-$(TargetRaylibTag)_macos/lib/libraylib.dylib">
<PackagePath>runtimes/osx-x64/native/</PackagePath>
<BuildAction>None</BuildAction>
</_PackageFiles>
<_PackageFiles Include="$(NativesRoot)osx-arm64/raylib-$(TargetRaylibTag)_macos/lib/libraylib.dylib">
<PackagePath>runtimes/osx-arm64/native/</PackagePath>
<BuildAction>None</BuildAction>
</_PackageFiles>
<_PackageFiles Include="$(NativesRoot)browser-wasm/raylib-$(TargetRaylibTag)_webassembly/lib/libraylib.web.a">
<PackagePath>runtimes/browser-wasm/native/raylib.a</PackagePath>
<BuildAction>None</BuildAction> <BuildAction>None</BuildAction>
</_PackageFiles> </_PackageFiles>
</ItemGroup> </ItemGroup>
@ -145,53 +101,65 @@
<!-- TARGET: LOCAL DEVELOPMENT --> <!-- TARGET: LOCAL DEVELOPMENT -->
<!-- ================================================================== --> <!-- ================================================================== -->
<Target Name="CopyNativeToOutput" AfterTargets="Build" <!-- Resolve and download the native library for a given RID (used by ProjectReference consumers). -->
Condition="'$(GeneratePackageOnBuild)' != 'true' AND '$(RuntimeIdentifier)' != ''"> <Target Name="_PrepareNativeLibrary" DependsOnTargets="_ResolveRaylibNative" Outputs="@(_RaylibNativeLibraryItem)">
<PropertyGroup>
<_RaylibNativesDir>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/$(NativesRoot)'))</_RaylibNativesDir>
</PropertyGroup>
<CallTarget Targets="_DownloadAndExtractInternal"/> <CallTarget Targets="_DownloadAndExtractInternal"/>
<ItemGroup> <ItemGroup>
<_NativeToCopy Include="$(NativesRoot)$(RuntimeIdentifier)/**/$(LibPattern)"/> <_NativeCandidate Include="$(_RaylibNativesDir)$(RuntimeIdentifier)/**/$(LibPattern)"/>
<_RaylibNativeLibraryItem Include="@(_NativeCandidate)"/>
</ItemGroup> </ItemGroup>
<Copy SourceFiles="@(_NativeToCopy)" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="true"/> </Target>
<!-- Stage libraylib.web.a as raylib.a for wasm linking (pinvoke module name must match LibraryImport). -->
<Target Name="_StageWasmNative" DependsOnTargets="_ResolveRaylibNative"
Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
<PropertyGroup>
<_WasmNativeSrc>$(NativesRoot)browser-wasm/$(RaylibPackageName)/lib/libraylib.web.a</_WasmNativeSrc>
<_WasmNativeDst>$(MSBuildThisFileDirectory)obj/browser-wasm/raylib.a</_WasmNativeDst>
</PropertyGroup>
<CallTarget Targets="_DownloadAndExtractInternal"/>
<MakeDir Directories="$(MSBuildThisFileDirectory)obj/browser-wasm"/>
<Copy SourceFiles="$(_WasmNativeSrc)" DestinationFiles="$(_WasmNativeDst)" SkipUnchangedFiles="true"/>
</Target> </Target>
<!-- ================================================================== --> <!-- ================================================================== -->
<!-- WORKER: DOWNLOADER --> <!-- WORKER: DOWNLOADER -->
<!-- ================================================================== --> <!-- ================================================================== -->
<Target Name="_DownloadAndExtractInternal" Condition="'$(RaylibPackageName)' != ''"> <!-- Resolves the archive metadata first (properties can't read items at eval time, so the
RID -> package mapping must be applied here in the execution phase via DependsOnTargets).
Tasks are guarded on RaylibPackageName so an unknown RID is a no-op. -->
<Target Name="_DownloadAndExtractInternal" DependsOnTargets="_ResolveRaylibNative">
<PropertyGroup> <PropertyGroup>
<_WorkDir>$(NativesRoot)$(RuntimeIdentifier)/</_WorkDir> <_WorkDir>$(NativesRoot)$(RuntimeIdentifier)/</_WorkDir>
<_ArchiveFile>$(_WorkDir)$(RaylibPackageName)$(ArchiveExt)</_ArchiveFile> <_ArchiveFile>$(_WorkDir)$(RaylibPackageName)$(ArchiveExt)</_ArchiveFile>
<_ExtractMarker>$(_WorkDir).extracted</_ExtractMarker> <_ExtractMarker>$(_WorkDir).extracted</_ExtractMarker>
</PropertyGroup> </PropertyGroup>
<Message Text="=== _DownloadAndExtractInternal ===" Importance="high"/> <Message Text="Downloading raylib $(TargetRaylibTag) native for $(RuntimeIdentifier)"
<Message Text="RID = $(RuntimeIdentifier)" Importance="high"/> Importance="normal" Condition="'$(RaylibPackageName)' != ''"/>
<Message Text="Archive = $(_ArchiveFile)" Importance="high"/>
<Message Text="Marker = $(_ExtractMarker)" Importance="high"/>
<MakeDir Directories="$(_WorkDir)"/> <MakeDir Directories="$(_WorkDir)" Condition="'$(RaylibPackageName)' != ''"/>
<DownloadFile <DownloadFile
SourceUrl="https://github.com/raysan5/raylib/releases/download/$(TargetRaylibTag)/$(RaylibPackageName)$(ArchiveExt)" SourceUrl="https://github.com/raysan5/raylib/releases/download/$(TargetRaylibTag)/$(RaylibPackageName)$(ArchiveExt)"
DestinationFolder="$(_WorkDir)" DestinationFolder="$(_WorkDir)"
DestinationFileName="$(RaylibPackageName)$(ArchiveExt)" DestinationFileName="$(RaylibPackageName)$(ArchiveExt)"
Condition="!Exists('$(_ArchiveFile)')" Condition="'$(RaylibPackageName)' != '' AND !Exists('$(_ArchiveFile)')"
Retries="3"/> Retries="3"/>
<Message Text="unZIPping" Importance="high" Condition="'$(ArchiveExt)' == '.zip' AND !Exists('$(_ExtractMarker)')"/>
<Unzip SourceFiles="$(_ArchiveFile)" <Unzip SourceFiles="$(_ArchiveFile)"
DestinationFolder="$(_WorkDir)" DestinationFolder="$(_WorkDir)"
OverwriteReadOnlyFiles="true" OverwriteReadOnlyFiles="true"
Condition="'$(ArchiveExt)' == '.zip' AND !Exists('$(_ExtractMarker)')"/> Condition="'$(ArchiveExt)' == '.zip' AND !Exists('$(_ExtractMarker)')"/>
<Message Text="unTARing" Importance="high" Condition="'$(ArchiveExt)' == '.tar.gz' AND !Exists('$(_ExtractMarker)')"/>
<Exec Command="tar -xzf &quot;$(RaylibPackageName)$(ArchiveExt)&quot;" <Exec Command="tar -xzf &quot;$(RaylibPackageName)$(ArchiveExt)&quot;"
WorkingDirectory="$(_WorkDir)" WorkingDirectory="$(_WorkDir)"
Condition="'$(ArchiveExt)' == '.tar.gz' AND !Exists('$(_ExtractMarker)')"/> Condition="'$(ArchiveExt)' == '.tar.gz' AND !Exists('$(_ExtractMarker)')"/>
<Touch Files="$(_ExtractMarker)" AlwaysCreate="true"/> <Touch Files="$(_ExtractMarker)" AlwaysCreate="true" Condition="'$(RaylibPackageName)' != ''"/>
<Message Text="Extraction complete" Importance="high"/>
</Target> </Target>
</Project> </Project>

View file

@ -1,10 +1,54 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'"> <!-- Default raylib release tag for consumers (Package/ProjectReference) that don't import Build.props. -->
<!-- WASM build needs explicit native reference due to semi-static linkage (?) --> <PropertyGroup>
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\runtimes\browser-wasm\native\raylib.a"/> <TargetRaylibTag Condition="'$(TargetRaylibTag)' == ''">6.0</TargetRaylibTag>
</ItemGroup> </PropertyGroup>
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'"> <PropertyGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
<EmccFlags>$(EmccFlags) -sUSE_GLFW=3</EmccFlags> <EmccFlags>$(EmccFlags) -sUSE_GLFW=3</EmccFlags>
</PropertyGroup> </PropertyGroup>
<!-- NuGet layout: runtimes/browser-wasm/native/raylib.a -->
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And Exists('$(MSBuildThisFileDirectory)..\runtimes\browser-wasm\native\raylib.a')">
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\runtimes\browser-wasm\native\raylib.a"/>
</ItemGroup>
<!-- ProjectReference / local build: stage via Raylib-cs.csproj -->
<Target Name="_StageRaylibWasmNative"
BeforeTargets="_PrepareForBrowserWasmBuildNative"
Condition="'$(RuntimeIdentifier)' == 'browser-wasm' And !Exists('$(MSBuildThisFileDirectory)..\runtimes\browser-wasm\native\raylib.a')">
<MSBuild Projects="$(MSBuildThisFileDirectory)Raylib-cs.csproj"
Targets="_StageWasmNative"
Properties="RuntimeIdentifier=browser-wasm;TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)"/>
<ItemGroup>
<NativeFileReference Include="$(MSBuildThisFileDirectory)obj\browser-wasm\raylib.a"/>
</ItemGroup>
</Target>
<!-- ProjectReference: copy raylib next to the app (NuGet does this automatically for PackageReference).
Guarded on the sibling csproj existing: present for ProjectReference (targets imported from source),
absent for PackageReference (targets shipped alone in buildTransitive/). -->
<Target Name="_CopyRaylibNativeToConsumerOutput"
AfterTargets="Build"
Condition="'$(RuntimeIdentifier)' != 'browser-wasm' And '$(MSBuildProjectName)' != 'Raylib-cs' And Exists('$(MSBuildThisFileDirectory)Raylib-cs.csproj')">
<PropertyGroup>
<!-- Use the explicit RID if set, else the host RID the SDK resolves (covers osx-arm64). -->
<_RaylibNativeRid Condition="'$(_RaylibNativeRid)' == ''">$(RuntimeIdentifier)</_RaylibNativeRid>
<_RaylibNativeRid Condition="'$(_RaylibNativeRid)' == ''">$(NETCoreSdkPortableRuntimeIdentifier)</_RaylibNativeRid>
<_RaylibNativeOutputDir>$(OutputPath)runtimes\$(_RaylibNativeRid)\native\</_RaylibNativeOutputDir>
</PropertyGroup>
<MSBuild Projects="$(MSBuildThisFileDirectory)Raylib-cs.csproj"
Targets="_PrepareNativeLibrary"
Properties="RuntimeIdentifier=$(_RaylibNativeRid);TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)">
<Output TaskParameter="TargetOutputs" ItemName="_RaylibNativeLibrary"/>
</MSBuild>
<MakeDir Directories="$(_RaylibNativeOutputDir)"/>
<Copy SourceFiles="@(_RaylibNativeLibrary)"
DestinationFolder="$(_RaylibNativeOutputDir)"
SkipUnchangedFiles="true"/>
<!-- Also copy to the app root so NativeLibrary.TryLoad("raylib") succeeds. -->
<Copy SourceFiles="@(_RaylibNativeLibrary)"
DestinationFolder="$(OutputPath)"
SkipUnchangedFiles="true"/>
</Target>
</Project> </Project>

View file

@ -26,7 +26,14 @@ public static unsafe partial class Raylib
static Raylib() static Raylib()
{ {
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport); // On WebAssembly (browser) the native library is statically linked into the main
// module, and P/Invokes are resolved by the runtime's built-in static-linking table.
// A custom resolver would override that and fail (there is no library to load), so we
// only install it on platforms where raylib is a separate dynamic library.
if (!OperatingSystem.IsBrowser())
{
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), ResolveDllImport);
}
} }
public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) public static IntPtr ResolveDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)

View file

@ -744,7 +744,7 @@ public static unsafe partial class Rlgl
/// <summary>Load depth texture/renderbuffer (to be attached to fbo)</summary> /// <summary>Load depth texture/renderbuffer (to be attached to fbo)</summary>
[LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureDepth")] [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureDepth")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial uint LoadTextureDepth(int width, int height, CBool useRenderBuffer); public static partial uint LoadTextureDepth(int width, int height, int useRenderBuffer);
/// <summary>Load texture cubemap data</summary> /// <summary>Load texture cubemap data</summary>
[LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap")] [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap")]
@ -813,15 +813,15 @@ public static unsafe partial class Rlgl
public static partial void FramebufferAttach( public static partial void FramebufferAttach(
uint fboId, uint fboId,
uint texId, uint texId,
FramebufferAttachType attachType, int attachType,
FramebufferAttachTextureType texType, int texType,
int mipLevel int mipLevel
); );
/// <summary>Verify framebuffer is complete</summary> /// <summary>Verify framebuffer is complete</summary>
[LibraryImport(NativeLibName, EntryPoint = "rlFramebufferComplete")] [LibraryImport(NativeLibName, EntryPoint = "rlFramebufferComplete")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial CBool FramebufferComplete(uint id); public static partial int FramebufferComplete(uint id);
/// <summary>Delete framebuffer from GPU</summary> /// <summary>Delete framebuffer from GPU</summary>
[LibraryImport(NativeLibName, EntryPoint = "rlUnloadFramebuffer")] [LibraryImport(NativeLibName, EntryPoint = "rlUnloadFramebuffer")]

View file

@ -186,6 +186,14 @@ public static unsafe partial class Raylib
/// <summary>Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)</summary> /// <summary>Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR)</summary>
public static void TraceLog(TraceLogLevel logLevel, string text) public static void TraceLog(TraceLogLevel logLevel, string text)
{ {
// raylib's TraceLog is variadic (const char *text, ...). WebAssembly cannot invoke
// variadic C functions from managed code (traps with "function signature mismatch").
if (OperatingSystem.IsBrowser())
{
Console.WriteLine(text);
return;
}
using Utf8Buffer str1 = text.ToUtf8Buffer(); using Utf8Buffer str1 = text.ToUtf8Buffer();
TraceLog(logLevel, str1.AsPointer()); TraceLog(logLevel, str1.AsPointer());
} }

View file

@ -4,6 +4,19 @@ namespace Raylib_cs;
public static unsafe partial class Rlgl public static unsafe partial class Rlgl
{ {
/// <summary>Load depth texture/renderbuffer (to be attached to fbo)</summary>
public static uint LoadTextureDepth(int width, int height, bool useRenderBuffer) =>
LoadTextureDepth(width, height, useRenderBuffer ? 1 : 0);
/// <summary>Attach texture/renderbuffer to a framebuffer</summary>
public static void FramebufferAttach(
uint fboId,
uint texId,
FramebufferAttachType attachType,
FramebufferAttachTextureType texType,
int mipLevel
) => FramebufferAttach(fboId, texId, (int)attachType, (int)texType, mipLevel);
/// <summary>Set shader value matrices</summary> /// <summary>Set shader value matrices</summary>
public static void SetUniformMatrices(int locIndex, Matrix4x4[] mat) public static void SetUniformMatrices(int locIndex, Matrix4x4[] mat)
{ {