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.InteropServices;
using System.Runtime.Serialization; 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;
{
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;
}
} }
if (type.IsArray)
private static class IsBlittableCache<T>
{ {
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 System;
using Xunit; using Xunit;
namespace Raylib_cs.Tests namespace Raylib_cs.Tests;
{
public class RaylibTests
{
private unsafe void CheckType<T>() where T : unmanaged
{
Assert.True(BlittableHelper.IsBlittable<T>());
}
[Fact] public class RaylibTests
public void CheckTypes() {
{ private unsafe void CheckType<T>() where T : unmanaged
CheckType<Color>(); {
CheckType<Rectangle>(); Assert.True(BlittableHelper.IsBlittable<T>());
CheckType<Image>(); }
CheckType<Texture2D>();
CheckType<RenderTexture2D>(); [Fact]
CheckType<NPatchInfo>(); public void CheckTypes()
CheckType<GlyphInfo>(); {
CheckType<Font>(); CheckType<Color>();
CheckType<Camera2D>(); CheckType<Rectangle>();
CheckType<Camera3D>(); CheckType<Image>();
CheckType<Mesh>(); CheckType<Texture2D>();
CheckType<Shader>(); CheckType<RenderTexture2D>();
CheckType<MaterialMap>(); CheckType<NPatchInfo>();
CheckType<Material>(); CheckType<GlyphInfo>();
CheckType<Transform>(); CheckType<Font>();
CheckType<BoneInfo>(); CheckType<Camera2D>();
CheckType<Model>(); CheckType<Camera3D>();
CheckType<ModelAnimation>(); CheckType<Mesh>();
CheckType<Ray>(); CheckType<Shader>();
CheckType<RayCollision>(); CheckType<MaterialMap>();
CheckType<BoundingBox>(); CheckType<Material>();
CheckType<Wave>(); CheckType<Transform>();
CheckType<AudioStream>(); CheckType<BoneInfo>();
CheckType<Sound>(); CheckType<Model>();
CheckType<Music>(); CheckType<ModelAnimation>();
CheckType<VrDeviceInfo>(); CheckType<Ray>();
CheckType<VrStereoConfig>(); CheckType<RayCollision>();
CheckType<RenderBatch>(); 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;
using System.Runtime.InteropServices; 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> /// <summary>
/// Wave type, defines audio wave data /// Number of samples
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint SampleCount;
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;
}
/// <summary> /// <summary>
/// Audio stream type<br/> /// Frequency (samples per second)
/// NOTE: Useful to create custom audio streams not bound to a specific file
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint SampleRate;
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> /// <summary>
/// Sound source type /// Bit depth (bits per sample): 8, 16, 32 (24 not supported)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint SampleSize;
public partial struct Sound
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary>
/// Total number of frames (considering channels)
/// </summary>
public uint FrameCount;
}
/// <summary> /// <summary>
/// Music stream type (audio file streaming from memory)<br/> /// Number of channels (1-mono, 2-stereo)
/// NOTE: Anything longer than ~10 seconds should be streamed
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public uint Channels;
public unsafe partial struct Music
{
/// <summary>
/// Audio stream
/// </summary>
public AudioStream Stream;
/// <summary> //TODO: SPAN<byte> ?
/// Total number of samples /// <summary>
/// </summary> /// Buffer data pointer
public uint FrameCount; /// </summary>
public void* Data;
/// <summary> }
/// Music looping enable
/// </summary> /// <summary>
public CBool Looping; /// Audio stream type<br/>
/// NOTE: Useful to create custom audio streams not bound to a specific file
/// <summary> /// </summary>
/// Type of music context (audio filetype) [StructLayout(LayoutKind.Sequential)]
/// </summary> public partial struct AudioStream
public int CtxType; {
//TODO: convert
//TODO span /// <summary>
/// <summary> /// Pointer to internal data(rAudioBuffer *) used by the audio system
/// Audio context data, depends on type /// </summary>
/// </summary> public IntPtr Buffer;
public void* CtxData;
} /// <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.Numerics;
using System.Runtime.InteropServices; 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> /// <summary>
[StructLayout(LayoutKind.Sequential)] /// Minimum vertex box-corner
public partial struct BoundingBox /// </summary>
public Vector3 Min;
/// <summary>
/// Maximum vertex box-corner
/// </summary>
public Vector3 Max;
public BoundingBox(Vector3 min, Vector3 max)
{ {
/// <summary> this.Min = min;
/// Minimum vertex box-corner this.Max = max;
/// </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;
}
} }
} }

View file

@ -1,40 +1,39 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; 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> /// <summary>
/// Camera2D, defines position/orientation in 2d space /// Camera offset (displacement from target)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public Vector2 Offset;
public partial struct Camera2D
/// <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> this.Offset = offset;
/// Camera offset (displacement from target) this.Target = target;
/// </summary> this.Rotation = rotation;
public Vector2 Offset; this.Zoom = zoom;
/// <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;
}
} }
} }

