2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-05 11:19:39 -04:00

Add .editorconfig and apply formatting

This commit is contained in:
ChrisDill 2023-08-27 15:20:26 +01:00
parent d1f0b9fd91
commit 696955463f
32 changed files with 7217 additions and 7194 deletions

51
.editorconfig Normal file

@ -0,0 +1,51 @@
# EditorConfig is awesome: http://EditorConfig.org
root = true
[*]
indent_style = space
# General
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
# C# styles
[*.cs]
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
csharp_style_namespace_declarations = file_scoped:warning
# Newline settings
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Spacing
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_around_binary_operators = before_and_after
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
# Blocks are allowed
csharp_prefer_braces = true:error
csharp_preserve_single_line_blocks = false
csharp_preserve_single_line_statements = false

@ -30,41 +30,40 @@ using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace Raylib_cs.Tests
namespace Raylib_cs.Tests;
public static class BlittableHelper
{
public static class BlittableHelper
public static bool IsBlittable<T>()
{
public static bool IsBlittable<T>()
{
return IsBlittableCache<T>.VALUE;
}
return IsBlittableCache<T>.VALUE;
}
public static bool IsBlittable(this Type type)
public static bool IsBlittable(this Type type)
{
if (type == typeof(decimal))
{
if (type == typeof(decimal))
{
return false;
}
if (type.IsArray)
{
var elementType = type.GetElementType();
return elementType != null && elementType.IsValueType && IsBlittable(elementType);
}
try
{
var instance = FormatterServices.GetUninitializedObject(type);
GCHandle.Alloc(instance, GCHandleType.Pinned).Free();
return true;
}
catch
{
return false;
}
return false;
}
private static class IsBlittableCache<T>
if (type.IsArray)
{
public static readonly bool VALUE = IsBlittable(typeof(T));
var elementType = type.GetElementType();
return elementType != null && elementType.IsValueType && IsBlittable(elementType);
}
try
{
var instance = FormatterServices.GetUninitializedObject(type);
GCHandle.Alloc(instance, GCHandleType.Pinned).Free();
return true;
}
catch
{
return false;
}
}
private static class IsBlittableCache<T>
{
public static readonly bool VALUE = IsBlittable(typeof(T));
}
}

@ -1,46 +1,45 @@
using System;
using Xunit;
namespace Raylib_cs.Tests
{
public class RaylibTests
{
private unsafe void CheckType<T>() where T : unmanaged
{
Assert.True(BlittableHelper.IsBlittable<T>());
}
namespace Raylib_cs.Tests;
[Fact]
public void CheckTypes()
{
CheckType<Color>();
CheckType<Rectangle>();
CheckType<Image>();
CheckType<Texture2D>();
CheckType<RenderTexture2D>();
CheckType<NPatchInfo>();
CheckType<GlyphInfo>();
CheckType<Font>();
CheckType<Camera2D>();
CheckType<Camera3D>();
CheckType<Mesh>();
CheckType<Shader>();
CheckType<MaterialMap>();
CheckType<Material>();
CheckType<Transform>();
CheckType<BoneInfo>();
CheckType<Model>();
CheckType<ModelAnimation>();
CheckType<Ray>();
CheckType<RayCollision>();
CheckType<BoundingBox>();
CheckType<Wave>();
CheckType<AudioStream>();
CheckType<Sound>();
CheckType<Music>();
CheckType<VrDeviceInfo>();
CheckType<VrStereoConfig>();
CheckType<RenderBatch>();
}
public class RaylibTests
{
private unsafe void CheckType<T>() where T : unmanaged
{
Assert.True(BlittableHelper.IsBlittable<T>());
}
[Fact]
public void CheckTypes()
{
CheckType<Color>();
CheckType<Rectangle>();
CheckType<Image>();
CheckType<Texture2D>();
CheckType<RenderTexture2D>();
CheckType<NPatchInfo>();
CheckType<GlyphInfo>();
CheckType<Font>();
CheckType<Camera2D>();
CheckType<Camera3D>();
CheckType<Mesh>();
CheckType<Shader>();
CheckType<MaterialMap>();
CheckType<Material>();
CheckType<Transform>();
CheckType<BoneInfo>();
CheckType<Model>();
CheckType<ModelAnimation>();
CheckType<Ray>();
CheckType<RayCollision>();
CheckType<BoundingBox>();
CheckType<Wave>();
CheckType<AudioStream>();
CheckType<Sound>();
CheckType<Music>();
CheckType<VrDeviceInfo>();
CheckType<VrStereoConfig>();
CheckType<RenderBatch>();
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,123 +1,122 @@
using System;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Wave type, defines audio wave data
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Wave
{
/// <summary>
/// Wave type, defines audio wave data
/// Number of samples
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Wave
{
/// <summary>
/// Number of samples
/// </summary>
public uint SampleCount;
/// <summary>
/// Frequency (samples per second)
/// </summary>
public uint SampleRate;
/// <summary>
/// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary>
public uint SampleSize;
/// <summary>
/// Number of channels (1-mono, 2-stereo)
/// </summary>
public uint Channels;
//TODO: SPAN<byte> ?
/// <summary>
/// Buffer data pointer
/// </summary>
public void* Data;
}
public uint SampleCount;
/// <summary>
/// Audio stream type<br/>
/// NOTE: Useful to create custom audio streams not bound to a specific file
/// Frequency (samples per second)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct AudioStream
{
//TODO: convert
/// <summary>
/// Pointer to internal data(rAudioBuffer *) used by the audio system
/// </summary>
public IntPtr Buffer;
/// <summary>
/// Pointer to internal data processor, useful for audio effects
/// </summary>
public IntPtr Processor;
/// <summary>
/// Frequency (samples per second)
/// </summary>
public uint SampleRate;
/// <summary>
/// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary>
public uint SampleSize;
/// <summary>
/// Number of channels (1-mono, 2-stereo)
/// </summary>
public uint Channels;
}
public uint SampleRate;
/// <summary>
/// Sound source type
/// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Sound
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary>
/// Total number of frames (considering channels)
/// </summary>
public uint FrameCount;
}
public uint SampleSize;
/// <summary>
/// Music stream type (audio file streaming from memory)<br/>
/// NOTE: Anything longer than ~10 seconds should be streamed
/// Number of channels (1-mono, 2-stereo)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Music
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
public uint Channels;
/// <summary>
/// Total number of samples
/// </summary>
public uint FrameCount;
/// <summary>
/// Music looping enable
/// </summary>
public CBool Looping;
/// <summary>
/// Type of music context (audio filetype)
/// </summary>
public int CtxType;
//TODO span
/// <summary>
/// Audio context data, depends on type
/// </summary>
public void* CtxData;
}
//TODO: SPAN<byte> ?
/// <summary>
/// Buffer data pointer
/// </summary>
public void* Data;
}
/// <summary>
/// Audio stream type<br/>
/// NOTE: Useful to create custom audio streams not bound to a specific file
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct AudioStream
{
//TODO: convert
/// <summary>
/// Pointer to internal data(rAudioBuffer *) used by the audio system
/// </summary>
public IntPtr Buffer;
/// <summary>
/// Pointer to internal data processor, useful for audio effects
/// </summary>
public IntPtr Processor;
/// <summary>
/// Frequency (samples per second)
/// </summary>
public uint SampleRate;
/// <summary>
/// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary>
public uint SampleSize;
/// <summary>
/// Number of channels (1-mono, 2-stereo)
/// </summary>
public uint Channels;
}
/// <summary>
/// Sound source type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Sound
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary>
/// Total number of frames (considering channels)
/// </summary>
public uint FrameCount;
}
/// <summary>
/// Music stream type (audio file streaming from memory)<br/>
/// NOTE: Anything longer than ~10 seconds should be streamed
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Music
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary>
/// Total number of samples
/// </summary>
public uint FrameCount;
/// <summary>
/// Music looping enable
/// </summary>
public CBool Looping;
/// <summary>
/// Type of music context (audio filetype)
/// </summary>
public int CtxType;
//TODO span
/// <summary>
/// Audio context data, depends on type
/// </summary>
public void* CtxData;
}

@ -1,26 +1,25 @@
using System.Numerics;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>Bounding box type</summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct BoundingBox
{
/// <summary>Bounding box type</summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct BoundingBox
/// <summary>
/// Minimum vertex box-corner
/// </summary>
public Vector3 Min;
/// <summary>
/// Maximum vertex box-corner
/// </summary>
public Vector3 Max;
public BoundingBox(Vector3 min, Vector3 max)
{
/// <summary>
/// Minimum vertex box-corner
/// </summary>
public Vector3 Min;
/// <summary>
/// Maximum vertex box-corner
/// </summary>
public Vector3 Max;
public BoundingBox(Vector3 min, Vector3 max)
{
this.Min = min;
this.Max = max;
}
this.Min = min;
this.Max = max;
}
}

@ -1,40 +1,39 @@
using System.Numerics;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Camera2D, defines position/orientation in 2d space
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Camera2D
{
/// <summary>
/// Camera2D, defines position/orientation in 2d space
/// Camera offset (displacement from target)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Camera2D
public Vector2 Offset;
/// <summary>
/// Camera target (rotation and zoom origin)
/// </summary>
public Vector2 Target;
/// <summary>
/// Camera rotation in degrees
/// </summary>
public float Rotation;
/// <summary>
/// Camera zoom (scaling), should be 1.0f by default
/// </summary>
public float Zoom;
public Camera2D(Vector2 offset, Vector2 target, float rotation, float zoom)
{
/// <summary>
/// Camera offset (displacement from target)
/// </summary>
public Vector2 Offset;
/// <summary>
/// Camera target (rotation and zoom origin)
/// </summary>
public Vector2 Target;
/// <summary>
/// Camera rotation in degrees
/// </summary>
public float Rotation;
/// <summary>
/// Camera zoom (scaling), should be 1.0f by default
/// </summary>
public float Zoom;
public Camera2D(Vector2 offset, Vector2 target, float rotation, float zoom)
{
this.Offset = offset;
this.Target = target;
this.Rotation = rotation;
this.Zoom = zoom;
}
this.Offset = offset;
this.Target = target;
this.Rotation = rotation;
this.Zoom = zoom;
}
}

