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

Merge branch 'master' into native

This commit is contained in:
Rgebee 2024-05-21 19:11:32 +01:00 committed by GitHub
commit cd41e019fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 62 additions and 13 deletions

View file

@ -5,7 +5,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StartupObject>Examples.Program</StartupObject>
<RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory>
<LangVersion>10</LangVersion>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

View file

@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>

View file

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<EnableDefaultItems>false</EnableDefaultItems>
<AssemblyName>Raylib-cs</AssemblyName>
<RootNamespace>Raylib_cs</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<NoWarn>$(NoWarn);1591</NoWarn>
<LangVersion>10.0</LangVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup>

View file

@ -2350,7 +2350,7 @@ public static unsafe partial class Raylib
/// <summary>Unload mesh from memory (RAM and/or VRAM)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void UnloadMesh(Mesh* mesh);
public static extern void UnloadMesh(Mesh mesh);
/// <summary>Draw a 3d mesh with material and transform</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]

View file

@ -0,0 +1,10 @@
using System;
namespace Raylib_cs;
/// <summary>
/// Audio stream processor.
/// Used with Raylib.AttachAudioMixedProcessor()
/// and Raylib.DetachAudioMixedProcessor()
/// </summary>
public delegate void AudioCallback<T>(Span<T> buffer);

View file

@ -0,0 +1,23 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Raylib_cs;
internal static unsafe class AudioMixed
{
public static AudioCallback<float> Callback = null;
[UnmanagedCallersOnly(CallConvs = new[]
{
typeof(CallConvCdecl),
})]
public static void Processor(void* buffer, uint frames)
{
// The buffer is stereo audio, so we need to double our frame count.
frames = Math.Min(frames * 2, int.MaxValue);
Span<float> floats = new(buffer, (int)frames);
Callback?.Invoke(floats);
}
}

View file

@ -911,15 +911,6 @@ public static unsafe partial class Raylib
}
}
/// <summary>Unload mesh from memory (RAM and/or VRAM)</summary>
public static void UnloadMesh(ref Mesh mesh)
{
fixed (Mesh* p = &mesh)
{
UnloadMesh(p);
}
}
/// <summary>Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)</summary>
public static void SetMaterialTexture(ref Material material, MaterialMapIndex mapType, Texture2D texture)
{
@ -1261,6 +1252,30 @@ public static unsafe partial class Raylib
}
}
/// <summary>
/// Attach audio stream processor to the entire audio pipeline
/// </summary>
public static void AttachAudioMixedProcessor(AudioCallback<float> processor)
{
if (AudioMixed.Callback == null)
{
AudioMixed.Callback = processor;
AttachAudioMixedProcessor(&AudioMixed.Processor);
}
}
/// <summary>
/// Detach audio stream processor from the entire audio pipeline
/// </summary>
public static void DetachAudioMixedProcessor(AudioCallback<float> processor)
{
if (AudioMixed.Callback == processor)
{
DetachAudioMixedProcessor(&AudioMixed.Processor);
AudioMixed.Callback = null;
}
}
public static string SubText(this string input, int position, int length)
{
return input.Substring(position, Math.Min(length, input.Length));