Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Raylib-5.0.0 #210

Merged
merged 22 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ jobs:
include:
- name: arm
arch: armeabi-v7a
cflags: "-mfloat-abi=softfp -mfpu=vfpv3-d16"
- name: arm64
arch: arm64-v8a
cflags: "-mfix-cortex-a53-835769"
- name: x86
arch: x86
- name: x64
Expand All @@ -83,7 +85,8 @@ jobs:
-D CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-D PLATFORM=Android \
-D ANDROID_ABI=${{ matrix.arch }} \
-D ANDROID_PLATFORM=21
-D ANDROID_PLATFORM=21 \
-D CMAKE_C_FLAGS="${{ matrix.cflags }}"
cmake --build build --config Release

- name: upload build
Expand Down
4 changes: 2 additions & 2 deletions Examples/Textures/ImageGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public static int Main()

InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation");

Image verticalGradient = GenImageGradientV(screenWidth, screenHeight, Color.RED, Color.BLUE);
Image horizontalGradient = GenImageGradientH(screenWidth, screenHeight, Color.RED, Color.BLUE);
Image verticalGradient = GenImageGradientLinear(screenWidth, screenHeight, 0, Color.RED, Color.BLUE);
Image horizontalGradient = GenImageGradientLinear(screenWidth, screenHeight, 90, Color.RED, Color.BLUE);
Image radialGradient = GenImageGradientRadial(screenWidth, screenHeight, 0.0f, Color.WHITE, Color.BLACK);
Image isChecked = GenImageChecked(screenWidth, screenHeight, 32, 32, Color.RED, Color.BLUE);
Image whiteNoise = GenImageWhiteNoise(screenWidth, screenHeight, 0.5f);
Expand Down
1 change: 0 additions & 1 deletion Raylib-cs.Tests/RaylibTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Xunit;

namespace Raylib_cs.Tests;
Expand Down
2 changes: 1 addition & 1 deletion Raylib-cs/Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<TargetRaylibTag>4.5.0</TargetRaylibTag>
<TargetRaylibTag>5.0</TargetRaylibTag>
<Version>5.0.0</Version>
<PackageVersion>5.0.0</PackageVersion>
</PropertyGroup>
Expand Down
145 changes: 135 additions & 10 deletions Raylib-cs/interop/Raylib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static unsafe partial class Raylib
/// </summary>
public const string NativeLibName = "raylib";

public const string RAYLIB_VERSION = "4.5";
public const string RAYLIB_VERSION = "5.0";

public const float DEG2RAD = MathF.PI / 180.0f;
public const float RAD2DEG = 180.0f / MathF.PI;
Expand Down Expand Up @@ -86,6 +86,10 @@ public static unsafe partial class Raylib
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ToggleFullscreen();

/// <summary>Toggle window state: borderless windowed (only PLATFORM_DESKTOP)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ToggleBorderlessWindowed();

/// <summary>Set window state: maximized, if resizable (only PLATFORM_DESKTOP)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void MaximizeWindow();
Expand Down Expand Up @@ -122,6 +126,10 @@ public static unsafe partial class Raylib
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetWindowMinSize(int width, int height);

/// <summary>Set window maximum dimensions (for FLAG_WINDOW_RESIZABLE)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetWindowMaxSize(int width, int height);

/// <summary>Set window dimensions</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetWindowSize(int width, int height);
Expand All @@ -130,6 +138,10 @@ public static unsafe partial class Raylib
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetWindowOpacity(float opacity);

/// <summary>Set window focused (only PLATFORM_DESKTOP)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetWindowFocused();

/// <summary>Get native window handle</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void* GetWindowHandle();
Expand Down Expand Up @@ -450,6 +462,14 @@ int count
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SetRandomSeed(uint seed);

/// <summary>Load random values sequence, no values repeated</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int* LoadRandomSequence(int count, int min, int max);

/// <summary>Unload random values sequence</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void UnloadRandomSequence(int *sequence);