@ -1,67 +1,66 @@
using System.Numerics;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Camera system modes
/// </summary>
public enum CameraMode
{
CAMERA_CUSTOM = 0,
CAMERA_FREE,
CAMERA_ORBITAL,
CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON
}
/// <summary>
/// Camera projection
/// </summary>
public enum CameraProjection
{
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC
}
/// <summary>
/// Camera3D, defines position/orientation in 3d space
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Camera3D
{
/// <summary>
/// Camera system modes
/// Camera position
/// </summary>
public enum CameraMode
{
CAMERA_CUSTOM = 0,
CAMERA_FREE,
CAMERA_ORBITAL,
CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON
}
public Vector3 Position;
/// <summary>
/// Camera projection
/// Camera target it looks-at
/// </summary>
public enum CameraProjection
{
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC
}
public Vector3 Target;
/// <summary>
/// Camera3D, defines position/orientation in 3d space
/// Camera up vector (rotation over its axis)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Camera3D
public Vector3 Up;
/// <summary>
/// Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
/// </summary>
public float FovY;
/// <summary>
/// Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
/// </summary>
public CameraProjection Projection;
public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovY, CameraProjection projection)
{
/// <summary>
/// Camera position
/// </summary>
public Vector3 Position;
/// <summary>
/// Camera target it looks-at
/// </summary>
public Vector3 Target;
/// <summary>
/// Camera up vector (rotation over its axis)
/// </summary>
public Vector3 Up;
/// <summary>
/// Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic
/// </summary>
public float FovY;
/// <summary>
/// Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
/// </summary>
public CameraProjection Projection;
public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovY, CameraProjection projection)
{
this.Position = position;
this.Target = target;
this.Up = up;
this.FovY = fovY;
this.Projection = projection;
}
this.Position = position;
this.Target = target;
this.Up = up;
this.FovY = fovY;
this.Projection = projection;
}
}

@ -1,67 +1,66 @@
using System;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Color type, RGBA (32bit)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Color
{
/// <summary>
/// Color type, RGBA (32bit)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Color
public byte R;
public byte G;
public byte B;
public byte A;
// Example - Color.RED instead of RED
// Custom raylib color palette for amazing visuals
public static readonly Color LIGHTGRAY = new Color(200, 200, 200, 255);
public static readonly Color GRAY = new Color(130, 130, 130, 255);
public static readonly Color DARKGRAY = new Color(80, 80, 80, 255);
public static readonly Color YELLOW = new Color(253, 249, 0, 255);
public static readonly Color GOLD = new Color(255, 203, 0, 255);
public static readonly Color ORANGE = new Color(255, 161, 0, 255);
public static readonly Color PINK = new Color(255, 109, 194, 255);
public static readonly Color RED = new Color(230, 41, 55, 255);
public static readonly Color MAROON = new Color(190, 33, 55, 255);
public static readonly Color GREEN = new Color(0, 228, 48, 255);
public static readonly Color LIME = new Color(0, 158, 47, 255);
public static readonly Color DARKGREEN = new Color(0, 117, 44, 255);
public static readonly Color SKYBLUE = new Color(102, 191, 255, 255);
public static readonly Color BLUE = new Color(0, 121, 241, 255);
public static readonly Color DARKBLUE = new Color(0, 82, 172, 255);
public static readonly Color PURPLE = new Color(200, 122, 255, 255);
public static readonly Color VIOLET = new Color(135, 60, 190, 255);
public static readonly Color DARKPURPLE = new Color(112, 31, 126, 255);
public static readonly Color BEIGE = new Color(211, 176, 131, 255);
public static readonly Color BROWN = new Color(127, 106, 79, 255);
public static readonly Color DARKBROWN = new Color(76, 63, 47, 255);
public static readonly Color WHITE = new Color(255, 255, 255, 255);
public static readonly Color BLACK = new Color(0, 0, 0, 255);
public static readonly Color BLANK = new Color(0, 0, 0, 0);
public static readonly Color MAGENTA = new Color(255, 0, 255, 255);
public static readonly Color RAYWHITE = new Color(245, 245, 245, 255);
public Color(byte r, byte g, byte b, byte a)
{
public byte R;
public byte G;
public byte B;
public byte A;
this.R = r;
this.G = g;
this.B = b;
this.A = a;
}
// Example - Color.RED instead of RED
// Custom raylib color palette for amazing visuals
public static readonly Color LIGHTGRAY = new Color(200, 200, 200, 255);
public static readonly Color GRAY = new Color(130, 130, 130, 255);
public static readonly Color DARKGRAY = new Color(80, 80, 80, 255);
public static readonly Color YELLOW = new Color(253, 249, 0, 255);
public static readonly Color GOLD = new Color(255, 203, 0, 255);
public static readonly Color ORANGE = new Color(255, 161, 0, 255);
public static readonly Color PINK = new Color(255, 109, 194, 255);
public static readonly Color RED = new Color(230, 41, 55, 255);
public static readonly Color MAROON = new Color(190, 33, 55, 255);
public static readonly Color GREEN = new Color(0, 228, 48, 255);
public static readonly Color LIME = new Color(0, 158, 47, 255);
public static readonly Color DARKGREEN = new Color(0, 117, 44, 255);
public static readonly Color SKYBLUE = new Color(102, 191, 255, 255);
public static readonly Color BLUE = new Color(0, 121, 241, 255);
public static readonly Color DARKBLUE = new Color(0, 82, 172, 255);
public static readonly Color PURPLE = new Color(200, 122, 255, 255);
public static readonly Color VIOLET = new Color(135, 60, 190, 255);
public static readonly Color DARKPURPLE = new Color(112, 31, 126, 255);
public static readonly Color BEIGE = new Color(211, 176, 131, 255);
public static readonly Color BROWN = new Color(127, 106, 79, 255);
public static readonly Color DARKBROWN = new Color(76, 63, 47, 255);
public static readonly Color WHITE = new Color(255, 255, 255, 255);
public static readonly Color BLACK = new Color(0, 0, 0, 255);
public static readonly Color BLANK = new Color(0, 0, 0, 0);
public static readonly Color MAGENTA = new Color(255, 0, 255, 255);
public static readonly Color RAYWHITE = new Color(245, 245, 245, 255);
public Color(int r, int g, int b, int a)
{
this.R = Convert.ToByte(r);
this.G = Convert.ToByte(g);
this.B = Convert.ToByte(b);
this.A = Convert.ToByte(a);
}
public Color(byte r, byte g, byte b, byte a)
{
this.R = r;
this.G = g;
this.B = b;
this.A = a;
}
public Color(int r, int g, int b, int a)
{
this.R = Convert.ToByte(r);
this.G = Convert.ToByte(g);
this.B = Convert.ToByte(b);
this.A = Convert.ToByte(a);
}
public override string ToString()
{
return $"{{R:{R} G:{G} B:{B} A:{A}}}";
}
public override string ToString()
{
return $"{{R:{R} G:{G} B:{B} A:{A}}}";
}
}

@ -1,181 +1,180 @@
using System;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// System config flags<br/>
/// NOTE: Every bit registers one state (use it with bit masks)<br/>
/// By default all flags are set to 0
/// </summary>
[Flags]
public enum ConfigFlags : uint
{
/// <summary>
/// System config flags<br/>
/// NOTE: Every bit registers one state (use it with bit masks)<br/>
/// By default all flags are set to 0
/// Set to try enabling V-Sync on GPU
/// </summary>
[Flags]
public enum ConfigFlags : uint
{
/// <summary>
/// Set to try enabling V-Sync on GPU
/// </summary>
FLAG_VSYNC_HINT = 0x00000040,
/// <summary>
/// Set to run program in fullscreen
/// </summary>
FLAG_FULLSCREEN_MODE = 0x00000002,
/// <summary>
/// Set to allow resizable window
/// </summary>
FLAG_WINDOW_RESIZABLE = 0x00000004,
/// <summary>
/// Set to disable window decoration (frame and buttons)
/// </summary>
FLAG_WINDOW_UNDECORATED = 0x00000008,
/// <summary>
/// Set to hide window
/// </summary>
FLAG_WINDOW_HIDDEN = 0x00000080,
/// <summary>
/// Set to minimize window (iconify)
/// </summary>
FLAG_WINDOW_MINIMIZED = 0x00000200,
/// <summary>
/// Set to maximize window (expanded to monitor)
/// </summary>
FLAG_WINDOW_MAXIMIZED = 0x00000400,
/// <summary>
/// Set to window non focused
/// </summary>
FLAG_WINDOW_UNFOCUSED = 0x00000800,
/// <summary>
/// Set to window always on top
/// </summary>
FLAG_WINDOW_TOPMOST = 0x00001000,
/// <summary>
/// Set to allow windows running while minimized
/// </summary>
FLAG_WINDOW_ALWAYS_RUN = 0x00000100,
/// <summary>
/// Set to allow transparent framebuffer
/// </summary>
FLAG_WINDOW_TRANSPARENT = 0x00000010,
/// <summary>
/// Set to support HighDPI
/// </summary>
FLAG_WINDOW_HIGHDPI = 0x00002000,
/// <summary>
/// Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
/// </summary>
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000,
/// <summary>
/// Set to try enabling MSAA 4X
/// </summary>
FLAG_MSAA_4X_HINT = 0x00000020,
/// <summary>
/// Set to try enabling interlaced video format (for V3D)
/// </summary>
FLAG_INTERLACED_HINT = 0x00010000,
}
FLAG_VSYNC_HINT = 0x00000040,
/// <summary>
/// Trace log level<br/>
/// NOTE: Organized by priority level
/// Set to run program in fullscreen
/// </summary>
public enum TraceLogLevel
{
/// <summary>
/// Display all logs
/// </summary>
LOG_ALL = 0,
/// <summary>
/// Trace logging, intended for internal use only
/// </summary>
LOG_TRACE,
/// <summary>
/// Debug logging, used for internal debugging, it should be disabled on release builds
/// </summary>
LOG_DEBUG,
/// <summary>
/// Info logging, used for program execution info
/// </summary>
LOG_INFO,
/// <summary>
/// Warning logging, used on recoverable failures
/// </summary>
LOG_WARNING,
/// <summary>
/// Error logging, used on unrecoverable failures
/// </summary>
LOG_ERROR,
/// <summary>
/// Fatal logging, used to abort program: exit(EXIT_FAILURE)
/// </summary>
LOG_FATAL,
/// <summary>
/// Disable logging
/// </summary>
LOG_NONE
}
FLAG_FULLSCREEN_MODE = 0x00000002,
/// <summary>
/// Color blending modes (pre-defined)
/// Set to allow resizable window
/// </summary>
public enum BlendMode
{
/// <summary>
/// Blend textures considering alpha (default)
/// </summary>
BLEND_ALPHA = 0,
FLAG_WINDOW_RESIZABLE = 0x00000004,
/// <summary>
/// Blend textures adding colors
/// </summary>
BLEND_ADDITIVE,
/// <summary>
/// Set to disable window decoration (frame and buttons)
/// </summary>
FLAG_WINDOW_UNDECORATED = 0x00000008,
/// <summary>
/// Blend textures multiplying colors
/// </summary>
BLEND_MULTIPLIED,
/// <summary>
/// Set to hide window
/// </summary>
FLAG_WINDOW_HIDDEN = 0x00000080,
/// <summary>
/// Blend textures adding colors (alternative)
/// </summary>
BLEND_ADD_COLORS,
/// <summary>
/// Set to minimize window (iconify)
/// </summary>
FLAG_WINDOW_MINIMIZED = 0x00000200,
/// <summary>
/// Blend textures subtracting colors (alternative)
/// </summary>
BLEND_SUBTRACT_COLORS,
/// <summary>
/// Set to maximize window (expanded to monitor)
/// </summary>
FLAG_WINDOW_MAXIMIZED = 0x00000400,
/// <summary>
/// Blend premultiplied textures considering alpha
/// </summary>
BLEND_ALPHA_PREMULTIPLY,
/// <summary>
/// Set to window non focused
/// </summary>
FLAG_WINDOW_UNFOCUSED = 0x00000800,
/// <summary>
/// Blend textures using custom src/dst factors (use rlSetBlendFactors())
/// </summary>
BLEND_CUSTOM,
/// <summary>
/// Set to window always on top
/// </summary>
FLAG_WINDOW_TOPMOST = 0x00001000,
/// <summary>
/// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())
/// </summary>
BLEND_CUSTOM_SEPARATE
}
/// <summary>
/// Set to allow windows running while minimized
/// </summary>
FLAG_WINDOW_ALWAYS_RUN = 0x00000100,
/// <summary>
/// Set to allow transparent framebuffer
/// </summary>
FLAG_WINDOW_TRANSPARENT = 0x00000010,
/// <summary>
/// Set to support HighDPI
/// </summary>
FLAG_WINDOW_HIGHDPI = 0x00002000,
/// <summary>
/// Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED
/// </summary>
FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000,
/// <summary>
/// Set to try enabling MSAA 4X
/// </summary>
FLAG_MSAA_4X_HINT = 0x00000020,
/// <summary>
/// Set to try enabling interlaced video format (for V3D)
/// </summary>
FLAG_INTERLACED_HINT = 0x00010000,
}
/// <summary>
/// Trace log level<br/>
/// NOTE: Organized by priority level
/// </summary>
public enum TraceLogLevel
{
/// <summary>
/// Display all logs
/// </summary>
LOG_ALL = 0,
/// <summary>
/// Trace logging, intended for internal use only
/// </summary>
LOG_TRACE,
/// <summary>
/// Debug logging, used for internal debugging, it should be disabled on release builds
/// </summary>
LOG_DEBUG,
/// <summary>
/// Info logging, used for program execution info
/// </summary>
LOG_INFO,
/// <summary>
/// Warning logging, used on recoverable failures
/// </summary>
LOG_WARNING,
/// <summary>
/// Error logging, used on unrecoverable failures
/// </summary>
LOG_ERROR,
/// <summary>
/// Fatal logging, used to abort program: exit(EXIT_FAILURE)
/// </summary>
LOG_FATAL,
/// <summary>
/// Disable logging
/// </summary>
LOG_NONE
}
/// <summary>
/// Color blending modes (pre-defined)
/// </summary>
public enum BlendMode
{
/// <summary>
/// Blend textures considering alpha (default)
/// </summary>
BLEND_ALPHA = 0,
/// <summary>
/// Blend textures adding colors
/// </summary>
BLEND_ADDITIVE,
/// <summary>
/// Blend textures multiplying colors
/// </summary>
BLEND_MULTIPLIED,
/// <summary>
/// Blend textures adding colors (alternative)
/// </summary>
BLEND_ADD_COLORS,
/// <summary>
/// Blend textures subtracting colors (alternative)
/// </summary>
BLEND_SUBTRACT_COLORS,
/// <summary>
/// Blend premultiplied textures considering alpha
/// </summary>
BLEND_ALPHA_PREMULTIPLY,
/// <summary>
/// Blend textures using custom src/dst factors (use rlSetBlendFactors())
/// </summary>
BLEND_CUSTOM,
/// <summary>
/// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate())
/// </summary>
BLEND_CUSTOM_SEPARATE
}