View file

@ -1,67 +1,66 @@
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; 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> /// <summary>
/// Camera system modes /// Camera position
/// </summary> /// </summary>
public enum CameraMode public Vector3 Position;
{
CAMERA_CUSTOM = 0,
CAMERA_FREE,
CAMERA_ORBITAL,
CAMERA_FIRST_PERSON,
CAMERA_THIRD_PERSON
}
/// <summary> /// <summary>
/// Camera projection /// Camera target it looks-at
/// </summary> /// </summary>
public enum CameraProjection public Vector3 Target;
{
CAMERA_PERSPECTIVE = 0,
CAMERA_ORTHOGRAPHIC
}
/// <summary> /// <summary>
/// Camera3D, defines position/orientation in 3d space /// Camera up vector (rotation over its axis)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public Vector3 Up;
public partial struct Camera3D
/// <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> this.Position = position;
/// Camera position this.Target = target;
/// </summary> this.Up = up;
public Vector3 Position; this.FovY = fovY;
this.Projection = projection;
/// <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;
}
} }
} }

View file

@ -1,67 +1,66 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Color type, RGBA (32bit)
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public partial struct Color
{ {
/// <summary> public byte R;
/// Color type, RGBA (32bit) public byte G;
/// </summary> public byte B;
[StructLayout(LayoutKind.Sequential)] public byte A;
public partial struct Color
// 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; this.R = r;
public byte G; this.G = g;
public byte B; this.B = b;
public byte A; this.A = a;
}
// Example - Color.RED instead of RED public Color(int r, int g, int b, int a)
// Custom raylib color palette for amazing visuals {
public static readonly Color LIGHTGRAY = new Color(200, 200, 200, 255); this.R = Convert.ToByte(r);
public static readonly Color GRAY = new Color(130, 130, 130, 255); this.G = Convert.ToByte(g);
public static readonly Color DARKGRAY = new Color(80, 80, 80, 255); this.B = Convert.ToByte(b);
public static readonly Color YELLOW = new Color(253, 249, 0, 255); this.A = Convert.ToByte(a);
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 override string ToString()
{ {
this.R = r; return $"{{R:{R} G:{G} B:{B} A:{A}}}";
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}}}";
}
} }
} }

View file