/// <summary>Takes a screenshot of current screen (saved a .png)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void TakeScreenshot(sbyte* fileName);
Expand Down Expand Up @@ -648,6 +668,10 @@ public static extern void SetSaveFileDataCallback(
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool IsKeyPressed(KeyboardKey key);

/// <summary>Detect if a key has been pressed again</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool IsKeyPressedRepeat(KeyboardKey key);

/// <summary>Detect if a key is being pressed</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool IsKeyDown(KeyboardKey key);
Expand Down Expand Up @@ -1026,6 +1050,10 @@ Color color2
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawCircleLines(int centerX, int centerY, float radius, Color color);

/// <summary>Draw circle outline (Vector version)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawCircleLinesV(Vector2 center, float radius, Color color);

/// <summary>Draw ellipse</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color);
Expand Down Expand Up @@ -1163,6 +1191,70 @@ public static extern void DrawPolyLinesEx(
Color color
);

// Splines drawing functions

/// <summary>Draw spline: Linear, minimum 2 points</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineLinear(Vector2 *points, int pointCount, float thick, Color color);

/// <summary>Draw spline: B-Spline, minimum 4 points</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineBasis(Vector2 *points, int pointCount, float thick, Color color);

/// <summary>Draw spline: Catmull-Rom, minimum 4 points</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineCatmullRom(Vector2 *points, int pointCount, float thick, Color color);

/// <summary>Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineBezierQuadratic(Vector2 *points, int pointCount, float thick, Color color);

/// <summary>Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineBezierCubic(Vector2 *points, int pointCount, float thick, Color color);

/// <summary>Draw spline segment: Linear, 2 points</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color);

/// <summary>Draw spline segment: B-Spline, 4 points</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color);

/// <summary>Draw spline segment: Catmull-Rom, 4 points</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color);

/// <summary>Draw spline segment: Quadratic Bezier, 2 points, 1 control point</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineSegmentBezierQuadratic(Vector2 p1, Vector2 c2, Vector2 p3, float thick, Color color);

/// <summary>Draw spline segment: Cubic Bezier, 2 points, 2 control points</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void DrawSplineSegmentBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float thick, Color color);

// Spline segment point evaluation functions, for a given t [0.0f .. 1.0f]

/// <summary>Get (evaluate) spline point: Linear</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector2 GetSplinePointLinear(Vector2 startPos, Vector2 endPos, float t);

/// <summary>Get (evaluate) spline point: B-Spline</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector2 GetSplinePointBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t);

/// <summary>Get (evaluate) spline point: Catmull-Rom</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector2 GetSplinePointCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t);

/// <summary>Get (evaluate) spline point: Quadratic Bezier</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector2 GetSplinePointBezierQuad(Vector2 p1, Vector2 c2, Vector2 p3, float t);

/// <summary>Get (evaluate) spline point: Cubic Bezier</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float t);

// Basic shapes collision detection functions

/// <summary>Check collision between two rectangles</summary>
Expand Down Expand Up @@ -1242,6 +1334,10 @@ public static extern Image LoadImageRaw(
int headerSize
);

/// <summary>Load image from SVG file data or string with specified size</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image LoadImageSvg(sbyte* fileName, int width, int height);

/// <summary>Load image sequence from file (frames appended to image.data)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image LoadImageAnim(sbyte* fileName, int* frames);
Expand Down Expand Up @@ -1270,6 +1366,10 @@ int headerSize
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool ExportImage(Image image, sbyte* fileName);

/// <summary>Export image to memory buffer</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern char* ExportImageToMemory(Image image, sbyte* fileType, int *fileSize);

/// <summary>Export image as code file defining an array of bytes</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool ExportImageAsCode(Image image, sbyte* fileName);
Expand All @@ -1281,13 +1381,9 @@ int headerSize
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image GenImageColor(int width, int height, Color color);

/// <summary>Generate image: vertical gradient</summary>
/// <summary>Generate image: linear gradient, direction in degrees [0..360], 0=Vertical gradient</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image GenImageGradientV(int width, int height, Color top, Color bottom);

/// <summary>Generate image: horizontal gradient</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image GenImageGradientH(int width, int height, Color left, Color right);
public static extern Image GenImageGradientLinear(int width, int height, int direction, Color start, Color end);

/// <summary>Generate image: radial gradient</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
Expand All @@ -1299,6 +1395,15 @@ public static extern Image GenImageGradientRadial(
Color outer
);

/// <summary>Generate image: square gradient</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image GenImageGradientSquare(
int width,
int height,
float density,
Color inner,
Color outer);

/// <summary>Generate image: checked</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Image GenImageChecked(
Expand Down Expand Up @@ -1412,6 +1517,10 @@ Color color
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ImageFlipHorizontal(Image* image);

/// <summary>Rotate image by input angle in degrees (-359 to 359)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ImageRotate(Image *image, int degrees);

/// <summary>Rotate image clockwise 90deg</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ImageRotateCW(Image* image);
Expand Down Expand Up @@ -1743,7 +1852,7 @@ Color tint
/// the default character set
/// </summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Font LoadFontEx(sbyte* fileName, int fontSize, int* fontChars, int glyphCount);
public static extern Font LoadFontEx(sbyte* fileName, int fontSize, int* codepoints, int codepointCount);