@ -1,94 +1,93 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Font type, defines generation method
/// </summary>
public enum FontType
{
/// <summary>
/// Font type, defines generation method
/// Default font generation, anti-aliased
/// </summary>
public enum FontType
{
/// <summary>
/// Default font generation, anti-aliased
/// </summary>
FONT_DEFAULT = 0,
/// <summary>
/// Bitmap font generation, no anti-aliasing
/// </summary>
FONT_BITMAP,
/// <summary>
/// SDF font generation, requires external shader
/// </summary>
FONT_SDF
}
FONT_DEFAULT = 0,
/// <summary>
/// GlyphInfo, font characters glyphs info
/// Bitmap font generation, no anti-aliasing
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct GlyphInfo
{
/// <summary>
/// Character value (Unicode)
/// </summary>
public int Value;
/// <summary>
/// Character offset X when drawing
/// </summary>
public int OffsetX;
/// <summary>
/// Character offset Y when drawing
/// </summary>
public int OffsetY;
/// <summary>
/// Character advance position X
/// </summary>
public int AdvanceX;
/// <summary>
/// Character image data
/// </summary>
public Image Image;
}
FONT_BITMAP,
/// <summary>
/// Font, font texture and GlyphInfo array data
/// SDF font generation, requires external shader
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Font
{
/// <summary>
/// Base size (default chars height)
/// </summary>
public int BaseSize;
/// <summary>
/// Number of characters
/// </summary>
public int GlyphCount;
/// <summary>
/// Padding around the glyph characters
/// </summary>
public int GlyphPadding;
/// <summary>
/// Texture atlas containing the glyphs
/// </summary>
public Texture2D Texture;
/// <summary>
/// Rectangles in texture for the glyphs
/// </summary>
public Rectangle* Recs;
/// <summary>
/// Glyphs info data
/// </summary>
public GlyphInfo* Glyphs;
}
FONT_SDF
}
/// <summary>
/// GlyphInfo, font characters glyphs info
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct GlyphInfo
{
/// <summary>
/// Character value (Unicode)
/// </summary>
public int Value;
/// <summary>
/// Character offset X when drawing
/// </summary>
public int OffsetX;
/// <summary>
/// Character offset Y when drawing
/// </summary>
public int OffsetY;
/// <summary>
/// Character advance position X
/// </summary>
public int AdvanceX;
/// <summary>
/// Character image data
/// </summary>
public Image Image;
}
/// <summary>
/// Font, font texture and GlyphInfo array data
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Font
{
/// <summary>
/// Base size (default chars height)
/// </summary>
public int BaseSize;
/// <summary>
/// Number of characters
/// </summary>
public int GlyphCount;
/// <summary>
/// Padding around the glyph characters
/// </summary>
public int GlyphPadding;
/// <summary>
/// Texture atlas containing the glyphs
/// </summary>
public Texture2D Texture;
/// <summary>
/// Rectangles in texture for the glyphs
/// </summary>
public Rectangle* Recs;
/// <summary>
/// Glyphs info data
/// </summary>
public GlyphInfo* Glyphs;
}

@ -1,148 +1,147 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Pixel formats<br/>
/// NOTE: Support depends on OpenGL version and platform
/// </summary>
public enum PixelFormat
{
/// <summary>
/// Pixel formats<br/>
/// NOTE: Support depends on OpenGL version and platform
/// 8 bit per pixel (no alpha)
/// </summary>
public enum PixelFormat
{
/// <summary>
/// 8 bit per pixel (no alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1,
/// <summary>
/// 8*2 bpp (2 channels)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
/// <summary>
/// 16 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R5G6B5,
/// <summary>
/// 24 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R8G8B8,
/// <summary>
/// 16 bpp (1 bit alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,
/// <summary>
/// 16 bpp (4 bit alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R4G4B4A4,
/// <summary>
/// 32 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
/// <summary>
/// 32 bpp (1 channel - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32,
/// <summary>
/// 32*3 bpp (3 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32,
/// <summary>
/// 32*4 bpp (4 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32A32,
/// <summary>
/// 4 bpp (no alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGB,
/// <summary>
/// 4 bpp (1 bit alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT3_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT5_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC1_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_RGB,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA,
/// <summary>
/// 2 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA
}
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1,
/// <summary>
/// Image, pixel data stored in CPU memory (RAM)
/// 8*2 bpp (2 channels)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Image
{
/// <summary>
/// Image raw data
/// </summary>
public void* Data;
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
/// <summary>
/// Image base width
/// </summary>
public int Width;
/// <summary>
/// 16 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R5G6B5,
/// <summary>
/// Image base height
/// </summary>
public int Height;
/// <summary>
/// 24 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R8G8B8,
/// <summary>
/// Mipmap levels, 1 by default
/// </summary>
public int Mipmaps;
/// <summary>
/// 16 bpp (1 bit alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,
/// <summary>
/// Data format (PixelFormat type)
/// </summary>
public PixelFormat Format;
}
/// <summary>
/// 16 bpp (4 bit alpha)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R4G4B4A4,
/// <summary>
/// 32 bpp
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
/// <summary>
/// 32 bpp (1 channel - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32,
/// <summary>
/// 32*3 bpp (3 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32,
/// <summary>
/// 32*4 bpp (4 channels - float)
/// </summary>
PIXELFORMAT_UNCOMPRESSED_R32G32B32A32,
/// <summary>
/// 4 bpp (no alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGB,
/// <summary>
/// 4 bpp (1 bit alpha)
/// </summary>
PIXELFORMAT_COMPRESSED_DXT1_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT3_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_DXT5_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC1_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_RGB,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGB,
/// <summary>
/// 4 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_PVRT_RGBA,
/// <summary>
/// 8 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA,
/// <summary>
/// 2 bpp
/// </summary>
PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA
}
/// <summary>
/// Image, pixel data stored in CPU memory (RAM)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Image
{
/// <summary>
/// Image raw data
/// </summary>
public void* Data;
/// <summary>
/// Image base width
/// </summary>
public int Width;
/// <summary>
/// Image base height
/// </summary>
public int Height;
/// <summary>
/// Mipmap levels, 1 by default
/// </summary>
public int Mipmaps;
/// <summary>
/// Data format (PixelFormat type)
/// </summary>
public PixelFormat Format;
}

File diff suppressed because it is too large Load Diff