@ -1,181 +1,180 @@
using System; 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> /// <summary>
/// System config flags<br/> /// Set to try enabling V-Sync on GPU
/// NOTE: Every bit registers one state (use it with bit masks)<br/>
/// By default all flags are set to 0
/// </summary> /// </summary>
[Flags] FLAG_VSYNC_HINT = 0x00000040,
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,
}
/// <summary> /// <summary>
/// Trace log level<br/> /// Set to run program in fullscreen
/// NOTE: Organized by priority level
/// </summary> /// </summary>
public enum TraceLogLevel FLAG_FULLSCREEN_MODE = 0x00000002,
{
/// <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> /// <summary>
/// Color blending modes (pre-defined) /// Set to allow resizable window
/// </summary> /// </summary>
public enum BlendMode FLAG_WINDOW_RESIZABLE = 0x00000004,
{
/// <summary>
/// Blend textures considering alpha (default)
/// </summary>
BLEND_ALPHA = 0,
/// <summary> /// <summary>
/// Blend textures adding colors /// Set to disable window decoration (frame and buttons)
/// </summary> /// </summary>
BLEND_ADDITIVE, FLAG_WINDOW_UNDECORATED = 0x00000008,
/// <summary> /// <summary>
/// Blend textures multiplying colors /// Set to hide window
/// </summary> /// </summary>
BLEND_MULTIPLIED, FLAG_WINDOW_HIDDEN = 0x00000080,
/// <summary> /// <summary>
/// Blend textures adding colors (alternative) /// Set to minimize window (iconify)
/// </summary> /// </summary>
BLEND_ADD_COLORS, FLAG_WINDOW_MINIMIZED = 0x00000200,
/// <summary> /// <summary>
/// Blend textures subtracting colors (alternative) /// Set to maximize window (expanded to monitor)
/// </summary> /// </summary>
BLEND_SUBTRACT_COLORS, FLAG_WINDOW_MAXIMIZED = 0x00000400,
/// <summary> /// <summary>
/// Blend premultiplied textures considering alpha /// Set to window non focused
/// </summary> /// </summary>
BLEND_ALPHA_PREMULTIPLY, FLAG_WINDOW_UNFOCUSED = 0x00000800,
/// <summary> /// <summary>
/// Blend textures using custom src/dst factors (use rlSetBlendFactors()) /// Set to window always on top
/// </summary> /// </summary>
BLEND_CUSTOM, FLAG_WINDOW_TOPMOST = 0x00001000,
/// <summary> /// <summary>
/// Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) /// Set to allow windows running while minimized
/// </summary> /// </summary>
BLEND_CUSTOM_SEPARATE 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; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Font type, defines generation method
/// </summary>
public enum FontType
{ {
/// <summary> /// <summary>
/// Font type, defines generation method /// Default font generation, anti-aliased
/// </summary> /// </summary>
public enum FontType FONT_DEFAULT = 0,
{
/// <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
}
/// <summary> /// <summary>
/// GlyphInfo, font characters glyphs info /// Bitmap font generation, no anti-aliasing
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] FONT_BITMAP,
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> /// <summary>
/// Font, font texture and GlyphInfo array data /// SDF font generation, requires external shader
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] FONT_SDF
public unsafe partial struct Font }
{
/// <summary> /// <summary>
/// Base size (default chars height) /// GlyphInfo, font characters glyphs info
/// </summary> /// </summary>
public int BaseSize; [StructLayout(LayoutKind.Sequential)]
public partial struct GlyphInfo
/// <summary> {
/// Number of characters /// <summary>
/// </summary> /// Character value (Unicode)
public int GlyphCount; /// </summary>
public int Value;
/// <summary>
/// Padding around the glyph characters /// <summary>
/// </summary> /// Character offset X when drawing
public int GlyphPadding; /// </summary>
public int OffsetX;
/// <summary>
/// Texture atlas containing the glyphs /// <summary>
/// </summary> /// Character offset Y when drawing
public Texture2D Texture; /// </summary>
public int OffsetY;
/// <summary>
/// Rectangles in texture for the glyphs /// <summary>
/// </summary> /// Character advance position X
public Rectangle* Recs; /// </summary>
public int AdvanceX;
/// <summary>
/// Glyphs info data /// <summary>
/// </summary> /// Character image data
public GlyphInfo* Glyphs; /// </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; 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> /// <summary>
/// Pixel formats<br/> /// 8 bit per pixel (no alpha)
/// NOTE: Support depends on OpenGL version and platform
/// </summary> /// </summary>
public enum PixelFormat PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1,
{
/// <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
}
/// <summary> /// <summary>
/// Image, pixel data stored in CPU memory (RAM) /// 8*2 bpp (2 channels)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA,
public unsafe partial struct Image
{
/// <summary>
/// Image raw data
/// </summary>
public void* Data;
/// <summary> /// <summary>
/// Image base width /// 16 bpp
/// </summary> /// </summary>
public int Width; PIXELFORMAT_UNCOMPRESSED_R5G6B5,
/// <summary> /// <summary>
/// Image base height /// 24 bpp
/// </summary> /// </summary>
public int Height; PIXELFORMAT_UNCOMPRESSED_R8G8B8,
/// <summary> /// <summary>
/// Mipmap levels, 1 by default /// 16 bpp (1 bit alpha)
/// </summary> /// </summary>
public int Mipmaps; PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,
/// <summary> /// <summary>
/// Data format (PixelFormat type) /// 16 bpp (4 bit alpha)
/// </summary> /// </summary>
public PixelFormat Format; 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;
using System.Runtime.InteropServices; 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"; var message = GetLogMessage(new IntPtr(text), new IntPtr(args));
internal const string Libc = "libc"; Console.WriteLine(message);
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)] public static string GetLogMessage(IntPtr format, IntPtr args)
struct VaListLinuxX64
{ {
uint _gpOffset; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
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)
{ {
var message = GetLogMessage(new IntPtr(text), new IntPtr(args)); return AppleLogCallback(format, args);
Console.WriteLine(message);
} }
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 LinuxX64LogCallback(format, args);
{ }
return AppleLogCallback(format, args);
}
// Special marshalling is needed on Linux desktop 64 bits. var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && IntPtr.Size == 8) if (byteLength <= 1)
{ {
return LinuxX64LogCallback(format, args); return string.Empty;
} }
var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1; var buffer = Marshal.AllocHGlobal(byteLength);
if (byteLength <= 1) 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; return string.Empty;
} }
return Marshal.PtrToStringUTF8(buffer) ?? string.Empty;
var buffer = Marshal.AllocHGlobal(byteLength); }
VsPrintf(buffer, format, args); finally
{
string result = Marshal.PtrToStringUTF8(buffer);
Marshal.FreeHGlobal(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;
}
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; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Material map index
/// </summary>
public enum MaterialMapIndex
{ {
/// <summary> /// <summary>
/// Material map index /// NOTE: Same as MATERIAL_MAP_DIFFUSE
/// </summary> /// </summary>
public enum MaterialMapIndex MATERIAL_MAP_ALBEDO = 0,
{
/// <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,
}
/// <summary> /// <summary>
/// Material texture map /// NOTE: Same as MATERIAL_MAP_SPECULAR
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] MATERIAL_MAP_METALNESS,
public partial struct MaterialMap
{
/// <summary>
/// Material map texture
/// </summary>
public Texture2D Texture;
/// <summary> MATERIAL_MAP_NORMAL,
/// Material map color MATERIAL_MAP_ROUGHNESS,
/// </summary> MATERIAL_MAP_OCCLUSION,
public Color Color; MATERIAL_MAP_EMISSION,
MATERIAL_MAP_HEIGHT,
/// <summary>
/// Material map value
/// </summary>
public float Value;
}
/// <summary> /// <summary>
/// Material type (generic) /// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] MATERIAL_MAP_CUBEMAP,
public unsafe partial struct Material
{
/// <summary>
/// Material shader
/// </summary>
public Shader Shader;
//TODO: convert /// <summary>
/// <summary> /// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// Material maps /// </summary>
/// </summary> MATERIAL_MAP_IRRADIANCE,
public MaterialMap* Maps;
/// <summary> /// <summary>
/// Material generic parameters (if required) /// NOTE: Uses GL_TEXTURE_CUBE_MAP
/// </summary> /// </summary>
public fixed float Param[4]; 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; 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> /// <summary>
/// Vertex data definning a mesh<br/> /// Number of vertices stored in arrays
/// NOTE: Data stored in CPU memory (and GPU)
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public int VertexCount;
public unsafe partial struct Mesh
{
/// <summary>
/// Number of vertices stored in arrays
/// </summary>
public int VertexCount;
/// <summary> /// <summary>
/// Number of triangles stored (indexed or not) /// Number of triangles stored (indexed or not)
/// </summary> /// </summary>
public int TriangleCount; public int TriangleCount;
#region Default vertex data #region Default vertex data
/// <summary> /// <summary>
/// Vertex position (XYZ - 3 components per vertex) (shader-location = 0) /// Vertex position (XYZ - 3 components per vertex) (shader-location = 0)
/// </summary> /// </summary>
public float* Vertices; public float* Vertices;
/// <summary> /// <summary>
/// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) /// Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
/// </summary> /// </summary>
public float* TexCoords; public float* TexCoords;
/// <summary> /// <summary>
/// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5) /// Vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
/// </summary> /// </summary>
public float* TexCoords2; public float* TexCoords2;
/// <summary> /// <summary>
/// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) /// Vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
/// </summary> /// </summary>
public float* Normals; public float* Normals;
/// <summary> /// <summary>
/// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) /// Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
/// </summary> /// </summary>
public float* Tangents; public float* Tangents;
/// <summary> /// <summary>
/// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) /// Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
/// </summary> /// </summary>
public byte* Colors; public byte* Colors;
/// <summary> /// <summary>
/// Vertex indices (in case vertex data comes indexed) /// Vertex indices (in case vertex data comes indexed)
/// </summary> /// </summary>
public ushort* Indices; public ushort* Indices;
#endregion #endregion
#region Animation vertex data #region Animation vertex data
/// <summary> /// <summary>
/// Animated vertex positions (after bones transformations) /// Animated vertex positions (after bones transformations)
/// </summary> /// </summary>
public float* AnimVertices; public float* AnimVertices;
/// <summary> /// <summary>
/// Animated normals (after bones transformations) /// Animated normals (after bones transformations)
/// </summary> /// </summary>
public float* AnimNormals; public float* AnimNormals;
/// <summary> /// <summary>
/// Vertex bone ids, up to 4 bones influence by vertex (skinning) /// Vertex bone ids, up to 4 bones influence by vertex (skinning)
/// </summary> /// </summary>
public byte* BoneIds; public byte* BoneIds;
/// <summary> /// <summary>
/// Vertex bone weight, up to 4 bones influence by vertex (skinning) /// Vertex bone weight, up to 4 bones influence by vertex (skinning)
/// </summary> /// </summary>
public float* BoneWeights; public float* BoneWeights;
#endregion #endregion
#region OpenGL identifiers #region OpenGL identifiers
/// <summary> /// <summary>
/// OpenGL Vertex Array Object id /// OpenGL Vertex Array Object id
/// </summary> /// </summary>
public uint VaoId; public uint VaoId;
/// <summary> /// <summary>
/// OpenGL Vertex Buffer Objects id (default vertex data, uint[]) /// OpenGL Vertex Buffer Objects id (default vertex data, uint[])
/// </summary> /// </summary>
public uint* VboId; public uint* VboId;
#endregion #endregion
}
} }

View file

@ -2,144 +2,143 @@ using System;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// Bone information
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct BoneInfo
{ {
/// <summary> /// <summary>
/// Bone information /// Bone name (char[32])
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public fixed sbyte Name[32];
public unsafe partial struct BoneInfo
{
/// <summary>
/// Bone name (char[32])
/// </summary>
public fixed sbyte Name[32];
/// <summary>
/// Bone parent
/// </summary>
public int Parent;
}
/// <summary> /// <summary>
/// Model type /// Bone parent
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public int Parent;
public unsafe partial struct Model }
{
/// <summary>
/// Local transform matrix
/// </summary>
public Matrix4x4 Transform;
/// <summary> /// <summary>
/// Number of meshes /// Model type
/// </summary> /// </summary>
public int MeshCount; [StructLayout(LayoutKind.Sequential)]
public unsafe partial struct Model
/// <summary> {
/// Number of materials /// <summary>
/// </summary> /// Local transform matrix
public int MaterialCount; /// </summary>
public Matrix4x4 Transform;
/// <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> /// <summary>
/// Model animation /// Number of meshes
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] public int MeshCount;
public readonly unsafe partial struct ModelAnimation
/// <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> readonly Transform** _framePoses;
/// Number of bones
/// </summary>
public readonly int BoneCount;
/// <summary> readonly int _frameCount;
/// Number of animation frames
/// </summary>
public readonly int FrameCount;
/// <summary> readonly int _boneCount;
/// Bones information (skeleton, BoneInfo *)
/// </summary>
public readonly BoneInfo* Bones;
/// <inheritdoc cref="Bones"/> public FramePoses this[int index] => new(_framePoses[index], _boneCount);
public ReadOnlySpan<BoneInfo> BoneInfo => new(Bones, BoneCount);
/// <summary> public Transform this[int index1, int index2] => new FramePoses(_framePoses[index1], _boneCount)[index2];
/// Poses array by frame (Transform **)
/// </summary>
public readonly Transform** FramePoses;
/// <inheritdoc cref="FramePoses"/> internal FramePosesCollection(Transform** framePoses, int frameCount, int boneCount)
public FramePosesCollection FramePosesColl => new(FramePoses, FrameCount, BoneCount);
public struct FramePosesCollection
{ {
readonly Transform** _framePoses; this._framePoses = framePoses;
this._frameCount = frameCount;
readonly int _frameCount; this._boneCount = boneCount;
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;
} }
} }
} }
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; using System.Runtime.InteropServices;
namespace Raylib_cs namespace Raylib_cs;
/// <summary>
/// N-patch layout
/// </summary>
public enum NPatchLayout
{ {
/// <summary> /// <summary>
/// N-patch layout /// Npatch defined by 3x3 tiles
/// </summary> /// </summary>
public enum NPatchLayout NPATCH_NINE_PATCH = 0,
{
/// <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
}
/// <summary> /// <summary>
/// N-Patch layout info /// Npatch defined by 1x3 tiles
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] NPATCH_THREE_PATCH_VERTICAL,
public partial struct NPatchInfo
{
/// <summary>
/// Texture source rectangle
/// </summary>
public Rectangle Source;
/// <summary> /// <summary>
/// Left border offset /// Npatch defined by 3x1 tiles
/// </summary> /// </summary>
public int Left; NPATCH_THREE_PATCH_HORIZONTAL
}
/// <summary> /// <summary>
/// Top border offset /// N-Patch layout info
/// </summary> /// </summary>
public int Top; [StructLayout(LayoutKind.Sequential)]
public partial struct NPatchInfo
{
/// <summary>
/// Texture source rectangle
/// </summary>
public Rectangle Source;
/// <summary> /// <summary>
/// Right border offset /// Left border offset
/// </summary> /// </summary>
public int Right; public int Left;
/// <summary> /// <summary>
/// Bottom border offset /// Top border offset
/// </summary> /// </summary>
public int Bottom; public int Top;
/// <summary> /// <summary>
/// Layout of the n-patch: 3x3, 1x3 or 3x1 /// Right border offset
/// </summary> /// </summary>
public NPatchLayout Layout; 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