2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-06-30 19:03:42 -04:00

Update to raylib 5.5 (#279)

This commit is contained in:
JupiterRider
2024-12-21 16:00:13 +01:00
committed by GitHub
parent 7b5b322a5b
commit a3dfd57b5a
23 changed files with 504 additions and 124 deletions

View File

@ -0,0 +1,35 @@
using System;
using System.Runtime.InteropServices;
namespace Raylib_cs;
/// <summary>Automation event</summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct AutomationEvent
{
/// <summary>Event frame</summary>
public uint Frame;
/// <summary>Event type (AutomationEventType)</summary>
public uint Type;
/// <summary>Event parameters (if required)</summary>
public fixed int Params[4];
}
/// <summary>Automation event list</summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct AutomationEventList
{
/// <summary>Events max entries (MAX_AUTOMATION_EVENTS)</summary>
public uint Capacity;
/// <summary>Events entries count</summary>
public uint Count;
/// <summary>Events entries</summary>
public AutomationEvent* Events;
/// <inheritdoc cref="Events"/>
public ReadOnlySpan<AutomationEvent> EventsAsSpan => new(Events, (int)Count);
}

View File

@ -128,7 +128,7 @@ public enum KeyboardKey
// Android key buttons
Back = 4,
Menu = 82,
Menu = 5,
VolumeUp = 24,
VolumeDown = 25
}
@ -305,7 +305,7 @@ public enum GamepadButton
RightFaceUp,
/// <summary>
/// Gamepad right button right (i.e. PS3: Square, Xbox: X)
/// Gamepad right button right (i.e. PS3: Circle, Xbox: B)
/// </summary>
RightFaceRight,
@ -315,7 +315,7 @@ public enum GamepadButton
RightFaceDown,
/// <summary>
/// Gamepad right button left (i.e. PS3: Circle, Xbox: B)
/// Gamepad right button left (i.e. PS3: Square, Xbox: X)
/// </summary>
RightFaceLeft,
@ -411,11 +411,6 @@ public unsafe partial struct VrDeviceInfo
/// </summary>
public float VScreenSize;
/// <summary>
/// HMD screen center in meters
/// </summary>
public float VScreenCenter;
/// <summary>
/// HMD distance between eye and display in meters
/// </summary>

View File

@ -1,4 +1,5 @@
using System;
using System.Numerics;
using System.Runtime.InteropServices;
namespace Raylib_cs;
@ -202,6 +203,16 @@ public unsafe partial struct Mesh
/// </summary>
public float* BoneWeights = default;
/// <summary>
/// Bones animated transformation matrices
/// </summary>
public Matrix4x4* BoneMatrices = default;
/// <summary>
/// Number of bones
/// </summary>
public int BoneCount;
#endregion
#region OpenGL identifiers

View File

@ -15,7 +15,7 @@ public partial struct Ray
public Vector3 Position;
/// <summary>
/// Ray direction
/// Ray direction (normalized)
/// </summary>
public Vector3 Direction;

View File