@ -4,161 +4,160 @@
using System;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
internal readonly struct Native
{
internal readonly struct Native
internal const string Msvcrt = "msvcrt";
internal const string Libc = "libc";
internal const string LibSystem = "libSystem";
[DllImport(LibSystem, EntryPoint = "vasprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VasPrintfApple(ref IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfLinux(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfWindows(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfLinux(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfWindows(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
struct VaListLinuxX64
{
uint _gpOffset;
uint _fpOffset;
IntPtr _overflowArgArea;
IntPtr _regSaveArea;
}
/// <summary>
/// Logging workaround for formatting strings from native code
/// </summary>
public static unsafe class Logging
{
[UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static unsafe void LogConsole(int msgType, sbyte* text, sbyte* args)
{
internal const string Msvcrt = "msvcrt";
internal const string Libc = "libc";
internal const string LibSystem = "libSystem";
[DllImport(LibSystem, EntryPoint = "vasprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VasPrintfApple(ref IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfLinux(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsPrintfWindows(IntPtr buffer, IntPtr format, IntPtr args);
[DllImport(Libc, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfLinux(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
[DllImport(Msvcrt, EntryPoint = "vsnprintf", CallingConvention = CallingConvention.Cdecl)]
public static extern int VsnPrintfWindows(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args);
var message = GetLogMessage(new IntPtr(text), new IntPtr(args));
Console.WriteLine(message);
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
struct VaListLinuxX64
public static string GetLogMessage(IntPtr format, IntPtr args)
{
uint _gpOffset;
uint _fpOffset;
IntPtr _overflowArgArea;
IntPtr _regSaveArea;
}
/// <summary>
/// Logging workaround for formatting strings from native code
/// </summary>
public static unsafe class Logging
{
[UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static unsafe void LogConsole(int msgType, sbyte* text, sbyte* args)
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var message = GetLogMessage(new IntPtr(text), new IntPtr(args));
Console.WriteLine(message);
return AppleLogCallback(format, args);
}
public static string GetLogMessage(IntPtr format, IntPtr args)
// Special marshalling is needed on Linux desktop 64 bits.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && IntPtr.Size == 8)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return AppleLogCallback(format, args);
}
return LinuxX64LogCallback(format, args);
}
// Special marshalling is needed on Linux desktop 64 bits.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && IntPtr.Size == 8)
{
return LinuxX64LogCallback(format, args);
}
var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1;
if (byteLength <= 1)
{
return string.Empty;
}
var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1;
if (byteLength <= 1)
var buffer = Marshal.AllocHGlobal(byteLength);
VsPrintf(buffer, format, args);
string result = Marshal.PtrToStringUTF8(buffer);
Marshal.FreeHGlobal(buffer);
return result;
}
static string AppleLogCallback(IntPtr format, IntPtr args)
{
IntPtr buffer = IntPtr.Zero;
try
{
var count = Native.VasPrintfApple(ref buffer, format, args);
if (count == -1)
{
return string.Empty;
}
var buffer = Marshal.AllocHGlobal(byteLength);
VsPrintf(buffer, format, args);
string result = Marshal.PtrToStringUTF8(buffer);
return Marshal.PtrToStringUTF8(buffer) ?? string.Empty;
}
finally
{
Marshal.FreeHGlobal(buffer);
return result;
}
static string AppleLogCallback(IntPtr format, IntPtr args)
{
IntPtr buffer = IntPtr.Zero;
try
{
var count = Native.VasPrintfApple(ref buffer, format, args);
if (count == -1)
{
return string.Empty;
}
return Marshal.PtrToStringUTF8(buffer) ?? string.Empty;
}
finally
{
Marshal.FreeHGlobal(buffer);
}
}
static string LinuxX64LogCallback(IntPtr format, IntPtr args)
{
// The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure.
var listStructure = Marshal.PtrToStructure<VaListLinuxX64>(args);
IntPtr listPointer = IntPtr.Zero;
int byteLength = 0;
string result = "";
// Get length of args
listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(listStructure));
Marshal.StructureToPtr(listStructure, listPointer, false);
byteLength = Native.VsnPrintfLinux(IntPtr.Zero, UIntPtr.Zero, format, listPointer) + 1;
// Allocate buffer for result
Marshal.StructureToPtr(listStructure, listPointer, false);
IntPtr utf8Buffer = IntPtr.Zero;
utf8Buffer = Marshal.AllocHGlobal(byteLength);
// Print result into buffer
Native.VsPrintfLinux(utf8Buffer, format, listPointer);
result = Marshal.PtrToStringUTF8(utf8Buffer);
Marshal.FreeHGlobal(listPointer);
Marshal.FreeHGlobal(utf8Buffer);
return result;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args)
{
var os = Environment.OSVersion;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsnPrintfWindows(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsnPrintfLinux(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsPrintfWindows(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsPrintfLinux(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
}
}
static string LinuxX64LogCallback(IntPtr format, IntPtr args)
{
// The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure.
var listStructure = Marshal.PtrToStructure<VaListLinuxX64>(args);
IntPtr listPointer = IntPtr.Zero;
int byteLength = 0;
string result = "";
// Get length of args
listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(listStructure));
Marshal.StructureToPtr(listStructure, listPointer, false);
byteLength = Native.VsnPrintfLinux(IntPtr.Zero, UIntPtr.Zero, format, listPointer) + 1;
// Allocate buffer for result
Marshal.StructureToPtr(listStructure, listPointer, false);
IntPtr utf8Buffer = IntPtr.Zero;
utf8Buffer = Marshal.AllocHGlobal(byteLength);
// Print result into buffer
Native.VsPrintfLinux(utf8Buffer, format, listPointer);
result = Marshal.PtrToStringUTF8(utf8Buffer);
Marshal.FreeHGlobal(listPointer);
Marshal.FreeHGlobal(utf8Buffer);
return result;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args)
{
var os = Environment.OSVersion;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsnPrintfWindows(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsnPrintfLinux(buffer, size, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
}
// https://github.com/dotnet/runtime/issues/51052
static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Native.VsPrintfWindows(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return Native.VsPrintfLinux(buffer, format, args);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Native.VsPrintfLinux(buffer, format, args);
}
return -1;
}
}

@ -1,91 +1,90 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Material map index
/// </summary>
public enum MaterialMapIndex
{
/// <summary>
/// Material map index
/// NOTE: Same as MATERIAL_MAP_DIFFUSE
/// </summary>
public enum MaterialMapIndex
{
/// <summary>
/// NOTE: Same as MATERIAL_MAP_DIFFUSE
/// </summary>
MATERIAL_MAP_ALBEDO = 0,
/// <summary>
/// NOTE: Same as MATERIAL_MAP_SPECULAR
/// </summary>
MATERIAL_MAP_METALNESS,
MATERIAL_MAP_NORMAL,
MATERIAL_MAP_ROUGHNESS,
MATERIAL_MAP_OCCLUSION,
MATERIAL_MAP_EMISSION,
MATERIAL_MAP_HEIGHT,
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_CUBEMAP,
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_IRRADIANCE,
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_PREFILTER,
MATERIAL_MAP_BRDF,
MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO,
MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS,
}
MATERIAL_MAP_ALBEDO = 0,
/// <summary>
/// Material texture map
/// NOTE: Same as MATERIAL_MAP_SPECULAR
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct MaterialMap
{
/// <summary>
/// Material map texture
/// </summary>
public Texture2D Texture;
MATERIAL_MAP_METALNESS,
/// <summary>
/// Material map color
/// </summary>
public Color Color;
/// <summary>
/// Material map value
/// </summary>
public float Value;
}
MATERIAL_MAP_NORMAL,
MATERIAL_MAP_ROUGHNESS,
MATERIAL_MAP_OCCLUSION,
MATERIAL_MAP_EMISSION,
MATERIAL_MAP_HEIGHT,
/// <summary>
/// Material type (generic)
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Material
{
/// <summary>
/// Material shader
/// </summary>
public Shader Shader;
MATERIAL_MAP_CUBEMAP,
//TODO: convert
/// <summary>
/// Material maps
/// </summary>
public MaterialMap* Maps;
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_IRRADIANCE,
/// <summary>
/// Material generic parameters (if required)
/// </summary>
public fixed float Param[4];
}
/// <summary>
/// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary>
MATERIAL_MAP_PREFILTER,
MATERIAL_MAP_BRDF,
MATERIAL_MAP_DIFFUSE = MATERIAL_MAP_ALBEDO,
MATERIAL_MAP_SPECULAR = MATERIAL_MAP_METALNESS,
}
/// <summary>
/// Material texture map
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct MaterialMap
{
/// <summary>
/// Material map texture
/// </summary>
public Texture2D Texture;
/// <summary>
/// Material map color
/// </summary>
public Color Color;
/// <summary>
/// Material map value
/// </summary>
public float Value;
}
/// <summary>
/// Material type (generic)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Material
{
/// <summary>
/// Material shader
/// </summary>
public Shader Shader;
//TODO: convert
/// <summary>
/// Material maps
/// </summary>
public MaterialMap* Maps;
/// <summary>
/// Material generic parameters (if required)
/// </summary>
public fixed float Param[4];
}

@ -1,99 +1,98 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Vertex data definning a mesh<br/>
/// NOTE: Data stored in CPU memory (and GPU)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Mesh
{
/// <summary>
/// Vertex data definning a mesh<br/>
/// NOTE: Data stored in CPU memory (and GPU)
/// Number of vertices stored in arrays
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Mesh
{
/// <summary>
/// Number of vertices stored in arrays
/// </summary>
public int VertexCount;
public int VertexCount;
/// <summary>
/// Number of triangles stored (indexed or not)
/// </summary>
public int TriangleCount;
/// <summary>
/// Number of triangles stored (indexed or not)
/// </summary>
public int TriangleCount;
#region Default vertex data
#region Default vertex data
/// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// </summary>
public float* Vertices;
/// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// </summary>
public float* Vertices;
/// <summary>
/// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
/// </summary>
public float* TexCoords;
/// <summary>
/// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
/// </summary>
public float* TexCoords;
/// <summary>
/// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
/// </summary>
public float* TexCoords2;
/// <summary>
/// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
/// </summary>
public float* TexCoords2;
/// <summary>
/// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
/// </summary>
public float* Normals;
/// <summary>
/// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
/// </summary>
public float* Normals;
/// <summary>
/// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
/// </summary>
public float* Tangents;
/// <summary>
/// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
/// </summary>
public float* Tangents;
/// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary>
public byte* Colors;
/// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary>
public byte* Colors;
/// <summary>
/// Vertex indices (in case vertex data comes indexed)
/// </summary>
public ushort* Indices;
/// <summary>
/// Vertex indices (in case vertex data comes indexed)
/// </summary>
public ushort* Indices;
#endregion
#endregion
#region Animation vertex data
#region Animation vertex data
/// <summary>
/// Animated vertex positions (after bones transformations)
/// </summary>
public float* AnimVertices;
/// <summary>
/// Animated vertex positions (after bones transformations)
/// </summary>
public float* AnimVertices;
/// <summary>
/// Animated normals (after bones transformations)
/// </summary>
public float* AnimNormals;
/// <summary>
/// Animated normals (after bones transformations)
/// </summary>
public float* AnimNormals;
/// <summary>
/// Vertex bone ids, up to 4 bones influence by vertex (skinning)
/// </summary>
public byte* BoneIds;
/// <summary>
/// Vertex bone ids, up to 4 bones influence by vertex (skinning)
/// </summary>
public byte* BoneIds;
/// <summary>
/// Vertex bone weight, up to 4 bones influence by vertex (skinning)
/// </summary>
public float* BoneWeights;
/// <summary>
/// Vertex bone weight, up to 4 bones influence by vertex (skinning)
/// </summary>
public float* BoneWeights;
#endregion
#endregion
#region OpenGL identifiers
#region OpenGL identifiers
/// <summary>
/// OpenGL Vertex Array Object id
/// </summary>
public uint VaoId;
/// <summary>
/// OpenGL Vertex Array Object id
/// </summary>
public uint VaoId;
/// <summary>
/// OpenGL Vertex Buffer Objects id (default vertex data, uint[])
/// </summary>
public uint* VboId;
/// <summary>
/// OpenGL Vertex Buffer Objects id (default vertex data, uint[])
/// </summary>
public uint* VboId;
#endregion
}
#endregion
}

@ -2,144 +2,143 @@ using System;
using System.Numerics;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Bone information
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct BoneInfo
{
/// <summary>
/// Bone information
/// Bone name (char[32])
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct BoneInfo
{
/// <summary>
/// Bone name (char[32])
/// </summary>
public fixed sbyte Name[32];
/// <summary>
/// Bone parent
/// </summary>
public int Parent;
}
public fixed sbyte Name[32];
/// <summary>
/// Model type
/// Bone parent
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Model
{
/// <summary>
/// Local transform matrix
/// </summary>
public Matrix4x4 Transform;
public int Parent;
}
/// <summary>
/// Number of meshes
/// </summary>
public int MeshCount;
/// <summary>
/// Number of materials
/// </summary>
public int MaterialCount;
/// <summary>
/// Meshes array (Mesh *)
/// </summary>
public Mesh* Meshes;
/// <summary>
/// Materials array (Material *)
/// </summary>
public Material* Materials;
/// <summary>
/// Mesh material number (int *)
/// </summary>
public int* MeshMaterial;
/// <summary>
/// Number of bones
/// </summary>
public int BoneCount;
//TODO: Span
/// <summary>
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public BoneInfo* Bones;
//TODO: Span
/// <summary>
/// Bones base transformation (pose, Transform *)
/// </summary>
public Transform* BindPose;
}
/// <summary>
/// Model type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Model
{
/// <summary>
/// Local transform matrix
/// </summary>
public Matrix4x4 Transform;
/// <summary>
/// Model animation
/// Number of meshes
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe partial struct ModelAnimation
public int MeshCount;
/// <summary>
/// Number of materials
/// </summary>
public int MaterialCount;
/// <summary>
/// Meshes array (Mesh *)
/// </summary>
public Mesh* Meshes;
/// <summary>
/// Materials array (Material *)
/// </summary>
public Material* Materials;
/// <summary>
/// Mesh material number (int *)
/// </summary>
public int* MeshMaterial;
/// <summary>
/// Number of bones
/// </summary>
public int BoneCount;
//TODO: Span
/// <summary>
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public BoneInfo* Bones;
//TODO: Span
/// <summary>
/// Bones base transformation (pose, Transform *)
/// </summary>
public Transform* BindPose;
}
/// <summary>
/// Model animation
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe partial struct ModelAnimation
{
/// <summary>
/// Number of bones
/// </summary>
public readonly int BoneCount;
/// <summary>
/// Number of animation frames
/// </summary>
public readonly int FrameCount;
/// <summary>
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public readonly BoneInfo* Bones;
/// <inheritdoc cref="Bones"/>
public ReadOnlySpan<BoneInfo> BoneInfo => new(Bones, BoneCount);
/// <summary>
/// Poses array by frame (Transform **)
/// </summary>
public readonly Transform** FramePoses;
/// <inheritdoc cref="FramePoses"/>
public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount);
public struct FramePosesCollection
{
/// <summary>
/// Number of bones
/// </summary>
public readonly int BoneCount;
readonly Transform** _framePoses;
/// <summary>
/// Number of animation frames
/// </summary>
public readonly int FrameCount;
readonly int _frameCount;
/// <summary>
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public readonly BoneInfo* Bones;
readonly int _boneCount;
/// <inheritdoc cref="Bones"/>
public ReadOnlySpan<BoneInfo> BoneInfo => new(Bones, BoneCount);
public FramePoses this[int index] => new(_framePoses[index], _boneCount);
/// <summary>
/// Poses array by frame (Transform **)
/// </summary>
public readonly Transform** FramePoses;
public Transform this[int index1, int index2] => new FramePoses(_framePoses[index1], _boneCount)[index2];
/// <inheritdoc cref="FramePoses"/>
public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount);
public struct FramePosesCollection
internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount)
{
readonly Transform** _framePoses;
readonly int _frameCount;
readonly int _boneCount;
public FramePoses this[int index] => new(_framePoses[index], _boneCount);
public Transform this[int index1, int index2] => new FramePoses(_framePoses[index1], _boneCount)[index2];
internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount)
{
this._framePoses = framePoses;
this._frameCount = frameCount;
this._boneCount = boneCount;
}
}
}
public unsafe struct FramePoses
{
readonly Transform* _poses;
readonly int _count;
public ref Transform this[int index] => ref _poses[index];
internal FramePoses(Transform* poses, int count)
{
this._poses = poses;
this._count = count;
this._framePoses = framePoses;
this._frameCount = frameCount;
this._boneCount = boneCount;
}
}
}
public unsafe struct FramePoses
{
readonly Transform* _poses;
readonly int _count;
public ref Transform this[int index] => ref _poses[index];
internal FramePoses(Transform* poses, int count)
{
this._poses = poses;
this._count = count;
}
}

@ -1,62 +1,61 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// N-patch layout
/// </summary>
public enum NPatchLayout
{
/// <summary>
/// N-patch layout
/// Npatch defined by 3x3 tiles
/// </summary>
public enum NPatchLayout
{
/// <summary>
/// Npatch defined by 3x3 tiles
/// </summary>
NPATCH_NINE_PATCH = 0,
/// <summary>
/// Npatch defined by 1x3 tiles
/// </summary>
NPATCH_THREE_PATCH_VERTICAL,
/// <summary>
/// Npatch defined by 3x1 tiles
/// </summary>
NPATCH_THREE_PATCH_HORIZONTAL
}
NPATCH_NINE_PATCH = 0,
/// <summary>
/// N-Patch layout info
/// Npatch defined by 1x3 tiles
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct NPatchInfo
{
/// <summary>
/// Texture source rectangle
/// </summary>
public Rectangle Source;
NPATCH_THREE_PATCH_VERTICAL,
/// <summary>
/// Left border offset
/// </summary>
public int Left;
/// <summary>
/// Top border offset
/// </summary>
public int Top;
/// <summary>
/// Right border offset
/// </summary>
public int Right;
/// <summary>
/// Bottom border offset
/// </summary>
public int Bottom;
/// <summary>
/// Layout of the n-patch: 3x3, 1x3 or 3x1
/// </summary>
public NPatchLayout Layout;
}
/// <summary>
/// Npatch defined by 3x1 tiles
/// </summary>
NPATCH_THREE_PATCH_HORIZONTAL
}
/// <summary>
/// N-Patch layout info
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct NPatchInfo
{
/// <summary>
/// Texture source rectangle
/// </summary>
public Rectangle Source;
/// <summary>
/// Left border offset
/// </summary>
public int Left;
/// <summary>
/// Top border offset
/// </summary>
public int Top;
/// <summary>
/// Right border offset
/// </summary>
public int Right;
/// <summary>
/// Bottom border offset
/// </summary>
public int Bottom;
/// <summary>
/// Layout of the n-patch: 3x3, 1x3 or 3x1
/// </summary>
public NPatchLayout Layout;
}

@ -1,55 +1,54 @@
using System.Numerics;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Ray, ray for raycasting
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Ray
{
/// <summary>
/// Ray, ray for raycasting
/// Ray position (origin)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Ray
{
/// <summary>
/// Ray position (origin)
/// </summary>
public Vector3 Position;
/// <summary>
/// Ray direction
/// </summary>
public Vector3 Direction;
public Ray(Vector3 position, Vector3 direction)
{
this.Position = position;
this.Direction = direction;
}
}
public Vector3 Position;
/// <summary>
/// Raycast hit information
/// Ray direction
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct RayCollision
public Vector3 Direction;
public Ray(Vector3 position, Vector3 direction)
{
/// <summary>
/// Did the ray hit something?
/// </summary>
public CBool Hit;
/// <summary>
/// Distance to the nearest hit
/// </summary>
public float Distance;
/// <summary>
/// Point of the nearest hit
/// </summary>
public Vector3 Point;
/// <summary>
/// Surface normal of hit
/// </summary>
public Vector3 Normal;
this.Position = position;
this.Direction = direction;
}
}
/// <summary>
/// Raycast hit information
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct RayCollision
{
/// <summary>
/// Did the ray hit something?
/// </summary>
public CBool Hit;
/// <summary>
/// Distance to the nearest hit
/// </summary>
public float Distance;
/// <summary>
/// Point of the nearest hit
/// </summary>
public Vector3 Point;
/// <summary>
/// Surface normal of hit
/// </summary>
public Vector3 Normal;
}

File diff suppressed because it is too large Load Diff

@ -1,29 +1,28 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Rectangle type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Rectangle
{
/// <summary>
/// Rectangle type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Rectangle
public float X;
public float Y;
public float Width;
public float Height;
public Rectangle(float x, float y, float width, float height)
{
public float X;
public float Y;
public float Width;
public float Height;
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
}
public Rectangle(float x, float y, float width, float height)
{
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
}
public override string ToString()
{
return $"{{X:{X} Y:{Y} Width:{Width} Height:{Height}}}";
}
public override string ToString()
{
return $"{{X:{X} Y:{Y} Width:{Width} Height:{Height}}}";
}
}

@ -1,271 +1,270 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// RenderBatch type
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct RenderBatch
{
/// <summary>
/// RenderBatch type
/// Number of vertex buffers (multi-buffering support)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct RenderBatch
{
/// <summary>
/// Number of vertex buffers (multi-buffering support)
/// </summary>
int _buffersCount;
/// <summary>
/// Current buffer tracking in case of multi-buffering
/// </summary>
int _currentBuffer;
/// <summary>
/// Dynamic buffer(s) for vertex data
/// </summary>
VertexBuffer* _vertexBuffer;
/// <summary>
/// Draw calls array, depends on textureId
/// </summary>
DrawCall* _draws;
/// <summary>
/// Draw calls counter
/// </summary>
int _drawsCounter;
/// <summary>
/// Current depth value for next draw
/// </summary>
float _currentDepth;
}
int _buffersCount;
/// <summary>
/// Dynamic vertex buffers (position + texcoords + colors + indices arrays)
/// Current buffer tracking in case of multi-buffering
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct VertexBuffer
{
/// <summary>
/// Number of elements in the buffer (QUADS)
/// </summary>
public int ElementCount;
/// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// </summary>
public float* Vertices;
/// <summary>
/// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
/// </summary>
public float* TexCoords;
/// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary>
public byte* Colors;
/// <summary>
/// Vertex indices (in case vertex data comes indexed) (6 indices per quad)<br/>
/// unsigned int* for GRAPHICS_API_OPENGL_11 or GRAPHICS_API_OPENGL_33<br/>
/// unsigned short* for GRAPHICS_API_OPENGL_ES2
/// </summary>
public void* Indices;
/// <summary>
/// OpenGL Vertex Array Object id
/// </summary>
public uint VaoId;
/// <summary>
/// OpenGL Vertex Buffer Objects id (4 types of vertex data)
/// </summary>
public fixed uint VboId[4];
}
int _currentBuffer;
/// <summary>
/// Dynamic vertex buffers (position + texcoords + colors + indices arrays)
/// Dynamic buffer(s) for vertex data
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct DrawCall
{
/// <summary>
/// Drawing mode: LINES, TRIANGLES, QUADS
/// </summary>
int _mode;
/// <summary>
/// Number of vertices for the draw call
/// </summary>
int _vertexCount;
/// <summary>
/// Number of vertices required for index alignment (LINES, TRIANGLES)
/// </summary>
int _vertexAlignment;
/// <summary>
/// Texture id to be used on the draw -> Use to create new draw call if changes
/// </summary>
uint _textureId;
}
public enum GlVersion
{
OPENGL_11 = 1,
OPENGL_21,
OPENGL_33,
OPENGL_43,
OPENGL_ES_20
}
public enum FramebufferAttachType
{
RL_ATTACHMENT_COLOR_CHANNEL0 = 0,
RL_ATTACHMENT_COLOR_CHANNEL1,
RL_ATTACHMENT_COLOR_CHANNEL2,
RL_ATTACHMENT_COLOR_CHANNEL3,
RL_ATTACHMENT_COLOR_CHANNEL4,
RL_ATTACHMENT_COLOR_CHANNEL5,
RL_ATTACHMENT_COLOR_CHANNEL6,
RL_ATTACHMENT_COLOR_CHANNEL7,
RL_ATTACHMENT_DEPTH = 100,
RL_ATTACHMENT_STENCIL = 200,
}
public enum FramebufferAttachTextureType
{
RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_X,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Y,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Z,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z,
RL_ATTACHMENT_TEXTURE2D = 100,
RL_ATTACHMENT_RENDERBUFFER = 200,
}
VertexBuffer* _vertexBuffer;
/// <summary>
/// Matrix Modes (equivalent to OpenGL)
/// Draw calls array, depends on textureId
/// </summary>
public enum MatrixMode
{
/// <summary>
/// GL_MODELVIEW
/// </summary>
MODELVIEW = 0x1700,
/// <summary>
/// GL_PROJECTION
/// </summary>
PROJECTION = 0x1701,
/// <summary>
/// GL_TEXTURE
/// </summary>
TEXTURE = 0x1702
}
DrawCall* _draws;
/// <summary>
/// Primitive assembly draw modes
/// Draw calls counter
/// </summary>
public enum DrawMode
{
/// <summary>
/// GL_LINES
/// </summary>
LINES = 0x0001,
/// <summary>
/// GL_TRIANGLES
/// </summary>
TRIANGLES = 0x0004,
/// <summary>
/// GL_QUADS
/// </summary>
QUADS = 0x0007
}
int _drawsCounter;
/// <summary>
/// Texture parameters (equivalent to OpenGL defines)
/// Current depth value for next draw
/// </summary>
public enum TextureFilters
{
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST
/// <br/>
/// GL_NEAREST
/// </summary>
NEAREST = 0x2600,
/// <summary>
/// RL_TEXTURE_FILTER_LINEAR
/// <br/>
/// GL_LINEAR
/// </summary>
LINEAR = 0x2601,
/// <summary>
/// RL_TEXTURE_FILTER_MIP_NEAREST
/// <br/>
/// GL_NEAREST_MIPMAP_NEAREST
/// </summary>
MIP_NEAREST = 0x2700,
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR
/// <br/>
/// GL_NEAREST_MIPMAP_LINEAR
/// </summary>
NEAREST_MIP_LINEAR = 0x2702,
/// <summary>
/// RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST
/// <br/>
/// GL_LINEAR_MIPMAP_NEAREST
/// </summary>
LINEAR_MIP_NEAREST = 0x2701,
/// <summary>
/// RL_TEXTURE_FILTER_MIP_LINEAR
/// <br/>
/// GL_LINEAR_MIPMAP_LINEAR
/// </summary>
MIP_LINEAR = 0x2703,
/// <summary>
/// RL_TEXTURE_FILTER_ANISOTROPIC
/// <br/>
/// Anisotropic filter (custom identifier)
/// </summary>
ANISOTROPIC = 0x3000
}
/// <summary>
/// GL Shader type
/// </summary>
public enum ShaderType
{
/// <summary>
/// RL_FRAGMENT_SHADER
/// <br/>
/// GL_FRAGMENT_SHADER
/// </summary>
FRAGMENT = 0x8B30,
/// <summary>
/// RL_VERTEX_SHADER
/// <br/>
/// GL_VERTEX_SHADER
/// </summary>
VERTEX = 0x8B31,
/// <summary>
/// RL_COMPUTE_SHADER
/// <br/>
/// GL_COMPUTE_SHADER
/// </summary>
COMPUTE = 0x91b9
}
float _currentDepth;
}
/// <summary>
/// Dynamic vertex buffers (position + texcoords + colors + indices arrays)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct VertexBuffer
{
/// <summary>
/// Number of elements in the buffer (QUADS)
/// </summary>
public int ElementCount;
/// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// </summary>
public float* Vertices;
/// <summary>
/// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
/// </summary>
public float* TexCoords;
/// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary>
public byte* Colors;
/// <summary>
/// Vertex indices (in case vertex data comes indexed) (6 indices per quad)<br/>
/// unsigned int* for GRAPHICS_API_OPENGL_11 or GRAPHICS_API_OPENGL_33<br/>
/// unsigned short* for GRAPHICS_API_OPENGL_ES2
/// </summary>
public void* Indices;
/// <summary>
/// OpenGL Vertex Array Object id
/// </summary>
public uint VaoId;
/// <summary>
/// OpenGL Vertex Buffer Objects id (4 types of vertex data)
/// </summary>
public fixed uint VboId[4];
}
/// <summary>
/// Dynamic vertex buffers (position + texcoords + colors + indices arrays)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct DrawCall
{
/// <summary>
/// Drawing mode: LINES, TRIANGLES, QUADS
/// </summary>
int _mode;
/// <summary>
/// Number of vertices for the draw call
/// </summary>
int _vertexCount;
/// <summary>
/// Number of vertices required for index alignment (LINES, TRIANGLES)
/// </summary>
int _vertexAlignment;
/// <summary>
/// Texture id to be used on the draw -> Use to create new draw call if changes
/// </summary>
uint _textureId;
}
public enum GlVersion
{
OPENGL_11 = 1,
OPENGL_21,
OPENGL_33,
OPENGL_43,
OPENGL_ES_20
}
public enum FramebufferAttachType
{
RL_ATTACHMENT_COLOR_CHANNEL0 = 0,
RL_ATTACHMENT_COLOR_CHANNEL1,
RL_ATTACHMENT_COLOR_CHANNEL2,
RL_ATTACHMENT_COLOR_CHANNEL3,
RL_ATTACHMENT_COLOR_CHANNEL4,
RL_ATTACHMENT_COLOR_CHANNEL5,
RL_ATTACHMENT_COLOR_CHANNEL6,
RL_ATTACHMENT_COLOR_CHANNEL7,
RL_ATTACHMENT_DEPTH = 100,
RL_ATTACHMENT_STENCIL = 200,
}
public enum FramebufferAttachTextureType
{
RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_X,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Y,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Z,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z,
RL_ATTACHMENT_TEXTURE2D = 100,
RL_ATTACHMENT_RENDERBUFFER = 200,
}
/// <summary>
/// Matrix Modes (equivalent to OpenGL)
/// </summary>
public enum MatrixMode
{
/// <summary>
/// GL_MODELVIEW
/// </summary>
MODELVIEW = 0x1700,
/// <summary>
/// GL_PROJECTION
/// </summary>
PROJECTION = 0x1701,
/// <summary>
/// GL_TEXTURE
/// </summary>
TEXTURE = 0x1702
}
/// <summary>
/// Primitive assembly draw modes
/// </summary>
public enum DrawMode
{
/// <summary>
/// GL_LINES
/// </summary>
LINES = 0x0001,
/// <summary>
/// GL_TRIANGLES
/// </summary>
TRIANGLES = 0x0004,
/// <summary>
/// GL_QUADS
/// </summary>
QUADS = 0x0007
}
/// <summary>
/// Texture parameters (equivalent to OpenGL defines)
/// </summary>
public enum TextureFilters
{
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST
/// <br/>
/// GL_NEAREST
/// </summary>
NEAREST = 0x2600,
/// <summary>
/// RL_TEXTURE_FILTER_LINEAR
/// <br/>
/// GL_LINEAR
/// </summary>
LINEAR = 0x2601,
/// <summary>
/// RL_TEXTURE_FILTER_MIP_NEAREST
/// <br/>
/// GL_NEAREST_MIPMAP_NEAREST
/// </summary>
MIP_NEAREST = 0x2700,
/// <summary>
/// RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR
/// <br/>
/// GL_NEAREST_MIPMAP_LINEAR
/// </summary>
NEAREST_MIP_LINEAR = 0x2702,
/// <summary>
/// RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST
/// <br/>
/// GL_LINEAR_MIPMAP_NEAREST
/// </summary>
LINEAR_MIP_NEAREST = 0x2701,
/// <summary>
/// RL_TEXTURE_FILTER_MIP_LINEAR
/// <br/>
/// GL_LINEAR_MIPMAP_LINEAR
/// </summary>
MIP_LINEAR = 0x2703,
/// <summary>
/// RL_TEXTURE_FILTER_ANISOTROPIC
/// <br/>
/// Anisotropic filter (custom identifier)
/// </summary>
ANISOTROPIC = 0x3000
}
/// <summary>
/// GL Shader type
/// </summary>
public enum ShaderType
{
/// <summary>
/// RL_FRAGMENT_SHADER
/// <br/>
/// GL_FRAGMENT_SHADER
/// </summary>
FRAGMENT = 0x8B30,
/// <summary>
/// RL_VERTEX_SHADER
/// <br/>
/// GL_VERTEX_SHADER
/// </summary>
VERTEX = 0x8B31,
/// <summary>
/// RL_COMPUTE_SHADER
/// <br/>
/// GL_COMPUTE_SHADER
/// </summary>
COMPUTE = 0x91b9
}

@ -1,26 +1,25 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// RenderTexture2D type, for texture rendering
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct RenderTexture2D
{
/// <summary>
/// RenderTexture2D type, for texture rendering
/// OpenGL Framebuffer Object (FBO) id
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct RenderTexture2D
{
/// <summary>
/// OpenGL Framebuffer Object (FBO) id
/// </summary>
public uint Id;
public uint Id;
/// <summary>
/// Color buffer attachment texture
/// </summary>
public Texture2D Texture;
/// <summary>
/// Color buffer attachment texture
/// </summary>
public Texture2D Texture;
/// <summary>
/// Depth buffer attachment texture
/// </summary>
public Texture2D Depth;
}
/// <summary>
/// Depth buffer attachment texture
/// </summary>
public Texture2D Depth;
}

@ -1,84 +1,83 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Shader location index
/// </summary>
public enum ShaderLocationIndex
{
SHADER_LOC_VERTEX_POSITION = 0,
SHADER_LOC_VERTEX_TEXCOORD01,
SHADER_LOC_VERTEX_TEXCOORD02,
SHADER_LOC_VERTEX_NORMAL,
SHADER_LOC_VERTEX_TANGENT,
SHADER_LOC_VERTEX_COLOR,
SHADER_LOC_MATRIX_MVP,
SHADER_LOC_MATRIX_VIEW,
SHADER_LOC_MATRIX_PROJECTION,
SHADER_LOC_MATRIX_MODEL,
SHADER_LOC_MATRIX_NORMAL,
SHADER_LOC_VECTOR_VIEW,
SHADER_LOC_COLOR_DIFFUSE,
SHADER_LOC_COLOR_SPECULAR,
SHADER_LOC_COLOR_AMBIENT,
SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_METALNESS,
SHADER_LOC_MAP_NORMAL,
SHADER_LOC_MAP_ROUGHNESS,
SHADER_LOC_MAP_OCCLUSION,
SHADER_LOC_MAP_EMISSION,
SHADER_LOC_MAP_HEIGHT,
SHADER_LOC_MAP_CUBEMAP,
SHADER_LOC_MAP_IRRADIANCE,
SHADER_LOC_MAP_PREFILTER,
SHADER_LOC_MAP_BRDF,
SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS,
}
/// <summary>
/// Shader attribute data types
/// </summary>
public enum ShaderAttributeDataType
{
SHADER_ATTRIB_FLOAT = 0,
SHADER_ATTRIB_VEC2,
SHADER_ATTRIB_VEC3,
SHADER_ATTRIB_VEC4
}
/// <summary>
/// Shader uniform data type
/// </summary>
public enum ShaderUniformDataType
{
SHADER_UNIFORM_FLOAT = 0,
SHADER_UNIFORM_VEC2,
SHADER_UNIFORM_VEC3,
SHADER_UNIFORM_VEC4,
SHADER_UNIFORM_INT,
SHADER_UNIFORM_IVEC2,
SHADER_UNIFORM_IVEC3,
SHADER_UNIFORM_IVEC4,
SHADER_UNIFORM_SAMPLER2D
}
/// <summary>
/// Shader type (generic)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Shader
{
/// <summary>
/// Shader location index
/// Shader program id
/// </summary>
public enum ShaderLocationIndex
{
SHADER_LOC_VERTEX_POSITION = 0,
SHADER_LOC_VERTEX_TEXCOORD01,
SHADER_LOC_VERTEX_TEXCOORD02,
SHADER_LOC_VERTEX_NORMAL,
SHADER_LOC_VERTEX_TANGENT,
SHADER_LOC_VERTEX_COLOR,
SHADER_LOC_MATRIX_MVP,
SHADER_LOC_MATRIX_VIEW,
SHADER_LOC_MATRIX_PROJECTION,
SHADER_LOC_MATRIX_MODEL,
SHADER_LOC_MATRIX_NORMAL,
SHADER_LOC_VECTOR_VIEW,
SHADER_LOC_COLOR_DIFFUSE,
SHADER_LOC_COLOR_SPECULAR,
SHADER_LOC_COLOR_AMBIENT,
SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_METALNESS,
SHADER_LOC_MAP_NORMAL,
SHADER_LOC_MAP_ROUGHNESS,
SHADER_LOC_MAP_OCCLUSION,
SHADER_LOC_MAP_EMISSION,
SHADER_LOC_MAP_HEIGHT,
SHADER_LOC_MAP_CUBEMAP,
SHADER_LOC_MAP_IRRADIANCE,
SHADER_LOC_MAP_PREFILTER,
SHADER_LOC_MAP_BRDF,
SHADER_LOC_MAP_DIFFUSE = SHADER_LOC_MAP_ALBEDO,
SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS,
}
public uint Id;
/// <summary>
/// Shader attribute data types
/// Shader locations array (MAX_SHADER_LOCATIONS, int *)
/// </summary>
public enum ShaderAttributeDataType
{
SHADER_ATTRIB_FLOAT = 0,
SHADER_ATTRIB_VEC2,
SHADER_ATTRIB_VEC3,
SHADER_ATTRIB_VEC4
}
/// <summary>
/// Shader uniform data type
/// </summary>
public enum ShaderUniformDataType
{
SHADER_UNIFORM_FLOAT = 0,
SHADER_UNIFORM_VEC2,
SHADER_UNIFORM_VEC3,
SHADER_UNIFORM_VEC4,
SHADER_UNIFORM_INT,
SHADER_UNIFORM_IVEC2,
SHADER_UNIFORM_IVEC3,
SHADER_UNIFORM_IVEC4,
SHADER_UNIFORM_SAMPLER2D
}
/// <summary>
/// Shader type (generic)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Shader
{
/// <summary>
/// Shader program id
/// </summary>
public uint Id;
/// <summary>
/// Shader locations array (MAX_SHADER_LOCATIONS, int *)
/// </summary>
public int* Locs;
}
public int* Locs;
}

@ -1,137 +1,136 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Texture parameters: filter mode<br/>
/// NOTE 1: Filtering considers mipmaps if available in the texture<br/>
/// NOTE 2: Filter is accordingly set for minification and magnification
/// </summary>
public enum TextureFilter
{
/// <summary>
/// Texture parameters: filter mode<br/>
/// NOTE 1: Filtering considers mipmaps if available in the texture<br/>
/// NOTE 2: Filter is accordingly set for minification and magnification
/// No filter, just pixel aproximation
/// </summary>
public enum TextureFilter
{
/// <summary>
/// No filter, just pixel aproximation
/// </summary>
TEXTURE_FILTER_POINT = 0,
/// <summary>
/// Linear filtering
/// </summary>
TEXTURE_FILTER_BILINEAR,
/// <summary>
/// Trilinear filtering (linear with mipmaps)
/// </summary>
TEXTURE_FILTER_TRILINEAR,
/// <summary>
/// Anisotropic filtering 4x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_4X,
/// <summary>
/// Anisotropic filtering 8x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_8X,
/// <summary>
/// Anisotropic filtering 16x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_16X,
}
TEXTURE_FILTER_POINT = 0,
/// <summary>
/// Texture parameters: wrap mode
/// Linear filtering
/// </summary>
public enum TextureWrap
{
/// <summary>
/// Repeats texture in tiled mode
/// </summary>
TEXTURE_WRAP_REPEAT = 0,
/// <summary>
/// Clamps texture to edge pixel in tiled mode
/// </summary>
TEXTURE_WRAP_CLAMP,
/// <summary>
/// Mirrors and repeats the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_REPEAT,
/// <summary>
/// Mirrors and clamps to border the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_CLAMP
}
TEXTURE_FILTER_BILINEAR,
/// <summary>
/// Cubemap layouts
/// Trilinear filtering (linear with mipmaps)
/// </summary>
public enum CubemapLayout
{
/// <summary>
/// Automatically detect layout type
/// </summary>
CUBEMAP_LAYOUT_AUTO_DETECT = 0,
/// <summary>
/// Layout is defined by a vertical line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_VERTICAL,
/// <summary>
/// Layout is defined by a horizontal line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_HORIZONTAL,
/// <summary>
/// Layout is defined by a 3x4 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR,
/// <summary>
/// Layout is defined by a 4x3 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE,
/// <summary>
/// Layout is defined by a panorama image (equirectangular map)
/// </summary>
CUBEMAP_LAYOUT_PANORAMA
}
TEXTURE_FILTER_TRILINEAR,
/// <summary>
/// Texture2D type<br/>
/// NOTE: Data stored in GPU memory
/// Anisotropic filtering 4x
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Texture2D
{
/// <summary>
/// OpenGL texture id
/// </summary>
public uint Id;
TEXTURE_FILTER_ANISOTROPIC_4X,
/// <summary>
/// Texture base width
/// </summary>
public int Width;
/// <summary>
/// Anisotropic filtering 8x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_8X,
/// <summary>
/// Texture base height
/// </summary>
public int Height;
/// <summary>
/// Mipmap levels, 1 by default
/// </summary>
public int Mipmaps;
/// <summary>
/// Data format (PixelFormat type)
/// </summary>
public PixelFormat Format;
}
/// <summary>
/// Anisotropic filtering 16x
/// </summary>
TEXTURE_FILTER_ANISOTROPIC_16X,
}
/// <summary>
/// Texture parameters: wrap mode
/// </summary>
public enum TextureWrap
{
/// <summary>
/// Repeats texture in tiled mode
/// </summary>
TEXTURE_WRAP_REPEAT = 0,
/// <summary>
/// Clamps texture to edge pixel in tiled mode
/// </summary>
TEXTURE_WRAP_CLAMP,
/// <summary>
/// Mirrors and repeats the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_REPEAT,
/// <summary>
/// Mirrors and clamps to border the texture in tiled mode
/// </summary>
TEXTURE_WRAP_MIRROR_CLAMP
}
/// <summary>
/// Cubemap layouts
/// </summary>
public enum CubemapLayout
{
/// <summary>
/// Automatically detect layout type
/// </summary>
CUBEMAP_LAYOUT_AUTO_DETECT = 0,
/// <summary>
/// Layout is defined by a vertical line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_VERTICAL,
/// <summary>
/// Layout is defined by a horizontal line with faces
/// </summary>
CUBEMAP_LAYOUT_LINE_HORIZONTAL,
/// <summary>
/// Layout is defined by a 3x4 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR,
/// <summary>
/// Layout is defined by a 4x3 cross with cubemap faces
/// </summary>
CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE,
/// <summary>
/// Layout is defined by a panorama image (equirectangular map)
/// </summary>
CUBEMAP_LAYOUT_PANORAMA
}
/// <summary>
/// Texture2D type<br/>
/// NOTE: Data stored in GPU memory
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Texture2D
{
/// <summary>
/// OpenGL texture id
/// </summary>
public uint Id;
/// <summary>
/// Texture base width
/// </summary>
public int Width;
/// <summary>
/// Texture base height
/// </summary>
public int Height;
/// <summary>
/// Mipmap levels, 1 by default
/// </summary>
public int Mipmaps;
/// <summary>
/// Data format (PixelFormat type)
/// </summary>
public PixelFormat Format;
}

@ -1,27 +1,26 @@
using System.Numerics;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Transform, vectex transformation data
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Transform
{
/// <summary>
/// Transform, vectex transformation data
/// Translation
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Transform
{
/// <summary>
/// Translation
/// </summary>
public Vector3 Translation;
public Vector3 Translation;
/// <summary>
/// Rotation
/// </summary>
public Quaternion Rotation;
/// <summary>
/// Rotation
/// </summary>
public Quaternion Rotation;
/// <summary>
/// Scale
/// </summary>
public Vector3 Scale;
}
/// <summary>
/// Scale
/// </summary>
public Vector3 Scale;
}

@ -1,36 +1,35 @@
using System;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Converts text to a Ansi buffer for passing to native code
/// </summary>
public readonly ref struct AnsiBuffer
{
/// <summary>
/// Converts text to a Ansi buffer for passing to native code
/// </summary>
public readonly ref struct AnsiBuffer
private readonly IntPtr _data;
public AnsiBuffer(string text)
{
private readonly IntPtr _data;
public AnsiBuffer(string text)
{
_data = Marshal.StringToHGlobalAnsi(text);
}
public unsafe sbyte* AsPointer()
{
return (sbyte*)_data.ToPointer();
}
public void Dispose()
{
Marshal.FreeHGlobal(_data);
}
_data = Marshal.StringToHGlobalAnsi(text);
}
public static class AnsiStringUtils
public unsafe sbyte* AsPointer()
{
public static AnsiBuffer ToAnsiBuffer(this string text)
{
return new AnsiBuffer(text);
}
return (sbyte*)_data.ToPointer();
}
public void Dispose()
{
Marshal.FreeHGlobal(_data);
}
}
public static class AnsiStringUtils
{
public static AnsiBuffer ToAnsiBuffer(this string text)
{
return new AnsiBuffer(text);
}
}

@ -1,87 +1,89 @@
using System;
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
[StructLayout(LayoutKind.Sequential)]
public readonly struct CBool
{
[StructLayout(LayoutKind.Sequential)]
public readonly struct CBool
/* The values of booleans in C++ are stored in a single byte, which means it
* only supports values from -128 to 127. It is possible to argument that
* they only support a single bit, yes, but the minimum storage unit of a
* computer is a sbyte, so that's what we'll be using when doing operations,
* which can be later implicitely cast onto any type during usage.
*
* It is wise to note that C booleans are any numeric value, but allocating an
* Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the
* process is basically treated as a 0-cost instantiation, but it's better to rely
* on explicit motivation than to blindly trust the runtime judgement on its memory
* management.
*
* 'value' is visible and constructable (if necessary), but impossible to modify or access.
*/
public sbyte Value
{
/* The values of booleans in C++ are stored in a single byte, which means it
* only supports values from -128 to 127. It is possible to argument that
* they only support a single bit, yes, but the minimum storage unit of a
* computer is a sbyte, so that's what we'll be using when doing operations,
* which can be later implicitely cast onto any type during usage.
*
* It is wise to note that C booleans are any numeric value, but allocating an
* Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the
* process is basically treated as a 0-cost instantiation, but it's better to rely
* on explicit motivation than to blindly trust the runtime judgement on its memory
* management.
*
* 'value' is visible and constructable (if necessary), but impossible to modify or access.
*/
public sbyte Value { init; private get; }
init; private get;
}
// Constructors for easier usage.
public CBool(bool value)
{
this.Value = (sbyte)(value ? 1 : 0);
}
public CBool(Int64 value)
{
this.Value = (sbyte)(value != 0 ? 1 : 0);
}
// Constructors for easier usage.
public CBool(bool value)
{
this.Value = (sbyte)(value ? 1 : 0);
}
public CBool(Int64 value)
{
this.Value = (sbyte)(value != 0 ? 1 : 0);
}
// CBool -> Native
// Allows for arithmetic between CBools and for assignment to greater integer variables.
public static implicit operator sbyte(CBool x)
{
return x.Value;
}
// CBool -> Native
// Allows for arithmetic between CBools and for assignment to greater integer variables.
public static implicit operator sbyte(CBool x)
{
return x.Value;
}
// Allows for CBools to be implicitely assigned to a native boolean variable.
public static implicit operator bool(CBool x)
{
return x.Value != 0 ? true : false;
}
// Allows for CBools to be implicitely assigned to a native boolean variable.
public static implicit operator bool(CBool x)
{
return x.Value != 0 ? true : false;
}
// Native -> CBool
// Allows native booleans to be implicitely constructed into CBools while passing parameters.
public static implicit operator CBool(bool x)
{
return new CBool { Value = (sbyte)(x ? 1 : 0) };
}
// Native -> CBool
// Allows native booleans to be implicitely constructed into CBools while passing parameters.
public static implicit operator CBool(bool x)
{
return new CBool { Value = (sbyte)(x ? 1 : 0) };
}
// Same goes for integer numeric values (any value, so an Int64 is used).
public static implicit operator CBool(Int64 x)
{
return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) };
}
// Same goes for integer numeric values (any value, so an Int64 is used).
public static implicit operator CBool(Int64 x)
{
return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) };
}
/* Arithmetic overloads
* Operations between CBools and integers are already covered by the implicit
* sbyte cast. So no need to worry about those.
*
* All casts return CBool, since there is no way to know if the assignment is
* to a native boolean or integer, or a CBool.
*/
/* Arithmetic overloads
* Operations between CBools and integers are already covered by the implicit
* sbyte cast. So no need to worry about those.
*
* All casts return CBool, since there is no way to know if the assignment is
* to a native boolean or integer, or a CBool.
*/
// Addition
public static CBool operator +(CBool left, CBool right)
{
return new CBool { Value = (sbyte)(left.Value + right.Value) };
}
// Addition
public static CBool operator +(CBool left, CBool right)
{
return new CBool { Value = (sbyte)(left.Value + right.Value) };
}
// Subtraction
public static CBool operator -(CBool left, CBool right)
{
return new CBool { Value = (sbyte)(left.Value - right.Value) };
}
// Subtraction
public static CBool operator -(CBool left, CBool right)
{
return new CBool { Value = (sbyte)(left.Value - right.Value) };
}
// ToString override
public override string ToString()
{
return ((bool)this).ToString();
}
// ToString override
public override string ToString()
{
return ((bool)this).ToString();
}
}

@ -1,26 +1,25 @@
using System.Runtime.InteropServices;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// File path list
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct FilePathList
{
/// <summary>
/// File path list
/// Filepaths max entries
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct FilePathList
{
/// <summary>
/// Filepaths max entries
/// </summary>
public uint Capacity;
public uint Capacity;
/// <summary>
/// Filepaths entries count
/// </summary>
public uint Count;
/// <summary>
/// Filepaths entries count
/// </summary>
public uint Count;
/// <summary>
/// Filepaths entries
/// </summary>
public byte** Paths;
}
/// <summary>
/// Filepaths entries
/// </summary>
public byte** Paths;
}

@ -1,63 +1,62 @@
using System;
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Raylib_cs
namespace Raylib_cs;
/// <summary>
/// Converts text to a UTF8 buffer for passing to native code
/// </summary>
public readonly ref struct Utf8Buffer
{
/// <summary>
/// Converts text to a UTF8 buffer for passing to native code
/// </summary>
public readonly ref struct Utf8Buffer
private readonly IntPtr _data;
public Utf8Buffer(string text)
{
private readonly IntPtr _data;
public Utf8Buffer(string text)
{
_data = Marshal.StringToCoTaskMemUTF8(text);
}
public unsafe sbyte* AsPointer()
{
return (sbyte*)_data.ToPointer();
}
public void Dispose()
{
Marshal.ZeroFreeCoTaskMemUTF8(_data);
}
_data = Marshal.StringToCoTaskMemUTF8(text);
}
public static class Utf8StringUtils
public unsafe sbyte* AsPointer()
{
public static Utf8Buffer ToUtf8Buffer(this string text)
{
return new Utf8Buffer(text);
}
return (sbyte*)_data.ToPointer();
}
public static byte[] ToUtf8String(this string text)
{
if (text == null)
{
return null;
}
var length = Encoding.UTF8.GetByteCount(text);
var byteArray = new byte[length + 1];
var wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0);
byteArray[wrote] = 0;
return byteArray;
}
public static unsafe string GetUTF8String(sbyte* bytes)
{
return Marshal.PtrToStringUTF8((IntPtr)bytes);
}
public static byte[] GetUTF8Bytes(this string text)
{
return Encoding.UTF8.GetBytes(text);
}
public void Dispose()
{
Marshal.ZeroFreeCoTaskMemUTF8(_data);
}
}
public static class Utf8StringUtils
{
public static Utf8Buffer ToUtf8Buffer(this string text)
{
return new Utf8Buffer(text);
}
public static byte[] ToUtf8String(this string text)
{
if (text == null)
{
return null;
}
var length = Encoding.UTF8.GetByteCount(text);
var byteArray = new byte[length + 1];
var wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0);
byteArray[wrote] = 0;
return byteArray;
}
public static unsafe string GetUTF8String(sbyte* bytes)
{
return Marshal.PtrToStringUTF8((IntPtr)bytes);
}
public static byte[] GetUTF8Bytes(this string text)
{
return Encoding.UTF8.GetBytes(text);
}
}