/// <summary>Load font from Image (XNA style)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
Expand All @@ -1756,8 +1865,8 @@ public static extern Font LoadFontFromMemory(
byte* fileData,
int dataSize,
int fontSize,
int* fontChars,
int glyphCount
int* codepoints,
int codepointCount
);

/// <summary>Check if a font is ready</summary>
Expand Down Expand Up @@ -1857,6 +1966,10 @@ Color tint

// Text font info functions

/// <summary>Set vertical line spacing when drawing with line-breaks</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetTextLineSpacing(int spacing);

/// <summary>Measure string width for default font</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int MeasureText(sbyte* text, int fontSize);
Expand Down Expand Up @@ -2419,6 +2532,10 @@ float radius2
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void SetMasterVolume(float volume);

/// <summary>Set master volume (listener)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern float GetMasterVolume();


// Wave/Sound loading/unloading functions

Expand All @@ -2442,6 +2559,10 @@ float radius2
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Sound LoadSoundFromWave(Wave wave);

/// <summary>Create a new sound that shares the same sample data as the source sound, does not own the sound data</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Sound LoadSoundAlias(Sound source);

/// <summary>Checks if a sound is ready</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool IsSoundReady(Sound sound);
Expand All @@ -2458,6 +2579,10 @@ float radius2
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void UnloadSound(Sound sound);

/// <summary>Unload a sound alias (does not deallocate sample data)</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void UnloadSoundAlias(Sound alias);

/// <summary>Export wave data to file</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool ExportWave(Wave wave, sbyte* fileName);
Expand Down
8 changes: 8 additions & 0 deletions Raylib-cs/interop/Raymath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ float outputEnd
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector3 Vector3Normalize(Vector3 v);

/// <summary>Calculate the projection of the vector v1 on to v2</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector3 Vector3Project(Vector3 v1, Vector3 v2);

/// <summary>Calculate the rejection of the vector v1 on to v2</summary>
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern Vector3 Vector3Reject(Vector3 v1, Vector3 v2);

/// <summary>
/// Orthonormalize provided vectors<br/>
/// Makes vectors normalized and orthogonal to each other<br/>
Expand Down
8 changes: 8 additions & 0 deletions Raylib-cs/interop/Rlgl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ public static void Begin(DrawMode mode)
[DllImport(NativeLibName, EntryPoint = "rlDisableFramebuffer", CallingConvention = CallingConvention.Cdecl)]
public static extern void DisableFramebuffer();

/// <summary>Blit active framebuffer to main framebuffer</summary>
[DllImport(NativeLibName, EntryPoint = "rlBlitFramebuffer", CallingConvention = CallingConvention.Cdecl)]
public static extern void BlitFramebuffer();

/// <summary>Activate multiple draw color buffers</summary>
[DllImport(NativeLibName, EntryPoint = "rlActiveDrawBuffers", CallingConvention = CallingConvention.Cdecl)]
public static extern void ActiveDrawBuffers(int count);
Expand Down Expand Up @@ -375,6 +379,10 @@ public static void Begin(DrawMode mode)
[DllImport(NativeLibName, EntryPoint = "rlEnableWireMode", CallingConvention = CallingConvention.Cdecl)]
public static extern void EnableWireMode();

/// <summary>Enable point mode</summary>
[DllImport(NativeLibName, EntryPoint = "rlEnablePointMode", CallingConvention = CallingConvention.Cdecl)]
public static extern void EnablePointMode();

/// <summary>Disable wire mode</summary>
[DllImport(NativeLibName, EntryPoint = "rlDisableWireMode", CallingConvention = CallingConvention.Cdecl)]
public static extern void DisableWireMode();
Expand Down
5 changes: 5 additions & 0 deletions Raylib-cs/types/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public enum ConfigFlags : uint
/// </summary>
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000,

/// <summary>
/// Set to run program in borderless windowed mode
/// </summary>
FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000,

/// <summary>
/// Set to try enabling MSAA 4X
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion Raylib-cs/types/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public unsafe partial struct Model
/// Model animation
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe partial struct ModelAnimation
public unsafe partial struct ModelAnimation
{
/// <summary>
/// Number of bones
Expand All @@ -104,6 +104,11 @@ public readonly unsafe partial struct ModelAnimation
/// </summary>
public readonly Transform** FramePoses;

/// <summary>
/// Animation name (char[32])
/// </summary>
public fixed sbyte Name[32];

/// <inheritdoc cref="FramePoses"/>
public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount);

Expand Down
1 change: 0 additions & 1 deletion Raylib-cs/types/Music.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Runtime.InteropServices;

namespace Raylib_cs;
Expand Down
Loading