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

Add .editorconfig and apply formatting

This commit is contained in:
Chris 2023-08-27 15:20:26 +01:00
commit 696955463f
32 changed files with 6831 additions and 6808 deletions

51
.editorconfig Normal file
View 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

View file

@ -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));
}
}

View file

@ -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

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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}}}";
}
}

View file

@ -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
}

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}
}

View file

@ -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];
}

View file

@ -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
}

View file

@ -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;
}
}

View file

@ -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>
/// Npatch defined by 3x1 tiles
/// </summary>
NPATCH_THREE_PATCH_HORIZONTAL
}
/// <summary>
/// Top border offset
/// </summary>
public int Top;
/// <summary>
/// N-Patch layout info
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct NPatchInfo
{
/// <summary>
/// Texture source rectangle
/// </summary>
public Rectangle Source;
/// <summary>
/// Right border offset
/// </summary>
public int Right;
/// <summary>
/// Left border offset
/// </summary>
public int Left;
/// <summary>
/// Bottom border offset
/// </summary>
public int Bottom;
/// <summary>
/// Top border offset
/// </summary>
public int Top;
/// <summary>
/// Layout of the n-patch: 3x3, 1x3 or 3x1
/// </summary>
public NPatchLayout Layout;
}
/// <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;
}

Some files were not shown because too many files have changed in this diff Show more