@ -119,13 +119,6 @@ public static unsafe partial class Raylib
return LoadImageRaw(str1.AsPointer(), width, height, format, headerSize);
}
/// <summary>Load image sequence from file (frames appended to image.data)</summary>
public static Image LoadImageSvg(string fileName, int width, int height)
{
using var str1 = fileName.ToAnsiBuffer();
return LoadImageSvg(str1.AsPointer(), width, height);
}
/// <summary>Load image sequence from file (frames appended to image.data)</summary>
public static Image LoadImageAnim(string fileName, out int frames)
{
@ -514,6 +507,18 @@ public static unsafe partial class Raylib
}
}
/// <summary>Apply custom square convolution kernel to image</summary>
public static void ImageKernelConvolution(ref Image image, float[] kernel)
{
fixed (Image* imagePtr = &image)
{
fixed (float* kernelPtr = kernel)
{
ImageKernelConvolution(imagePtr, kernelPtr, kernel.Length);
}
}
}
/// <summary>Crop an image to a defined rectangle</summary>
public static void ImageCrop(ref Image image, Rectangle crop)
{
@ -726,6 +731,15 @@ public static unsafe partial class Raylib
}
}
/// <summary>Draw a line defining thickness within an image</summary>
public static void ImageDrawLineEx(ref Image dst, Vector2 start, Vector2 end, int thick, Color color)
{
fixed (Image* p = &dst)
{
ImageDrawLineEx(p, start, end, thick, color);
}
}
/// <summary>Draw circle within an image</summary>
public static void ImageDrawCircle(ref Image dst, int centerX, int centerY, int radius, Color color)
{
@ -780,6 +794,57 @@ public static unsafe partial class Raylib
}
}
/// <summary>Draw triangle within an image</summary>
public static void ImageDrawTriangle(ref Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color)
{
fixed (Image* p = &dst)
{
ImageDrawTriangle(p, v1, v2, v3, color);
}
}
/// <summary>Draw triangle with interpolated colors within an image</summary>
public static void ImageDrawTriangleEx(ref Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3)
{
fixed (Image* p = &dst)
{
ImageDrawTriangleEx(p, v1, v2, v3, c1, c2, c3);
}
}
/// <summary>Draw triangle outline within an image</summary>
public static void ImageDrawTriangleLines(ref Image dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color)
{
fixed (Image* p = &dst)
{
ImageDrawTriangleLines(p, v1, v2, v3, color);
}
}
/// <summary>Draw a triangle fan defined by points within an image (first vertex is the center)</summary>
public static void ImageDrawTriangleFan(ref Image dst, Vector2[] points, Color color)
{
fixed (Image* imagePtr = &dst)
{
fixed (Vector2* vec2Ptr = points)
{
ImageDrawTriangleFan(imagePtr, vec2Ptr, points.Length, color);
}
}
}
/// <summary>Draw a triangle strip defined by points within an image</summary>
public static void ImageDrawTriangleStrip(ref Image dst, Vector2[] points, Color color)
{
fixed (Image* imagePtr = &dst)
{
fixed (Vector2* vec2Ptr = points)
{
ImageDrawTriangleStrip(imagePtr, vec2Ptr, points.Length, color);
}
}
}
/// <summary>Draw a source image within a destination image (tint applied to source)</summary>
public static void ImageDraw(ref Image dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint)
{
@ -870,7 +935,10 @@ public static unsafe partial class Raylib
return LoadFont(str1.AsPointer());
}
/// <summary>Load font from file with extended parameters</summary>
/// <summary>
/// Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load
/// the default character set, font size is provided in pixels height
/// </summary>
public static Font LoadFontEx(string fileName, int fontSize, int[] codepoints, int codepointCount)
{
using var str1 = fileName.ToAnsiBuffer();
@ -974,12 +1042,12 @@ public static unsafe partial class Raylib
}
}
/// <summary>Crop a wave to defined samples range</summary>
public static void WaveCrop(ref Wave wave, int initSample, int finalSample)
/// <summary>Crop a wave to defined frames range</summary>
public static void WaveCrop(ref Wave wave, int initFrame, int finalFrame)
{
fixed (Wave* p = &wave)
{
WaveCrop(p, initSample, finalSample);
WaveCrop(p, initFrame, finalFrame);
}
}
@ -1172,6 +1240,13 @@ public static unsafe partial class Raylib
return ExportMesh(mesh, str1.AsPointer());
}
/// <summary>Export mesh as code file (.h) defining multiple arrays of vertex attributes</summary>
public static CBool ExportMeshAsCode(Mesh mesh, string fileName)
{
using var str1 = fileName.ToAnsiBuffer();
return ExportMeshAsCode(mesh, str1.AsPointer());
}
/// <summary>Draw a triangle strip defined by points</summary>
public static void DrawTriangleStrip3D(Vector3[] points, int pointCount, Color color)
{
@ -1322,4 +1397,34 @@ public static unsafe partial class Raylib
{
model.Materials[materialIndex].Shader = shader;
}
/// <summary>Get a ray trace from mouse position</summary>
[ObsoleteAttribute("This method is obsolete. Call GetScreenToWorldRay instead.")]
public static Ray GetMouseRay(Vector2 mousePosition, Camera3D camera)
{
return GetScreenToWorldRay(mousePosition, camera);
}
/// <summary>Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS</summary>
public static AutomationEventList LoadAutomationEventList(string fileName)
{
using var str1 = fileName.ToUtf8Buffer();
return LoadAutomationEventList(str1.AsPointer());
}
/// <summary>Export automation events list as text file</summary>
public static CBool ExportAutomationEventList(AutomationEventList list, string fileName)
{
using var str1 = fileName.ToUtf8Buffer();
return ExportAutomationEventList(list, str1.AsPointer());
}
/// <summary>Set automation event list to record to</summary>
public static void SetAutomationEventList(ref AutomationEventList list)
{
fixed (AutomationEventList* p = &list)
{
SetAutomationEventList(p);
}
}
}

View File

@ -61,6 +61,11 @@ public unsafe partial struct VertexBuffer
/// </summary>
public float* TexCoords;
/// <summary>
/// Vertex normal (XYZ - 3 components per vertex) (shader-location = 2)
/// </summary>
public float* Normals;
/// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary>
@ -79,9 +84,9 @@ public unsafe partial struct VertexBuffer
public uint VaoId;
/// <summary>
/// OpenGL Vertex Buffer Objects id (4 types of vertex data)
/// OpenGL Vertex Buffer Objects id (5 types of vertex data)
/// </summary>
public fixed uint VboId[4];
public fixed uint VboId[5];
/// <summary>
/// Access <see cref="Vertices"/>
@ -99,6 +104,14 @@ public unsafe partial struct VertexBuffer
return new(TexCoords, ElementCount * sizeof(float) / sizeof(T));
}
/// <summary>
/// Access <see cref="Normals"/>
/// </summary>
public readonly Span<T> NormalsAs<T>() where T : unmanaged
{
return new(Normals, ElementCount * sizeof(float) / sizeof(T));
}
/// <summary>
/// Access <see cref="Colors"/>
/// </summary>

View File

@ -0,0 +1,15 @@
using System.Numerics;
namespace Raylib_cs;
public static unsafe partial class Rlgl
{
/// <summary>Set shader value matrices</summary>
public static void SetUniformMatrices(int locIndex, Matrix4x4[] mat)
{
fixed (Matrix4x4* p = mat)
{
SetUniformMatrices(locIndex, p, mat.Length);
}
}
}

View File

@ -33,6 +33,9 @@ public enum ShaderLocationIndex
MapIrradiance,
MapPrefilter,
MapBrdf,
VertexBoneIds,
VertexBoneWeights,
BoneMatrices,
MapDiffuse = MapAlbedo,
MapSpecular = MapMetalness,
@ -62,6 +65,10 @@ public enum ShaderUniformDataType
IVec2,
IVec3,
IVec4,
UInt,
UIVec2,
UIVec3,
UIVec4,
Sampler2D
}

View File

@ -94,12 +94,7 @@ public enum CubemapLayout
/// <summary>
/// Layout is defined by a 4x3 cross with cubemap faces
/// </summary>
CrossFourByThree,
/// <summary>
/// Layout is defined by a panorama image (equirectangular map)
/// </summary>
Panorama
CrossFourByThree
}
/// <summary>